[PATCH] D157079: [TableGen] Fix wrong lex result on 64-bit integer boundaries
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 12:48:07 PDT 2023
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.
LGTM.
================
Comment at: llvm/lib/TableGen/TGLexer.cpp:468
+
+ // Check if it's a hex or a binary value
if (CurPtr[-1] == '0') {
----------------
================
Comment at: llvm/lib/TableGen/TGLexer.cpp:484
- // Check for a sign without a digit.
- if (!isdigit(CurPtr[0])) {
- if (CurPtr[-1] == '-')
- return tgtok::minus;
- else if (CurPtr[-1] == '+')
- return tgtok::plus;
+ // For a hex or binary value, we always convert it to an unsigned value
+ bool IsMinus = false;
----------------
Add a period to a full sentence.
================
Comment at: llvm/test/TableGen/64-bit-int.td:22
+#ifdef VALID
+ bits<64> BinVal = 0x8000000000000000;
+ bits<64> HexVal = 0b1000000000000000000000000000000000000000000000000000000000000000;
----------------
I think you swapped BinVal and HexVal?
I think it's useful to give the same suffix for Bin/Hex/Dec values with the same value.
```
BinVal0 = 0b.........;
HexVal0 = 0x8000000000000000;
bits<64> DecVal0 = 9223372036854775808;
HexVal1 = 0x8000000000000001;
bits<64> DecVal1 = 9223372036854775809;
```
This grouping makes it clear that 9223372036854775808 equals 0x8000000000000000....
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157079/new/
https://reviews.llvm.org/D157079
More information about the llvm-commits
mailing list