blob: 8cc75b89b8fe59009eae5a0a96f4cd528807777d [file] [log] [blame]
Chris Lattnerf5a08922001-07-15 00:23:59 +00001Date: Sun, 8 Jul 2001 09:37:22 -0500
2From: Vikram S. Adve <vadve@cs.uiuc.edu>
3To: Ruchira Sasanka <sasanka@students.uiuc.edu>
4Cc: Chris Lattner <lattner@cs.uiuc.edu>
5Subject: machine instruction operands
6
7Ruchira,
8
9When generating machine instructions, I have to make several choices about
10operands. For cases were a register is required, there are 3 cases:
11
121. The register is for a Value* that is already in the VM code.
13
142. The register is for a value that is not in the VM code, usually because 2
15machine instructions get generated for a single VM instruction (and the
16register holds the result of the first m/c instruction and is used by the
17second m/c instruction).
18
193. The register is a pre-determined machine register.
20
21E.g, for this VM instruction:
22 ptr = alloca type, numElements
23I have to generate 2 machine instructions:
24 reg = mul constant, numElements
25 ptr = add %sp, reg
26
27Each machine instruction is of class MachineInstr.
28It has a vector of operands. All register operands have type MO_REGISTER.
29The 3 types of register operands are marked using this enum:
30
31 enum VirtualRegisterType {
32 MO_VMVirtualReg, // virtual register for *value
33 MO_MInstrVirtualReg, // virtual register for result of *minstr
34 MO_MachineReg // pre-assigned machine register `regNum'
35 } vregType;
36
37Here's how this affects register allocation:
38
391. MO_VMVirtualReg is the standard case: you just do the register
40allocation.
41
422. MO_MInstrVirtualReg is the case where there is a hidden register being
43used. You should decide how you want to handle it, e.g., do you want do
44create a Value object during the preprocessing phase to make the value
45explicit (like for address register for the RETURN instruction).
46
473. For case MO_MachineReg, you don't need to do anything, at least for
48SPARC. The only machine regs I am using so far are %g0 and %sp.
49
50--Vikram
51