Use live out sets for return values instead of imp_defs, which is cleaner and faster.
[oota-llvm.git] / lib / AsmParser / Lexer.l
index 1c85059757a58ad8cafa4ebb71ef54f925922d90..2edc50fa10198d9c3a256387b08d33af03f3522e 100644 (file)
@@ -107,7 +107,7 @@ char *UnEscapeLexed(char *Buffer, bool AllowNull) {
   for (char *BIn = Buffer; *BIn; ) {
     if (BIn[0] == '\\' && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
       char Tmp = BIn[3]; BIn[3] = 0;     // Terminate string
-      *BOut = strtol(BIn+1, 0, 16);  // Convert to number
+      *BOut = (char)strtol(BIn+1, 0, 16);  // Convert to number
       if (!AllowNull && !*BOut)
         ThrowException("String literal cannot accept \\00 escape!");
       
@@ -139,6 +139,7 @@ VarID       %[-a-zA-Z$._][-a-zA-Z$._0-9]*
 
 /* Label identifiers end with a colon */
 Label       [-a-zA-Z$._0-9]+:
+QuoteLabel \"[^\"]+\":
 
 /* Quoted names can contain any character except " and \ */
 StringConstant \"[^\"]*\"
@@ -179,7 +180,6 @@ false           { return FALSETOK; }
 declare         { return DECLARE; }
 global          { return GLOBAL; }
 constant        { return CONSTANT; }
-const           { return CONST; }
 internal        { return INTERNAL; }
 linkonce        { return LINKONCE; }
 weak            { return WEAK; }
@@ -189,11 +189,14 @@ external        { return EXTERNAL; }
 implementation  { return IMPLEMENTATION; }
 zeroinitializer { return ZEROINITIALIZER; }
 \.\.\.          { return DOTDOTDOT; }
+undef           { return UNDEF; }
 null            { return NULL_TOK; }
 to              { return TO; }
 except          { RET_TOK(TermOpVal, Unwind, UNWIND); }
 not             { return NOT; }  /* Deprecated, turned into XOR */
 target          { return TARGET; }
+triple          { return TRIPLE; }
+deplibs         { return DEPLIBS; }
 endian          { return ENDIAN; }
 pointersize     { return POINTERSIZE; }
 little          { return LITTLE; }
@@ -212,8 +215,8 @@ long            { llvmAsmlval.PrimType = Type::LongTy  ; return LONG;   }
 ulong           { llvmAsmlval.PrimType = Type::ULongTy ; return ULONG;  }
 float           { llvmAsmlval.PrimType = Type::FloatTy ; return FLOAT;  }
 double          { llvmAsmlval.PrimType = Type::DoubleTy; return DOUBLE; }
-type            { llvmAsmlval.PrimType = Type::TypeTy  ; return TYPE;   }
 label           { llvmAsmlval.PrimType = Type::LabelTy ; return LABEL;  }
+type            { return TYPE;   }
 opaque          { return OPAQUE; }
 
 add             { RET_TOK(BinaryOpVal, Add, ADD); }
@@ -246,7 +249,7 @@ br              { RET_TOK(TermOpVal, Br, BR); }
 switch          { RET_TOK(TermOpVal, Switch, SWITCH); }
 invoke          { RET_TOK(TermOpVal, Invoke, INVOKE); }
 unwind          { RET_TOK(TermOpVal, Unwind, UNWIND); }
-
+unreachable     { RET_TOK(TermOpVal, Unreachable, UNREACHABLE); }
 
 malloc          { RET_TOK(MemOpVal, Malloc, MALLOC); }
 alloca          { RET_TOK(MemOpVal, Alloca, ALLOCA); }
@@ -267,6 +270,12 @@ getelementptr   { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
                  llvmAsmlval.StrVal = strdup(yytext);
                  return LABELSTR; 
                 }
+{QuoteLabel}    {
+                  yytext[strlen(yytext)-2] = 0;  // nuke colon, end quote
+                  UnEscapeLexed(yytext+1);
+                 llvmAsmlval.StrVal = strdup(yytext+1);
+                 return LABELSTR; 
+                }
 
 {StringConstant} { // Note that we cannot unescape a string constant here!  The
                    // string constant might contain a \00 which would not be 
@@ -293,13 +302,19 @@ getelementptr   { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
                    return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
                  }
 
-{EPInteger}     { llvmAsmlval.UIntVal = atoull(yytext+1); return UINTVAL; }
+{EPInteger}     {
+                  uint64_t Val = atoull(yytext+1);
+                  if ((unsigned)Val != Val)
+                    ThrowException("Invalid value number (too large)!");
+                  llvmAsmlval.UIntVal = unsigned(Val);
+                  return UINTVAL;
+                }
 {ENInteger}     {
                   uint64_t Val = atoull(yytext+2);
                  // +1:  we have bigger negative range
                  if (Val > (uint64_t)INT32_MAX+1)
                    ThrowException("Constant too large for signed 32 bits!");
-                  llvmAsmlval.SIntVal = -Val;
+                  llvmAsmlval.SIntVal = (int)-Val;
                  return SINTVAL;
                 }