mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
30 lines
424 B
C
30 lines
424 B
C
// #target: elf-riscv32
|
|
module test;
|
|
|
|
def Sum = fn int(int a, int b);
|
|
|
|
fn int sum(int a, int b)
|
|
{
|
|
return a + b;
|
|
}
|
|
|
|
fn void main(String[] args)
|
|
{
|
|
int a = 1;
|
|
int b = 2;
|
|
int result = 0;
|
|
Sum sum_ptr = ∑
|
|
|
|
asm
|
|
{
|
|
mv $a0, a;
|
|
mv $a1, b;
|
|
jalr $ra, sum_ptr, 0;
|
|
mv result, $a0;
|
|
}
|
|
}
|
|
|
|
|
|
/* #expect: test.ll
|
|
|
|
"mv a0, $1\0Amv a1, $2\0Ajalr ra, $3, 0\0Amv $0, a0\0A", "=r,r,r,r,~{x1},~{x10},~{x11}"(i32 %1, i32 %2, ptr %3)
|