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.

25 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

source_filename = "assign_test.sy"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; 配置信息
define dso_local i32 @main() { ; 定义主函数
%1 = alloca float, align 4 ; 分配一个float, 相当于b
%2 = alloca [2 x i32], align 4 ; 分配两个i32相当于a[2]
store float 0x3FFCCCCCC0000000, float* %1, align 4 ; 相当于b=1.8用二进制表示1.8
%3 = getelementptr [2 x i32], [2 x i32]* %2, i64 0, i64 0 ; 获得%2的第0个元素的指针下同
store i32 2, i32* %3 ; 将这个值赋给2即a[0]=2相当于a[2]={2}。
%4 = getelementptr [2 x i32], [2 x i32]* %2, i64 0, i64 0
%5 = load i32, i32* %4, align 4
%6 = sitofp i32 %5 to float ; 把%5也就是a[0]转成float
%7 = load float, float* %1, align 4
%8 = fmul float %6, %7
%9 = fptosi float %8 to i32 ; 把%8也就是a[0]*b转成i32
%10 = getelementptr [2 x i32], [2 x i32]* %2, i64 0, i64 1 ; 获得%2的第1个元素的指针下同
store i32 %9, i32* %10, align 4 ; 把%9的结果存储在%10即a[1]中)
%11 = getelementptr [2 x i32], [2 x i32]* %2, i64 0, i64 1
%12 = load i32, i32* %11, align 4 ; 读出%10即a[1])的值
ret i32 %12 ; main 返回
}