add step1 part1

master
Odeinjul 1 year ago
parent d946049212
commit a994f51267
No known key found for this signature in database
GPG Key ID: E384228B2B38FFBB

@ -0,0 +1,117 @@
; ModuleID = 'go_upstairs.c'
source_filename = "go_upstairs.c"
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx14.0.0"
@num = global [2 x i32] [i32 4, i32 8], align 4
@tmp = global i32 1, align 4
@n = common global i32 0, align 4
@x = common global [1 x i32] zeroinitializer, align 4
; Function Attrs: noinline nounwind optnone ssp uwtable(sync)
define i32 @climbStairs(i32 noundef %0) #0 {
%2 = alloca i32, align 4
%3 = alloca i32, align 4
%4 = alloca [10 x i32], align 4
%5 = alloca i32, align 4
store i32 %0, i32* %3, align 4
%6 = load i32, i32* %3, align 4
%7 = icmp slt i32 %6, 4
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i32, i32* %3, align 4
store i32 %9, i32* %2, align 4
br label %41
10: ; preds = %1
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
store i32 0, i32* %11, align 4
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 1
store i32 1, i32* %12, align 4
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 2
store i32 2, i32* %13, align 4
store i32 3, i32* %5, align 4
br label %14
14: ; preds = %19, %10
%15 = load i32, i32* %5, align 4
%16 = load i32, i32* %3, align 4
%17 = add nsw i32 %16, 1
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %36
19: ; preds = %14
%20 = load i32, i32* %5, align 4
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %22
%24 = load i32, i32* %23, align 4
%25 = load i32, i32* %5, align 4
%26 = sub nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %27
%29 = load i32, i32* %28, align 4
%30 = add nsw i32 %24, %29
%31 = load i32, i32* %5, align 4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %32
store i32 %30, i32* %33, align 4
%34 = load i32, i32* %5, align 4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5, align 4
br label %14, !llvm.loop !10
36: ; preds = %14
%37 = load i32, i32* %3, align 4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %38
%40 = load i32, i32* %39, align 4
store i32 %40, i32* %2, align 4
br label %41
41: ; preds = %36, %8
%42 = load i32, i32* %2, align 4
ret i32 %42
}
; Function Attrs: noinline nounwind optnone ssp uwtable(sync)
define i32 @main() #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 0, i32* %1, align 4
%3 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @num, i64 0, i64 0), align 4
store i32 %3, i32* @n, align 4
%4 = load i32, i32* @tmp, align 4
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [2 x i32], [2 x i32]* @num, i64 0, i64 %5
%7 = load i32, i32* %6, align 4
store i32 %7, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @x, i64 0, i64 0), align 4
%8 = load i32, i32* @n, align 4
%9 = load i32, i32* @tmp, align 4
%10 = add nsw i32 %8, %9
%11 = call i32 @climbStairs(i32 noundef %10)
store i32 %11, i32* %2, align 4
%12 = load i32, i32* %2, align 4
%13 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @x, i64 0, i64 0), align 4
%14 = sub nsw i32 %12, %13
ret i32 %14
}
attributes #0 = { noinline nounwind optnone ssp uwtable(sync) "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "probe-stack"="__chkstk_darwin" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+crc,+crypto,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+v8.5a,+zcm,+zcz" }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!llvm.ident = !{!9}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 14, i32 0]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 8, !"branch-target-enforcement", i32 0}
!3 = !{i32 8, !"sign-return-address", i32 0}
!4 = !{i32 8, !"sign-return-address-all", i32 0}
!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0}
!6 = !{i32 7, !"PIC Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 1}
!8 = !{i32 7, !"frame-pointer", i32 1}
!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}

@ -0,0 +1,19 @@
; ModuleID = 'assign_hand.sy'
define i32 @main() #0 {
%1 = alloca float, align 4 ;b
store float 0x3FFCCCCCC0000000, float* %1, align 4
%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
%4 = load float, float* %1, align 4
%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
%8 = fmul float %4, %7 ;b * a[0]
%9 = fptosi float %8 to i32
%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
ret i32 %11
}

@ -0,0 +1,12 @@
@a = common global i32 0, align 4
define i32 @main() #0 {
store i32 10, i32* @a, align 4
%1 = load i32, i32* @a, align 4
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %4
3:
ret i32 %1
4:
ret i32 0
}

@ -0,0 +1,48 @@
; ModuleID = 'Student/task1/sy/assign_test.c'
source_filename = "Student/task1/sy/assign_test.c"
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx14.0.0"
@__const.main.a = private unnamed_addr constant [2 x i32] [i32 2, i32 0], align 4
; Function Attrs: noinline nounwind optnone ssp uwtable(sync)
define i32 @main() #0 {
%1 = alloca i32, align 4
%2 = alloca float, align 4
%3 = alloca [2 x i32], align 4
store i32 0, i32* %1, align 4
store float 0x3FFCCCCCC0000000, float* %2, align 4
%4 = bitcast [2 x i32]* %3 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %4, i8* align 4 bitcast ([2 x i32]* @__const.main.a to i8*), i64 8, i1 false)
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%6 = load i32, i32* %5, align 4
%7 = sitofp i32 %6 to float
%8 = load float, float* %2, align 4
%9 = fmul float %7, %8
%10 = fptosi float %9 to i32
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
store i32 %10, i32* %11, align 4
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%13 = load i32, i32* %12, align 4
ret i32 %13
}
; Function Attrs: argmemonly nofree nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1
attributes #0 = { noinline nounwind optnone ssp uwtable(sync) "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "probe-stack"="__chkstk_darwin" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+crc,+crypto,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+v8.5a,+zcm,+zcz" }
attributes #1 = { argmemonly nofree nounwind willreturn }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!llvm.ident = !{!9}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 14, i32 0]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 8, !"branch-target-enforcement", i32 0}
!3 = !{i32 8, !"sign-return-address", i32 0}
!4 = !{i32 8, !"sign-return-address-all", i32 0}
!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0}
!6 = !{i32 7, !"PIC Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 1}
!8 = !{i32 7, !"frame-pointer", i32 1}
!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}

@ -0,0 +1,45 @@
; ModuleID = 'Student/task1/sy/if_test.c'
source_filename = "Student/task1/sy/if_test.c"
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx14.0.0"
@a = common global i32 0, align 4
; Function Attrs: noinline nounwind optnone ssp uwtable(sync)
define i32 @main() #0 {
%1 = alloca i32, align 4
store i32 0, i32* %1, align 4
store i32 10, i32* @a, align 4
%2 = load i32, i32* @a, align 4
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = load i32, i32* @a, align 4
store i32 %5, i32* %1, align 4
br label %7
6: ; preds = %0
store i32 0, i32* %1, align 4
br label %7
7: ; preds = %6, %4
%8 = load i32, i32* %1, align 4
ret i32 %8
}
attributes #0 = { noinline nounwind optnone ssp uwtable(sync) "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "probe-stack"="__chkstk_darwin" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+crc,+crypto,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+v8.5a,+zcm,+zcz" }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!llvm.ident = !{!9}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 14, i32 0]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 8, !"branch-target-enforcement", i32 0}
!3 = !{i32 8, !"sign-return-address", i32 0}
!4 = !{i32 8, !"sign-return-address-all", i32 0}
!5 = !{i32 8, !"sign-return-address-with-bkey", i32 0}
!6 = !{i32 7, !"PIC Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 1}
!8 = !{i32 7, !"frame-pointer", i32 1}
!9 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
Loading…
Cancel
Save