02 - Intermediate Representation (IR)
Relation between compliers and static analyzers
My Answer:
- After scanner, parser, type checker phases, after translator step, the complier will produce program’s intermediate presentation(IR), and static analyzers will make some operations on these IRs, which could help generator function efficiently.
Exact Answer:
3AC and its common forms
My Answer:
3AC: Three Address-Code, which expressed program’s arguments’ movements, it has following formats:
Exact Answer:
As a concrete instance:
1 | ----- Code ----- |
Build basic blocks on top of IR
My Answer:
Follow these steps:
Posix: there has a program P
- P 的第一条指令是 leader
- Conditional transfer 的 jmp 地址是 leader
- Conditional transfer instruction 是 leader❌: 应该是 conditional 的下一条 instr.
Warning: Basic Block(BB) 只有一个输入一个输出,BB内没有中间输入 or 中间输出
- 一个 BB 只有一个 leader,一个 leader 到下一个 leader 的中间过程的指令形成一个 BB
Exact Answer:
For example:
Construct flow graphs on top of BBs
My Answer:
- BB中有相同变量的需要有连接 (不准确): B follows A in the original order of instrs.
- goto 的直接连接
- conditional(if)的需要和下一个 BB 有连接,因为 if 的条件可能返回 false.
Exact Answer:
还需加 Entry 和 Exit, Entry contains the IR’s first instr.
Exit from any BB containing an instr and could be the last instr of IR.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Sicilienne!
评论
Valine# ValineDisqus