开发者

How to hint types when compiling with llvm-gcc?

开发者 https://www.devze.com 2023-04-08 02:53 出处:网络
In some C code, I\'m defining a simple static array as a function argument, say: void foo(float color[3]);

In some C code, I'm defining a simple static array as a function argument, say:

void foo(float color[3]);

When I compile it with llvm-gcc, it produces the following LLVM assembly language output:

define void @foo(float* %n1) nounwind ssp {

Is there any way I can hint to the compiler that I'd like it to generate code using an LLVM array [3 x float] or vector <3 x float&g开发者_运维百科t; on the stack, instead of a pointer?


void foo(float color[3]); is defined by the C standard to be equivalent to void foo(float *color);. Maybe you want void foo(float (*color)[3]), or struct vec { float elems[3]; }; void foo(struct vec color);?


Generally speaking, you cannot. It's C standard / platform ABI which defines the layout of your types, etc.

If you want such fine control over IR emission you'd need to do this by hands (or modify clang, etc.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号