Compiler Programming Basics by Michael Dsouza & Michael Dsouza

Compiler Programming Basics by Michael Dsouza & Michael Dsouza

Author:Michael Dsouza & Michael Dsouza [Dsouza, Michael]
Language: eng
Format: azw3
Publisher: UNKNOWN
Published: 2017-04-28T04:00:00+00:00


7.3 The intermediate language

In this chapter we have chosen a fairly low-level fine-grained intermediate language, as it is best suited to convey the techniques we want to cover. We will not treat translation of function calls until chapter 10, so a “program” in our intermediate language will, for the time being, correspond to the body of a function or procedure in a real program. For the same reason, function calls are initially treated as primitive operations in the intermediate language.

The grammar for the intermediate language is shown in grammar 7.1. A program is a sequence of instructions. The instructions are:

• A label. This has no effect but serves only to mark the position in the program as a target for jumps.

• An assignment of an atomic expression (constant or variable) to a variable. • A unary operator applied to an atomic expression, with the result stored in a variable.

7.4. SYNTAX-DIRECTED TRANSLATION 151

• A binary operator applied to a variable and an atomic expression, with the result stored in a variable.

• A transfer from memory to a variable. The memory location is an atomic expression.

• A transfer from a variable to memory. The memory location is an atomic expression.

• A jump to a label. • A conditional selection between jumps to two labels. The condition is found by comparing a variable with an atomic expression by using a relational operator (=, =, <, >, ≤ or≥).

• A function call. The arguments to the function call are variables and the result is assigned to a variable. This instruction is used even if there is no actual result (i.e, if a procedure is called instead of a function), in which case the result variable is a dummy variable.

An atomic expression is either a variable or a constant.

We have not specified the set of unary and binary operations, but we expect

these to include normal integer arithmetic and bitwise logical operations. We assume that all values are integers. Adding floating-point numbers and

other primitive types is not difficult, though.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.