[llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l
Chris Lattner
lattner at cs.uiuc.edu
Thu Apr 17 17:18:01 PDT 2003
Changes in directory llvm/lib/AsmParser:
Lexer.l updated: 1.30 -> 1.31
---
Log message:
Allow hexadecimal integer constants to be used
---
Diffs of the changes:
Index: llvm/lib/AsmParser/Lexer.l
diff -u llvm/lib/AsmParser/Lexer.l:1.30 llvm/lib/AsmParser/Lexer.l:1.31
--- llvm/lib/AsmParser/Lexer.l:1.30 Wed Apr 16 15:28:31 2003
+++ llvm/lib/AsmParser/Lexer.l Thu Apr 17 17:17:32 2003
@@ -48,10 +48,7 @@
return Result;
}
-// HexToFP - Convert the ascii string in hexidecimal format to the floating
-// point representation of it.
-//
-static double HexToFP(const char *Buffer) {
+static uint64_t HexIntToVal(const char *Buffer) {
uint64_t Result = 0;
for (; *Buffer; ++Buffer) {
uint64_t OldRes = Result;
@@ -67,6 +64,15 @@
if (Result < OldRes) // Uh, oh, overflow detected!!!
ThrowException("constant bigger than 64 bits detected!");
}
+ return Result;
+}
+
+
+// HexToFP - Convert the ascii string in hexidecimal format to the floating
+// point representation of it.
+//
+static double HexToFP(const char *Buffer) {
+ uint64_t Result = HexIntToVal(Buffer);
assert(sizeof(double) == sizeof(Result) &&
"Data sizes incompatible on this target!");
@@ -142,6 +148,11 @@
* hexadecimal number for when exponential notation is not precise enough.
*/
HexFPConstant 0x[0-9A-Fa-f]+
+
+/* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing
+ * it to deal with 64 bit numbers.
+ */
+HexIntConstant [us]0x[0-9A-Fa-f]+
%%
{Comment} { /* Ignore comments for now */ }
@@ -249,7 +260,10 @@
llvmAsmlval.SInt64Val = -Val;
return ESINT64VAL;
}
-
+{HexIntConstant} {
+ llvmAsmlval.UInt64Val = HexIntToVal(yytext+3);
+ return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
+ }
{EPInteger} { llvmAsmlval.UIntVal = atoull(yytext+1); return UINTVAL; }
{ENInteger} {
More information about the llvm-commits
mailing list