[llvm-commits] [llvm] r47407 - /llvm/trunk/lib/AsmParser/llvmAsmParser.y
Devang Patel
dpatel at apple.com
Fri Feb 22 17:09:43 PST 2008
On Feb 21, 2008, at 10:02 PM, Chris Lattner wrote:
>> +ReturnedVal : ResolvedVal {
>> + $$ = new std::vector<Value *>();
>> + $$->push_back($1);
>> + CHECK_FOR_ERROR
>> + }
>> + | ReturnedVal ',' ConstVal {
>
> Why ConstVal here? Any value can be returned, it seems that this
> should be ResolvedVal.
Fixed.
>
>
>> @@ -2565,8 +2576,31 @@
>>
>> };
>>
>> -BBTerminatorInst : RET ResolvedVal { // Return with a
>> result...
>> - $$ = new ReturnInst($2);
>> +BBTerminatorInst :
>> + RET ReturnedVal { // Return with a result...
>> + if($2->size() == 1)
>> + $$ = new ReturnInst($2->back());
>> + else {
>> +
>> + std::vector<const Type*> Elements;
>> + std::vector<Constant*> Vals;
>> + for (std::vector<Value *>::iterator I = $2->begin(),
>> + E = $2->end(); I != E; ++I) {
>> + Value *V = *I;
>> + Constant *C = cast<Constant>(V);
>> + Elements.push_back(V->getType());
>> + Vals.push_back(C);
>> + }
>> +
>> + const StructType *STy = StructType::get(Elements);
>> + PATypeHolder *PTy =
>> + new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
>> +
>> + Constant *CS = ConstantStruct::get(STy, Vals); // *$2);
>> + $$ = new ReturnInst(CS);
>> + delete PTy;
>> + }
>> + delete $2;
>
> This isn't going to work for returning non-constants. Return should
> take multiple operands when multiple things are returned, it shouldn't
> force them together into a constantstruct.
OK. Fixed.
-
Devang
More information about the llvm-commits
mailing list