X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAsmParser%2FllvmAsmParser.y.cvs;h=5a824ae8fe44b9b24c9972869946b741ddef3092;hb=e6be34a53ecbe8c2ff9f0793b13d847e94c0de91;hp=2848945648eeb0e41d0c266b0b682a5e0bafafb0;hpb=222ebf70b7577be05c3555de0fdd16f1577a0832;p=oota-llvm.git diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs index 2848945648e..5a824ae8fe4 100644 --- a/lib/AsmParser/llvmAsmParser.y.cvs +++ b/lib/AsmParser/llvmAsmParser.y.cvs @@ -25,6 +25,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Streams.h" +#include "llvm/ParamAttrsList.h" #include #include #include @@ -578,12 +579,13 @@ static BasicBlock *getBBVal(const ValID &ID) { } if (ID.Type == ValID::LocalName) { std::string Name = ID.getName(); Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); - if (N) + if (N) { if (N->getType()->getTypeID() == Type::LabelTyID) BB = cast(N); else GenerateError("Reference to label '" + Name + "' is actually of type '"+ N->getType()->getDescription() + "'"); + } } else if (ID.Type == ValID::LocalID) { if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) { if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID) @@ -1023,6 +1025,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) { // ValueRef - Unresolved reference to a definition or BB %type ValueRef ConstValueRef SymbolicValueRef %type ResolvedVal // pair +%type ReturnedVal // Tokens and types for handling constant integer values // // ESINT64VAL - A negative number within long long range @@ -1093,6 +1096,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) { // Other Operators %token PHI_TOK SELECT VAARG %token EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR +%token GETRESULT // Function Attributes %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST @@ -1231,6 +1235,8 @@ ParamAttr : ZEROEXT { $$ = ParamAttr::ZExt; } | NOALIAS { $$ = ParamAttr::NoAlias; } | BYVAL { $$ = ParamAttr::ByVal; } | NEST { $$ = ParamAttr::Nest; } + | ALIGN EUINT64VAL { $$ = + ParamAttr::constructAlignmentFromInt($2); } ; OptParamAttrs : /* empty */ { $$ = ParamAttr::None; } @@ -1456,7 +1462,7 @@ ResultTypes : Types { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription()); - if (!(*$1)->isFirstClassType()) + if (!(*$1)->isFirstClassType() && !isa($1->get())) GEN_ERROR("LLVM functions cannot return aggregate types"); $$ = $1; } @@ -1733,7 +1739,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription()); const PointerType *Ty = dyn_cast($1->get()); if (Ty == 0) - GEN_ERROR("Global const reference must be a pointer type"); + GEN_ERROR("Global const reference must be a pointer type " + (*$1)->getDescription()); // ConstExprs can exist in the body of a function, thus creating // GlobalValues whenever they refer to a variable. Because we are in @@ -2520,6 +2526,16 @@ ResolvedVal : Types ValueRef { } ; +ReturnedVal : ResolvedVal { + $$ = new std::vector(); + $$->push_back($1); + CHECK_FOR_ERROR + } + | ReturnedVal ',' ResolvedVal { + ($$=$1)->push_back($3); + CHECK_FOR_ERROR + }; + BasicBlockList : BasicBlockList BasicBlock { $$ = $1; CHECK_FOR_ERROR @@ -2562,8 +2578,12 @@ InstructionList : InstructionList Inst { }; -BBTerminatorInst : RET ResolvedVal { // Return with a result... - $$ = new ReturnInst($2); +BBTerminatorInst : + RET ReturnedVal { // Return with a result... + ValueList &VL = *$2; + assert(!VL.empty() && "Invalid ret operands!"); + $$ = new ReturnInst(&VL[0], VL.size()); + delete $2; CHECK_FOR_ERROR } | RET VOID { // Return with no result... @@ -3130,6 +3150,14 @@ MemoryInst : MALLOC Types OptCAlign { $$ = new StoreInst($3, tmpVal, $1, $7); delete $5; } +| GETRESULT Types SymbolicValueRef ',' EUINT64VAL { + Value *TmpVal = getVal($2->get(), $3); + if (!GetResultInst::isValidOperands(TmpVal, $5)) + GEN_ERROR("Invalid getresult operands"); + $$ = new GetResultInst(TmpVal, $5); + delete $2; + CHECK_FOR_ERROR + } | GETELEMENTPTR Types ValueRef IndexList { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());