Skip to content

Commit 0280558

Browse files
author
Pavel Samolysov
authored
[sycl-post-link][NFC] Put passes and their dependencies in namespace llvm (#5346)
Currently the SYCLDeviceLibReqMask and SpecConstantsPass classes are declared inside the global namespace. To make them aligned with all the other declarations used in the sycl-post-link tool, the passes and their dependencies have been moved into the llvm namespace.
1 parent 7e5bd8f commit 0280558

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@
1818
#include "llvm/ADT/Triple.h"
1919
#include "llvm/IR/Module.h"
2020

21+
#include <string>
22+
#include <unordered_map>
23+
2124
static constexpr char DEVICELIB_FUNC_PREFIX[] = "__devicelib_";
2225

26+
using namespace llvm;
27+
2328
namespace {
29+
30+
using SYCLDeviceLibFuncMap = std::unordered_map<std::string, DeviceLibExt>;
31+
2432
// Please update SDLMap if any item is added to or removed from
2533
// fallback device libraries in libdevice.
2634
SYCLDeviceLibFuncMap SDLMap = {

llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
#pragma once
1818

1919
#include "llvm/Pass.h"
20-
#include <unordered_map>
21-
using namespace llvm;
20+
21+
#include <cstdint>
22+
23+
namespace llvm {
2224

2325
// DeviceLibExt is shared between sycl-post-link tool and sycl runtime.
2426
// If any change is made here, need to sync with DeviceLibExt definition
@@ -32,7 +34,6 @@ enum class DeviceLibExt : std::uint32_t {
3234
cl_intel_devicelib_cstring,
3335
};
3436

35-
using SYCLDeviceLibFuncMap = std::unordered_map<std::string, DeviceLibExt>;
3637
class SYCLDeviceLibReqMaskPass : public ModulePass {
3738
public:
3839
static char ID;
@@ -43,3 +44,5 @@ class SYCLDeviceLibReqMaskPass : public ModulePass {
4344
private:
4445
uint32_t MReqMask;
4546
};
47+
48+
} // namespace llvm

llvm/tools/sycl-post-link/SpecConstants.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ PreservedAnalyses SpecConstantsPass::run(Module &M,
794794
return IRModified ? PreservedAnalyses::none() : PreservedAnalyses::all();
795795
}
796796

797-
bool SpecConstantsPass::collectSpecConstantMetadata(Module &M,
797+
bool SpecConstantsPass::collectSpecConstantMetadata(const Module &M,
798798
SpecIDMapTy &IDMap) {
799799
NamedMDNode *MD = M.getNamedMetadata(SPEC_CONST_MD_STRING);
800800
if (!MD)
@@ -825,7 +825,7 @@ bool SpecConstantsPass::collectSpecConstantMetadata(Module &M,
825825
}
826826

827827
bool SpecConstantsPass::collectSpecConstantDefaultValuesMetadata(
828-
Module &M, std::vector<char> &DefaultValues) {
828+
const Module &M, std::vector<char> &DefaultValues) {
829829
NamedMDNode *N = M.getNamedMetadata(SPEC_CONST_DEFAULT_VAL_MD_STRING);
830830
if (!N)
831831
return false;

llvm/tools/sycl-post-link/SpecConstants.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
#include "llvm/IR/Module.h"
2020
#include "llvm/IR/PassManager.h"
2121

22-
#include <map>
2322
#include <vector>
2423

2524
namespace llvm {
25+
2626
class StringRef;
27-
}
2827

2928
// Represents either an element of a composite specialization constant or a
3029
// single scalar specialization constant - at SYCL RT level composite
@@ -46,28 +45,29 @@ struct SpecConstantDescriptor {
4645
// Encodes size of scalar specialization constant.
4746
unsigned Size;
4847
};
49-
using SpecIDMapTy =
50-
llvm::MapVector<llvm::StringRef, std::vector<SpecConstantDescriptor>>;
5148

52-
class SpecConstantsPass : public llvm::PassInfoMixin<SpecConstantsPass> {
49+
using SpecIDMapTy = MapVector<StringRef, std::vector<SpecConstantDescriptor>>;
50+
51+
class SpecConstantsPass : public PassInfoMixin<SpecConstantsPass> {
5352
public:
5453
// SetValAtRT parameter controls spec constant lowering mode:
5554
// - if true, it is lowered to SPIRV intrinsic which retrieves constant value
5655
// - if false, it is replaced with C++ default (used for AOT compilers)
5756
SpecConstantsPass(bool SetValAtRT = true) : SetValAtRT(SetValAtRT) {}
58-
llvm::PreservedAnalyses run(llvm::Module &M,
59-
llvm::ModuleAnalysisManager &MAM);
57+
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
6058

6159
// Searches given module for occurrences of specialization constant-specific
6260
// metadata and builds "spec constant name" -> vector<"spec constant int ID">
6361
// map
64-
static bool collectSpecConstantMetadata(llvm::Module &M, SpecIDMapTy &IDMap);
62+
static bool collectSpecConstantMetadata(const Module &M, SpecIDMapTy &IDMap);
6563
// Searches given module for occurrences of specialization constant-specific
6664
// metadata and builds vector of default values for every spec constant.
6765
static bool
68-
collectSpecConstantDefaultValuesMetadata(llvm::Module &M,
66+
collectSpecConstantDefaultValuesMetadata(const Module &M,
6967
std::vector<char> &DefaultValues);
7068

7169
private:
7270
bool SetValAtRT;
7371
};
72+
73+
} // namespace llvm

0 commit comments

Comments
 (0)