Add some missing node names
[oota-llvm.git] / lib / AsmParser / llvmAsmParser.y
index b71f618779be2d33c00751c437d9123fb369d038..5d9fada8dcadee01e35cd23e283df82137e6c1cb 100644 (file)
 %{
 #include "ParserInternals.h"
 #include "llvm/CallingConv.h"
+#include "llvm/InlineAsm.h"
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
 #include "llvm/SymbolTable.h"
+#include "llvm/Assembly/AutoUpgrade.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/MathExtras.h"
 #include <algorithm>
 #include <iostream>
 #include <list>
@@ -49,7 +52,8 @@ static Module *ParserResult;
 
 static bool ObsoleteVarArgs;
 static bool NewVarArgs;
-static BasicBlock* CurBB;
+static BasicBlock *CurBB;
+static GlobalVariable *CurGV;
 
 
 // This contains info used when building the body of a function.  It is
@@ -102,12 +106,16 @@ static struct PerModuleInfo {
       ThrowException(UndefinedReferences);
     }
 
+    // Look for intrinsic functions and CallInst that need to be upgraded
+    for (Module::iterator FI = CurrentModule->begin(),
+         FE = CurrentModule->end(); FI != FE; )
+      UpgradeCallsToIntrinsic(FI++);
+
     Values.clear();         // Clear out function local definitions
     Types.clear();
     CurrentModule = 0;
   }
 
-
   // GetForwardRefForGlobal - Check to see if there is a forward reference
   // for this global.  If so, remove it from the GlobalRefs map and return it.
   // If not, just return null.
@@ -301,11 +309,25 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
   case ValID::ConstUndefVal:      // Is it an undef value?
     return UndefValue::get(Ty);
 
+  case ValID::ConstZeroVal:      // Is it a zero value?
+    return Constant::getNullValue(Ty);
+    
   case ValID::ConstantVal:       // Fully resolved constant?
     if (D.ConstantValue->getType() != Ty)
       ThrowException("Constant expression type different from required type!");
     return D.ConstantValue;
 
+  case ValID::InlineAsmVal: {    // Inline asm expression
+    const PointerType *PTy = dyn_cast<PointerType>(Ty);
+    const FunctionType *FTy =
+      PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
+    if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
+      ThrowException("Invalid type for asm constraint string!");
+    InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
+                                   D.IAD->HasSideEffects);
+    D.destroy();   // Free InlineAsmDescriptor.
+    return IA;
+  }
   default:
     assert(0 && "Unhandled case!");
     return 0;
@@ -514,9 +536,10 @@ static void setValueName(Value *V, char *NameStr) {
 
 /// ParseGlobalVariable - Handle parsing of a global.  If Initializer is null,
 /// this is a declaration, otherwise it is a definition.
-static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
-                                bool isConstantGlobal, const Type *Ty,
-                                Constant *Initializer) {
+static GlobalVariable *
+ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
+                    bool isConstantGlobal, const Type *Ty,
+                    Constant *Initializer) {
   if (isa<FunctionType>(Ty))
     ThrowException("Cannot declare global vars of function type!");
 
@@ -547,7 +570,7 @@ static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
     GV->setLinkage(Linkage);
     GV->setConstant(isConstantGlobal);
     InsertValue(GV, CurModule.Values);
-    return;
+    return GV;
   }
 
   // If this global has a name, check to see if there is already a definition
@@ -572,7 +595,7 @@ static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
         if (isConstantGlobal)
           EGV->setConstant(true);
         EGV->setLinkage(Linkage);
-        return;
+        return EGV;
       }
 
       ThrowException("Redefinition of global variable named '" + Name +
@@ -585,6 +608,7 @@ static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
     new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
                        CurModule.CurrentModule);
   InsertValue(GV, CurModule.Values);
+  return GV;
 }
 
 // setTypeName - Set the specified type to the name given.  The name may be
@@ -749,14 +773,12 @@ static PATypeHolder HandleUpRefs(const Type *ty) {
   }
 
   if (ObsoleteVarArgs && NewVarArgs)
