Skip to content

Commit 57b35b4

Browse files
committed
Update control flow
1 parent 654cb8e commit 57b35b4

File tree

4 files changed

+150
-151
lines changed

4 files changed

+150
-151
lines changed

assets/05_for.png

-22.9 KB
Binary file not shown.

code/article_05/for.ll

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
; for.ll
2-
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3-
target triple = "x86_64-apple-macosx10.15.0"
4-
52
define i32 @main() {
6-
%i = alloca i32 ; int i = ...
7-
store i32 0, i32* %i ; ... = 0
3+
%i = alloca i32 ; int i = ...
4+
store i32 0, ptr %i ; ... = 0
85
br label %start
96
start:
10-
%i_value = load i32, i32* %i
11-
%comparison_result = icmp slt i32 %i_value, 4 ; test if i < a
7+
%i_value = load i32, ptr %i
8+
%comparison_result = icmp slt i32 %i_value, 4 ; Test if i < 4
129
br i1 %comparison_result, label %A, label %B
1310
A:
14-
; do something A
15-
%1 = add i32 %i_value, 1 ; ... = i + 1
16-
store i32 %1, i32* %i ; i = ...
11+
; Do something A
12+
%1 = add i32 %i_value, 1 ; ... = i + 1
13+
store i32 %1, ptr %i ; i = ...
1714
br label %start
1815
B:
19-
; do something B
16+
; Do something B
2017

2118
ret i32 0
22-
}
19+
}

0 commit comments

Comments
 (0)