[llvm-dev] Getting TargetLowering in AsmPrinter / Lowering constant addrspacecast
Justin Holewinski via llvm-dev
llvm-dev at lists.llvm.org
Mon Dec 14 15:46:19 PST 2015
Yeah, NVPTX is funny and requires some extra handling; especially in regards to how such casts are emitted in the assembly. It’s certainly not ideal. We actually wrap such casts in a custom MCExpr sub-class.
On 12/14/15, 6:41 PM, "Manuel Jacob" <me at manueljacob.de> wrote:
>Hi,
>
>I'd like to add support for addrspacecast in initializers of global
>variables, at least for the trivial case. The trivial case is if
>TargetLowering::isNoopAddrSpaceCast(SrcAS, DestAS) returns true. In
>this case the MCExpr for the addrspacecast is the MCExpr of its first
>operand.
>
>It seems hard to obtain an instance of TargetLowering in
>AsmPrinter::lowerConstant(). Other methods in this class obtain it by
>calling `MF->getSubtarget().getTargetLowering()`. However, because MF
>is nullptr when lowering initializers of global variables, it won't
>work. My impression is that this is not possible because every function
>has its own TargetLowering instance. Is that correct?
>
>NVPTX solves the problem by having a method on it's NVPTXAsmPrinter
>class, which is mostly a copy of AsmPrinter::lowerConstant() and knows
>how to handle addrspacecasts. However, this probably isn't a solution
>for e.g. X86.
>
>Suggestions are highly welcome.
>
>-Manuel
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
More information about the llvm-dev
mailing list