Skip to content

Commit 2d83924

Browse files
committed
make intrinsic getters member functions. Add a getArch abstraction b\c CodeGenModule is incomplete in the header\CGHLSLRuntime.h
1 parent 23e15ce commit 2d83924

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18177,9 +18177,8 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
1817718177
Value *Op0 = EmitScalarExpr(E->getArg(0));
1817818178
return Builder.CreateIntrinsic(
1817918179
/*ReturnType=*/llvm::Type::getInt1Ty(getLLVMContext()),
18180-
CGHLSLRuntime::get_hlsl_all_intrinsic(
18181-
CGM.getTarget().getTriple().getArch()),
18182-
ArrayRef<Value *>{Op0}, nullptr, "hlsl.all");
18180+
CGM.getHLSLRuntime().get_hlsl_all_intrinsic(), ArrayRef<Value *>{Op0},
18181+
nullptr, "hlsl.all");
1818318182
}
1818418183
case Builtin::BI__builtin_hlsl_elementwise_any: {
1818518184
Value *Op0 = EmitScalarExpr(E->getArg(0));

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer &Buf) {
115115

116116
} // namespace
117117

118+
llvm::Triple::ArchType CGHLSLRuntime::getArch() {
119+
return CGM.getTarget().getTriple().getArch();
120+
}
121+
118122
void CGHLSLRuntime::addConstant(VarDecl *D, Buffer &CB) {
119123
if (D->getStorageClass() == SC_Static) {
120124
// For static inside cbuffer, take as global static.
@@ -342,8 +346,7 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B,
342346
}
343347
if (D.hasAttr<HLSLSV_DispatchThreadIDAttr>()) {
344348
llvm::Function *ThreadIDIntrinsic =
345-
CGM.getIntrinsic(CGHLSLRuntime::get_hlsl_thread_id_intrinsic(
346-
CGM.getTarget().getTriple().getArch()));
349+
CGM.getIntrinsic(get_hlsl_thread_id_intrinsic());
347350
return buildVectorInput(B, ThreadIDIntrinsic, Ty);
348351
}
349352
assert(false && "Unhandled parameter attribute");

clang/lib/CodeGen/CGHLSLRuntime.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
// Define the function generator macro
3333
#define GENERATE_HLSL_INTRINSIC_FUNCTION(name) \
34-
static llvm::Intrinsic::ID get_hlsl_##name##_intrinsic( \
35-
const llvm::Triple::ArchType Arch) { \
34+
llvm::Intrinsic::ID get_hlsl_##name##_intrinsic() { \
35+
llvm::Triple::ArchType Arch = getArch(); \
3636
switch (Arch) { \
3737
case llvm::Triple::dxil: \
3838
return llvm::Intrinsic::dx_##name; \
@@ -125,6 +125,7 @@ class CGHLSLRuntime {
125125
BufferResBinding &Binding);
126126
void addConstant(VarDecl *D, Buffer &CB);
127127
void addBufferDecls(const DeclContext *DC, Buffer &CB);
128+
llvm::Triple::ArchType getArch();
128129
llvm::SmallVector<Buffer> Buffers;
129130
};
130131

0 commit comments

Comments
 (0)