Dump the old va_arg and va_next upgrade support. No need to keep track of
[oota-llvm.git] / lib / AsmParser / llvmAsmParser.y
index 10270eba3888715409ca67cee961f36b02c83280..51fe7c9cc5c707af04549bba38ae1003124a48d5 100644 (file)
 #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 "llvm/Support/Streams.h"
 #include <algorithm>
-#include <iostream>
 #include <list>
 #include <utility>
 
@@ -58,16 +57,14 @@ static Module *ParserResult;
 //
 //#define DEBUG_UPREFS 1
 #ifdef DEBUG_UPREFS
-#define UR_OUT(X) std::cerr << X
+#define UR_OUT(X) llvm_cerr << X
 #else
 #define UR_OUT(X)
 #endif
 
 #define YYERROR_VERBOSE 1
 
-static bool ObsoleteVarArgs;
 static bool NewVarArgs;
-static BasicBlock *CurBB;
 static GlobalVariable *CurGV;
 
 
@@ -124,11 +121,6 @@ static struct PerModuleInfo {
       return;
     }
 
-    // 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;
@@ -813,12 +805,10 @@ static PATypeHolder HandleUpRefs(const Type *ty) {
   return Ty;
 }
 
-
 // common code from the two 'RunVMAsmParser' functions
 static Module* RunParser(Module * M) {
 
   llvmAsmlineno = 1;      // Reset the current line number...
-  ObsoleteVarArgs = false;
   NewVarArgs = false;
   CurModule.CurrentModule = M;
 
@@ -837,113 +827,6 @@ static Module* RunParser(Module * M) {
   Module *Result = ParserResult;
   ParserResult = 0;
 
-  //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
-  {
-    Function* F;
-    if ((F = Result->getNamedFunction("llvm.va_start"))
-        && F->getFunctionType()->getNumParams() == 0)
-      ObsoleteVarArgs = true;
-    if((F = Result->getNamedFunction("llvm.va_copy"))
-       && F->getFunctionType()->getNumParams() == 1)
-      ObsoleteVarArgs = true;
-  }
-
-  if (ObsoleteVarArgs && NewVarArgs) {
-    GenerateError(
-      "This file is corrupt: it uses both new and old style varargs");
-    return 0;
-  }
-
-  if(ObsoleteVarArgs) {
-    if(Function* F = Result->getNamedFunction("llvm.va_start")) {
-      if (F->arg_size() != 0) {
-        GenerateError("Obsolete va_start takes 0 argument!");
-        return 0;
-      }
-      
-      //foo = va_start()
-      // ->
-      //bar = alloca typeof(foo)
-      //va_start(bar)
-      //foo = load bar
-
-      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_start", 
-                                                 RetTy, ArgTyPtr, (Type *)0);
-
-      while (!F->use_empty()) {
-        CallInst* CI = cast<CallInst>(F->use_back());
-        AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
-        new CallInst(NF, bar, "", CI);
-        Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
-        CI->replaceAllUsesWith(foo);
-        CI->getParent()->getInstList().erase(CI);
-      }
-      Result->getFunctionList().erase(F);
-    }
-    
-    if(Function* F = Result->getNamedFunction("llvm.va_end")) {
-      if(F->arg_size() != 1) {
-        GenerateError("Obsolete va_end takes 1 argument!");
-        return 0;
-      }
-
-      //vaend foo
-      // ->
-      //bar = alloca 1 of typeof(foo)
-      //vaend bar
-      const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
-      const Type* ArgTy = F->getFunctionType()->getParamType(0);
-      const Type* ArgTyPtr = PointerType::get(ArgTy);
-      Function* NF = Result->getOrInsertFunction("llvm.va_end", 
-                                                 RetTy, ArgTyPtr, (Type *)0);
-
-      while (!F->use_empty()) {
-        CallInst* CI = cast<CallInst>(F->use_back());
-        AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
-        new StoreInst(CI->getOperand(1), bar, CI);
-        new CallInst(NF, bar, "", CI);
-        CI->getParent()->getInstList().erase(CI);
-      }
-      Result->getFunctionList().erase(F);
-    }
-
-    if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
-      if(F->arg_size() != 1) {
-        GenerateError("Obsolete va_copy takes 1 argument!");
-        return 0;
-      }
-      //foo = vacopy(bar)
-      // ->
-      //a = alloca 1 of typeof(foo)
-      //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, ArgTyPtr,
-                                                 (Type *)0);
-
-      while (!F->use_empty()) {
-        CallInst* CI = cast<CallInst>(F->use_back());
-        AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", 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);
-      }
-      Result->getFunctionList().erase(F);
-    }
-  }
-
   return Result;
 }
 
