4efae7842b09740c53df2ee178b6b2554ca33020
[oota-llvm.git] / utils / TableGen / CodeGenRegisters.h
1 //===- CodeGenRegisters.h - Register and RegisterClass Info -----*- C++ -*-===//
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 // This file defines structures to encapsulate information gleaned from the
11 // target register and register class definitions.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef CODEGEN_REGISTERS_H
16 #define CODEGEN_REGISTERS_H
17
18 #include <string>
19 #include <vector>
20 #include "llvm/CodeGen/ValueTypes.h"
21
22 namespace llvm {
23   class Record;
24
25   /// CodeGenRegister - Represents a register definition.
26   struct CodeGenRegister {
27     Record *TheDef;
28     const std::string &getName() const;
29     unsigned DeclaredSpillSize, DeclaredSpillAlignment;
30     CodeGenRegister(Record *R);
31   };
32
33
34   struct CodeGenRegisterClass {
35     Record *TheDef;
36     std::string Namespace;
37     std::vector<Record*> Elements;
38     std::vector<MVT::ValueType> VTs;
39     unsigned SpillSize;
40     unsigned SpillAlignment;
41     int CopyCost;
42     std::vector<Record*> SubRegClasses;
43     std::string MethodProtos, MethodBodies;
44
45     const std::string &getName() const;
46     const std::vector<MVT::ValueType> &getValueTypes() const { return VTs; }
47     unsigned getNumValueTypes() const { return VTs.size(); }
48     
49     MVT::ValueType getValueTypeNum(unsigned VTNum) const {
50       if (VTNum < VTs.size())
51         return VTs[VTNum];
52       assert(0 && "VTNum greater than number of ValueTypes in RegClass!");
53       abort();
54     }
55
56     CodeGenRegisterClass(Record *R);
57   };
58 }
59
60 #endif