Skip to content

Commit 9b10b8e

Browse files
committed
[TableGen] Avoid warnings with INT64_MIN
The number 0x8000000000000000 caused: warning: integer constant is so large that it is unsigned Emit the INT64_MIN macro instead of a negative literal. Triggered in #151687
1 parent 3af4cbb commit 9b10b8e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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(INT64_MIN),
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(INT64_MIN),
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
237237

238238
MatchTableRecord MatchTable::IntValue(unsigned NumBytes, int64_t IntValue) {
239239
assert(isUIntN(NumBytes * 8, IntValue) || isIntN(NumBytes * 8, IntValue));
240-
auto Str = llvm::to_string(IntValue);
240+
auto Str = IntValue == INT64_MIN ? "INT64_MIN" : llvm::to_string(IntValue);
241241
if (NumBytes == 1 && IntValue < 0)
242242
Str = "uint8_t(" + Str + ")";
243243
// TODO: Could optimize this directly to save the compiler some work when

0 commit comments

Comments
 (0)