[LLVMdev] Fixing VAARG on PPC64
Ivan Llopard
ivanllopard at gmail.com
Fri Mar 23 09:31:44 PDT 2012
Le 23/03/2012 17:02, Hal Finkel a écrit :
> On Fri, 23 Mar 2012 09:50:12 +0100
> Ivan Llopard<ivanllopard at gmail.com> wrote:
>
>> Hi Finkel,
>>
>> Le 23/03/2012 05:50, Hal Finkel a écrit :
>>> The PowerPC backend on PPC64 for non-Darwin (SVR4 ABI) systems
>>> currently has a problem handling integer types smaller than 64 bits.
>>> This is because the ABI specifies that these types are
>>> zero-extended to 64 bits on the stack and the default logic
>>> provided in LegalizeDAG does not use that convention. Specifically,
>>> for these targets we have: setOperationAction(ISD::VAARG,
>>> MVT::Other, Expand); I thought that I could solve this problem by:
>>> setOperationAction(ISD::VAARG, MVT::i1, Promote);
>>> AddPromotedToType (ISD::VAARG, MVT::i1, MVT::i64);
>>> setOperationAction(ISD::VAARG, MVT::i8, Promote);
>>> AddPromotedToType (ISD::VAARG, MVT::i8, MVT::i64);
>>> setOperationAction(ISD::VAARG, MVT::i16, Promote);
>>> AddPromotedToType (ISD::VAARG, MVT::i16, MVT::i64);
>>> setOperationAction(ISD::VAARG, MVT::i32, Promote);
>>> AddPromotedToType (ISD::VAARG, MVT::i32, MVT::i64);
>>> but this does not seem to have any effect. I thought this would work
>>> because SDValue DAGTypeLegalizer::PromoteIntRes_VAARG seems to have
>>> the appropriate logic. Is this a bug, or am I misunderstanding how
>>> Promote works?
>> IMHO, you are doing it right but it looks like ISD::VAARG is not
>> handled in SelectionDAGLegalize::PromoteNode() yet. DAGTypeLegalizer
>> is used to legalize "non-legal" types regardless of the operation
>> (need confirmation).
> Thanks! That makes sense, and looking more closely at the
> PromoteIntRes_VAARG code, it finds the type to which to promote by
> calling TLI.getRegisterType, which won't work in this case. This should
> not be difficult to fix.
I think that PromoteIntRes_VAARG won't even get called if VAARG has a
legal type, which is the case for i32 in PPC for example. If you want to
promote VAARG nodes with a legal type to i64, you should rather add
another case in SelectionDAGLegalize::PromoteNode(). If I understand
correctly, it's there where promotion of legal types is done.
Ivan
>
> -Hal
>
>> Ivan
>>
>>> Thanks again,
>>> Hal
>>>
>
>
More information about the llvm-dev
mailing list