File ChangingEmitter.html    Author McKeeman    Copyright © 2007    index

Changing the Emitter Object

Preliminaries

First read about the emitter.

In MATLAB in the mxcom directory, try

   >> help Emitter.m
   >> xcom -emitTrace x:=1
   >> xcom -emitTrace -asmTrace x:=1
   >> xcom -genTrace -emitTrace -asmTrace x:=1

Small Changes to the Emitter

A small change to X trickles down to either a new case in an existing action or a new action. If the change involves the current expressions, the invariants of the operand tracking mechanism must be preserved. If the change introduces a new expression type, that type must be integrated into the symbol table and emitter operands.

Changing the Emitter for New Hardware

If xcom is just going to be implemented for a different CPU, then the exisiting EmitX86.m can be renamed and then modified. New calls to the a new assembler need to be formulated.

If xcom is to be multi-targetted (retain the x86 and add a new target CPU), the calls to the assembler need to be conditional on which CPU is targetted, but the rest of the emitter mechanism is likely to be correct. One can imagine making the assembler calls conditional on the target platform (increasing the size of EmitX86.m) or one can imagine implementing another parallel emitter which is chosen by the Generator, perhaps at startup.

In the end, if enough different platforms are going to be targetted, it will pay to insert an abstract machine between the emitter and assemblers. I doubt this will ever be worth the effort for xcom.