[LLVMdev] Calling-convention lowering proposal

Chris Lattner clattner at apple.com
Sat Apr 25 13:35:54 PDT 2009


On Apr 23, 2009, at 8:09 PM, Dan Gohman wrote:
> Attached is a patch which significantly reworks how calls, incoming
> arguments, and outgoing return values are lowered. It's a major  
> change,
> affecting all targets, so I'm looking for feedback on the approach.
>
> The goal of the patch is to eliminate a bunch of awkward code,
> eliminate some unnecessary differences between targets, and to
> facilitate future refactoring and feature work.

Nice!

> This patch gets rid of ISD::CALL, ISD::FORMAL_ARGUMENTS, ISD::RET, and
> ISD::ISD::ARG_FLAGS, as well as the old LowerArguments and LowerCallTo
> hooks. To replace them, it adds three new TargetLowering hooks:
> LowerCall, LowerFormalArguments, and LowerReturn. These hooks provide
> targets with the same information as the special nodes, except in an
> immediately usable form instead of awkwardly encoded as SDNode
> operands. The patch also re-works a substantial portion of the
> target-independent tail-call code. The patch also includes changes
> for all in-tree targets to use the new hooks.

This is a great improvement!  Most of my comments are general design  
thoughts, not specific to this one patch.  I understand that this is  
one step in the right direction.

Do clients end up lowering the return information before they lower  
the argument information?  If they do, it should be relatively  
straight-forward to support "spilling to the stack" return values that  
can't fit in physregs.  It would be nice to eventually support  
arbitrary return values in the code generator.  Doing this would  
basically just require return lowering to push an extra iPtr argument.

Looking at the patch, it seems odd that ISD::LIBCALL still exists.  Is  
the "CSE of libcalls" optimization really important in practice?  If  
so, perhaps this should be done as an explicit dag combine  
optimization: if two clumps of flagged together nodes are identical  
and have the same inputs, replace one clump with the other.  This  
would be a nice general solution instead of something specific to calls.

Unrelated, but it would also be nice to make INLINEASM nodes have  
their own SDNode subclass someday instead of a bunch of magically  
indexed operands.  Similar to Nate's recent shuffle change.

InputArg/OutputArg should probably contain an ArgFlagsTy instead of  
inherit from it.


I like the various -'s of random call lowering stuff from the .td  
files, this is great!

-Chris





More information about the llvm-dev mailing list