case lltok::kw_target: if (ParseTargetDefinition()) return true; break;
case lltok::kw_deplibs: if (ParseDepLibs()) return true; break;
case lltok::kw_type: if (ParseUnnamedType()) return true; break;
+ case lltok::LocalVarID: if (ParseUnnamedType()) return true; break;
case lltok::StringConstant: // FIXME: REMOVE IN LLVM 3.0
case lltok::LocalVar: if (ParseNamedType()) return true; break;
+ case lltok::GlobalID: if (ParseUnnamedGlobal()) return true; break;
case lltok::GlobalVar: if (ParseNamedGlobal()) return true; break;
case lltok::Metadata: if (ParseStandaloneMetadata()) return true; break;
case lltok::NamedMD: if (ParseNamedMetadata()) return true; break;
return ParseToken(lltok::rsquare, "expected ']' at end of list");
}
-/// toplevelentity
+/// ParseUnnamedType:
/// ::= 'type' type
+/// ::= LocalVarID '=' 'type' type
bool LLParser::ParseUnnamedType() {
+ unsigned TypeID = NumberedTypes.size();
+
+ // Handle the LocalVarID form.
+ if (Lex.getKind() == lltok::LocalVarID) {
+ if (Lex.getUIntVal() != TypeID)
+ return Error(Lex.getLoc(), "type expected to be numbered '%" +
+ utostr(TypeID) + "'");
+ Lex.Lex(); // eat LocalVarID;
+
+ if (ParseToken(lltok::equal, "expected '=' after name"))
+ return true;
+ }
+
assert(Lex.getKind() == lltok::kw_type);
LocTy TypeLoc = Lex.getLoc();
Lex.Lex(); // eat kw_type
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty)) return true;
- unsigned TypeID = NumberedTypes.size();
-
// See if this type was previously referenced.
std::map<unsigned, std::pair<PATypeHolder, LocTy> >::iterator
FI = ForwardRefTypeIDs.find(TypeID);
LocTy NameLoc = Lex.getLoc();
Lex.Lex(); // eat LocalVar.
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseToken(lltok::equal, "expected '=' after name") ||
ParseToken(lltok::kw_type, "expected 'type' after name") ||
return false;
}
+/// ParseUnnamedGlobal:
+/// OptionalVisibility ALIAS ...
+/// OptionalLinkage OptionalVisibility ... -> global variable
+/// GlobalID '=' OptionalVisibility ALIAS ...
+/// GlobalID '=' OptionalLinkage OptionalVisibility ... -> global variable
+bool LLParser::ParseUnnamedGlobal() {
+ unsigned VarID = NumberedVals.size();
+ std::string Name;
+ LocTy NameLoc = Lex.getLoc();
+
+ // Handle the GlobalID form.
+ if (Lex.getKind() == lltok::GlobalID) {
+ if (Lex.getUIntVal() != VarID)
+ return Error(Lex.getLoc(), "variable expected to be numbered '%" +
+ utostr(VarID) + "'");
+ Lex.Lex(); // eat GlobalID;
+
+ if (ParseToken(lltok::equal, "expected '=' after name"))
+ return true;
+ }
+
+ bool HasLinkage;
+ unsigned Linkage, Visibility;
+ if (ParseOptionalLinkage(Linkage, HasLinkage) ||
+ ParseOptionalVisibility(Visibility))
+ return true;
+
+ if (HasLinkage || Lex.getKind() != lltok::kw_alias)
+ return ParseGlobal(Name, NameLoc, Linkage, HasLinkage, Visibility);
+ return ParseAlias(Name, NameLoc, Visibility);
+}
+
/// ParseNamedGlobal:
/// GlobalVar '=' OptionalVisibility ALIAS ...
/// GlobalVar '=' OptionalLinkage OptionalVisibility ... -> global variable
bool LLParser::ParseMDString(MetadataBase *&MDS) {
std::string Str;
if (ParseStringConstant(Str)) return true;
- MDS = Context.getMDString(Str);
+ MDS = MDString::get(Context, Str);
return false;
}
// Create MDNode forward reference
SmallVector<Value *, 1> Elts;
std::string FwdRefName = "llvm.mdnode.fwdref." + utostr(MID);
- Elts.push_back(Context.getMDString(FwdRefName));
- MDNode *FwdNode = Context.getMDNode(Elts.data(), Elts.size());
+ Elts.push_back(MDString::get(Context, FwdRefName));
+ MDNode *FwdNode = MDNode::get(Context, Elts.data(), Elts.size());
ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc());
Node = FwdNode;
return false;
if (ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
- NamedMDNode::Create(Name, Elts.data(), Elts.size(), M);
+ NamedMDNode::Create(Context, Name, Elts.data(), Elts.size(), M);
return false;
}
return true;
LocTy TyLoc;
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty, TyLoc))
return true;
|| ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
- MDNode *Init = Context.getMDNode(Elts.data(), Elts.size());
+ MDNode *Init = MDNode::get(Context, Elts.data(), Elts.size());
MetadataCache[MetadataID] = Init;
std::map<unsigned, std::pair<MetadataBase *, LocTy> >::iterator
FI = ForwardRefMDNodes.find(MetadataID);
bool ThreadLocal, IsConstant;
LocTy TyLoc;
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseOptionalToken(lltok::kw_thread_local, ThreadLocal) ||
ParseOptionalAddrSpace(AddrSpace) ||
ParseGlobalType(IsConstant) ||
return true;
}
- if (isa<FunctionType>(Ty) || Ty == Type::LabelTy)
+ if (isa<FunctionType>(Ty) || Ty == Type::getLabelTy(Context))
return Error(TyLoc, "invalid type for global variable");
GlobalVariable *GV = 0;
case lltok::kw_noinline: Attrs |= Attribute::NoInline; break;
case lltok::kw_readnone: Attrs |= Attribute::ReadNone; break;
case lltok::kw_readonly: Attrs |= Attribute::ReadOnly; break;
+ case lltok::kw_inlinehint: Attrs |= Attribute::InlineHint; break;
case lltok::kw_alwaysinline: Attrs |= Attribute::AlwaysInline; break;
case lltok::kw_optsize: Attrs |= Attribute::OptimizeForSize; break;
case lltok::kw_ssp: Attrs |= Attribute::StackProtect; break;
if (!UpRefs.empty())
return Error(UpRefs.back().Loc, "invalid unresolved type up reference");
- if (!AllowVoid && Result.get() == Type::VoidTy)
+ if (!AllowVoid && Result.get() == Type::getVoidTy(Context))
return Error(TypeLoc, "void type only allowed for function results");
return false;
break;
case lltok::kw_opaque:
// TypeRec ::= 'opaque'
- Result = OpaqueType::get();
+ Result = OpaqueType::get(Context);
Lex.Lex();
break;
case lltok::lbrace:
if (const Type *T = M->getTypeByName(Lex.getStrVal())) {
Result = T;
} else {
- Result = OpaqueType::get();
+ Result = OpaqueType::get(Context);
ForwardRefTypes.insert(std::make_pair(Lex.getStrVal(),
std::make_pair(Result,
Lex.getLoc())));
if (I != ForwardRefTypeIDs.end())
Result = I->second.first;
else {
- Result = OpaqueType::get();
+ Result = OpaqueType::get(Context);
ForwardRefTypeIDs.insert(std::make_pair(Lex.getUIntVal(),
std::make_pair(Result,
Lex.getLoc())));
Lex.Lex();
unsigned Val;
if (ParseUInt32(Val)) return true;
- OpaqueType *OT = OpaqueType::get(); //Use temporary placeholder.
+ OpaqueType *OT = OpaqueType::get(Context); //Use temporary placeholder.
UpRefs.push_back(UpRefRecord(Lex.getLoc(), Val, OT));
Result = OT;
break;
// TypeRec ::= TypeRec '*'
case lltok::star:
- if (Result.get() == Type::LabelTy)
+ if (Result.get() == Type::getLabelTy(Context))
return TokError("basic block pointers are invalid");
- if (Result.get() == Type::VoidTy)
+ if (Result.get() == Type::getVoidTy(Context))
return TokError("pointers to void are invalid; use i8* instead");
if (!PointerType::isValidElementType(Result.get()))
return TokError("pointer to this type is invalid");
// TypeRec ::= TypeRec 'addrspace' '(' uint32 ')' '*'
case lltok::kw_addrspace: {
- if (Result.get() == Type::LabelTy)
+ if (Result.get() == Type::getLabelTy(Context))
return TokError("basic block pointers are invalid");
- if (Result.get() == Type::VoidTy)
+ if (Result.get() == Type::getVoidTy(Context))
return TokError("pointers to void are invalid; use i8* instead");
if (!PointerType::isValidElementType(Result.get()))
return TokError("pointer to this type is invalid");
// Parse the argument.
LocTy ArgLoc;
- PATypeHolder ArgTy(Type::VoidTy);
+ PATypeHolder ArgTy(Type::getVoidTy(Context));
unsigned ArgAttrs1, ArgAttrs2;
Value *V;
if (ParseType(ArgTy, ArgLoc) ||
Lex.Lex();
} else {
LocTy TypeLoc = Lex.getLoc();
- PATypeHolder ArgTy(Type::VoidTy);
+ PATypeHolder ArgTy(Type::getVoidTy(Context));
unsigned Attrs;
std::string Name;
if ((inType ? ParseTypeRec(ArgTy) : ParseType(ArgTy)) ||
ParseOptionalAttrs(Attrs, 0)) return true;
- if (ArgTy == Type::VoidTy)
+ if (ArgTy == Type::getVoidTy(Context))
return Error(TypeLoc, "argument can not have void type");
if (Lex.getKind() == lltok::LocalVar ||
if ((inType ? ParseTypeRec(ArgTy) : ParseType(ArgTy)) ||
ParseOptionalAttrs(Attrs, 0)) return true;
- if (ArgTy == Type::VoidTy)
+ if (ArgTy == Type::getVoidTy(Context))
return Error(TypeLoc, "argument can not have void type");
if (Lex.getKind() == lltok::LocalVar ||
Lex.Lex(); // Consume the '{'
if (EatIfPresent(lltok::rbrace)) {
- Result = StructType::get(Packed);
+ Result = StructType::get(Context, Packed);
return false;
}
if (ParseTypeRec(Result)) return true;
ParamsList.push_back(Result);
- if (Result == Type::VoidTy)
+ if (Result == Type::getVoidTy(Context))
return Error(EltTyLoc, "struct element can not have void type");
if (!StructType::isValidElementType(Result))
return Error(EltTyLoc, "invalid element type for struct");
EltTyLoc = Lex.getLoc();
if (ParseTypeRec(Result)) return true;
- if (Result == Type::VoidTy)
+ if (Result == Type::getVoidTy(Context))
return Error(EltTyLoc, "struct element can not have void type");
if (!StructType::isValidElementType(Result))
return Error(EltTyLoc, "invalid element type for struct");
std::vector<const Type*> ParamsListTy;
for (unsigned i = 0, e = ParamsList.size(); i != e; ++i)
ParamsListTy.push_back(ParamsList[i].get());
- Result = HandleUpRefs(StructType::get(ParamsListTy, Packed));
+ Result = HandleUpRefs(StructType::get(Context, ParamsListTy, Packed));
return false;
}
return true;
LocTy TypeLoc = Lex.getLoc();
- PATypeHolder EltTy(Type::VoidTy);
+ PATypeHolder EltTy(Type::getVoidTy(Context));
if (ParseTypeRec(EltTy)) return true;
- if (EltTy == Type::VoidTy)
+ if (EltTy == Type::getVoidTy(Context))
return Error(TypeLoc, "array and vector element type cannot be void");
if (ParseToken(isVector ? lltok::greater : lltok::rsquare,
// If we have the value in the symbol table or fwd-ref table, return it.
if (Val) {
if (Val->getType() == Ty) return Val;
- if (Ty == Type::LabelTy)
+ if (Ty == Type::getLabelTy(F.getContext()))
P.Error(Loc, "'%" + Name + "' is not a basic block");
else
P.Error(Loc, "'%" + Name + "' defined with type '" +
}
// Don't make placeholders with invalid type.
- if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) && Ty != Type::LabelTy) {
+ if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) &&
+ Ty != Type::getLabelTy(F.getContext())) {
P.Error(Loc, "invalid use of a non-first-class type");
return 0;
}
// Otherwise, create a new forward reference for this value and remember it.
Value *FwdVal;
- if (Ty == Type::LabelTy)
- FwdVal = BasicBlock::Create(Name, &F);
+ if (Ty == Type::getLabelTy(F.getContext()))
+ FwdVal = BasicBlock::Create(F.getContext(), Name, &F);
else
FwdVal = new Argument(Ty, Name);
// If we have the value in the symbol table or fwd-ref table, return it.
if (Val) {
if (Val->getType() == Ty) return Val;
- if (Ty == Type::LabelTy)
+ if (Ty == Type::getLabelTy(F.getContext()))
P.Error(Loc, "'%" + utostr(ID) + "' is not a basic block");
else
P.Error(Loc, "'%" + utostr(ID) + "' defined with type '" +
return 0;
}
- if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) && Ty != Type::LabelTy) {
+ if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) &&
+ Ty != Type::getLabelTy(F.getContext())) {
P.Error(Loc, "invalid use of a non-first-class type");
return 0;
}
// Otherwise, create a new forward reference for this value and remember it.
Value *FwdVal;
- if (Ty == Type::LabelTy)
- FwdVal = BasicBlock::Create("", &F);
+ if (Ty == Type::getLabelTy(F.getContext()))
+ FwdVal = BasicBlock::Create(F.getContext(), "", &F);
else
FwdVal = new Argument(Ty);
const std::string &NameStr,
LocTy NameLoc, Instruction *Inst) {
// If this instruction has void type, it cannot have a name or ID specified.
- if (Inst->getType() == Type::VoidTy) {
+ if (Inst->getType() == Type::getVoidTy(F.getContext())) {
if (NameID != -1 || !NameStr.empty())
return P.Error(NameLoc, "instructions returning void cannot have a name");
return false;
/// forward reference record if needed.
BasicBlock *LLParser::PerFunctionState::GetBB(const std::string &Name,
LocTy Loc) {
- return cast_or_null<BasicBlock>(GetVal(Name, Type::LabelTy, Loc));
+ return cast_or_null<BasicBlock>(GetVal(Name,
+ Type::getLabelTy(F.getContext()), Loc));
}
BasicBlock *LLParser::PerFunctionState::GetBB(unsigned ID, LocTy Loc) {
- return cast_or_null<BasicBlock>(GetVal(ID, Type::LabelTy, Loc));
+ return cast_or_null<BasicBlock>(GetVal(ID,
+ Type::getLabelTy(F.getContext()), Loc));
}
/// DefineBB - Define the specified basic block, which is either named or
ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
- ID.MetadataVal = Context.getMDNode(Elts.data(), Elts.size());
+ ID.MetadataVal = MDNode::get(Context, Elts.data(), Elts.size());
return false;
}
ID.Kind = ValID::t_APFloat;
break;
case lltok::kw_true:
- ID.ConstantVal = Context.getTrue();
+ ID.ConstantVal = ConstantInt::getTrue(Context);
ID.Kind = ValID::t_Constant;
break;
case lltok::kw_false:
- ID.ConstantVal = Context.getFalse();
+ ID.ConstantVal = ConstantInt::getFalse(Context);
ID.Kind = ValID::t_Constant;
break;
case lltok::kw_null: ID.Kind = ValID::t_Null; break;
ParseToken(lltok::rbrace, "expected end of struct constant"))
return true;
- ID.ConstantVal = ConstantStruct::get(Elts.data(), Elts.size(), false);
+ ID.ConstantVal = ConstantStruct::get(Context, Elts.data(),
+ Elts.size(), false);
ID.Kind = ValID::t_Constant;
return false;
}
if (isPackedStruct) {
ID.ConstantVal =
- ConstantStruct::get(Elts.data(), Elts.size(), true);
+ ConstantStruct::get(Context, Elts.data(), Elts.size(), true);
ID.Kind = ValID::t_Constant;
return false;
}
}
case lltok::kw_c: // c "foo"
Lex.Lex();
- ID.ConstantVal = ConstantArray::get(Lex.getStrVal(), false);
+ ID.ConstantVal = ConstantArray::get(Context, Lex.getStrVal(), false);
if (ParseToken(lltok::StringConstant, "expected string")) return true;
ID.Kind = ValID::t_Constant;
return false;
case lltok::kw_inttoptr:
case lltok::kw_ptrtoint: {
unsigned Opc = Lex.getUIntVal();
- PATypeHolder DestTy(Type::VoidTy);
+ PATypeHolder DestTy(Type::getVoidTy(Context));
Constant *SrcVal;
Lex.Lex();
if (ParseToken(lltok::lparen, "expected '(' after constantexpr cast") ||
return Error(ID.Loc,"constexpr requires integer, fp, or vector operands");
Constant *C = ConstantExpr::get(Opc, Val0, Val1);
if (NUW)
- cast<OverflowingBinaryOperator>(C)->setHasNoUnsignedOverflow(true);
+ cast<OverflowingBinaryOperator>(C)->setHasNoUnsignedWrap(true);
if (NSW)
- cast<OverflowingBinaryOperator>(C)->setHasNoSignedOverflow(true);
+ cast<OverflowingBinaryOperator>(C)->setHasNoSignedWrap(true);
if (Exact)
cast<SDivOperator>(C)->setIsExact(true);
ID.ConstantVal = C;
// The lexer has no type info, so builds all float and double FP constants
// as double. Fix this here. Long double does not need this.
if (&ID.APFloatVal.getSemantics() == &APFloat::IEEEdouble &&
- Ty == Type::FloatTy) {
+ Ty == Type::getFloatTy(Context)) {
bool Ignored;
ID.APFloatVal.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
&Ignored);
return false;
case ValID::t_Undef:
// FIXME: LabelTy should not be a first-class type.
- if ((!Ty->isFirstClassType() || Ty == Type::LabelTy) &&
+ if ((!Ty->isFirstClassType() || Ty == Type::getLabelTy(Context)) &&
!isa<OpaqueType>(Ty))
return Error(ID.Loc, "invalid type for undef constant");
V = UndefValue::get(Ty);
return false;
case ValID::t_Zero:
// FIXME: LabelTy should not be a first-class type.
- if (!Ty->isFirstClassType() || Ty == Type::LabelTy)
+ if (!Ty->isFirstClassType() || Ty == Type::getLabelTy(Context))
return Error(ID.Loc, "invalid type for null constant");
- V = Context.getNullValue(Ty);
+ V = Constant::getNullValue(Ty);
return false;
case ValID::t_Constant:
if (ID.ConstantVal->getType() != Ty)
}
bool LLParser::ParseGlobalTypeAndValue(Constant *&V) {
- PATypeHolder Type(Type::VoidTy);
+ PATypeHolder Type(Type::getVoidTy(Context));
return ParseType(Type) ||
ParseGlobalValue(Type, V);
}
}
bool LLParser::ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
- PATypeHolder T(Type::VoidTy);
+ PATypeHolder T(Type::getVoidTy(Context));
return ParseType(T) ||
ParseValue(T, V, PFS);
}
unsigned Linkage;
unsigned Visibility, CC, RetAttrs;
- PATypeHolder RetType(Type::VoidTy);
+ PATypeHolder RetType(Type::getVoidTy(Context));
LocTy RetTypeLoc = Lex.getLoc();
if (ParseOptionalLinkage(Linkage) ||
ParseOptionalVisibility(Visibility) ||
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
if (PAL.paramHasAttr(1, Attribute::StructRet) &&
- RetType != Type::VoidTy)
+ RetType != Type::getVoidTy(Context))
return Error(RetTypeLoc, "functions with 'sret' argument must return void");
const FunctionType *FT =
switch (Token) {
default: return Error(Loc, "expected instruction opcode");
// Terminator Instructions.
- case lltok::kw_unwind: Inst = new UnwindInst(); return false;
- case lltok::kw_unreachable: Inst = new UnreachableInst(); return false;
+ case lltok::kw_unwind: Inst = new UnwindInst(Context); return false;
+ case lltok::kw_unreachable: Inst = new UnreachableInst(Context); return false;
case lltok::kw_ret: return ParseRet(Inst, BB, PFS);
case lltok::kw_br: return ParseBr(Inst, PFS);
case lltok::kw_switch: return ParseSwitch(Inst, PFS);
return Error(ModifierLoc, "nsw only applies to integer operations");
}
if (NUW)
- cast<OverflowingBinaryOperator>(Inst)->setHasNoUnsignedOverflow(true);
+ cast<OverflowingBinaryOperator>(Inst)->setHasNoUnsignedWrap(true);
if (NSW)
- cast<OverflowingBinaryOperator>(Inst)->setHasNoSignedOverflow(true);
+ cast<OverflowingBinaryOperator>(Inst)->setHasNoSignedWrap(true);
}
return Result;
}
/// ::= 'ret' TypeAndValue (',' TypeAndValue)+ [[obsolete: LLVM 3.0]]
bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
PerFunctionState &PFS) {
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty, true /*void allowed*/)) return true;
- if (Ty == Type::VoidTy) {
- Inst = ReturnInst::Create();
+ if (Ty == Type::getVoidTy(Context)) {
+ Inst = ReturnInst::Create(Context);
return false;
}
RV = I;
}
}
- Inst = ReturnInst::Create(RV);
+ Inst = ReturnInst::Create(Context, RV);
return false;
}
return false;
}
- if (Op0->getType() != Type::Int1Ty)
+ if (Op0->getType() != Type::getInt1Ty(Context))
return Error(Loc, "branch condition must have 'i1' type");
if (ParseToken(lltok::comma, "expected ',' after branch condition") ||
bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
LocTy CallLoc = Lex.getLoc();
unsigned CC, RetAttrs, FnAttrs;
- PATypeHolder RetType(Type::VoidTy);
+ PATypeHolder RetType(Type::getVoidTy(Context));
LocTy RetTypeLoc;
ValID CalleeID;
SmallVector<ParamInfo, 16> ArgList;
if (Opc == Instruction::FCmp) {
if (!LHS->getType()->isFPOrFPVector())
return Error(Loc, "fcmp requires floating point operands");
- Inst = new FCmpInst(Context, CmpInst::Predicate(Pred), LHS, RHS);
+ Inst = new FCmpInst(CmpInst::Predicate(Pred), LHS, RHS);
} else {
assert(Opc == Instruction::ICmp && "Unknown opcode for CmpInst!");
if (!LHS->getType()->isIntOrIntVector() &&
!isa<PointerType>(LHS->getType()))
return Error(Loc, "icmp requires integer operands");
- Inst = new ICmpInst(Context, CmpInst::Predicate(Pred), LHS, RHS);
+ Inst = new ICmpInst(CmpInst::Predicate(Pred), LHS, RHS);
}
return false;
}
bool LLParser::ParseCast(Instruction *&Inst, PerFunctionState &PFS,
unsigned Opc) {
LocTy Loc; Value *Op;
- PATypeHolder DestTy(Type::VoidTy);
+ PATypeHolder DestTy(Type::getVoidTy(Context));
if (ParseTypeAndValue(Op, Loc, PFS) ||
ParseToken(lltok::kw_to, "expected 'to' after cast value") ||
ParseType(DestTy))
/// ::= 'va_arg' TypeAndValue ',' Type
bool LLParser::ParseVA_Arg(Instruction *&Inst, PerFunctionState &PFS) {
Value *Op;
- PATypeHolder EltTy(Type::VoidTy);
+ PATypeHolder EltTy(Type::getVoidTy(Context));
LocTy TypeLoc;
if (ParseTypeAndValue(Op, PFS) ||
ParseToken(lltok::comma, "expected ',' after vaarg operand") ||
/// ParsePHI
/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Valueß ']')*
bool LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
Value *Op0, *Op1;
LocTy TypeLoc = Lex.getLoc();
ParseToken(lltok::lsquare, "expected '[' in phi value list") ||
ParseValue(Ty, Op0, PFS) ||
ParseToken(lltok::comma, "expected ',' after insertelement value") ||
- ParseValue(Type::LabelTy, Op1, PFS) ||
+ ParseValue(Type::getLabelTy(Context), Op1, PFS) ||
ParseToken(lltok::rsquare, "expected ']' in phi value list"))
return true;
if (ParseToken(lltok::lsquare, "expected '[' in phi value list") ||
ParseValue(Ty, Op0, PFS) ||
ParseToken(lltok::comma, "expected ',' after insertelement value") ||
- ParseValue(Type::LabelTy, Op1, PFS) ||
+ ParseValue(Type::getLabelTy(Context), Op1, PFS) ||
ParseToken(lltok::rsquare, "expected ']' in phi value list"))
return true;
}
bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
bool isTail) {
unsigned CC, RetAttrs, FnAttrs;
- PATypeHolder RetType(Type::VoidTy);
+ PATypeHolder RetType(Type::getVoidTy(Context));
LocTy RetTypeLoc;
ValID CalleeID;
SmallVector<ParamInfo, 16> ArgList;
/// ::= 'alloca' Type (',' TypeAndValue)? (',' OptionalAlignment)?
bool LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS,
unsigned Opc) {
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
Value *Size = 0;
LocTy SizeLoc;
unsigned Alignment = 0;
}
}
- if (Size && Size->getType() != Type::Int32Ty)
+ if (Size && Size->getType() != Type::getInt32Ty(Context))
return Error(SizeLoc, "element count must be i32");
if (Opc == Instruction::Malloc)
Lex.Lex();
V = 0;
} else {
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty)) return true;
if (Lex.getKind() == lltok::Metadata) {
Lex.Lex();