Peephole Optimizer in Retargetable Compilers*

Tzer-Shyong CHEN  Feipei LAI  Shu-Lin HWANG  Rung-Ji SHANG  

Publication
IEICE TRANSACTIONS on Information and Systems   Vol.E79-D   No.9   pp.1248-1256
Publication Date: 1996/09/25
Online ISSN: 
DOI: 
Print ISSN: 0916-8532
Type of Manuscript: PAPER
Category: Sofware System
Keyword: 
code generator,  compiler,  peephole optimizer,  retargetable compiler,  

Full Text: PDF>>
Buy this Article




Summary: 
Abstract machine modelling is a technique used frequently in developing the retargetable compilers. By translating the abstract machine operations into target machine instructions, we can construct retargetable compilers. However, such a technique will cause two problems. First, the code produced by the compilers is inefficient. Next, in order to emit the efficient code, the compilation time is too long. In view of these two disadvantages, we apply PO (peephole optimizer) in our retargetable compilers to do code optimization. Peephole optimizer searches for the adjacent instruction candidates in the intermediate code, and then replaces them with equivalent instructions of less cost. Furthermore, the peephole description table consists of simple tree-rewriting rules which are easily retargeted into different machines. At the same time, we have proposed a simple peephole pattern matching algorithm to reduce the peephole pattern matching time. The experiment indicates that the machine code generated by our compiler runs faster than that by GNU c compiler (gcc).