@@ -1002,13 +885,16 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
   bool                              BoolVal;
 
   char                             *StrVal;   // This memory is strdup'd!
-  llvm::ValID                             ValIDVal; // strdup'd memory maybe!
-
-  llvm::Instruction::BinaryOps            BinaryOpVal;
-  llvm::Instruction::TermOps              TermOpVal;
-  llvm::Instruction::MemoryOps            MemOpVal;
-  llvm::Instruction::OtherOps             OtherOpVal;
-  llvm::Module::Endianness                Endianness;
+  llvm::ValID                       ValIDVal; // strdup'd memory maybe!
+
+  llvm::Instruction::BinaryOps      BinaryOpVal;
+  llvm::Instruction::TermOps        TermOpVal;
+  llvm::Instruction::MemoryOps      MemOpVal;
+  llvm::Instruction::CastOps        CastOpVal;
+  llvm::Instruction::OtherOps       OtherOpVal;
+  llvm::Module::Endianness          Endianness;
+  llvm::ICmpInst::Predicate         IPredicate;
+  llvm::FCmpInst::Predicate         FPredicate;
 }
 
 %type <ModuleVal>     Module FunctionList
@@ -1076,17 +962,26 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
 
 // Binary Operators
 %type  <BinaryOpVal> ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories
-%token <BinaryOpVal> ADD SUB MUL DIV REM AND OR XOR
-%token <BinaryOpVal> SETLE SETGE SETLT SETGT SETEQ SETNE  // Binary Comarators
+%token <BinaryOpVal> ADD SUB MUL UDIV SDIV FDIV UREM SREM FREM AND OR XOR
+%token <BinaryOpVal> SETLE SETGE SETLT SETGT SETEQ SETNE  // Binary Comparators
+%token <OtherOpVal> ICMP FCMP
+%type  <IPredicate> IPredicates
+%type  <FPredicate> FPredicates
+%token  EQ NE SLT SGT SLE SGE ULT UGT ULE UGE 
+%token  OEQ ONE OLT OGT OLE OGE ORD UNO UEQ UNE
 
 // Memory Instructions
 %token <MemOpVal> MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR
 
+// Cast Operators
+%type <CastOpVal> CastOps
+%token <CastOpVal> TRUNC ZEXT SEXT FPTRUNC FPEXT BITCAST
+%token <CastOpVal> UITOFP SITOFP FPTOUI FPTOSI INTTOPTR PTRTOINT
+
 // Other Operators
 %type  <OtherOpVal> ShiftOps
-%token <OtherOpVal> PHI_TOK CAST SELECT SHL SHR VAARG
+%token <OtherOpVal> PHI_TOK SELECT SHL LSHR ASHR VAARG
 %token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
-%token VAARG_old VANEXT_old //OBSOLETE
 
 
 %start Module
