[clang] [llvm] [HLSL] Add initial support for output semantics (PR #168095)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 10:50:45 PST 2025


================
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple spirv-linux-vulkan-library -x hlsl -emit-llvm -finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV -DTARGET=spv
+// RUN: %clang_cc1 -triple dxil-px-shadermodel6.3-library -x hlsl -emit-llvm -finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DXIL -DTARGET=dx
+
+struct S0 {
+  float4 position[2];
+  float4 color;
+};
+
+
+[shader("pixel")]
+S0 main1(float4 input : A) : B {
+// CHECK:         %[[#ARG:]] = alloca %struct.S0, align 16
+// CHECK-SPIRV: %[[#INPUT:]] = load <4 x float>, ptr addrspace(7) @A0, align 16
+// CHECK-DXIL:           %A0 = call <4 x float> @llvm.dx.load.input.v4f32(i32 4, i32 0, i32 0, i8 0, i32 poison)
+// CHECK-DXIL:                 call void @{{.*}}main1{{.*}}(ptr %[[#ARG]], <4 x float> %A0)
+// CHECK-SPIRV:                call spir_func void @{{.*}}main1{{.*}}(ptr %[[#ARG]], <4 x float> %[[#INPUT]])
+
+  // CHECK:        %[[#ST:]] = load %struct.S0, ptr %[[#ARG]], align 16
+  // CHECK:       %[[#TMP:]] = extractvalue %struct.S0 %[[#ST]], 0
+  // CHECK-SPIRV:              store [2 x <4 x float>] %[[#TMP]], ptr addrspace(8) @B0, align 16
----------------
s-perron wrote:

Could we have something to make sure that the location for `@B*` variables have the correct location? We sort of get it from the index in the name, but that is not what the backend looks at right?

https://github.com/llvm/llvm-project/pull/168095


More information about the llvm-commits mailing list