LLVM CodeView library
[oota-llvm.git] / include / llvm / DebugInfo / CodeView / TypeRecord.h
1 //===- TypeRecord.h ---------------------------------------------*- 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 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H
12
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/DebugInfo/CodeView/CodeView.h"
16 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
17 #include <cinttypes>
18
19 namespace llvm {
20 namespace codeview {
21
22 class TypeRecord {
23 protected:
24   explicit TypeRecord(TypeRecordKind Kind) : Kind(Kind) {}
25
26 public:
27   TypeRecordKind getKind() const { return Kind; }
28
29 private:
30   TypeRecordKind Kind;
31 };
32
33 class ModifierRecord : public TypeRecord {
34 public:
35   ModifierRecord(TypeIndex ModifiedType, ModifierOptions Options)
36       : TypeRecord(TypeRecordKind::Modifier), ModifiedType(ModifiedType),
37         Options(Options) {}
38
39   TypeIndex getModifiedType() const { return ModifiedType; }
40   ModifierOptions getOptions() const { return Options; }
41
42 private:
43   TypeIndex ModifiedType;
44   ModifierOptions Options;
45 };
46
47 class ProcedureRecord : public TypeRecord {
48 public:
49   ProcedureRecord(TypeIndex ReturnType, CallingConvention CallConv,
50                   FunctionOptions Options, uint16_t ParameterCount,
51                   TypeIndex ArgumentList)
52       : TypeRecord(TypeRecordKind::Procedure), ReturnType(ReturnType),
53         CallConv(CallConv), Options(Options), ParameterCount(ParameterCount),
54         ArgumentList(ArgumentList) {}
55
56   TypeIndex getReturnType() const { return ReturnType; }
57   CallingConvention getCallConv() const { return CallConv; }
58   FunctionOptions getOptions() const { return Options; }
59   uint16_t getParameterCount() const { return ParameterCount; }
60   TypeIndex getArgumentList() const { return ArgumentList; }
61
62 private:
63   TypeIndex ReturnType;
64   CallingConvention CallConv;
65   FunctionOptions Options;
66   uint16_t ParameterCount;
67   TypeIndex ArgumentList;
68 };
69
70 class MemberFunctionRecord : public TypeRecord {
71 public:
72   MemberFunctionRecord(TypeIndex ReturnType, TypeIndex ClassType,
73                        TypeIndex ThisType, CallingConvention CallConv,
74                        FunctionOptions Options, uint16_t ParameterCount,
75                        TypeIndex ArgumentList, int32_t ThisPointerAdjustment)
76       : TypeRecord(TypeRecordKind::MemberFunction), ReturnType(ReturnType),
77         ClassType(ClassType), ThisType(ThisType), CallConv(CallConv),
78         Options(Options), ParameterCount(ParameterCount),
79         ArgumentList(ArgumentList),
80         ThisPointerAdjustment(ThisPointerAdjustment) {}
81
82   TypeIndex getReturnType() const { return ReturnType; }
83   TypeIndex getClassType() const { return ClassType; }
84   TypeIndex getThisType() const { return ThisType; }
85   CallingConvention getCallConv() const { return CallConv; }
86   FunctionOptions getOptions() const { return Options; }
87   uint16_t getParameterCount() const { return ParameterCount; }
88   TypeIndex getArgumentList() const { return ArgumentList; }
89   int32_t getThisPointerAdjustment() const { return ThisPointerAdjustment; }
90
91 private:
92   TypeIndex ReturnType;
93   TypeIndex ClassType;
94   TypeIndex ThisType;
95   CallingConvention CallConv;
96   FunctionOptions Options;
97   uint16_t ParameterCount;
98   TypeIndex ArgumentList;
99   int32_t ThisPointerAdjustment;
100 };
101
102 class ArgumentListRecord : public TypeRecord {
103 public:
104   explicit ArgumentListRecord(llvm::ArrayRef<TypeIndex> ArgumentTypes)
105       : TypeRecord(TypeRecordKind::ArgumentList), ArgumentTypes(ArgumentTypes) {
106   }
107
108   llvm::ArrayRef<TypeIndex> getArgumentTypes() const { return ArgumentTypes; }
109
110 private:
111   llvm::ArrayRef<TypeIndex> ArgumentTypes;
112 };
113
114 class PointerRecordBase : public TypeRecord {
115 public:
116   PointerRecordBase(TypeIndex ReferentType, PointerKind Kind, PointerMode Mode,
117                     PointerOptions Options, uint8_t Size)
118       : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType),
119         PtrKind(Kind), Mode(Mode), Options(Options), Size(Size) {}
120
121   TypeIndex getReferentType() const { return ReferentType; }
122   PointerKind getPointerKind() const { return PtrKind; }
123   PointerMode getMode() const { return Mode; }
124   PointerOptions getOptions() const { return Options; }
125   uint8_t getSize() const { return Size; }
126
127 private:
128   TypeIndex ReferentType;
129   PointerKind PtrKind;
130   PointerMode Mode;
131   PointerOptions Options;
132   uint8_t Size;
133 };
134
135 class PointerRecord : public PointerRecordBase {
136 public:
137   PointerRecord(TypeIndex ReferentType, PointerKind Kind, PointerMode Mode,
138                 PointerOptions Options, uint8_t Size)
139       : PointerRecordBase(ReferentType, Kind, Mode, Options, Size) {}
140 };
141
142 class PointerToMemberRecord : public PointerRecordBase {
143 public:
144   PointerToMemberRecord(TypeIndex ReferentType, PointerKind Kind,
145                         PointerMode Mode, PointerOptions Options, uint8_t Size,
146                         TypeIndex ContainingType,
147                         PointerToMemberRepresentation Representation)
148       : PointerRecordBase(ReferentType, Kind, Mode, Options, Size),
149         ContainingType(ContainingType), Representation(Representation) {}
150
151   TypeIndex getContainingType() const { return ContainingType; }
152   PointerToMemberRepresentation getRepresentation() const {
153     return Representation;
154   }
155
156 private:
157   TypeIndex ContainingType;
158   PointerToMemberRepresentation Representation;
159 };
160
161 class ArrayRecord : public TypeRecord {
162 public:
163   ArrayRecord(TypeIndex ElementType, TypeIndex IndexType, uint64_t Size,
164               llvm::StringRef Name)
165       : TypeRecord(TypeRecordKind::Array), ElementType(ElementType),
166         IndexType(IndexType), Size(Size), Name(Name) {}
167
168   TypeIndex getElementType() const { return ElementType; }
169   TypeIndex getIndexType() const { return IndexType; }
170   uint64_t getSize() const { return Size; }
171   llvm::StringRef getName() const { return Name; }
172
173 private:
174   TypeIndex ElementType;
175   TypeIndex IndexType;
176   uint64_t Size;
177   llvm::StringRef Name;
178 };
179
180 class TagRecord : public TypeRecord {
181 protected:
182   TagRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options,
183             TypeIndex FieldList, StringRef Name, StringRef UniqueName)
184       : TypeRecord(Kind), MemberCount(MemberCount), Options(Options),
185         FieldList(FieldList), Name(Name), UniqueName(UniqueName) {}
186
187 public:
188   uint16_t getMemberCount() const { return MemberCount; }
189   ClassOptions getOptions() const { return Options; }
190   TypeIndex getFieldList() const { return FieldList; }
191   StringRef getName() const { return Name; }
192   StringRef getUniqueName() const { return UniqueName; }
193
194 private:
195   uint16_t MemberCount;
196   ClassOptions Options;
197   TypeIndex FieldList;
198   StringRef Name;
199   StringRef UniqueName;
200 };
201
202 class AggregateRecord : public TagRecord {
203 public:
204   AggregateRecord(TypeRecordKind Kind, uint16_t MemberCount,
205                   ClassOptions Options, HfaKind Hfa,
206                   WindowsRTClassKind WinRTKind, TypeIndex FieldList,
207                   TypeIndex DerivationList, TypeIndex VTableShape,
208                   uint64_t Size, StringRef Name, StringRef UniqueName)
209       : TagRecord(Kind, MemberCount, Options, FieldList, Name, UniqueName),
210         Hfa(Hfa), WinRTKind(WinRTKind), DerivationList(DerivationList),
211         VTableShape(VTableShape), Size(Size) {}
212
213   HfaKind getHfa() const { return Hfa; }
214   WindowsRTClassKind getWinRTKind() const { return WinRTKind; }
215   TypeIndex getDerivationList() const { return DerivationList; }
216   TypeIndex getVTableShape() const { return VTableShape; }
217   uint64_t getSize() const { return Size; }
218
219 private:
220   HfaKind Hfa;
221   WindowsRTClassKind WinRTKind;
222   TypeIndex DerivationList;
223   TypeIndex VTableShape;
224   uint64_t Size;
225 };
226
227 class EnumRecord : public TagRecord {
228 public:
229   EnumRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList,
230              StringRef Name, StringRef UniqueName, TypeIndex UnderlyingType)
231       : TagRecord(TypeRecordKind::Enum, MemberCount, Options, FieldList, Name,
232                   UniqueName),
233         UnderlyingType(UnderlyingType) {}
234
235   TypeIndex getUnderlyingType() const { return UnderlyingType; }
236
237 private:
238   TypeIndex UnderlyingType;
239 };
240
241 class BitFieldRecord : TypeRecord {
242 public:
243   BitFieldRecord(TypeIndex Type, uint8_t BitSize, uint8_t BitOffset)
244       : TypeRecord(TypeRecordKind::BitField), Type(Type), BitOffset(BitOffset),
245         BitSize(BitSize) {}
246
247   TypeIndex getType() const { return Type; }
248   uint8_t getBitOffset() const { return BitOffset; }
249   uint8_t getBitSize() const { return BitSize; }
250
251 private:
252   TypeIndex Type;
253   uint8_t BitSize;
254   uint8_t BitOffset;
255 };
256
257 class VirtualTableShapeRecord : TypeRecord {
258 public:
259   explicit VirtualTableShapeRecord(ArrayRef<VirtualTableSlotKind> Slots)
260       : TypeRecord(TypeRecordKind::VirtualTableShape), Slots(Slots) {}
261
262   ArrayRef<VirtualTableSlotKind> getSlots() const { return Slots; }
263
264 private:
265   ArrayRef<VirtualTableSlotKind> Slots;
266 };
267 }
268 }
269
270 #endif