1 //===- Target/MRegisterInfo.h - Target Register Information -------*-C++-*-===//
3 // This file describes an abstract interface used to get information about a
4 // target machines register file. This information is used for a variety of
5 // purposed, especially register allocation.
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CODEGEN_MREGISTERINFO_H
10 #define LLVM_CODEGEN_MREGISTERINFO_H
14 /// MRegisterDesc - This record contains all of the information known about a
15 /// particular register.
17 struct MRegisterDesc {
18 const char *Name; // Assembly language name for the register
19 unsigned Flags; // Flags identifying register properties (defined below)
20 unsigned TSFlags; // Target Specific Flags
23 /// MRF namespace - This namespace contains flags that pertain to machine
26 namespace MRF { // MRF = Machine Register Flags
28 INT8 = 1 << 0, // This is an 8 bit integer register
29 INT16 = 1 << 1, // This is a 16 bit integer register
30 INT32 = 1 << 2, // This is a 32 bit integer register
31 INT64 = 1 << 3, // This is a 64 bit integer register
32 INT128 = 1 << 4, // This is a 128 bit integer register
34 FP32 = 1 << 5, // This is a 32 bit floating point register
35 FP64 = 1 << 6, // This is a 64 bit floating point register
36 FP80 = 1 << 7, // This is a 80 bit floating point register
37 FP128 = 1 << 8, // This is a 128 bit floating point register
41 /// MRegisterInfo base class - We assume that the target defines a static array
42 /// of MRegisterDesc objects that represent all of the machine registers that
43 /// the target has. As such, we simply have to track a pointer to this array so
44 /// that we can turn register number into a register descriptor.
47 const MRegisterDesc *Desc; // Pointer to the descriptor array
48 unsigned NumRegs; // Number of entries in the array
50 MRegisterInfo(const MRegisterDesc *D, unsigned NR) : Desc(D), NumRegs(NR) {}
53 enum { // Define some target independant constants
54 /// NoRegister - This 'hard' register is a 'noop' register for all backends.
55 /// This is used as the destination register for instructions that do not
56 /// produce a value. Some frontends may use this as an operand register to
57 /// mean special things, for example, the Sparc backend uses R0 to mean %g0
58 /// which always PRODUCES the value 0. The X86 backend does not use this
59 /// value as an operand register.
63 /// FirstVirtualRegister - This is the first register number that is
64 /// considered to be a 'virtual' register, which is part of the SSA
65 /// namespace. This must be the same for all targets, which means that each
66 /// target is limited to 1024 registers.
68 FirstVirtualRegister = 1024,
71 const MRegisterDesc &operator[](unsigned RegNo) const {
72 assert(RegNo < NumRegs &&
73 "Attempting to access record for invalid register number!");
77 /// Provide a get method, equivalent to [], but more useful if we have a
78 /// pointer to this object.
80 const MRegisterDesc &get(unsigned RegNo) const { return operator[](RegNo); }
82 // This will eventually get some virtual methods...