Introspecting the calling convention and triple

Hi

assume, that you know the calling convention of a function and the target-triple of the destination. You also know the types of the parameters.

How would you go about finding out, which machine register or stack offset/size will be used for those parameters, if they will be zero extended or not ?

Ciao
    Nat!

P.S. Apologies, for this being something somewhat of a cross-post, a bit reworded from an unanswered mail in cfe-dev :slight_smile:

Hi,

The triple doesn't really tell you much about the desired target but I won't go into that here. There's an explanation at http://lists.llvm.org/pipermail/llvm-dev/2015-July/087700.html.

I'm not sure how you'd extract the information you want from this but I can point you at the right code. At the clang level, you can find some of this using *ABIInfo::classifyReturnType() and *ABIInfo::classifyArgumentType(). These functions tell clang how to lower to LLVM-IR and specifies whether the return/argument is passed indirectly or not, sign/zero/not extended, etc. The code responsible for assigning registers, stack slots, etc. in the backend is in *TargetLowering::LowerCall(), *TargetLowering::LowerFormalArguments(), and *TargetLowering::LowerReturn().

Hope that helps