@@ -1114,11 +1009,31 @@ EINT64VAL : EUINT64VAL {
 // Operations that are notably excluded from this list include:
 // RET, BR, & SWITCH because they end basic blocks and are treated specially.
 //
-ArithmeticOps: ADD | SUB | MUL | DIV | REM;
+ArithmeticOps: ADD | SUB | MUL | UDIV | SDIV | FDIV | UREM | SREM | FREM;
 LogicalOps   : AND | OR | XOR;
 SetCondOps   : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;
-
-ShiftOps  : SHL | SHR;
+CastOps      : TRUNC | ZEXT | SEXT | FPTRUNC | FPEXT | BITCAST | 
+               UITOFP | SITOFP | FPTOUI | FPTOSI | INTTOPTR | PTRTOINT;
+ShiftOps     : SHL | LSHR | ASHR;
+IPredicates  
+  : EQ   { $$ = ICmpInst::ICMP_EQ; }  | NE   { $$ = ICmpInst::ICMP_NE; }
+  | SLT  { $$ = ICmpInst::ICMP_SLT; } | SGT  { $$ = ICmpInst::ICMP_SGT; }
+  | SLE  { $$ = ICmpInst::ICMP_SLE; } | SGE  { $$ = ICmpInst::ICMP_SGE; }
+  | ULT  { $$ = ICmpInst::ICMP_ULT; } | UGT  { $$ = ICmpInst::ICMP_UGT; }
+  | ULE  { $$ = ICmpInst::ICMP_ULE; } | UGE  { $$ = ICmpInst::ICMP_UGE; } 
+  ;
+
+FPredicates  
+  : OEQ  { $$ = FCmpInst::FCMP_OEQ; } | ONE  { $$ = FCmpInst::FCMP_ONE; }
+  | OLT  { $$ = FCmpInst::FCMP_OLT; } | OGT  { $$ = FCmpInst::FCMP_OGT; }
+  | OLE  { $$ = FCmpInst::FCMP_OLE; } | OGE  { $$ = FCmpInst::FCMP_OGE; }
+  | ORD  { $$ = FCmpInst::FCMP_ORD; } | UNO  { $$ = FCmpInst::FCMP_UNO; }
+  | UEQ  { $$ = FCmpInst::FCMP_UEQ; } | UNE  { $$ = FCmpInst::FCMP_UNE; }
+  | ULT  { $$ = FCmpInst::FCMP_ULT; } | UGT  { $$ = FCmpInst::FCMP_UGT; }
+  | ULE  { $$ = FCmpInst::FCMP_ULE; } | UGE  { $$ = FCmpInst::FCMP_UGE; }
+  | TRUETOK { $$ = FCmpInst::FCMP_TRUE; }
+  | FALSETOK { $$ = FCmpInst::FCMP_FALSE; }
+  ;
 
 // These are some types that allow classification if we only want a particular 
 // thing... for example, only a signed, unsigned, or integral type.
@@ -1558,9 +1473,8 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
     $$ = Constant::getNullValue(Ty);
     delete $1;
     CHECK_FOR_ERROR
-  };
-
-ConstVal : SIntType EINT64VAL {      // integral constants
+  }
+  | SIntType EINT64VAL {      // integral constants
     if (!ConstantInt::isValueValidForType($1, $2))
       GEN_ERROR("Constant value doesn't fit in type!");
     $$ = ConstantInt::get($1, $2);
@@ -1588,32 +1502,22 @@ ConstVal : SIntType EINT64VAL {      // integral constants
   };
 
 
-ConstExpr: CAST '(' ConstVal TO Types ')' {
-    if (!$3->getType()->isFirstClassType())
+ConstExpr: CastOps '(' ConstVal TO Types ')' {
+    Constant *Val = $3;
+    const Type *Ty = $5->get();
+    if (!Val->getType()->isFirstClassType())
       GEN_ERROR("cast constant expression from a non-primitive type: '" +
-                     $3->getType()->getDescription() + "'!");
-    if (!$5->get()->isFirstClassType())
+                     Val->getType()->getDescription() + "'!");
+    if (!Ty->isFirstClassType())
       GEN_ERROR("cast constant expression to a non-primitive type: '" +
-                     $5->get()->getDescription() + "'!");
-    $$ = ConstantExpr::getCast($3, $5->get());
+                Ty->getDescription() + "'!");
+    $$ = ConstantExpr::getCast($1, $3, $5->get());
     delete $5;
-    CHECK_FOR_ERROR
   }
   | GETELEMENTPTR '(' ConstVal IndexList ')' {
     if (!isa<PointerType>($3->getType()))
       GEN_ERROR("GetElementPtr requires a pointer operand!");
 
-    // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte struct
-    // indices to uint struct indices for compatibility.
-    generic_gep_type_iterator<std::vector<Value*>::iterator>
-      GTI = gep_type_begin($3->getType(), $4->begin(), $4->end()),
-      GTE = gep_type_end($3->getType(), $4->begin(), $4->end());
-    for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI)
-      if (isa<StructType>(*GTI))        // Only change struct indices
-        if (ConstantInt *CUI = dyn_cast<ConstantInt>((*$4)[i]))
-          if (CUI->getType() == Type::UByteTy)
-            (*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
-
     const Type *IdxTy =
       GetElementPtrInst::getIndexedType($3->getType(), *$4, true);
     if (!IdxTy)
@@ -1642,24 +1546,8 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
   | ArithmeticOps '(' ConstVal ',' ConstVal ')' {
     if ($3->getType() != $5->getType())
       GEN_ERROR("Binary operator types must match!");
-    // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
-    // To retain backward compatibility with these early compilers, we emit a
-    // cast to the appropriate integer type automatically if we are in the
-    // broken case.  See PR424 for more information.
-    if (!isa<PointerType>($3->getType())) {
-      $$ = ConstantExpr::get($1, $3, $5);
-    } else {
-      const Type *IntPtrTy = 0;
-      switch (CurModule.CurrentModule->getPointerSize()) {
-      case Module::Pointer32: IntPtrTy = Type::IntTy; break;
-      case Module::Pointer64: IntPtrTy = Type::LongTy; break;
-      default: GEN_ERROR("invalid pointer binary constant expr!");
-      }
-      $$ = ConstantExpr::get($1, ConstantExpr::getCast($3, IntPtrTy),
-                             ConstantExpr::getCast($5, IntPtrTy));
-      $$ = ConstantExpr::getCast($$, $3->getType());
-    }
-    CHECK_FOR_ERROR
+    CHECK_FOR_ERROR;
+    $$ = ConstantExpr::get($1, $3, $5);
   }
   | LogicalOps '(' ConstVal ',' ConstVal ')' {
     if ($3->getType() != $5->getType())
@@ -1678,11 +1566,22 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
     $$ = ConstantExpr::get($1, $3, $5);
     CHECK_FOR_ERROR
   }
+  | ICMP IPredicates '(' ConstVal ',' ConstVal ')' {
+    if ($4->getType() != $6->getType())
+      GEN_ERROR("icmp operand types must match!");
+    $$ = ConstantExpr::getICmp($2, $4, $6);
+  }
+  | FCMP FPredicates '(' ConstVal ',' ConstVal ')' {
+    if ($4->getType() != $6->getType())
+      GEN_ERROR("fcmp operand types must match!");
+    $$ = ConstantExpr::getFCmp($2, $4, $6);
+  }
   | ShiftOps '(' ConstVal ',' ConstVal ')' {
     if ($5->getType() != Type::UByteTy)
       GEN_ERROR("Shift count for shift constant must be unsigned byte!");
     if (!$3->getType()->isInteger())
       GEN_ERROR("Shift constant expression requires integer operand!");
+    CHECK_FOR_ERROR;
     $$ = ConstantExpr::get($1, $3, $5);
     CHECK_FOR_ERROR
   }
@@ -1872,12 +1771,10 @@ TargetDefinition : ENDIAN '=' BigOrLittle {
   | TRIPLE '=' STRINGCONSTANT {
     CurModule.CurrentModule->setTargetTriple($3);
     free($3);
-    CHECK_FOR_ERROR
-  };
+  }
   | DATALAYOUT '=' STRINGCONSTANT {
     CurModule.CurrentModule->setDataLayout($3);
     free($3);
-    CHECK_FOR_ERROR
   };
 
 LibrariesDefinition : '[' LibList ']';
@@ -2057,8 +1954,8 @@ Function : BasicBlockList END {
 };
 
 FnDeclareLinkage: /*default*/ |
-                  DLLIMPORT   { CurFun.Linkage = GlobalValue::DLLImportLinkage } |
-                  EXTERN_WEAK { CurFun.Linkage = GlobalValue::DLLImportLinkage };
+                  DLLIMPORT   { CurFun.Linkage = GlobalValue::DLLImportLinkage; } |
+                  EXTERN_WEAK { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; };
   
 FunctionProto : DECLARE { CurFun.isDeclare = true; } FnDeclareLinkage FunctionHeaderH {
     $$ = CurFun.CurrentFunction;
@@ -2200,12 +2097,16 @@ BasicBlock : InstructionList OptAssign BBTerminatorInst  {
   };
 
 InstructionList : InstructionList Inst {
+    if (CastInst *CI1 = dyn_cast<CastInst>($2))
+      if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
+        if (CI2->getParent() == 0)
+          $1->getInstList().push_back(CI2);
     $1->getInstList().push_back($2);
     $$ = $1;
     CHECK_FOR_ERROR
   }
   | /* empty */ {
-    $$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
+    $$ = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
     CHECK_FOR_ERROR
 
     // Make sure to move the basic block to the correct location in the
@@ -2217,7 +2118,7 @@ InstructionList : InstructionList Inst {
     CHECK_FOR_ERROR
   }
   | LABELSTR {
-    $$ = CurBB = getBBVal(ValID::create($1), true);
+    $$ = getBBVal(ValID::create($1), true);
     CHECK_FOR_ERROR
 
     // Make sure to move the basic block to the correct location in the
@@ -2425,8 +2326,11 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
         !isa<PackedType>((*$2).get()))
       GEN_ERROR(
         "Arithmetic operator requires integer, FP, or packed operands!");
-    if (isa<PackedType>((*$2).get()) && $1 == Instruction::Rem)
-      GEN_ERROR("Rem not supported on packed types!");
+    if (isa<PackedType>((*$2).get()) && 
+        ($1 == Instruction::URem || 
+         $1 == Instruction::SRem ||
+         $1 == Instruction::FRem))
+      GEN_ERROR("U/S/FRem not supported on packed types!");
     Value* val1 = getVal(*$2, $3); 
     CHECK_FOR_ERROR
     Value* val2 = getVal(*$2, $5);
@@ -2465,8 +2369,30 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
       GEN_ERROR("binary operator returned null!");
     delete $2;
   }
+  | ICMP IPredicates Types ValueRef ',' ValueRef  {
+    if (isa<PackedType>((*$3).get()))
+      GEN_ERROR("Packed types not supported by icmp instruction");
+    Value* tmpVal1 = getVal(*$3, $4);
+    CHECK_FOR_ERROR
+    Value* tmpVal2 = getVal(*$3, $6);
+    CHECK_FOR_ERROR
+    $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2);
+    if ($$ == 0)
+      GEN_ERROR("icmp operator returned null!");
+  }
+  | FCMP FPredicates Types ValueRef ',' ValueRef  {
+    if (isa<PackedType>((*$3).get()))
+      GEN_ERROR("Packed types not supported by fcmp instruction");
+    Value* tmpVal1 = getVal(*$3, $4);
+    CHECK_FOR_ERROR
+    Value* tmpVal2 = getVal(*$3, $6);
+    CHECK_FOR_ERROR
+    $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2);
+    if ($$ == 0)
+      GEN_ERROR("fcmp operator returned null!");
+  }
   | NOT ResolvedVal {
-    std::cerr << "WARNING: Use of eliminated 'not' instruction:"
+    llvm_cerr << "WARNING: Use of eliminated 'not' instruction:"
               << " Replacing with 'xor'.\n";
 
     Value *Ones = ConstantIntegral::getAllOnesValue($2->getType());
@@ -2483,16 +2409,20 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
       GEN_ERROR("Shift amount must be ubyte!");
     if (!$2->getType()->isInteger())
       GEN_ERROR("Shift constant expression requires integer operand!");
+    CHECK_FOR_ERROR;
     $$ = new ShiftInst($1, $2, $4);
     CHECK_FOR_ERROR
   }
