Notes: For each thing on this list, is there an instruction to do the computation? Can a combination of 2 or more 3-address instructions do it? Or shall we write a runtime library function to do the work? For everything in cgram.y that's not in this list: you should generate a semantic error: ANSI C feature not implemented.
C feature | Example | 3-address equivalent | Notes |
---|---|---|---|
int lit | 3 | generate "immediate" value in instruction | |
string lit | "hi" | allocate from const region; no code | |
x | allocate from global region; no code | ||
a[ i ] | are we assigning, or reading its value? | ||
+ | x + y | add L:12,G:24,G:28 | L:12 is a temp variable |
x - y | |||
x * y | |||
x / y | |||
-x | unary "negation" | ||
( i ) | |||
i == j | |||
i != j | |||
i <= j | |||
i < j | |||
i >= j | |||
i > j | |||
x = 5 | |||
f() | |||
return x | |||
if (expr) ... | |||
if (expr) ... else ... |