201250093 谭子悦

Overview

The basic goal of this lab is to generate LLVM IR for the simplest type of SysY program, which consists of:

And the correctness of our implementation will be tested by comparing the exit status code with the expected one.

Challenges

Logical Not operation

When implementing the unary operation !, at first I want to use the function LLVMBuildNot(), like the LLVMBuildNeg() for unary operation -. But then I realize that LLVM doesn't have a function for logical not operation at all, so I have to do it in another way.

Hence I decided to implement this in two steps:

 %temp1 = icmp eq i32 %temp0, 0
 %temp2 = zext i1 %temp1 to i32

And it works!