Skip to content

Commit 34e8354

Browse files
generate OpDecorate from demangled postfix (_R*) of a builtin
1 parent 7d6a5d3 commit 34e8354

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,14 +1298,18 @@ static void createRoundingModeDecoration(Instruction *I,
12981298
IRBuilder<> &B) {
12991299
LLVMContext &Ctx = I->getContext();
13001300
Type *Int32Ty = Type::getInt32Ty(Ctx);
1301-
SmallVector<Metadata *> MDs = {
1302-
MDNode::get(Ctx, ConstantAsMetadata::get(ConstantInt::get(
1303-
Int32Ty, SPIRV::Decoration::FPRoundingMode))),
1304-
MDNode::get(Ctx, ConstantAsMetadata::get(
1305-
ConstantInt::get(Int32Ty, RoundingModeDeco)))};
13061301
setInsertPointAfterDef(B, I);
1307-
B.CreateIntrinsic(Intrinsic::spv_assign_decoration, {I->getType()},
1308-
{I, MetadataAsValue::get(Ctx, MDNode::get(Ctx, MDs))});
1302+
B.CreateIntrinsic(
1303+
Intrinsic::spv_assign_decoration, {I->getType()},
1304+
{I,
1305+
MetadataAsValue::get(
1306+
Ctx,
1307+
MDNode::get(
1308+
Ctx, {MDNode::get(
1309+
Ctx, {ConstantAsMetadata::get(ConstantInt::get(
1310+
Int32Ty, SPIRV::Decoration::FPRoundingMode)),
1311+
ConstantAsMetadata::get(ConstantInt::get(
1312+
Int32Ty, RoundingModeDeco))})}))});
13091313
}
13101314

13111315
Instruction *SPIRVEmitIntrinsics::visitCallInst(CallInst &Call) {

llvm/test/CodeGen/SPIRV/instructions/integer-casts.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@
2424
; CHECK-DAG: OpName [[ZEXT8_16v4:%.*]] "u8tou16v4"
2525
; CHECK-DAG: OpName [[ZEXT16_32v4:%.*]] "u16tou32v4"
2626

27+
; CHECK-DAG: OpDecorate %[[#R17:]] FPRoundingMode RTZ
28+
; CHECK-DAG: OpDecorate %[[#R18:]] FPRoundingMode RTE
29+
; CHECK-DAG: OpDecorate %[[#R19:]] FPRoundingMode RTP
30+
; CHECK-DAG: OpDecorate %[[#R20:]] FPRoundingMode RTN
31+
2732
; CHECK-DAG: [[F32:%.*]] = OpTypeFloat 32
2833
; CHECK-DAG: [[F16:%.*]] = OpTypeFloat 16
2934
; CHECK-DAG: [[U64:%.*]] = OpTypeInt 64 0
3035
; CHECK-DAG: [[U32:%.*]] = OpTypeInt 32 0
3136
; CHECK-DAG: [[U16:%.*]] = OpTypeInt 16 0
3237
; CHECK-DAG: [[U8:%.*]] = OpTypeInt 8 0
38+
; CHECK-DAG: [[F32v2:%.*]] = OpTypeVector [[F32]] 2
3339
; CHECK-DAG: [[U32v4:%.*]] = OpTypeVector [[U32]] 4
3440
; CHECK-DAG: [[U16v4:%.*]] = OpTypeVector [[U16]] 4
3541
; CHECK-DAG: [[U8v4:%.*]] = OpTypeVector [[U8]] 4
@@ -254,6 +260,10 @@ define <4 x i32> @u16tou32v4(<4 x i16> %a) {
254260
; CHECK: %[[#]] = OpSConvert [[U32v4]] %[[#]]
255261
; CHECK: %[[#]] = OpConvertUToF [[F32]] %[[#]]
256262
; CHECK: %[[#]] = OpConvertUToF [[F32]] %[[#]]
263+
; CHECK: %[[#R17:]] = OpFConvert [[F32v2]] %[[#]]
264+
; CHECK: %[[#R18:]] = OpFConvert [[F32v2]] %[[#]]
265+
; CHECK: %[[#R19:]] = OpFConvert [[F32v2]] %[[#]]
266+
; CHECK: %[[#R20:]] = OpFConvert [[F32v2]] %[[#]]
257267
; CHECK: OpFunctionEnd
258268
define dso_local spir_kernel void @test_wrappers(ptr addrspace(4) %arg, i64 %arg_ptr, <4 x i8> %arg_v2) {
259269
%r1 = call spir_func i32 @__spirv_ConvertFToU(float 0.000000e+00)

0 commit comments

Comments
 (0)