Skip to content

Commit 4d0ebe8

Browse files
committed
remove template
1 parent 3978c8c commit 4d0ebe8

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
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-
CGM.getHLSLRuntime()
18181-
.getIntrinsic<Builtin::BI__builtin_hlsl_elementwise_all>(),
18182-
ArrayRef<Value *>{Op0}, nullptr, "hlsl.all");
18180+
CGM.getHLSLRuntime().getAllIntrinsic(), ArrayRef<Value *>{Op0}, nullptr,
18181+
"hlsl.all");
1818318182
}
1818418183
case Builtin::BI__builtin_hlsl_elementwise_any: {
1818518184
Value *Op0 = EmitScalarExpr(E->getArg(0));

clang/lib/CodeGen/CGHLSLRuntime.h

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,20 @@
3030
#include <optional>
3131
#include <vector>
3232

33-
#define GENERATE_HLSL_INTRINSIC_BASE(IntrinsicPostfix) \
34-
llvm::Triple::ArchType Arch = getArch(); \
35-
switch (Arch) { \
36-
case llvm::Triple::dxil: \
37-
return llvm::Intrinsic::dx_##IntrinsicPostfix; \
38-
case llvm::Triple::spirv: \
39-
return llvm::Intrinsic::spv_##IntrinsicPostfix; \
40-
default: \
41-
llvm_unreachable("Intrinsic " #IntrinsicPostfix \
42-
" not supported by target architecture"); \
43-
}
44-
45-
// A function generator macro for when there is no builtins or
46-
// when builtins are mapped to a set of intrinsics for different types.
33+
// A function generator macro for picking the right intrinsic
34+
// for the target backend
4735
#define GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix) \
4836
llvm::Intrinsic::ID get##FunctionName##Intrinsic() { \
49-
GENERATE_HLSL_INTRINSIC_BASE(IntrinsicPostfix) \
50-
}
51-
52-
// A template function generator macro for when we have builtins.
53-
#define GENERATE_HLSL_INTRINSIC_TEMPLATE(BuiltinName, IntrinsicPostfix) \
54-
template <> llvm::Intrinsic::ID getIntrinsic<Builtin::BI__##BuiltinName>() { \
55-
GENERATE_HLSL_INTRINSIC_BASE(IntrinsicPostfix) \
37+
llvm::Triple::ArchType Arch = getArch(); \
38+
switch (Arch) { \
39+
case llvm::Triple::dxil: \
40+
return llvm::Intrinsic::dx_##IntrinsicPostfix; \
41+
case llvm::Triple::spirv: \
42+
return llvm::Intrinsic::spv_##IntrinsicPostfix; \
43+
default: \
44+
llvm_unreachable("Intrinsic " #IntrinsicPostfix \
45+
" not supported by target architecture"); \
46+
} \
5647
}
5748

5849
namespace llvm {
@@ -81,8 +72,7 @@ class CGHLSLRuntime {
8172
// Start of reserved area for HLSL intrinsic getters.
8273
//===----------------------------------------------------------------------===//
8374

84-
template <unsigned BI> llvm::Intrinsic::ID getIntrinsic();
85-
GENERATE_HLSL_INTRINSIC_TEMPLATE(builtin_hlsl_elementwise_all, all)
75+
GENERATE_HLSL_INTRINSIC_FUNCTION(All, all)
8676
GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
8777

8878
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)