beanz created this revision.
beanz added reviewers: aaron.ballman, Anastasia, kuhar, bogner, python3kgae.
Herald added a project: All.
beanz requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: llvm-commits.

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 <https://reviews.llvm.org/D128569>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130016

Files:
  clang/include/clang/Basic/Builtins.def
  clang/test/CodeGenHLSL/builtins/create_handle.hlsl
  llvm/include/llvm/IR/IntrinsicsDirectX.td


Index: llvm/include/llvm/IR/IntrinsicsDirectX.td
===================================================================
--- llvm/include/llvm/IR/IntrinsicsDirectX.td
+++ llvm/include/llvm/IR/IntrinsicsDirectX.td
@@ -17,4 +17,6 @@
 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]>;
 }
Index: clang/test/CodeGenHLSL/builtins/create_handle.hlsl
===================================================================
--- /dev/null
+++ 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)
Index: clang/include/clang/Basic/Builtins.def
===================================================================
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -1700,6 +1700,7 @@
 
 // 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", "")


Index: llvm/include/llvm/IR/IntrinsicsDirectX.td
===================================================================
--- llvm/include/llvm/IR/IntrinsicsDirectX.td
+++ llvm/include/llvm/IR/IntrinsicsDirectX.td
@@ -17,4 +17,6 @@
 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]>;
 }
Index: clang/test/CodeGenHLSL/builtins/create_handle.hlsl
===================================================================
--- /dev/null
+++ 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)
Index: clang/include/clang/Basic/Builtins.def
===================================================================
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -1700,6 +1700,7 @@
 
 // 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", "")
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to