-  | CAST ResolvedVal TO Types {
-    if (!$4->get()->isFirstClassType())
-      GEN_ERROR("cast instruction to a non-primitive type: '" +
-                     $4->get()->getDescription() + "'!");
-    $$ = new CastInst($2, *$4);
+  | CastOps ResolvedVal TO Types {
+    Value* Val = $2;
+    const Type* Ty = $4->get();
+    if (!Val->getType()->isFirstClassType())
+      GEN_ERROR("cast from a non-primitive type: '" +
+                Val->getType()->getDescription() + "'!");
+    if (!Ty->isFirstClassType())
+      GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
+    $$ = CastInst::create($1, $2, $4->get());
     delete $4;
-    CHECK_FOR_ERROR
   }
   | SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
     if ($2->getType() != Type::BoolTy)
@@ -2508,49 +2438,6 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
     delete $4;
     CHECK_FOR_ERROR
   }
-  | VAARG_old ResolvedVal ',' Types {
-    ObsoleteVarArgs = true;
-    const Type* ArgTy = $2->getType();
-    Function* NF = CurModule.CurrentModule->
-      getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
-
-    //b = vaarg a, t -> 
-    //foo = alloca 1 of t
-    //bar = vacopy a 
-    //store bar -> foo
-    //b = vaarg foo, t
-    AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
-    CurBB->getInstList().push_back(foo);
-    CallInst* bar = new CallInst(NF, $2);
-    CurBB->getInstList().push_back(bar);
-    CurBB->getInstList().push_back(new StoreInst(bar, foo));
-    $$ = new VAArgInst(foo, *$4);
-    delete $4;
-    CHECK_FOR_ERROR
-  }
-  | VANEXT_old ResolvedVal ',' Types {
-    ObsoleteVarArgs = true;
-    const Type* ArgTy = $2->getType();
-    Function* NF = CurModule.CurrentModule->
-      getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
-
-    //b = vanext a, t ->
-    //foo = alloca 1 of t
-    //bar = vacopy a
-    //store bar -> foo
-    //tmp = vaarg foo, t
-    //b = load foo
-    AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
-    CurBB->getInstList().push_back(foo);
-    CallInst* bar = new CallInst(NF, $2);
-    CurBB->getInstList().push_back(bar);
-    CurBB->getInstList().push_back(new StoreInst(bar, foo));
-    Instruction* tmp = new VAArgInst(foo, *$4);
-    CurBB->getInstList().push_back(tmp);
-    $$ = new LoadInst(foo);
-    delete $4;
-    CHECK_FOR_ERROR
-  }
   | EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
     if (!ExtractElementInst::isValidOperands($2, $4))
       GEN_ERROR("Invalid extractelement operands!");
