Skip to content

Commit 84e48b0

Browse files
authored
Translate annotation string with the braces for UserSemantic decoration (#1895)
Decoration's handling is done alike to other decorations. However, we should preserve the braces so we save the input string after reverse translation.
1 parent 8b1e7f2 commit 84e48b0

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3164,7 +3164,9 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
31643164
.Case("force_pow2_depth", DecorationForcePow2DepthINTEL)
31653165
.Default(DecorationUserSemantic);
31663166
if (Dec == DecorationUserSemantic)
3167-
DecValues = std::vector<std::string>({AnnotatedDecoration.str()});
3167+
// Restore the braces to translate the whole input string
3168+
DecValues =
3169+
std::vector<std::string>({'{' + AnnotatedDecoration.str() + '}'});
31683170
else if (Dec == DecorationMergeINTEL) {
31693171
ValidDecorationFound = true;
31703172
std::pair<StringRef, StringRef> MergeValues = ValueStr.split(':');

test/extensions/INTEL/SPV_INTEL_fpga_memory_attributes/IntelFPGAMemoryAttributes.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
; CHECK-SPIRV-DAG: Decorate {{[0-9]+}} ForcePow2DepthINTEL 0
250250
; CHECK-SPIRV-DAG: Decorate {{[0-9]+}} ForcePow2DepthINTEL 1
251251

252+
; CHECK-SPIRV-DAG: Decorate {{[0-9]+}} UserSemantic "{sizeinfo:4,500}"
252253
; CHECK-SPIRV-NOT: Decorate [[#]] UserSemantic "{memory:MLAB}{sizeinfo:4,500}"
253254

254255
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
@@ -279,6 +280,7 @@ target triple = "spir"
279280
; CHECK-LLVM: [[STR_NMB_TE:@[0-9_.]+]] = {{.*}}{memory:DEFAULT}{numbanks:4}
280281
; CHECK-LLVM: [[STR_REG_VAR:@[0-9_.]+]] = {{.*}}{register:1}
281282
; CHECK-LLVM: [[STR_MEM_VAR:@[0-9_.]+]] = {{.*}}{memory:MLAB}
283+
; CHECK-LLVM: [[STR_MEM_VAR:@[0-9_.]+]] = {{.*}}{sizeinfo:4,500}
282284
; CHECK-LLVM: [[STR_MEM_SCT:@[0-9_.]+]] = {{.*}}{memory:BLOCK_RAM}
283285
; CHECK-LLVM: [[STR_BWD_VAR:@[0-9_.]+]] = {{.*}}{memory:DEFAULT}{bankwidth:8}
284286
; CHECK-LLVM: [[STR_BWD_SCT:@[0-9_.]+]] = {{.*}}{memory:DEFAULT}{bankwidth:4}

test/extensions/INTEL/SPV_INTEL_fpga_memory_attributes/IntelFPGAMemoryAttributesForStruct.ll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196

197197
; CHECK-SPIRV: Capability FPGAMemoryAttributesINTEL
198198
; CHECK-SPIRV: Extension "SPV_INTEL_fpga_memory_attributes"
199+
; CHECK-SPIRV-DAG: MemberDecorate {{[0-9]+}} 0 UserSemantic "{sizeinfo:4}"
199200
; CHECK-SPIRV-DAG: MemberDecorate {{[0-9]+}} 0 RegisterINTEL
200201
; CHECK-SPIRV-DAG: MemberDecorate {{[0-9]+}} 0 MemoryINTEL "DEFAULT"
201202
; CHECK-SPIRV-DAG: MemberDecorate {{[0-9]+}} 0 MemoryINTEL "MLAB"
@@ -242,6 +243,7 @@ target triple = "spir"
242243
%struct.state = type { [8 x i32] }
243244

244245
; CHECK-LLVM: [[STR_NMB_SCT:@[0-9_.]+]] = {{.*}}{memory:DEFAULT}{numbanks:4}
246+
; CHECK-LLVM: [[STR_SIZEINF:@[0-9_.]+]] = {{.*}}{sizeinfo:4}
245247
; CHECK-LLVM: [[STR_NMB_STE:@[0-9_.]+]] = {{.*}}{memory:DEFAULT}{numbanks:8}
246248
; CHECK-LLVM: [[STR_REG_SCT:@[0-9_.]+]] = {{.*}}{register:1}
247249
; CHECK-LLVM: [[STR_MEM_SCT:@[0-9_.]+]] = {{.*}}{memory:MLAB}
@@ -334,7 +336,8 @@ entry:
334336
%0 = bitcast %struct.numbanks_st* %s to i8*
335337
call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #5
336338
; CHECK-LLVM: %[[FLD_NMB_SCT:.*]] = getelementptr inbounds %struct.numbanks_st, %struct.numbanks_st* %{{[a-zA-Z0-9]+}}, i32 0, i32 0
337-
; CHECK-LLVM: call i32* @llvm.ptr.annotation.p0i32{{.*}}%[[FLD_NMB_SCT]]{{.*}}[[STR_NMB_SCT]]
339+
; CHECK-LLVM: %[[PTR_NMB_SCT:.*]] = call i32* @llvm.ptr.annotation.p0i32{{.*}}%[[FLD_NMB_SCT]]{{.*}}[[STR_NMB_SCT]]
340+
; CHECK-LLVM: call i32* @llvm.ptr.annotation.p0i32{{.*}}%[[PTR_NMB_SCT]]{{.*}}[[STR_SIZEINF]]
338341
%field = getelementptr inbounds %struct.numbanks_st, %struct.numbanks_st* %s, i32 0, i32 0
339342
%1 = call i32* @llvm.ptr.annotation.p0i32(i32* %field, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i32 0, i32 0), i32 3, i8* null)
340343
store i32 0, i32* %1, align 4, !tbaa !9

0 commit comments

Comments
 (0)