You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
872 B

12 months ago
define i32 @main() #0 {
; alloc b and store 1.8 to b
%1 = alloca float, align 4 ;b
store float 0x3FFCCCCCC0000000, float* %1, align 4
; alloc a[2] and store 2 to a[0]
%2 = alloca [2 x i32], align 4 ;a
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0 ;a[0]
store i32 2, i32* %3
; load b
%4 = load float, float* %1, align 4
; load a[0] and convert to float
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0 ;a[0]
%6 = load i32, i32* %5, align 4
%7 = sitofp i32 %6 to float ;a[0] to float
; calculate b * a[0]
%8 = fmul float %4, %7
%9 = fptosi float %8 to i32
; store to a[1]
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1 ;a[1]
store i32 %9, i32* %10, align 4;
%11 = load i32, i32* %10, align 4
; return a[1]
ret i32 %11
}