The machine representation encompasses any machine dependent optimization (such as register allocation) and representation needed for a target. In comparison to the IR, the MR is a "flat" representation - functions are represented as basic blocks and the edges between them and machine-specific instructions. Once code has gone through the MR phase, it is ready to output and run. Control flow is provided by the following objects: Module - Represents a compilation unit. The globalVariables slot holds a sequence of GlobalVariables contained in this module. The function slot holds a sequence of Functions contained in this module. Function - A function. Contains slots for variables (the inputs, the outputs, and local variables). The constants slot maps particular allocated constants to whatever global variable they are stored in. Note: May want a separate Closure object with a second set of input variables representing specifically the environment records that need to be passed in. BasicBlock - A basic block. Contains a linked list of instructions, the successor and predecessors sets, and slots for storing the set of variables live on entry and exit. Instruction - An instruction. This must be derived into various specific instructions for each target. The operands slot holds an array of operands for the instruction. Instruction types must implement "operandModes" to describe the format of their operands. Operands carry a type slot identifying the type and size of the operand. Mostly familiar operands are carried over from the IR: Memory - A memory reference, where the operands an array of operands that calculate the actual memory address. Label - A label used to reference a basic block in a branch instruction, or a function/closure in a function call. The target slot holds the basic block or function. GlobalVariable - A variable stored in the global data section of a module. The offset slot represents the offset within the data space. The name slot must be a symbol. LocalVariable - A stack-allocated variable. The offset slot represents the offset into the stack. The name slot may be a symbol or constant. InputVariable - A function argument. The location slot is either a machine register or a stack offset. Function arguments ideally are located in registers whenever possible. OutputVariable - A function result. The location slot is the same as for InputVariable. All instruction types must implement a method "operandModes" which describes how they use their operands, so that the register allocator and other phases can interpret them. The modes describe whether the operand is an input to the instruction, whether it is an output of the instruction (can coexist with input mode for read-modify-write instructions), and whether it utilizes a register, memory, or a constant. This is accomplished by overriding the methods isInput, isOutput, usesConstant, usesRegister, and usesMemory (among others). Operand modes all stem from the following base classes: Constant - A constant input operand (constant outputs are NOT supported). The type slot describes acceptable constants. Register - A register operand. The register slot describes the acceptable set of registers. RegisterStack - A register stack operand. This class is mainly intended to support such oddities as the FPU on x86 processes. The register slot describes the acceptable set of registers. Memory - A memory operand. The operandModes slot contains an array of operand modes for the address computation. The following generic derived operand modes are provided: Load - A memory input operand. Store - A memory output operand. LoadStore - A read-modify-write memory operand. Read - A register input operand. Write - A register output operand. ReadWrite - A read-modify-write register operand. Push - A register stack push (i.e. output) operand. Pop - A register stack pop (i.e. input) operand. All pops are assumed to occur before pushes. PopPush - A register stack read-modify-write (i.e. pop then push again) operand. Operand modes may be combined into compound operand modes with the following: Or - The disjunction of operand modes. May either be created with newModes: or created implicitly with the \/ method defined for operand modes.