Add code enough for emission of reg-reg and reg-imm moves. This allows us to compile...
[oota-llvm.git] / lib / Target / MSP430 / MSP430RegisterInfo.td
1 //===- MSP430RegisterInfo.td - MSP430 Register defs ----------*- tblgen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source 
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 //===----------------------------------------------------------------------===//
11 //  Declarations that describe the MSP430 register file
12 //===----------------------------------------------------------------------===//
13
14 class MSP430Reg<bits<4> num, string n> : Register<n> {
15   field bits<4> Num = num;
16   let Namespace = "MSP430";
17 }
18
19 //===----------------------------------------------------------------------===//
20 //  Registers
21 //===----------------------------------------------------------------------===//
22
23 def PC  : MSP430Reg<0,  "R0">;
24 def SP  : MSP430Reg<1,  "R1">;
25 def SR  : MSP430Reg<2,  "R2">;
26 def CG  : MSP430Reg<3,  "R3">;
27 def FP  : MSP430Reg<4,  "R4">;
28 def R5  : MSP430Reg<5,  "R5">;
29 def R6  : MSP430Reg<6,  "R6">;
30 def R7  : MSP430Reg<7,  "R7">;
31 def R8  : MSP430Reg<8,  "R8">;
32 def R9  : MSP430Reg<9,  "R9">;
33 def R10 : MSP430Reg<10, "R10">;
34 def R11 : MSP430Reg<11, "R11">;
35 def R12 : MSP430Reg<12, "R12">;
36 def R13 : MSP430Reg<13, "R13">;
37 def R14 : MSP430Reg<14, "R14">;
38 def R15 : MSP430Reg<15, "R15">;
39
40 // FIXME: we need subregs & special handling for 8 bit stuff
41
42 def GR16 : RegisterClass<"MSP430", [i16], 16,
43    // Volatile registers
44   [R12, R13, R14, R15, R11, R10, R9, R8, R7, R6, R5,
45    // Frame pointer, sometimes allocable
46    FP,
47    // Volatile, but not allocable
48    PC, SP, SR, CG]>
49 {
50   let MethodProtos = [{
51     iterator allocation_order_end(const MachineFunction &MF) const;
52   }];
53   let MethodBodies = [{
54     GR16Class::iterator
55     GR16Class::allocation_order_end(const MachineFunction &MF) const {
56       const TargetMachine &TM = MF.getTarget();
57       const TargetRegisterInfo *RI = TM.getRegisterInfo();
58       // Depending on whether the function uses frame pointer or not, last 5 or 4
59       // registers on the list above are reserved
60       if (RI->hasFP(MF))
61         return end()-5;
62       else
63         return end()-4;
64     }
65   }];
66 }
67