forked from OSchip/llvm-project
Allow hexadecimal integer constants to be used
llvm-svn: 5802
This commit is contained in:
parent
acdbe7158d
commit
e509bd47bf
|
@ -48,10 +48,7 @@ static uint64_t atoull(const char *Buffer) {
|
|||
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 @@ static double HexToFP(const char *Buffer) {
|
|||
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 @@ FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
|
|||
* 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 @@ getelementptr { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
|
|||
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} {
|
||||
|
|
Loading…
Reference in New Issue