Automatic Retargetable Code Generation: A New Technique

A new technique for automatic retargetable code generation is presented. This technique is based on the observation that a ‘reduced instruction set’ subset can always be found for a target machine instruction set; the rest of the instructions are seen to be equivalent to sequence of the reduced instruction set instructions. Given a target machine description, a method is presented which partitions it into two: one partition contains the reduced instruction set; the other contains the rest of the instructions, along with corresponding simulation sequences — these simulation sequences are unique with respect to the partition. In view of the above, the code generation problem, more precisely the instruction selection problem, is seen as a sequence of two phases: The first phase generates reduced instruction set code; the second phase finds opportunities for optimization through compaction of sub sequences in the generated code, to complex instructions. The full capability of the target machine can be potentially utilized due to the latter phase. Retargetability is achieved by automatically generating the above phases from the information in the partition. The phases are based on tree-pattern-matching, implemented through LR parsing. The technique has been tested for the MC 68000; simple comparisons show the generated code to be satisfactory.