Trouble implementing a new subtarget for X86

Hey all,
I am trying to implement a new subtarget for the X86 target that has only 64 bit registers and instructions and a very minimal ISA excluding any FPU instructions etc.

I have made the required changes to the instructions such that all the instructions that I don't wish to use have a required<> clause that precludes them from being utilised when compiling for this subtarget. I have modified the X86TargetLowering constructor to only include the GR64 group of registers for this particular subtarget.

I am now faced with issues with the Lowering of Formal targets. I have implemented a new calling convention that changes all arguments of type i8, i16 or i32 to i64 and only uses the 64 bit registers to pass arguments. I am however encountering an error in the FormalArgumentLowering function in x86ISelLowering.cpp. I have reproduced the error and Debug output in the attached file. The code being compiled is a simple 2 function program where main calls a function and that function counts to 'n' the parameter passed to it from main.

Can anyone help me figure out why the formal arguments suddenly have no EVT value?(that is the code that fails) at line 1979 of X86ISelLowering.cpp

Thanks a lot for your time,

error (3.2 KB)