1 //===- TypeRecord.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H
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"
24 explicit TypeRecord(TypeRecordKind Kind) : Kind(Kind) {}
27 TypeRecordKind getKind() const { return Kind; }
33 class ModifierRecord : public TypeRecord {
35 ModifierRecord(TypeIndex ModifiedType, ModifierOptions Options)
36 : TypeRecord(TypeRecordKind::Modifier), ModifiedType(ModifiedType),
39 TypeIndex getModifiedType() const { return ModifiedType; }
40 ModifierOptions getOptions() const { return Options; }
43 TypeIndex ModifiedType;
44 ModifierOptions Options;
47 class ProcedureRecord : public TypeRecord {
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) {}
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; }
64 CallingConvention CallConv;
65 FunctionOptions Options;
66 uint16_t ParameterCount;
67 TypeIndex ArgumentList;
70 class MemberFunctionRecord : public TypeRecord {
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) {}
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; }
95 CallingConvention CallConv;
96 FunctionOptions Options;
97 uint16_t ParameterCount;
98 TypeIndex ArgumentList;
99 int32_t ThisPointerAdjustment;
102 class ArgumentListRecord : public TypeRecord {
104 explicit ArgumentListRecord(llvm::ArrayRef<TypeIndex> ArgumentTypes)
105 : TypeRecord(TypeRecordKind::ArgumentList), ArgumentTypes(ArgumentTypes) {
108 llvm::ArrayRef<TypeIndex> getArgumentTypes() const { return ArgumentTypes; }
111 llvm::ArrayRef<TypeIndex> ArgumentTypes;
114 class PointerRecordBase : public TypeRecord {
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) {}
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; }
128 TypeIndex ReferentType;
131 PointerOptions Options;
135 class PointerRecord : public PointerRecordBase {
137 PointerRecord(TypeIndex ReferentType, PointerKind Kind, PointerMode Mode,
138 PointerOptions Options, uint8_t Size)
139 : PointerRecordBase(ReferentType, Kind, Mode, Options, Size) {}
142 class PointerToMemberRecord : public PointerRecordBase {
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) {}
151 TypeIndex getContainingType() const { return ContainingType; }
152 PointerToMemberRepresentation getRepresentation() const {
153 return Representation;
157 TypeIndex ContainingType;
158 PointerToMemberRepresentation Representation;
161 class ArrayRecord : public TypeRecord {
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) {}
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; }
174 TypeIndex ElementType;
177 llvm::StringRef Name;
180 class TagRecord : public TypeRecord {
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) {}
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; }
195 uint16_t MemberCount;
196 ClassOptions Options;
199 StringRef UniqueName;
202 class AggregateRecord : public TagRecord {
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) {}
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; }
221 WindowsRTClassKind WinRTKind;
222 TypeIndex DerivationList;
223 TypeIndex VTableShape;
227 class EnumRecord : public TagRecord {
229 EnumRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList,
230 StringRef Name, StringRef UniqueName, TypeIndex UnderlyingType)
231 : TagRecord(TypeRecordKind::Enum, MemberCount, Options, FieldList, Name,
233 UnderlyingType(UnderlyingType) {}
235 TypeIndex getUnderlyingType() const { return UnderlyingType; }
238 TypeIndex UnderlyingType;
241 class BitFieldRecord : TypeRecord {
243 BitFieldRecord(TypeIndex Type, uint8_t BitSize, uint8_t BitOffset)
244 : TypeRecord(TypeRecordKind::BitField), Type(Type), BitOffset(BitOffset),
247 TypeIndex getType() const { return Type; }
248 uint8_t getBitOffset() const { return BitOffset; }
249 uint8_t getBitSize() const { return BitSize; }
257 class VirtualTableShapeRecord : TypeRecord {
259 explicit VirtualTableShapeRecord(ArrayRef<VirtualTableSlotKind> Slots)
260 : TypeRecord(TypeRecordKind::VirtualTableShape), Slots(Slots) {}
262 ArrayRef<VirtualTableSlotKind> getSlots() const { return Slots; }
265 ArrayRef<VirtualTableSlotKind> Slots;