mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
119 lines
2.5 KiB
C
119 lines
2.5 KiB
C
module test;
|
|
|
|
func int foo1()
|
|
{
|
|
char *pp = void;
|
|
uint w_cnt = void;
|
|
|
|
w_cnt += *pp;
|
|
|
|
return (int)(w_cnt);
|
|
}
|
|
|
|
extern func void test2(int, double, float);
|
|
|
|
func void foo2(int x)
|
|
{
|
|
test2(x, x ? 1.0 : 12.5, 1.0);
|
|
}
|
|
|
|
func int trys(ichar* s, int x)
|
|
{
|
|
int asa = void;
|
|
double val = void;
|
|
int lls = void;
|
|
if (x)
|
|
{
|
|
asa = lls + asa;
|
|
}
|
|
else
|
|
{
|
|
}
|
|
return asa + (int)(val);
|
|
}
|
|
|
|
struct InternalFPF
|
|
{
|
|
char type;
|
|
}
|
|
|
|
func void setInternalFPFZero(InternalFPF* dest) @noinline
|
|
{
|
|
dest.type = 0;
|
|
}
|
|
|
|
func void denormalize(InternalFPF* ptr)
|
|
{
|
|
setInternalFPFZero(ptr);
|
|
}
|
|
|
|
|
|
// #expect: test.ll
|
|
|
|
%pp = alloca i8*, align 8
|
|
%w_cnt = alloca i32, align 4
|
|
%0 = load i32, i32* %w_cnt, align 4
|
|
%1 = load i8*, i8** %pp, align 8
|
|
%2 = load i8, i8* %1, align 8
|
|
%uiuiext = zext i8 %2 to i32
|
|
%add = add i32 %0, %uiuiext
|
|
store i32 %add, i32* %w_cnt, align 4
|
|
%3 = load i32, i32* %w_cnt, align 4
|
|
ret i32 %3
|
|
|
|
%x = alloca i32, align 4
|
|
store i32 %0, i32* %x, align 4
|
|
%1 = load i32, i32* %x, align 4
|
|
%2 = load i32, i32* %x, align 4
|
|
%intbool = icmp ne i32 %2, 0
|
|
br i1 %intbool, label %cond.lhs, label %cond.rhs
|
|
cond.lhs:
|
|
br label %cond.phi
|
|
cond.rhs:
|
|
br label %cond.phi
|
|
cond.phi:
|
|
%val = phi double [ 1.000000e+00, %cond.lhs ], [ 1.250000e+01, %cond.rhs ]
|
|
call void @test2(i32 %1, double %val, float 1.000000e+00)
|
|
ret void
|
|
|
|
%s = alloca i8*, align 8
|
|
%x = alloca i32, align 4
|
|
%asa = alloca i32, align 4
|
|
%val = alloca double, align 8
|
|
%lls = alloca i32, align 4
|
|
store i32 %1, i32* %x, align 4
|
|
%2 = load i32, i32* %x, align 4
|
|
%intbool = icmp ne i32 %2, 0
|
|
br i1 %intbool, label %if.then, label %if.exit
|
|
|
|
if.then:
|
|
%3 = load i32, i32* %lls, align 4
|
|
%4 = load i32, i32* %asa, align 4
|
|
%add = add i32 %3, %4
|
|
store i32 %add, i32* %asa, align 4
|
|
br label %if.exit
|
|
|
|
if.exit:
|
|
%5 = load i32, i32* %asa, align 4
|
|
%6 = load double, double* %val, align 8
|
|
%fpui = fptoui double %6 to i32
|
|
%add1 = add i32 %5, %fpui
|
|
ret i32 %add1
|
|
|
|
|
|
void @test.setInternalFPFZero(%InternalFPF* %0)
|
|
%dest = alloca %InternalFPF*, align 8
|
|
store %InternalFPF* %0, %InternalFPF** %dest, align 8
|
|
%1 = load %InternalFPF*, %InternalFPF** %dest, align 8
|
|
%2 = getelementptr inbounds %InternalFPF, %InternalFPF* %1, i32 0, i32 0
|
|
store i8 0, i8* %2, align 8
|
|
ret void
|
|
|
|
void @test.denormalize(%InternalFPF* %0)
|
|
entry:
|
|
%ptr = alloca %InternalFPF*, align 8
|
|
store %InternalFPF* %0, %InternalFPF** %ptr, align 8
|
|
%1 = load %InternalFPF*, %InternalFPF** %ptr, align 8
|
|
call void @test.setInternalFPFZero(%InternalFPF* %1)
|
|
ret void
|