PIC Backend: 16-bit registers / return type

此生再无相见时 提交于 2020-01-03 02:59:08

问题


I started writing an LLVM Backend for 16-bit PIC microcontrollers (PIC24, dsPIC30/33). After copying and renaming stuff from Lanai, removing much, adding some and making the backend known to clang I can translate

short foo(void) { return 6*7; }

to

mov #0x2A, W0
ret

which is precisely what I wanted.

The DataLayout is set to "e-m:e-p:16:16-i16:16-a:0:16-n16-S16" and the registers are defined as

def GPR : RegisterClass<"PIC", [i16], 16, (sequence "W%u", 0, 15)>;

and added as

addRegisterClass(MVT::i16, &PIC::GPRRegClass);

However when I change the above return type to 'int', I get "Return operand #1 has unhandled type i16" which is strange because i16 is the only type currently handled:

def RetCC_PIC16 : CallingConv<[
  // Use W0 to return 16-bit value.
  CCIfType<[i16], CCAssignToReg<[W0]>>
]>;

Compilation aborts in LowerReturn() at

CCInfo.AnalyzeReturn(Outs, RetCC_PIC16);

What am I missing? What else do I have to do to tell clang / llvm which int size to use and how to return it?

Where does the identifier GPRRegClass come from and is it actually correct?


回答1:


SOLVED: this disappeared after I set the size of int correctly; see How to tell clang that my LLVM Target should use 16-bit 'int'?



来源:https://stackoverflow.com/questions/39456108/pic-backend-16-bit-registers-return-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!