mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
41 lines
972 B
Plaintext
41 lines
972 B
Plaintext
// #target: macos-x64
|
|
module test;
|
|
import std;
|
|
|
|
struct Vector3
|
|
{
|
|
float x, y, z;
|
|
}
|
|
|
|
macro @printVecs(Vector3... vectors)
|
|
{
|
|
for (int $i = 0; $i < vectors.len; ++$i)
|
|
{
|
|
// do something
|
|
}
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
@printVecs({10, 5, 3}, {9, 6, 4}, {5, 4, 3});
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
define void @test.main() #0 {
|
|
entry:
|
|
%literal = alloca [3 x %Vector3], align 16
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %literal, ptr align 16 @.__const, i32 36, i1 false)
|
|
%0 = insertvalue %"Vector3[]" undef, ptr %literal, 0
|
|
%1 = insertvalue %"Vector3[]" %0, i64 3, 1
|
|
br label %loop.cond
|
|
loop.cond: ; preds = %loop.inc, %entry
|
|
%2 = extractvalue %"Vector3[]" %1, 1
|
|
%lt = icmp ult i64 0, %2
|
|
br i1 %lt, label %loop.inc, label %loop.exit
|
|
loop.inc: ; preds = %loop.cond
|
|
br label %loop.cond
|
|
loop.exit: ; preds = %loop.cond
|
|
ret void
|
|
}
|