Replace the tablegen RegisterClass field SubRegClassList with an alist-like data
[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 "llvm/CodeGen/ValueTypes.h"
19 #include "llvm/ADT/DenseMap.h"
20 #include <string>
21 #include <vector>
22 #include <cstdlib>
23
24 namespace llvm {
25   class Record;
26
27   /// CodeGenRegister - Represents a register definition.
28   struct CodeGenRegister {
29     Record *TheDef;
30     const std::string &getName() const;
31     unsigned DeclaredSpillSize, DeclaredSpillAlignment;
32     CodeGenRegister(Record *R);
33   };
34
35
36   struct CodeGenRegisterClass {
37     Record *TheDef;
38     std::string Namespace;
39     std::vector<Record*> Elements;
40     std::vector<MVT::SimpleValueType> VTs;
41     unsigned SpillSize;
42     unsigned SpillAlignment;
43     int CopyCost;
44     // Map SubRegIndex -> RegisterClass
45     DenseMap<Record*,Record*> SubRegClasses;
46     std::string MethodProtos, MethodBodies;
47
48     const std::string &getName() const;
49     const std::vector<MVT::SimpleValueType> &getValueTypes() const {return VTs;}
50     unsigned getNumValueTypes() const { return VTs.size(); }
51     
52     MVT::SimpleValueType getValueTypeNum(unsigned VTNum) const {
53       if (VTNum < VTs.size())
54         return VTs[VTNum];
55       assert(0 && "VTNum greater than number of ValueTypes in RegClass!");
56       abort();
57     }
58
59     CodeGenRegisterClass(Record *R);
60   };
61 }
62
63 #endif