本文介绍了PIC后端:16位寄存器/返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始为16位PIC微控制器(PIC24,dsPIC30/33)编写LLVM后端.从Lanai复制并重命名内容后,删除了很多内容,添加了一些内容,并使后端对clang来说我可以翻译

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; }

mov #0x2A, W0
ret

这正是我想要的.

DataLayout设置为"e-m:e-p:16:16-i16:16-a:0:16-n16-S16",并且寄存器定义为

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)>;

并添加为

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

但是,当我将上述返回类型更改为'int'时,我得到"返回操作数#1具有未处理的类型i16 ",这很奇怪,因为i16仅是 当前处理的类型:

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]>>
]>;

编译在Lowerpturn()中终止

Compilation aborts in LowerReturn() at

CCInfo.AnalyzeReturn(Outs, RetCC_PIC16);

我想念什么?我还需要做什么来告诉clang/llvm使用哪个int大小以及如何返回它?

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?

标识符GPRRegClass来自哪里,它实际上是正确的吗?

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

推荐答案

已解决:在我正确设置int的大小后,此问题消失了;参见如何告诉clang我的LLVM目标应该使用16位'int'?

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'?

这篇关于PIC后端:16位寄存器/返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 19:29