[llvm-dev] Understanding TargetLowering::LowerCall
Zhang via llvm-dev
llvm-dev at lists.llvm.org
Mon Mar 22 20:57:58 PDT 2021
Thanks Tim.
One more thing I'm still not quite clear is how to differ GlobalAddress from registers when selection instructions.
Say the Initial DAG is :
```
load<(dereferenceable load 4 from @gv)> t0, TargetGlobalAddress:i64<i32* @gv> 0, undef:i64
```
And in our ISA we have:
```
LOAD_RM reg1,reg2 which basically means reg1 = *reg2
```
However when I use [(set (i32 GP32:$dst),(load GP64:$reg))] as the pattern for this ISA. the aforementioned DAGNode got matched as well.
How do I prevent such nodes from being matched since in our ISA GlobalAddress requires custom lowering
------------------ Original ------------------
From: "Tim Northover"<t.p.northover at gmail.com>;
Date: Mon, Mar 22, 2021 05:57 PM
To: "Zhang"<admin at mayuyu.io>;
Cc: "llvm-dev"<llvm-dev at lists.llvm.org>;
Subject: Re: [llvm-dev] Understanding TargetLowering::LowerCall
On Mon, 22 Mar 2021 at 07:36, Zhang via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> For CallSites that contains a GlobalValue as one of the arguments, where exactly does the lowering from GlobalAddress to iPTR took place?.
It's generally no different for a callsite than any other GlobalValue
user. The generic SelectionDAGBuilder code will create a GlobalAddress
SDNode with iPTR type because the type of a GlobalValue is actually a
pointer to the type of the underlying object.
The call lowering code will get this iPTR node, and may well decide to
pass it to the callee in a register.
As for the GlobalAddress node, that goes through normal lowering to a
target-specific instruction sequence to materialize the address of the
global object. Often this is via custom C++ in LegalizeDAG (i.e.
`setOperationAction(ISD::GlobalValue, MVT::i64, Custom)`).
Cheers.
Tim.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210323/1b8640d9/attachment.html>
More information about the llvm-dev
mailing list