|
30 | 30 | #include <optional>
|
31 | 31 | #include <vector>
|
32 | 32 |
|
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 |
47 | 35 | #define GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix) \
|
48 | 36 | 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 | + } \ |
56 | 47 | }
|
57 | 48 |
|
58 | 49 | namespace llvm {
|
@@ -81,8 +72,7 @@ class CGHLSLRuntime {
|
81 | 72 | // Start of reserved area for HLSL intrinsic getters.
|
82 | 73 | //===----------------------------------------------------------------------===//
|
83 | 74 |
|
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) |
86 | 76 | GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
|
87 | 77 |
|
88 | 78 | //===----------------------------------------------------------------------===//
|
|
0 commit comments