Skip to content

Commit a433592

Browse files
authored
[TableGen] Fix wrong bits output in GenericTable (llvm#66867)
We used to return `int` in `getAsInt`, while `IntInit::getValue` returns `int64_t` and `utohexstr` needs `uint64_t`. The casting causes the wrong hex value when printing bits value.
1 parent 6fc8667 commit a433592

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/test/TableGen/generic-tables.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ include "llvm/TableGen/SearchableTable.td"
2525
// CHECK-LABEL: GET_ATable_IMPL
2626
// CHECK: constexpr AEntry ATable[] = {
2727
// CHECK-NOT: { "aaa"
28-
// CHECK: { "baz", 0x2, 0x6, 0x0 },
29-
// CHECK: { "foo", 0x4, 0x4, 0x0 },
30-
// CHECK: { "foobar", 0x4, 0x5, 0x0 },
31-
// CHECK: { "bar", 0x5, 0x3, 0x0 },
28+
// CHECK: { "baz", 0x2, 0x6, 0xFFFFFFFF00000000 },
29+
// CHECK: { "foo", 0x4, 0x4, 0x100000000 },
30+
// CHECK: { "foobar", 0x4, 0x5, 0x100000000 },
31+
// CHECK: { "bar", 0x5, 0x3, 0x100000000 },
3232
// CHECK: };
3333

3434
// CHECK: const AEntry *lookupATableByValues(uint8_t Val1, uint16_t Val2) {

llvm/utils/TableGen/SearchableTableEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ using namespace llvm;
3131

3232
namespace {
3333

34-
int getAsInt(Init *B) {
34+
int64_t getAsInt(Init *B) {
3535
return cast<IntInit>(
3636
B->convertInitializerTo(IntRecTy::get(B->getRecordKeeper())))
3737
->getValue();
3838
}
39-
int getInt(Record *R, StringRef Field) {
39+
int64_t getInt(Record *R, StringRef Field) {
4040
return getAsInt(R->getValueInit(Field));
4141
}
4242

0 commit comments

Comments
 (0)