Machine-translated by Google. Questions are authored in English.
Top

Discussion

The getreg function of a simple code generator

  • A.decides the order in which the instructions will run
  • B.chooses a register for a result, spilling one if necessary
  • C.returns the number of registers the machine provides
  • D.computes the cost of the instruction about to be emitted

Answer: B

Correct answer: chooses a register for a result, spilling one if necessary

When every register is occupied, getreg must decide which value to evict - preferring one already in memory, or one with no next use in the block - and emit a store if the value would otherwise be lost. That decision is the heart of a simple code generator’s register management.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.