[LLVMdev] Problem selecting the correct registers for a calling convention

Job Noorman jobnoorman at gmail.com
Tue Nov 27 07:32:49 PST 2012


I'm currently working on the MSP430 backend and I have some problems 
implementing the calling convention.

It's a 16-bit architecture which dictates that arguments should be passed in 
registers R15-R12. Therefore, I have something like this is a .td file:
    CCIfType<[i16], CCAssignToReg<[R15W, R14W, R13W, R12W]>>

32-bit arguments should be passed in R14:R15 (R12:R13). Since it's a little 
endian architecture, R14 (R12) should contain the least significant bytes and 
R15 (R13) the most significant ones.

The problem is that before the calling convention is applied, i32's are 
legalized into two i16's, the first one containing the least significant 
bytes. This causes R15 to be selected for the least significant bytes, which 
is not what I want.

This issue is basically that I cannot find a way to distinguish two i16 
arguments from one i32. Is there a way to do this in LLVM? Preferably using 
tablegen, of course:-)

Kind regards,
Job



More information about the llvm-dev mailing list