[LLVMdev] Can I add GlobalVariable in MachineFunctionPass ?

Micah Villmow micah.villmow at smachines.com
Mon Aug 5 08:23:32 PDT 2013


I originally did do it a similar way, but that was before many of the more modern LLVM Machine structures existed.

You can see how I eventually did  it here:
http://llvm.org/svn/llvm-project/llvm/branches/AMDILBackend/lib/Target/AMDIL/AMDILModuleInfo.cpp

You don't need to put the information in a global variable as you can store it in the MachineModuleInfo and then query/modify it where needed from the various locations.

Micah

From: Anthony Yu [mailto:swpenim at gmail.com]
Sent: Monday, August 05, 2013 8:00 AM
To: Micah Villmow
Cc: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] Can I add GlobalVariable in MachineFunctionPass ?

Micah,

As you expected, I am trying to create local memory but in the NVPTX backend. It's really not convenient that I can't create local memory in runOnMachineFunction.
Hmm....
Since I should do it at doInitialization stage, I also need to do some tricks in global variable and AsmPrinter to resize it.
Did you use the similar way?

Antony



2013/8/5 Micah Villmow <micah.villmow at smachines.com<mailto:micah.villmow at smachines.com>>
Antony,
 What are you trying to accomplish in this case? I did something very similar in the AMDIL backend, but it was not the cleanest solution and you are correct it has to be do at doInitialization stage and not at runOnMachineFunction.
Micah

> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu<mailto:llvmdev-bounces at cs.uiuc.edu> [mailto:llvmdev-bounces at cs.uiuc.edu<mailto:llvmdev-bounces at cs.uiuc.edu>]
> On Behalf Of Antony Yu
> Sent: Monday, August 05, 2013 3:41 AM
> To: llvmdev at cs.uiuc.edu<mailto:llvmdev at cs.uiuc.edu>
> Subject: [LLVMdev] Can I add GlobalVariable in MachineFunctionPass ?
>
> Hello,
>
> I want to add a global variable of arrayType in my MachineFunctionPass.
> However, I only get const Module from
> MachineFunction.getMMI().getModule().
> I can't add any global variable to a const Module.
> Another way is to add a global variable in doInitialization in my
> MachineFunctionPass, but I can't determine the size of my arrayType for
> global variable in doInitialization.
>
> Is there any suggestion that can help me achieve this?
>
> Thanks in advance.
> Antony Yu
>
>
>
> --
> View this message in context: http://llvm.1065342.n5.nabble.com/Can-I-add-
> GlobalVariable-in-MachineFunctionPass-tp60165.html
> Sent from the LLVM - Dev mailing list archive at Nabble.com.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu<mailto:LLVMdev at cs.uiuc.edu>         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130805/3d879bc8/attachment.html>


More information about the llvm-dev mailing list