December 2015
Beginner to intermediate
166 pages
3h 8m
English
An if-else statement has a condition expression and two code paths to execute, depending on the condition evaluating to true or false. The condition expression is generally a comparison statement. Let's emit a condition statement at the start of the block. For example, let the condition be like a<100.
Value *val2 = Builder.getInt32(100); Value *Compare = Builder.CreateICmpULT(val, val2, "cmptmp");
On compilation, we get following output:
; ModuleID = 'my compiler'
@x = common global i32, align 4
define i32 @foo(i32 %a, i32 %b) {
entry:
%multmp = mul i32 %a, 16
%cmptmp = icmp ult i32 %multmp, 100
ret i32 %multmp
}The next step is to define the then and else block expressions, which will be executed depending on the ...
Read now
Unlock full access