Going from argument to register and back

I am having trouble trying to figure out two pieces of information from
attempting to map arguments to registers.

How do I determine, based on the argument name, which register the value
is supposed to be assigned to?

I can hard-coded it currently and it will be correct 100% of the time
with the current set of assumptions,

but I would rather determine it dynamically so that I can change my
assumptions and still get the right results.

Thanks,

Micah Villmow

Systems Engineer

Advanced Technology & Performance

Advanced Micro Devices Inc.

4555 Great America Pkwy,

Santa Clara, CA. 95054

P: 408-572-6219

F: 408-572-6596

Why would you want to map arguments to registers based on names? Calling conventions are encoded in td files such X86CallingConv.td. Parameter registers etc. are determined from argument number / type, not names.

Evan

One of the requirements for the backend that I am targeting is certain
meta-data needs to be returned to the runtime. This includes the mapping
between parameters and the locations this data is expected to be stored
at. This is mainly because there are multiple address spaces and each
one is mapped differently but all are assigned registers from the same
register class. So this mapping needs to be known at compile time and
passed in the generated code to the runtime to be processed before
execution.

The typical solution to this is to have a one “load” instruction for each address space. The load for address space #17 knows that it is for that addr space. Instruction selection handles its generation, and the asmprinter hook can print whatever metadata you want.

-Chris