【发布时间】:2016-09-16 06:25:56
【问题描述】:
对于我的 PIC 后端,我希望 'int' 为 16 位。我/我的目标如何告诉 clang 'int' 的大小应该是多少?仅定义 16 位寄存器似乎还不够。
目前“clang -O2 -emit-llvm -target pic”转换
int foo(int a, int b) { return a + b; }
到这个 IR 代码,使用 32 位整数:
; ModuleID = '../test/sum.c'
source_filename = "../test/sum.c"
target datalayout = "e-m:e-p:16:16-i16:16-a:0:16-n16-S16"
target triple = "pic"
; Function Attrs: norecurse nounwind readnone
define i32 @foo(i32 %a, i32 %b) local_unnamed_addr #0 {
entry:
%add = add nsw i32 %b, %a
ret i32 %add
}
attributes #0 = { norecurse nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.ident = !{!0}
!0 = !{!"clang version 4.0.0 (http://llvm.org/git/clang.git 92920e1616528c259756dd8190d4a47058fae127) (http://llvm.org/git/llvm.git 7ca31361200d6bc8a75fa06f112083a8be544287)"}
这可能是也可能不是我在PIC Backend: 16-bit registers / return type 中描述的“Return operand #1 has unhandled type i16”消息的原因。但是,在转向其他问题之前,我可能应该正确地确定 clang 输出中使用的类型。
【问题讨论】:
标签: clang llvm pic llvm-clang