method prologue code generation
thomas.wuerthinger at oracle.com
Wed Apr 10 08:59:58 PDT 2013
On Apr 10, 2013, at 5:33 PM, "Venkatachalam, Vasanth" <Vasanth.Venkatachalam at amd.com> wrote:
> I'm looking at PTXBackend.emitCode( ) and it looks like the code for the method prologue is being emitted before the actual code generation takes place in the call to lirGen.lir.emitCode(tasm). In particular, it looks like the registers that are later used in the code generation of the method body are being manually declared here.
> Can someone explain the intent for doing things in this order?
I believe this is more a requirement of PTX assembly to declare the kernel parameters before the kernel body.
> My concern is the following. It looks like the mapping of method parameters/variables to registers only happens in the call to lirGen.lir.emitCode( ), so before this call takes place it seems you wouldn't really know which registers will be used for different parameters/variables.
> So how would you know what registers need to be declared in the prologue section, before you generate the code for the body of the method?
The locations used for the parameters are usually part of the calling convention. This contract between the caller and the callee is defined based on the method signature.
> On the other hand, do you have a way of piping the variable->register mapping information from lirGen.lir.emitCode( ) so that you can retrieve this when you generate the prologue?
It is not necessary to pipe the parameter->register information as it is defined based on the method signature. The variable->register mapping is done automatically by the register allocator. In PTX, you only have to specify how many registers you want to "reserve" for future use.
Hope this helps,
More information about the graal-dev