mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
51 lines
1.1 KiB
C
51 lines
1.1 KiB
C
// #target: macos-x64
|
|
|
|
module test;
|
|
import std::io;
|
|
fn void main()
|
|
{
|
|
int x = 222;
|
|
int y = 223;
|
|
long z = 0;
|
|
z = x + y;
|
|
z *= x;
|
|
int g = 0;
|
|
int* gp = &g;
|
|
int[4] a = { 3, 4, 5, 6 };
|
|
int* xa = &a;
|
|
usz asf = 1;
|
|
int aa = 3;
|
|
asm
|
|
{
|
|
|
|
movl x, 4;
|
|
movl [gp], x;
|
|
movl x, 1;
|
|
movl [xa + asf * 4 + 4], x;
|
|
movl $eax, (23 + x);
|
|
movl x, $eax;
|
|
movq [&z], 33;
|
|
addl aa, 22;
|
|
}
|
|
io::printfln("aa: %d", aa);
|
|
io::printfln("Z: %d", z);
|
|
io::printfln("x: %d", x);
|
|
io::printfln("G was: %d", g);
|
|
foreach(int abc : a) io::printfln("%d", abc);
|
|
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
%5 = load i32*, i32** %gp, align 8
|
|
%6 = load i32*, i32** %xa, align 8
|
|
%7 = load i64, i64* %asf, align 8
|
|
%8 = load i32, i32* %x, align 4
|
|
%add3 = add i32 23, %8
|
|
%9 = load i32, i32* %aa, align 4
|
|
%10 = call { i32, i32 } asm alignstack "movl $$4, $0\0Amovl $0, ($3)\0Amovl $$1, $0\0Amovl $0, 4($4,$5,4)\0Amovl $6, %eax\0Amovl %eax, $0\0Amovq $$33, $1\0Aaddl $$22, $2\0A", "=&r,=*&m,=r,r,r,r,r,2,~{cc},~{rax},~{flags},~{dirflag},~{fspr}"
|
|
%11 = extractvalue { i32, i32 } %10, 0
|
|
store i32 %11, i32* %x, align 4
|
|
%12 = extractvalue { i32, i32 } %10, 1
|
|
store i32 %12, i32* %aa, align 4
|