Author: Chris Bieneman Date: 2022-07-28T09:16:11-05:00 New Revision: fe13002bb37caf7425dfdb56b8f891c3f33b54b6
URL: https://github.com/llvm/llvm-project/commit/fe13002bb37caf7425dfdb56b8f891c3f33b54b6 DIFF: https://github.com/llvm/llvm-project/commit/fe13002bb37caf7425dfdb56b8f891c3f33b54b6.diff LOG: [HLSL] Add __builtin_hlsl_create_handle This is pretty straightforward, it just adds a builtin to return a pointer to a resource handle. This maps to a dx intrinsic. The shape of this builtin and the underlying intrinsic will likely shift a bit as this implementation becomes more feature complete, but this is a good basis to get started. Depends on D128569. Differential Revision: https://reviews.llvm.org/D130016 Added: clang/test/CodeGenHLSL/builtins/create_handle.hlsl Modified: clang/include/clang/Basic/Builtins.def llvm/include/llvm/IR/IntrinsicsDirectX.td Removed: ################################################################################ diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index f19807dbbb0bb..c67f0dfe9ab04 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -1700,6 +1700,7 @@ LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG) // HLSL LANGBUILTIN(__builtin_hlsl_wave_active_count_bits, "Uib", "nc", HLSL_LANG) +LANGBUILTIN(__builtin_hlsl_create_handle, "v*Uc", "nc", HLSL_LANG) // Builtins for XRay BUILTIN(__xray_customevent, "vcC*z", "") diff --git a/clang/test/CodeGenHLSL/builtins/create_handle.hlsl b/clang/test/CodeGenHLSL/builtins/create_handle.hlsl new file mode 100644 index 0000000000000..61226c2b54e72 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/create_handle.hlsl @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s + +void fn() { + (void)__builtin_hlsl_create_handle(0); +} + +// CHECK: call ptr @llvm.dx.create.handle(i8 0) diff --git a/llvm/include/llvm/IR/IntrinsicsDirectX.td b/llvm/include/llvm/IR/IntrinsicsDirectX.td index 57c47a15bd70a..80e5b7919b9c6 100644 --- a/llvm/include/llvm/IR/IntrinsicsDirectX.td +++ b/llvm/include/llvm/IR/IntrinsicsDirectX.td @@ -17,4 +17,6 @@ def int_dx_group_id : Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem, IntrWi def int_dx_thread_id_in_group : Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem, IntrWillReturn]>; def int_dx_flattened_thread_id_in_group : Intrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrWillReturn]>; +def int_dx_create_handle : ClangBuiltin<"__builtin_hlsl_create_handle">, + Intrinsic<[ llvm_ptr_ty ], [llvm_i8_ty], [IntrNoMem, IntrWillReturn]>; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits