This work deals with the implementation of a retargetable compiler for a specific programming language that can be systematically reconfigured to generate code for a variety of distinct target computers. In pursuing this goal, a model is proposed and in particular the following three aspects arising from the model are presented:
(1) Designing a target machine description language which allows the specification of instruction set semantics.
(2) Developing an algorithm for code generation in a compiler.
(3) Developing algorithms for constructing code generators from the machine description.
It can be viewed as an extension of Graham-Glanville's scheme[G&G78]. All formal properties established by Glanville hold on our implementation. Furthermore, we modified the algorithms to produce a correct transition table from a target machine description. The major contributions of our technique are as follows:
(1) We have derived a simple algorithm handling the looping problems[O&P84]. The LALR (1) properties and the conflict resolution methods make it possible to derive the algorithm.
(2) The target machine description language is substantially enlarged to describe the behavior of a code generator. To do this, we used the semantic escape characters which control the process of code emission.
(3) The LALR(1) technique is used to make an initial transition table. Moreover, the formula for computing lookahead sets can be obtained in a more efficient form the characteristics of an instruction grammar.
We have implemented a code generator constructor system by modifying our parser generating system[PAR81]. with this code generator constructor system, the code generators for the pascal subset on two computers are implemented.
본 논문은 Language-dependent 부분에 이용해 오던 문법 이론을 Back-endProcessing에 적용하여 재목적 컴파이러를 위한 Code generator를 자동적으로 구성하였다. 이때 발생되는 여러가지 문제중 특히 Looping 문제를 체계적으로 해결하고 증명하였다. 이것은 Graham-Glanville 구조의 확장으로 생각할 수있으며 그들에 의해 세워졌던 모든 형식적인 속성은 역시 우리의 Scheme에서도 성립한다. 더우기 우리는 Machine description으로 부터 옳바른 Table를 유도하기 위해서 사용된 여러가지 Algorithm을 수정, 개선하였다.
컴파일러의 Code generation 과정을 자동화 하려는 기법이며, 이것에 대한 우리의 공헌은 다음과 같이 요약될 수 있다.
1) Instruction Grammar의 Ambiguity로 부터 야기되는 Looping 문제를 다루는 간단하고 능률적인 Algorithm을 유도하였으며 LALR(1)의 특성과 Ambiguity 해결 방법은 이것을 가능하게 했다.
2) Code generation 과정을 빠르고 잘 표현할 수 있도록 Target machine을 묘사하는 언어를 확장하였다.
3) 초기 Table를 만드는 데 LALR(1) 기술을 사용하였으며, Instruction grammar의 특수한 형태로 부터 Lookahead set을 구하는 효과적인 Formula 를 얻었다.
이 논문에서 묘사된 Code generator의 자동화 System은 설치되었으며, 이System을 이용하여 2개의 Machine에 대한 Code generator를 설치, 실험하였다.