The evaluation of arithmetic expressions on both register-oriented and stack-oriented machines can be studied using the same model because registers can be treated as a stack during the evaluation of expression trees, without loss in code efficiency. The machine model in this paper has a hardware stack in which all computations take place. Register-register and register-memory instructions are modeled by considering four possible instructions for each binary operator, depending on whether one or two operands are taken from the stack and on whether the left or the right operand is on top of the stack. There is a cost associated with each operation code, as well as costs for accessing a value in a register or in memory. The minimum cost of computing an expression tree is used to compare machines. As part of the framework that allows the comparisons to be performed, a parameterized algorithm for determining the number of stores that must occur in an optimal computation is developed. This algorithm forms the basis of an optimal code generation algorithm.
ASJC Scopus subject areas
- Computational Theory and Mathematics
- Computer Graphics and Computer-Aided Design
- Hardware and Architecture
- Information Systems
- Theoretical Computer Science