Skip to content

Commit 3784bfa

Browse files
authored
[TableGen] Fix GIMT_Encode8 with a large argument (llvm#153429)
error: integer literal is too large to be represented in a signed integer type, interpreting as unsigned [-Werror,-Wimplicitly-unsigned-literal] Introduced in llvm#153391
1 parent 7efceca commit 3784bfa

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

llvm/test/TableGen/GlobalISelCombinerEmitter/match-table.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def MyCombiner: GICombiner<"GenMyCombiner", [
181181
// CHECK-NEXT: GIM_RecordInsnIgnoreCopies, /*DefineMI*/1, /*MI*/0, /*OpIdx*/1, // MIs[1]
182182
// CHECK-NEXT: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_CONSTANT),
183183
// CHECK-NEXT: // MIs[1] z
184-
// CHECK-NEXT: GIM_CheckLiteralInt, /*MI*/1, /*Op*/1, GIMT_Encode8(18446744073709551574),
184+
// CHECK-NEXT: GIM_CheckLiteralInt, /*MI*/1, /*Op*/1, GIMT_Encode8(18446744073709551574u),
185185
// CHECK-NEXT: GIM_CheckConstantInt8, /*MI*/0, /*Op*/2, 43,
186186
// CHECK-NEXT: GIM_CheckIsSafeToFold, /*NumInsns*/1,
187187
// CHECK-NEXT: // Combiner Rule #5: InOutInstTest1

llvm/test/TableGen/GlobalISelEmitter/int64min.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ def ANDI : I<(outs GPR:$dst), (ins GPR:$src1, i64imm:$src2), []>;
1717
// CHECK-NEXT: GIM_RootCheckRegBankForClass, /*Op*/1, /*RC*/GIMT_Encode2(MyTarget::GPRRegClassID),
1818
// CHECK-NEXT: // MIs[0] Operand 2
1919
// CHECK-NEXT: GIM_RootCheckType, /*Op*/2, /*Type*/GILLT_s64,
20-
// CHECK-NEXT: GIM_CheckConstantInt, /*MI*/0, /*Op*/2, GIMT_Encode8(9223372036854775808),
20+
// CHECK-NEXT: GIM_CheckConstantInt, /*MI*/0, /*Op*/2, GIMT_Encode8(9223372036854775808u),
2121
// CHECK-NEXT: // (and:{ *:[i64] } GPR:{ *:[i64] }:$rs1, -9223372036854775808:{ *:[i64] }) => (ANDI:{ *:[i64] } GPR:{ *:[i64] }:$rs1, -9223372036854775808:{ *:[i64] })
2222
// CHECK-NEXT: GIR_BuildRootMI, /*Opcode*/GIMT_Encode2(MyTarget::ANDI),
2323
// CHECK-NEXT: GIR_RootToRootCopy, /*OpIdx*/0, // DstI[dst]
2424
// CHECK-NEXT: GIR_RootToRootCopy, /*OpIdx*/1, // rs1
25-
// CHECK-NEXT: GIR_AddImm, /*InsnID*/0, /*Imm*/GIMT_Encode8(9223372036854775808),
25+
// CHECK-NEXT: GIR_AddImm, /*InsnID*/0, /*Imm*/GIMT_Encode8(9223372036854775808u),
2626
// CHECK-NEXT: GIR_RootConstrainSelectedInstOperands,
2727
// CHECK-NEXT: // GIR_Coverage, 0,
2828
// CHECK-NEXT: GIR_EraseRootFromParent_Done,

llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ MatchTableRecord MatchTable::IntValue(unsigned NumBytes, int64_t IntValue) {
241241
if (NumBytes < 8)
242242
UIntValue &= (UINT64_C(1) << NumBytes * 8) - 1;
243243
std::string Str = llvm::to_string(UIntValue);
244+
if (UIntValue > INT64_MAX)
245+
Str += 'u';
244246
// TODO: Could optimize this directly to save the compiler some work when
245247
// building the file
246248
return MatchTableRecord(std::nullopt, Str, NumBytes,

0 commit comments

Comments
 (0)