-  {
-    std::cerr << "This file is corrupt in that it uses both new and old style varargs\n";
-    abort();
-  }
+    ThrowException("This file is corrupt: it uses both new and old style varargs");
 
   if(ObsoleteVarArgs) {
     if(Function* F = Result->getNamedFunction("llvm.va_start")) {
-      assert(F->arg_size() == 0 && "Obsolete va_start takes 0 argument!");
+      if (F->arg_size() != 0)
+        ThrowException("Obsolete va_start takes 0 argument!");
       
       //foo = va_start()
       // ->
@@ -768,7 +790,7 @@ static PATypeHolder HandleUpRefs(const Type *ty) {
       const Type* ArgTy = F->getFunctionType()->getReturnType();
       const Type* ArgTyPtr = PointerType::get(ArgTy);
       Function* NF = Result->getOrInsertFunction("llvm.va_start", 
-                                                 RetTy, ArgTyPtr, 0);
+                                                 RetTy, ArgTyPtr, (Type *)0);
 
       while (!F->use_empty()) {
         CallInst* CI = cast<CallInst>(F->use_back());
@@ -782,7 +804,9 @@ static PATypeHolder HandleUpRefs(const Type *ty) {
     }
     
     if(Function* F = Result->getNamedFunction("llvm.va_end")) {
-      assert(F->arg_size() == 1 && "Obsolete va_end takes 1 argument!");
+      if(F->arg_size() != 1)
+        ThrowException("Obsolete va_end takes 1 argument!");
+
       //vaend foo
       // ->
       //bar = alloca 1 of typeof(foo)
@@ -791,7 +815,7 @@ static PATypeHolder HandleUpRefs(const Type *ty) {
       const Type* ArgTy = F->getFunctionType()->getParamType(0);
       const Type* ArgTyPtr = PointerType::get(ArgTy);
       Function* NF = Result->getOrInsertFunction("llvm.va_end", 
-                                                 RetTy, ArgTyPtr, 0);
+                                                 RetTy, ArgTyPtr, (Type *)0);
 
       while (!F->use_empty()) {
         CallInst* CI = cast<CallInst>(F->use_back());
@@ -804,24 +828,30 @@ static PATypeHolder HandleUpRefs(const Type *ty) {
     }
 
     if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
-      assert(F->arg_size() == 1 && "Obsolete va_copy takes 1 argument!");
+      if(F->arg_size() != 1)
+        ThrowException("Obsolete va_copy takes 1 argument!");
       //foo = vacopy(bar)
       // ->
       //a = alloca 1 of typeof(foo)
-      //vacopy(a, bar)
+      //b = alloca 1 of typeof(foo)
+      //store bar -> b
+      //vacopy(a, b)
       //foo = load a
       
       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
       const Type* ArgTy = F->getFunctionType()->getReturnType();
       const Type* ArgTyPtr = PointerType::get(ArgTy);
       Function* NF = Result->getOrInsertFunction("llvm.va_copy", 
-                                                 RetTy, ArgTyPtr, ArgTy, 0);
+                                                 RetTy, ArgTyPtr, ArgTyPtr,
+                                                 (Type *)0);
 
       while (!F->use_empty()) {
         CallInst* CI = cast<CallInst>(F->use_back());
         AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
-        new CallInst(NF, a, CI->getOperand(1), "", CI);
-        Value* foo = new LoadInst(a, "vacopy.fix.2", CI);
+        AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
+        new StoreInst(CI->getOperand(1), b, CI);
+        new CallInst(NF, a, b, "", CI);
+        Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
         CI->replaceAllUsesWith(foo);
         CI->getParent()->getInstList().erase(CI);
       }
@@ -914,6 +944,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
 %type <BoolVal>       GlobalType                  // GLOBAL or CONSTANT?
 %type <BoolVal>       OptVolatile                 // 'volatile' or not
 %type <BoolVal>       OptTailCall                 // TAIL CALL or plain CALL.
+%type <BoolVal>       OptSideEffect               // 'sideeffect' or not.
 %type <Linkage>       OptLinkage
 %type <Endianness>    BigOrLittle
 
@@ -942,13 +973,14 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
 
 %token <StrVal> VAR_ID LABELSTR STRINGCONSTANT
 %type  <StrVal> Name OptName OptAssign
-
+%type  <UIntVal> OptAlign OptCAlign
+%type <StrVal> OptSection SectionString
 
 %token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
-%token DECLARE GLOBAL CONSTANT VOLATILE
+%token DECLARE GLOBAL CONSTANT SECTION VOLATILE
 %token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK  APPENDING
-%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
-%token DEPLIBS CALL TAIL
+%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN
+%token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
 %token CC_TOK CCC_TOK FASTCC_TOK COLDCC_TOK
 %type <UIntVal> OptCallingConv
 
@@ -966,6 +998,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
 // Other Operators
 %type  <OtherOpVal> ShiftOps
 %token <OtherOpVal> PHI_TOK CAST SELECT SHL SHR VAARG
+%token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT
 %token VAARG_old VANEXT_old //OBSOLETE
 
 
@@ -1029,6 +1062,47 @@ OptCallingConv : /*empty*/      { $$ = CallingConv::C; } |
                    $$ = $2;
                  };
 
+// OptAlign/OptCAlign - An optional alignment, and an optional alignment with
+// a comma before it.
+OptAlign : /*empty*/        { $$ = 0; } |
+           ALIGN EUINT64VAL {
+  $$ = $2;
+  if ($$ != 0 && !isPowerOf2_32($$))
+    ThrowException("Alignment must be a power of two!");
+};
+OptCAlign : /*empty*/            { $$ = 0; } |
+            ',' ALIGN EUINT64VAL {
+  $$ = $3;
+  if ($$ != 0 && !isPowerOf2_32($$))
+    ThrowException("Alignment must be a power of two!");
+};
+
+
+SectionString : SECTION STRINGCONSTANT {
+  for (unsigned i = 0, e = strlen($2); i != e; ++i)
+    if ($2[i] == '"' || $2[i] == '\\')
+      ThrowException("Invalid character in section name!");
+  $$ = $2;
+};
+
+OptSection : /*empty*/ { $$ = 0; } |
+             SectionString { $$ = $1; };
+
+// GlobalVarAttributes - Used to pass the attributes string on a global.  CurGV
+// is set to be the global we are processing.
+//
+GlobalVarAttributes : /* empty */ {} |
+                     ',' GlobalVarAttribute GlobalVarAttributes {};
+GlobalVarAttribute : SectionString {
+    CurGV->setSection($1);
+    free($1);
+  } 
+  | ALIGN EUINT64VAL {
+    if ($2 != 0 && !isPowerOf2_32($2))
+      ThrowException("Alignment must be a power of two!");
+    CurGV->setAlignment($2);
+  };
+
 //===----------------------------------------------------------------------===//
 // Types includes all predefined types... except void, because it can only be
 // used in specific contexts (function returning void for example).  To have
@@ -1087,12 +1161,12 @@ UpRTypes : '\\' EUINT64VAL {                   // Type UpReference
   }
   | '<' EUINT64VAL 'x' UpRTypes '>' {          // Packed array type?
      const llvm::Type* ElemTy = $4->get();
-     if ((unsigned)$2 != $2) {
+     if ((unsigned)$2 != $2)
         ThrowException("Unsigned result not equal to signed result");
-     }
-     if(!ElemTy->isPrimitiveType()) {
+     if (!ElemTy->isPrimitiveType())
         ThrowException("Elemental type of a PackedType must be primitive");
-     }
+     if (!isPowerOf2_32($2))
+       ThrowException("Vector length should be a power of 2!");
      $$ = new PATypeHolder(HandleUpRefs(PackedType::get(*$4, (unsigned)$2)));
      delete $4;
   }
@@ -1195,11 +1269,12 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
                      " when array has size " + itostr(NumElements) + "!");
     std::vector<Constant*> Vals;
     if (ETy == Type::SByteTy) {
-      for (char *C = $3; C != EndStr; ++C)
+      for (signed char *C = (signed char *)$3; C != (signed char *)EndStr; ++C)
         Vals.push_back(ConstantSInt::get(ETy, *C));
     } else if (ETy == Type::UByteTy) {
-      for (char *C = $3; C != EndStr; ++C)
-        Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
+      for (unsigned char *C = (unsigned char *)$3; 
+           C != (unsigned char*)EndStr; ++C)
+        Vals.push_back(ConstantUInt::get(ETy, *C));
     } else {
       free($3);
       ThrowException("Cannot build string arrays of non byte sized elements!");
@@ -1446,8 +1521,11 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
   | LogicalOps '(' ConstVal ',' ConstVal ')' {
     if ($3->getType() != $5->getType())
       ThrowException("Logical operator types must match!");
-    if (!$3->getType()->isIntegral())
-      ThrowException("Logical operands must have integral types!");
+    if (!$3->getType()->isIntegral()) {
+      if (!isa<PackedType>($3->getType()) || 
+          !cast<PackedType>($3->getType())->getElementType()->isIntegral())
+        ThrowException("Logical operator requires integral operands!");
+    }
     $$ = ConstantExpr::get($1, $3, $5);
   }
   | SetCondOps '(' ConstVal ',' ConstVal ')' {
@@ -1461,9 +1539,16 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
     if (!$3->getType()->isInteger())
       ThrowException("Shift constant expression requires integer operand!");
     $$ = ConstantExpr::get($1, $3, $5);
+  }
+  | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' {
+        if (!isa<PackedType>($3->getType()))
+      ThrowException("First operand of extractelement must be "
+                     "packed type!");
+    if ($5->getType() != Type::UIntTy)
+      ThrowException("Second operand of extractelement must be uint!");
+    $$ = ConstantExpr::getExtractElement($3, $5);
   };
 
-
 // ConstVector - A list of comma separated constants.
 ConstVector : ConstVector ',' ConstVal {
     ($$ = $1)->push_back($3);
@@ -1499,6 +1584,9 @@ FunctionList : FunctionList Function {
   | FunctionList FunctionProto {
     $$ = $1;
   }
+  | FunctionList MODULE ASM_TOK AsmBlock {
+    $$ = $1;
+  }  
   | FunctionList IMPLEMENTATION {
     $$ = $1;
   }
@@ -1537,13 +1625,20 @@ ConstPool : ConstPool OptAssign TYPE TypesV {
   }
   | ConstPool FunctionProto {       // Function prototypes can be in const pool
   }
+  | ConstPool MODULE ASM_TOK AsmBlock {  // Asm blocks can be in the const pool
+  }
   | ConstPool OptAssign OptLinkage GlobalType ConstVal {
     if ($5 == 0) ThrowException("Global value initializer is not a constant!");
-    ParseGlobalVariable($2, $3, $4, $5->getType(), $5);
+    CurGV = ParseGlobalVariable($2, $3, $4, $5->getType(), $5);
+                                                       } GlobalVarAttributes {
+    CurGV = 0;
   }
   | ConstPool OptAssign EXTERNAL GlobalType Types {
-    ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, *$5, 0);
+    CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage,
+                                             $4, *$5, 0);
     delete $5;
+                                                   } GlobalVarAttributes {
+    CurGV = 0;
   }
   | ConstPool TARGET TargetDefinition { 
   }
@@ -1553,6 +1648,17 @@ ConstPool : ConstPool OptAssign TYPE TypesV {
   };
 
 
+AsmBlock : STRINGCONSTANT {
+  const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
+  char *EndStr = UnEscapeLexed($1, true);
+  std::string NewAsm($1, EndStr);
+  free($1);
+
+  if (AsmSoFar.empty())
+    CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
+  else
+    CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
+};
 
 BigOrLittle : BIG    { $$ = Module::BigEndian; };
 BigOrLittle : LITTLE { $$ = Module::LittleEndian; };
@@ -1627,7 +1733,8 @@ ArgList : ArgListH {
     $$ = 0;
   };
 
-FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')' {
+FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')' 
+                  OptSection OptAlign {
   UnEscapeLexed($3);
   std::string FunctionName($3);
   free($3);  // Free strdup'd memory!
@@ -1685,6 +1792,11 @@ FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')' {
 
   CurFun.FunctionStart(Fn);
   Fn->setCallingConv($1);
+  Fn->setAlignment($8);
+  if ($7) {
+    Fn->setSection($7);
+    free($7);
+  }
 
   // Add all of the arguments we parsed to the function...
   if ($5) {                     // Is null if empty...
@@ -1732,6 +1844,13 @@ FunctionProto : DECLARE { CurFun.isDeclare = true; } FunctionHeaderH {
 //                        Rules to match Basic Blocks
 //===----------------------------------------------------------------------===//
 
+OptSideEffect : /* empty */ {
+    $$ = false;
+  }
+  | SIDEEFFECT {
+    $$ = true;
+  };
+
 ConstValueRef : ESINT64VAL {    // A reference to a direct constant
     $$ = ValID::create($1);
   }
@@ -1753,6 +1872,9 @@ ConstValueRef : ESINT64VAL {    // A reference to a direct constant
   | UNDEF {
     $$ = ValID::createUndef();
   }
+  | ZEROINITIALIZER {     // A vector zero constant.
+    $$ = ValID::createZeroInit();
+  }
   | '<' ConstVector '>' { // Nonempty unsized packed vector
     const Type *ETy = (*$2)[0]->getType();
     int NumElements = $2->size(); 
@@ -1779,6 +1901,15 @@ ConstValueRef : ESINT64VAL {    // A reference to a direct constant
   }
   | ConstExpr {
     $$ = ValID::create($1);
+  }
+  | ASM_TOK OptSideEffect STRINGCONSTANT ',' STRINGCONSTANT {
+    char *End = UnEscapeLexed($3, true);
+    std::string AsmStr = std::string($3, End);
+    End = UnEscapeLexed($5, true);
+    std::string Constraints = std::string($5, End);
+    $$ = ValID::createInlineAsm(AsmStr, Constraints, $2);
+    free($3);
+    free($5);
   };
 
 // SymbolicValueRef - Reference to one of two ways of symbolically refering to
@@ -2010,8 +2141,11 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
     delete $2;
   }
   | LogicalOps Types ValueRef ',' ValueRef {
-    if (!(*$2)->isIntegral())
-      ThrowException("Logical operator requires integral operands!");
+    if (!(*$2)->isIntegral()) {
+      if (!isa<PackedType>($2->get()) ||
+          !cast<PackedType>($2->get())->getElementType()->isIntegral())
+        ThrowException("Logical operator requires integral operands!");
+    }
     $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5));
     if ($$ == 0)
       ThrowException("binary operator returned null!");
@@ -2069,7 +2203,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
     ObsoleteVarArgs = true;
     const Type* ArgTy = $2->getType();
     Function* NF = CurModule.CurrentModule->
-      getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, 0);
+      getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
 
     //b = vaarg a, t -> 
     //foo = alloca 1 of t
@@ -2088,7 +2222,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
     ObsoleteVarArgs = true;
     const Type* ArgTy = $2->getType();
     Function* NF = CurModule.CurrentModule->
-      getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, 0);
+      getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
 
     //b = vanext a, t ->
     //foo = alloca 1 of t
@@ -2106,6 +2240,26 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
     $$ = new LoadInst(foo);
     delete $4;
   }
+  | EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
+    if (!isa<PackedType>($2->getType()))
+      ThrowException("First operand of extractelement must be "
+                     "packed type!");
+    if ($4->getType() != Type::UIntTy)
+      ThrowException("Second operand of extractelement must be uint!");
+    $$ = new ExtractElementInst($2, $4);
+  }
+  | INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
+    if (!isa<PackedType>($2->getType()))
+      ThrowException("First operand of insertelement must be "
+                     "packed type!");
+    if ($4->getType() != 
+        cast<PackedType>($2->getType())->getElementType())
+      ThrowException("Second operand of insertelement must be "
+                     "packed element type!");
+    if ($6->getType() != Type::UIntTy)
+      ThrowException("Third operand of insertelement must be uint!");
+    $$ = new InsertElementInst($2, $4, $6);
+  }
   | PHI_TOK PHIList {
     const Type *Ty = $2->front().first->getType();
     if (!Ty->isFirstClassType())
@@ -2198,20 +2352,20 @@ OptVolatile : VOLATILE {
 
 
 
-MemoryInst : MALLOC Types {
-    $$ = new MallocInst(*$2);
+MemoryInst : MALLOC Types OptCAlign {
+    $$ = new MallocInst(*$2, 0, $3);
     delete $2;
   }
-  | MALLOC Types ',' UINT ValueRef {
-    $$ = new MallocInst(*$2, getVal($4, $5));
+  | MALLOC Types ',' UINT ValueRef OptCAlign {
+    $$ = new MallocInst(*$2, getVal($4, $5), $6);
     delete $2;
   }
-  | ALLOCA Types {
-    $$ = new AllocaInst(*$2);
+  | ALLOCA Types OptCAlign {
+    $$ = new AllocaInst(*$2, 0, $3);
     delete $2;
   }
-  | ALLOCA Types ',' UINT ValueRef {
-    $$ = new AllocaInst(*$2, getVal($4, $5));
+  | ALLOCA Types ',' UINT ValueRef OptCAlign {
+    $$ = new AllocaInst(*$2, getVal($4, $5), $6);
     delete $2;
   }
   | FREE ResolvedVal {