fix file header
[oota-llvm.git] / lib / AsmParser / Lexer.l
index 47c067ba8ce7e2736c03ac3b47464226362e1b30..3092891527db01b7443ef1956c391568e9a740b3 100644 (file)
 
 %{
 #include "ParserInternals.h"
+#include "llvm/Module.h"
 #include <list>
 #include "llvmAsmParser.h"
-#include <ctype.h>
-#include <stdlib.h>
+#include <cctype>
+#include <cstdlib>
 
 #define RET_TOK(type, Enum, sym) \
   llvmAsmlval.type = Instruction::Enum; return sym
@@ -72,15 +73,17 @@ static uint64_t HexIntToVal(const char *Buffer) {
 // 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!");
   // Behave nicely in the face of C TBAA rules... see:
   // http://www.nullstone.com/htmls/category/aliastyp.htm
-  //
-  char *ProxyPointer = (char*)&Result;
-  return *(double*)ProxyPointer;   // Cast Hex constant to double
+  union {
+    uint64_t UI;
+    double FP;
+  } UIntToFP;
+  UIntToFP.UI = HexIntToVal(Buffer);
+
+  assert(sizeof(double) == sizeof(uint64_t) &&
+         "Data sizes incompatible on this target!");
+  return UIntToFP.FP;   // Cast Hex constant to double
 }
 
 
@@ -126,7 +129,7 @@ VarID       %[-a-zA-Z$._][-a-zA-Z$._0-9]*
 Label       [-a-zA-Z$._0-9]+:
 
 /* Quoted names can contain any character except " and \ */
-StringConstant \"[^\"]+\"
+StringConstant \"[^\"]*\"
 
 
 /* [PN]Integer: match positive and negative literal integer values that
@@ -167,15 +170,23 @@ constant        { return CONSTANT; }
 const           { return CONST; }
 internal        { return INTERNAL; }
 linkonce        { return LINKONCE; }
+weak            { return WEAK; }
 appending       { return APPENDING; }
 uninitialized   { return EXTERNAL; }    /* Deprecated, turn into external */
 external        { return EXTERNAL; }
 implementation  { return IMPLEMENTATION; }
+zeroinitializer { return ZEROINITIALIZER; }
 \.\.\.          { return DOTDOTDOT; }
 null            { return NULL_TOK; }
 to              { return TO; }
 except          { return EXCEPT; }
 not             { return NOT; }  /* Deprecated, turned into XOR */
+target          { return TARGET; }
+endian          { return ENDIAN; }
+pointersize     { return POINTERSIZE; }
+little          { return LITTLE; }
+big             { return BIG; }
+volatile        { return VOLATILE; }
 
 void            { llvmAsmlval.PrimType = Type::VoidTy  ; return VOID;   }
 bool            { llvmAsmlval.PrimType = Type::BoolTy  ; return BOOL;   }
@@ -208,16 +219,20 @@ setgt           { RET_TOK(BinaryOpVal, SetGT, SETGT); }
 setle           { RET_TOK(BinaryOpVal, SetLE, SETLE); }
 setge           { RET_TOK(BinaryOpVal, SetGE, SETGE); }
 
-phi             { RET_TOK(OtherOpVal, PHINode, PHI); }
+phi             { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
 call            { RET_TOK(OtherOpVal, Call, CALL); }
 cast            { RET_TOK(OtherOpVal, Cast, CAST); }
 shl             { RET_TOK(OtherOpVal, Shl, SHL); }
 shr             { RET_TOK(OtherOpVal, Shr, SHR); }
+va_arg          { return VA_ARG; /* FIXME: OBSOLETE */}
+vanext          { RET_TOK(OtherOpVal, VANext, VANEXT); }
+vaarg           { RET_TOK(OtherOpVal, VAArg , VAARG); }
 
 ret             { RET_TOK(TermOpVal, Ret, RET); }
 br              { RET_TOK(TermOpVal, Br, BR); }
 switch          { RET_TOK(TermOpVal, Switch, SWITCH); }
 invoke          { RET_TOK(TermOpVal, Invoke, INVOKE); }
+unwind          { RET_TOK(TermOpVal, Unwind, UNWIND); }
 
 
 malloc          { RET_TOK(MemOpVal, Malloc, MALLOC); }