@@ -2585,8 +2472,8 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
     CHECK_FOR_ERROR
   }
   | OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')'  {
-    const PointerType *PFTy;
-    const FunctionType *Ty;
+    const PointerType *PFTy = 0;
+    const FunctionType *Ty = 0;
 
     if (!(PFTy = dyn_cast<PointerType>($3->get())) ||
         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
@@ -2730,17 +2617,6 @@ MemoryInst : MALLOC Types OptCAlign {
     if (!isa<PointerType>($2->get()))
       GEN_ERROR("getelementptr insn requires pointer operand!");
 
-    // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte struct
-    // indices to uint struct indices for compatibility.
-    generic_gep_type_iterator<std::vector<Value*>::iterator>
-      GTI = gep_type_begin($2->get(), $4->begin(), $4->end()),
-      GTE = gep_type_end($2->get(), $4->begin(), $4->end());
-    for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI)
-      if (isa<StructType>(*GTI))        // Only change struct indices
-        if (ConstantInt *CUI = dyn_cast<ConstantInt>((*$4)[i]))
-          if (CUI->getType() == Type::UByteTy)
-            (*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
-
     if (!GetElementPtrInst::getIndexedType(*$2, *$4, true))
       GEN_ERROR("Invalid getelementptr indices for type '" +
                      (*$2)->getDescription()+ "'!");