Concepts Introduced in Chapter 8 register assignment instruction - - PowerPoint PPT Presentation

concepts introduced in chapter 8
SMART_READER_LITE
LIVE PREVIEW

Concepts Introduced in Chapter 8 register assignment instruction - - PowerPoint PPT Presentation

Concepts Introduced in Chapter 8 register assignment instruction selection run-time stack management followed by Fig. 8.1 1 EECS 665 Compiler Construction Target Program The target program can be Absolute machine language


slide-1
SLIDE 1

EECS 665 Compiler Construction 1

Concepts Introduced in Chapter 8

  • register assignment
  • instruction selection
  • run-time stack management

followed by Fig. 8.1

slide-2
SLIDE 2

EECS 665 Compiler Construction 2

Target Program

The target program can be

– Absolute machine language – Relocatable machine language – Assembly language

slide-3
SLIDE 3

EECS 665 Compiler Construction 3

Tasks Performed by a Code Generator

  • Register assignment
  • Instruction selection
  • Management of the run-time stack
slide-4
SLIDE 4

EECS 665 Compiler Construction 4

Register Assignment

  • Register assignment is the assignment of

temporaries to hardware registers.

  • Challenges

– Use of register pairs – Overlapping of registers – Operations in specific registers – Spills

slide-5
SLIDE 5

EECS 665 Compiler Construction 5

Instruction Selection

  • Instruction selection is the mapping of the

intermediate language operations to machine instructions.

  • Have to choose not only the appropriate

instructions, but also the addressing mode of each

  • perand.
slide-6
SLIDE 6

EECS 665 Compiler Construction 6

SPARC Addressing Modes

Name Assembly RTL immediate n n register %n r[n] register deferred [%n] M[r[n]] displacement [%n+m] M[r[n]+m] [%n-m] M[r[n]-m] indexed [%n+%m] M[r[n]+r[m]]

slide-7
SLIDE 7

EECS 665 Compiler Construction 7

Run-Time Stack Management

  • Allocating and deallocating space on the run-time

stack when entering and leaving a function.

  • Partitioning the register set into scratch and

nonscratch sets.

  • Saving and restoring nonscratch registers that are

used in the function.

  • Dedicating registers for managing the run-time

stack.

  • Passing arguments.
  • Responsibility of callee versus caller.
slide-8
SLIDE 8

EECS 665 Compiler Construction 8

Evaluation Order of Arguments

  • What is printed by the following program?

i n t g = ; i n t f ( ) { r e t u r n g ; } i n t f 1 ( ) { r e t u r n + + g ; } m a i n ( ) { p r i n t f ( “ % d % d \ n ” , f ( ) , f 1 ( ) ) ; }