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.)
精彩评论