Study Guide Jeopardy Flashcards

1
Q

What is a graphical IR?

A

representation of structure and semantics of code in a visual way

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

What is a syntax tree(Concrete and Abstract)

A

Rooted, undirected graph containing no cycles.
Flows from start symbol, to terminal, where state is root and terminals are leaves, interior nodes are all non terminals

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

What is an abstract syntax tree?

A

A CST, with details abstracted away. Near source level representation.

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

What is a directed acyclic graph?

A

Directed graph with no cycles, partially ordered.

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

What is a linear IR?

A

Representation of code as a sequence of instructions.

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

What is postfix notation?

A

linear IR where expressions are written at the end of the operator (ab+)

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

What is Three Address code?

A

Linear IR, 4 tuple, closely resembling assembly for modern machines

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

What are the benefits of an intermediate language

A

Completely decouples front and backends
Useful for debugging

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

Why might you use graphical IR over linear? And vice versa?

A

Graphical: good for analyzing and optimizing code and showing relationships
Linear: better for code generation and execution, concise and closer to machine code

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

What is the value of utilizing an IR?

A

Simplifies compiler design by breaking it into modular phases

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

What is syntax-directed translation?

A

Translation scheme by which the parse of the source program is used to derive the meaning of the program using semantic rules or actions associated with grammar symbols

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

What is a syntax-directed definition?

A

Context free grammar augmented with a set of attributes and a set of rules which guides semantic analysis

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

Which direction along a parse tree do synthesized and inherited attributes move information?

A

Synthesized attributes are used to pass information up the parse tree
Inherited attributes are used to pass information down parse tree

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

What is a variable?

A

A named storage location in a program that holds the value which determines what data it can store.

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

What is type coercion? Is it good or bad?

A

When a type conversion is initiated by the compiler or runtime environment. Like converting an int into a float

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

What is an expression?

A

A syntactic entity in a programming language that may be evaluated to determine its value

17
Q

What are two different kinds of expressions?

A

Arithmetic expressions: has operators, operates, parentheses, function calls
Relational expressions: binary expression that has 2 operants and 1 relational operator, comparing the values of operants
Boolean expressions: consisting of Boolean variables, Boolean constants relational expressions and Boolean operators (AND, OR, NOT)

18
Q

What are design concerns for expressions (know 2)

A
  1. Order of evaluation: sequence in which operators and operants are processed affects the results
  2. Type compatibility: ensuring the operants are compatible with the operator to prevent errors or type coercion
  3. Precedence and associating: governing operator idea while side effects influence operand order
19
Q

What is a precedence and what does it apply to?

A

Precedence is applied to expressions and it’s when expressions are governed by orders of evaluation

20
Q

What is a basic block?

A

Set of TAC instruction that are always executed sequentially form beginning to end.

21
Q

What is the difference between machine-independent and machine-dependent optimization?

A

Machine-independent occurs IR level and can be done regardless of target machine. Machine-dependent leverages instructions and architecture of the target machine

22
Q

What are two challenges with machine-dependent optimization?

A

Portability: code optimized for one hardware platform might not run well on other
Maintenance complexity: needing to update and manage code differently for each target hardware architecture

23
Q

Why do we do optimization?

A

It reduces processing time, aids in space management, saves on memory

24
Q

What is local optimization/what level is it done at?

A

Transforms basic blocks into DAGs and then utilizes the useful expression properties and structure of DAGs to improve code. On the level of basic block

25
Q

What is global optimization/what level is it done at?

A

Moving loop invariant computations outside of loops, common subexpression elimination (removing redundant computations) and register allocation. On the level of , multiple blocks/whole program

26
Q

What is the scope of a variable?

A

Where a variable can be accessed in a program.

27
Q

What is the difference between static and dynamic scope?

A

Static scope determines scope of a variable at compile time
Dynamic scope: determines scope based on runtime