0

What does FJUMP mean in this context?

The following is a Three Address Code (TAC) Intermediate Representation for a register machine: it contains a function called foo, which takes an integer parameter n and a parameter a which is an array of integers. Write down the high-level language counterpart in Java-like pseudocode.

label Foo:
    res = 1
    i = 1
label BAR:
    t1 = i LEQ n
    a[1] = res
    i = i ADD 1
    res = res MUL i
    JUMP BAR
label BAZ:

I thought a jump instruction in three address code is something like "if x goto L"?

James Skemp
  • 8,018
  • 9
  • 64
  • 107
user2976568
  • 149
  • 1
  • 2
  • 12

1 Answers1

2

The relevant excerpt is:

t1 = i LEQ n
FJUMP t1 BAZ

Which I take to mean "if i is less than or equal to n, jump to BAZ". So FJUMP indeed does seem to denote a conditional jump (as you read it, feel free to insert the "if" and "goto" parts yourself!).

You have to understand that three-address code is not a language. It is a class of intermediate representations (languages) that have similar characteristics, not unlike the classes of object-oriented or functional languages. As a compiler developer, you get to design your three-address code, should you opt to use such an intermediate representation.


On a side note, I have a feeling that students of compiler theory tend to read their textbooks too literally. If you look at a bunch of reasonably modern compilers, you are likely to find recurring patterns, but they tend to differ quite significantly in the details.

Martin Törnwall
  • 9,299
  • 2
  • 28
  • 35