blob: 8a8ba0f52bc1effdd8c54600f1f8054ce1e2711b [file]
// 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;
};
// CHECK-SPIRV-DAG: @A0 = external hidden thread_local addrspace(7) externally_initialized constant <4 x float>, !spirv.Decorations ![[#METADATA_0:]]
[shader("vertex")]
S0 main1(float4 input : A) : B {
// CHECK: %[[ARG:.*]] = alloca %struct.S0
// CHECK-SPIRV: %[[INPUT:.*]] = load <4 x float>, ptr addrspace(7) @A0, align 4
// CHECK-DXIL: %[[INPUT:.*]] = call <4 x float> @llvm.dx.load.input.v4f32(i32 0, i32 0, i8 0, i32 poison)
// CHECK-DXIL: call void @{{.*}}main1{{.*}}(ptr %[[ARG]], <4 x float> %[[INPUT]])
// CHECK-SPIRV: call spir_func void @{{.*}}main1{{.*}}(ptr %[[ARG]], <4 x float> %[[INPUT]])
// CHECK: %[[ST:.*]] = load %struct.S0, ptr %[[ARG]]
// CHECK: %[[POSITIONS:.*]] = extractvalue %struct.S0 %[[ST]], 0
// CHECK-SPIRV: store [2 x <4 x float>] %[[POSITIONS]], ptr addrspace(8) @B0, align 4
// CHECK-DXIL: %[[POS0:.*]] = extractvalue [2 x <4 x float>] %[[POSITIONS]], 0
// CHECK-DXIL: call void @llvm.dx.store.output.v4f32(i32 0, i32 0, i8 0, <4 x float> %[[POS0]])
// CHECK-DXIL: %[[POS1:.*]] = extractvalue [2 x <4 x float>] %[[POSITIONS]], 1
// CHECK-DXIL: call void @llvm.dx.store.output.v4f32(i32 0, i32 1, i8 0, <4 x float> %[[POS1]])
// CHECK: %[[COLOR:.*]] = extractvalue %struct.S0 %[[ST]], 1
// CHECK-SPIRV: store <4 x float> %[[COLOR]], ptr addrspace(8) @B2, align 4
// CHECK-DXIL: call void @llvm.dx.store.output.v4f32(i32 1, i32 0, i8 0, <4 x float> %[[COLOR]])
S0 output;
output.position[0] = input;
output.position[1] = input;
output.color = input;
return output;
}
// CHECK-DXIL: !dx.semantic.signatures = !{![[#ENTRY_SIG:]]}
// CHECK-DXIL: ![[#ENTRY_SIG]] = !{ptr @main1, ![[#INPUT_SIG:]], ![[#OUTPUT_SIG:]]}
// CHECK-DXIL: ![[#INPUT_SIG]] = !{![[#INPUT_ELEMENT:]]}
// CHECK-DXIL: ![[#OUTPUT_SIG]] = !{![[#OUTPUT_ELEMENT_0:]], ![[#OUTPUT_ELEMENT_1:]]}
// CHECK-SPIRV-DAG: ![[#METADATA_0]] = !{![[#METADATA_1:]]}
// CHECK-SPIRV-DAG: ![[#METADATA_1]] = !{i32 30, i32 0}
// | `- Location index
// `-> Decoration "Location"