Code Generation Flashcards

1
Q

What are the 3 main components of code generation?

A
  1. Instruction Selection
  2. Register Allocation
  3. Instruction Scheduling
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Instruction Selection?

A

Essentially pattern matching statements in the Intermediate Representation to statements in the target code

Makes locally optimal choices

Assumes we have enough registers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How might we optimise integer multiplication?

A

We can convert the problem into a series of bit shifts and additions, these operations are a lot quicker than multiplying.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does a pre-call do?

A

Allocate memory for a procedure to be called

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the Prologue do?

A

Initialises variables at the start of a function call

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why are function calls problematic?

A

Though they make the programmer’s life easier,

There is a significant overhead when calling and exiting the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a live range?

A

The interval between a variable’s definition and its last use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is top-down register allocation?

A

Reserve registers for the most frequently used values.

All other values are loaded from memory when needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is bottom up register allocation?

A

We assign values to registers when the values become live,

If there are no registers available, we choose the register whose value will be used latest in the future, and save its value in memory (spilling)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is spilling?

A

This is when there are no free registers left, so we must move values to memory

E.g If we have 10 live values, but only 9 registers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you compute the priority function used in Instruction Scheduling?

A

weight = latency + max(weight of children)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly