Changes to support making the shift instructions be true BinaryOperators.
[oota-llvm.git] / lib / AsmParser / Lexer.l.cvs
index b47ae910c7ca450abf5fd7434a028a72cce84b07..e5e8256bc111204b65dbb97bf27b8534a96e6912 100644 (file)
@@ -41,27 +41,13 @@ void set_scan_string (const char * str) {
 
 // Construct a token value for a non-obsolete token
 #define RET_TOK(type, Enum, sym) \
-  llvmAsmlval.type.opcode = Instruction::Enum; \
-  llvmAsmlval.type.obsolete = false; \
+  llvmAsmlval.type = Instruction::Enum; \
   return sym
 
 // Construct a token value for an obsolete token
-#define RET_TOK_OBSOLETE(type, Enum, sym) \
-  llvmAsmlval.type.opcode = Instruction::Enum; \
-  llvmAsmlval.type.obsolete = true; \
-  return sym
-
-// Construct a token value for a non-obsolete type
-#define RET_TY(CType, sym) \
-  llvmAsmlval.TypeVal.type = new PATypeHolder(CType); \
-  llvmAsmlval.TypeVal.signedness = isSignless; \
-  return sym
-
-// Construct a token value for an obsolete token
-#define RET_TY_OBSOLETE(CType, sign, sym) \
-  llvmAsmlval.TypeVal.type = new PATypeHolder(CType); \
-  llvmAsmlval.TypeVal.signedness = sign; \
-  return sym
+#define RET_TY(CTYPE, SYM) \
+  llvmAsmlval.PrimType = CTYPE;\
+  return SYM
 
 namespace llvm {
 
@@ -162,8 +148,11 @@ using namespace llvm;
 /* Comments start with a ; and go till end of line */
 Comment    ;.*
 
-/* Variable(Value) identifiers start with a % sign */
-VarID       %[-a-zA-Z$._][-a-zA-Z$._0-9]*
+/* Local Values and Type identifiers start with a % sign */
+LocalVarName       %[-a-zA-Z$._][-a-zA-Z$._0-9]*
+
+/* Global Value identifiers start with an @ sign */
+GlobalVarName       @[-a-zA-Z$._][-a-zA-Z$._0-9]*
 
 /* Label identifiers end with a colon */
 Label       [-a-zA-Z$._0-9]+:
@@ -171,16 +160,16 @@ QuoteLabel \"[^\"]+\":
 
 /* Quoted names can contain any character except " and \ */
 StringConstant \"[^\"]*\"
+AtStringConstant @\"[^\"]*\"
+  
+/* LocalVarID/GlobalVarID: match an unnamed local variable slot ID. */
+LocalVarID     %[0-9]+
+GlobalVarID    @[0-9]+
 
+/* Integer types are specified with i and a bitwidth */
+IntegerType i[0-9]+
 
-/* [PN]Integer: match positive and negative literal integer values that
- * are preceeded by a '%' character.  These represent unnamed variable slots.
- */
-EPInteger     %[0-9]+
-ENInteger    %-[0-9]+
-
-
-/* E[PN]Integer: match positive and negative literal integer values */
+/* E[PN]Integer: match positive and negative literal integer values. */
 PInteger   [0-9]+
 NInteger  -[0-9]+
 
@@ -206,6 +195,7 @@ end             { return ENDTOK; }
 true            { return TRUETOK;  }
 false           { return FALSETOK; }
 declare         { return DECLARE; }
+define          { return DEFINE; }
 global          { return GLOBAL; }
 constant        { return CONSTANT; }
 internal        { return INTERNAL; }
@@ -214,8 +204,8 @@ weak            { return WEAK; }
 appending       { return APPENDING; }
 dllimport       { return DLLIMPORT; }
 dllexport       { return DLLEXPORT; }
+hidden          { return HIDDEN; }
 extern_weak     { return EXTERN_WEAK; }
-uninitialized   { return EXTERNAL; }    /* Deprecated, turn into external */
 external        { return EXTERNAL; }
 implementation  { return IMPLEMENTATION; }
 zeroinitializer { return ZEROINITIALIZER; }
@@ -223,17 +213,11 @@ zeroinitializer { return ZEROINITIALIZER; }
 undef           { return UNDEF; }
 null            { return NULL_TOK; }
 to              { return TO; }
-except          { RET_TOK(TermOpVal, Unwind, UNWIND); }
-not             { return NOT; }  /* Deprecated, turned into XOR */
 tail            { return TAIL; }
 target          { return TARGET; }
 triple          { return TRIPLE; }
 deplibs         { return DEPLIBS; }
-endian          { return ENDIAN; }
-pointersize     { return POINTERSIZE; }
 datalayout      { return DATALAYOUT; }
-little          { return LITTLE; }
-big             { return BIG; }
 volatile        { return VOLATILE; }
 align           { return ALIGN;  }
 section         { return SECTION; }
@@ -243,52 +227,69 @@ sideeffect      { return SIDEEFFECT; }
 
 cc              { return CC_TOK; }
 ccc             { return CCC_TOK; }
-csretcc         { return CSRETCC_TOK; }
 fastcc          { return FASTCC_TOK; }
 coldcc          { return COLDCC_TOK; }
 x86_stdcallcc   { return X86_STDCALLCC_TOK; }
 x86_fastcallcc  { return X86_FASTCALLCC_TOK; }
 
-void            { RET_TY(Type::VoidTy, VOID);  }
-bool            { RET_TY(Type::BoolTy, BOOL);  }
-sbyte           { RET_TY_OBSOLETE(Type::SByteTy, isSigned,   SBYTE); }
-ubyte           { RET_TY_OBSOLETE(Type::UByteTy, isUnsigned, UBYTE); }
-short           { RET_TY_OBSOLETE(Type::ShortTy, isSigned,   SHORT); }
-ushort          { RET_TY_OBSOLETE(Type::UShortTy,isUnsigned, USHORT); }
-int             { RET_TY_OBSOLETE(Type::IntTy,   isSigned,   INT);    }
-uint            { RET_TY_OBSOLETE(Type::UIntTy,  isUnsigned, UINT);   }
-long            { RET_TY_OBSOLETE(Type::LongTy,  isSigned,   LONG);   }
-ulong           { RET_TY_OBSOLETE(Type::ULongTy, isUnsigned, ULONG);  }
-float           { RET_TY(Type::FloatTy, FLOAT);  }
-double          { RET_TY(Type::DoubleTy, DOUBLE); }
-label           { RET_TY(Type::LabelTy,  LABEL);  }
+inreg           { return INREG; }
+sret            { return SRET;  }
+
+void            { RET_TY(Type::VoidTy,  VOID);  }
+float           { RET_TY(Type::FloatTy, FLOAT); }
+double          { RET_TY(Type::DoubleTy,DOUBLE);}
+label           { RET_TY(Type::LabelTy, LABEL); }
 type            { return TYPE;   }
 opaque          { return OPAQUE; }
+{IntegerType}   { uint64_t NumBits = atoull(yytext+1);
+                  if (NumBits < IntegerType::MIN_INT_BITS || 
+                      NumBits > IntegerType::MAX_INT_BITS)
+                    GenerateError("Bitwidth for integer type out of range!");
+                  const Type* Ty = IntegerType::get(NumBits);
+                  RET_TY(Ty, INTTYPE);
+                }
 
 add             { RET_TOK(BinaryOpVal, Add, ADD); }
 sub             { RET_TOK(BinaryOpVal, Sub, SUB); }
 mul             { RET_TOK(BinaryOpVal, Mul, MUL); }
-div             { RET_TOK_OBSOLETE(BinaryOpVal, UDiv, UDIV); }
 udiv            { RET_TOK(BinaryOpVal, UDiv, UDIV); }
 sdiv            { RET_TOK(BinaryOpVal, SDiv, SDIV); }
 fdiv            { RET_TOK(BinaryOpVal, FDiv, FDIV); }
-rem             { RET_TOK_OBSOLETE(BinaryOpVal, URem, UREM); }
 urem            { RET_TOK(BinaryOpVal, URem, UREM); }
 srem            { RET_TOK(BinaryOpVal, SRem, SREM); }
 frem            { RET_TOK(BinaryOpVal, FRem, FREM); }
+shl             { RET_TOK(BinaryOpVal, Shl, SHL); }
+lshr            { RET_TOK(BinaryOpVal, LShr, LSHR); }
+ashr            { RET_TOK(BinaryOpVal, AShr, ASHR); }
 and             { RET_TOK(BinaryOpVal, And, AND); }
 or              { RET_TOK(BinaryOpVal, Or , OR ); }
 xor             { RET_TOK(BinaryOpVal, Xor, XOR); }
-setne           { RET_TOK(BinaryOpVal, SetNE, SETNE); }
-seteq           { RET_TOK(BinaryOpVal, SetEQ, SETEQ); }
-setlt           { RET_TOK(BinaryOpVal, SetLT, SETLT); }
-setgt           { RET_TOK(BinaryOpVal, SetGT, SETGT); }
-setle           { RET_TOK(BinaryOpVal, SetLE, SETLE); }
-setge           { RET_TOK(BinaryOpVal, SetGE, SETGE); }
+icmp            { RET_TOK(OtherOpVal,  ICmp,  ICMP); }
+fcmp            { RET_TOK(OtherOpVal,  FCmp,  FCMP); }
+
+eq              { return EQ;  }
+ne              { return NE;  }
+slt             { return SLT; }
+sgt             { return SGT; }
+sle             { return SLE; }
+sge             { return SGE; }
+ult             { return ULT; }
+ugt             { return UGT; }
+ule             { return ULE; }
+uge             { return UGE; }
+oeq             { return OEQ; }
+one             { return ONE; }
+olt             { return OLT; }
+ogt             { return OGT; }
+ole             { return OLE; }
+oge             { return OGE; }
+ord             { return ORD; }
+uno             { return UNO; }
+ueq             { return UEQ; }
+une             { return UNE; }
 
 phi             { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
 call            { RET_TOK(OtherOpVal, Call, CALL); }
-cast            { RET_TOK_OBSOLETE(CastOpVal, Trunc, TRUNC); }
 trunc           { RET_TOK(CastOpVal, Trunc, TRUNC); }
 zext            { RET_TOK(CastOpVal, ZExt, ZEXT); }
 sext            { RET_TOK(CastOpVal, SExt, SEXT); }
@@ -302,12 +303,6 @@ inttoptr        { RET_TOK(CastOpVal, IntToPtr, INTTOPTR); }
 ptrtoint        { RET_TOK(CastOpVal, PtrToInt, PTRTOINT); }
 bitcast         { RET_TOK(CastOpVal, BitCast, BITCAST); }
 select          { RET_TOK(OtherOpVal, Select, SELECT); }
-shl             { RET_TOK(OtherOpVal, Shl, SHL); }
-shr             { RET_TOK_OBSOLETE(OtherOpVal, LShr, LSHR); }
-lshr            { RET_TOK(OtherOpVal, LShr, LSHR); }
-ashr            { RET_TOK(OtherOpVal, AShr, ASHR); }
-vanext          { return VANEXT_old; }
-vaarg           { return VAARG_old; }
 va_arg          { RET_TOK(OtherOpVal, VAArg , VAARG); }
 ret             { RET_TOK(TermOpVal, Ret, RET); }
 br              { RET_TOK(TermOpVal, Br, BR); }
@@ -328,10 +323,15 @@ insertelement   { RET_TOK(OtherOpVal, InsertElement, INSERTELEMENT); }
 shufflevector   { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); }
 
 
-{VarID}         {
+{LocalVarName}  {
                   UnEscapeLexed(yytext+1);
                   llvmAsmlval.StrVal = strdup(yytext+1);             // Skip %
-                  return VAR_ID;
+                  return LOCALVAR;
+                }
+{GlobalVarName} {
+                  UnEscapeLexed(yytext+1);
+                  llvmAsmlval.StrVal = strdup(yytext+1);             // Skip @
+                  return GLOBALVAR;
                 }
 {Label}         {
                   yytext[strlen(yytext)-1] = 0;  // nuke colon
@@ -355,6 +355,12 @@ shufflevector   { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); }
                    llvmAsmlval.StrVal = strdup(yytext+1);  // Nuke start quote
                    return STRINGCONSTANT;
                  }
+{AtStringConstant} {
+                     yytext[strlen(yytext)-1] = 0;           // nuke end quote
+                     llvmAsmlval.StrVal = strdup(yytext+2);  // Nuke @, quote
+                     return ATSTRINGCONSTANT;
+                   }
+
 
 
 {PInteger}      { llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; }
@@ -371,20 +377,19 @@ shufflevector   { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); }
                    return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
                  }
 
-{EPInteger}     {
+{LocalVarID}     {
                   uint64_t Val = atoull(yytext+1);
                   if ((unsigned)Val != Val)
                     GenerateError("Invalid value number (too large)!");
                   llvmAsmlval.UIntVal = unsigned(Val);
-                  return UINTVAL;
+                  return LOCALVAL_ID;
                 }
-{ENInteger}     {
-                  uint64_t Val = atoull(yytext+2);
-                  // +1:  we have bigger negative range
-                  if (Val > (uint64_t)INT32_MAX+1)
-                    GenerateError("Constant too large for signed 32 bits!");
-                  llvmAsmlval.SIntVal = (int)-Val;
-                  return SINTVAL;
+{GlobalVarID}   {
+                  uint64_t Val = atoull(yytext+1);
+                  if ((unsigned)Val != Val)
+                    GenerateError("Invalid value number (too large)!");
+                  llvmAsmlval.UIntVal = unsigned(Val);
+                  return GLOBALVAL_ID;
                 }
 
 {FPConstant}    { llvmAsmlval.FPVal = atof(yytext); return FPVAL; }