Use isNull instead of getNode() to test for existence of a node, this is cheaper.
[oota-llvm.git] / lib / Target / X86 / X86RegisterInfo.td
1 //===- X86RegisterInfo.td - Describe the X86 Register File ------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the X86 Register file, defining the registers themselves,
11 // aliases between the registers, and the register classes built out of the
12 // registers.
13 //
14 //===----------------------------------------------------------------------===//
15
16 //===----------------------------------------------------------------------===//
17 //  Register definitions...
18 //
19 let Namespace = "X86" in {
20   // 32-bit registers
21   def EAX : Register; def ECX : Register;
22   def EDX : Register; def EBX : Register;
23   def ESP : Register; def EBP : Register;
24   def ESI : Register; def EDI : Register;
25   
26   // 16-bit registers
27   def AX : Register; def CX : Register;
28   def DX : Register; def BX : Register;
29   def SP : Register; def BP : Register;
30   def SI : Register; def DI : Register;
31   
32   // 8-bit registers
33   def AL : Register; def CL : Register;
34   def DL : Register; def BL : Register;
35   def AH : Register; def CH : Register;
36   def DH : Register; def BH : Register;
37   
38   // Pseudo Floating Point registers
39   def FP0 : Register; def FP1 : Register;
40   def FP2 : Register; def FP3 : Register;
41   def FP4 : Register; def FP5 : Register;
42   def FP6 : Register; 
43
44   // Floating point stack registers
45   def ST0 : NamedReg<"ST(0)">; def ST1 : NamedReg<"ST(1)">;
46   def ST2 : NamedReg<"ST(2)">; def ST3 : NamedReg<"ST(3)">;
47   def ST4 : NamedReg<"ST(4)">; def ST5 : NamedReg<"ST(5)">;
48   def ST6 : NamedReg<"ST(6)">; def ST7 : NamedReg<"ST(7)">; 
49   
50   // Flags, Segment registers, etc...
51   
52   // This is a slimy hack to make it possible to say that flags are clobbered...
53   // Ideally we'd model instructions based on which particular flag(s) they
54   // could clobber. 
55   //def EFLAGS : Register;
56 }
57
58 //===----------------------------------------------------------------------===//
59 // Register alias definitions... define which registers alias which others.  We
60 // only specify which registers the small registers alias, because the register
61 // file generator is smart enough to figure out that AL aliases AX if we tell it
62 // that AX aliases AL (for example).
63 //
64 def : RegisterAliases<AL, [AX, EAX]>; def : RegisterAliases<BL, [BX, EBX]>;
65 def : RegisterAliases<CL, [CX, ECX]>; def : RegisterAliases<DL, [DX, EDX]>;
66 def : RegisterAliases<AH, [AX, EAX]>; def : RegisterAliases<BH, [BX, EBX]>;
67 def : RegisterAliases<CH, [CX, ECX]>; def : RegisterAliases<DH, [DX, EDX]>;
68
69 def : RegisterAliases<AX, [EAX]>;     def : RegisterAliases<BX, [EBX]>;
70 def : RegisterAliases<CX, [ECX]>;     def : RegisterAliases<DX, [EDX]>;
71 def : RegisterAliases<SI, [ESI]>;     def : RegisterAliases<DI, [EDI]>;
72 def : RegisterAliases<SP, [ESP]>;     def : RegisterAliases<BP, [EBP]>;
73
74 //===----------------------------------------------------------------------===//
75 // Register Class Definitions... now that we have all of the pieces, define the
76 // top-level register classes.  The order specified in the register list is
77 // implicitly defined to be the register allocation order.
78 //
79 def R8  : RegisterClass<i8,  1, [AL, CL, DL, BL, AH, CH, DH, BH]>;
80 def R16 : RegisterClass<i16, 2, [AX, CX, DX, BX, SI, DI, BP, SP]> {
81   let Methods = [{
82     iterator allocation_order_end(MachineFunction &MF) const {
83       if (hasFP(MF))     // Does the function dedicate EBP to being a frame ptr?
84         return end()-2;  // If so, don't allocate SP or BP
85       else
86         return end()-1;  // If not, just don't allocate SP
87     }
88   }];
89 }
90
91 def R32 : RegisterClass<i32, 4, [EAX, ECX, EDX, EBX, ESI, EDI, EBP, ESP]> {
92   let Methods = [{
93     iterator allocation_order_end(MachineFunction &MF) const {
94       if (hasFP(MF))     // Does the function dedicate EBP to being a frame ptr?
95         return end()-2;  // If so, don't allocate ESP or EBP
96       else
97         return end()-1;  // If not, just don't allocate ESP
98     }
99   }];
100 }
101
102 def RFP : RegisterClass<f80, 4, [FP0, FP1, FP2, FP3, FP4, FP5, FP6]>;
103
104 // Registers which cannot be allocated... and are thus left unnamed.
105 def : RegisterClass<f80, 4, [ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7]>;
106 //def : RegisterClass<i16, 2, [EFLAGS]>;
107