forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenClass.h
123 lines (104 loc) · 5.12 KB
/
GenClass.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//===--- GenClass.h - Swift IR generation for classes -----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file provides the private interface to the class-emission code.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_IRGEN_GENCLASS_H
#define SWIFT_IRGEN_GENCLASS_H
#include "llvm/ADT/SmallVector.h"
namespace llvm {
class Constant;
class Value;
class Function;
}
namespace swift {
class CanType;
class ClassDecl;
class ExtensionDecl;
class ProtocolDecl;
class SILType;
class Type;
class VarDecl;
namespace irgen {
class HeapLayout;
class IRGenFunction;
class IRGenModule;
class OwnedAddress;
class Size;
enum class ReferenceCounting : unsigned char;
enum class IsaEncoding : unsigned char;
enum class ClassDeallocationKind : unsigned char;
OwnedAddress projectPhysicalClassMemberAddress(IRGenFunction &IGF,
llvm::Value *base,
SILType baseType,
SILType fieldType,
VarDecl *field);
std::tuple<llvm::Constant * /*classData*/,
llvm::Constant * /*metaclassData*/,
Size>
emitClassPrivateDataFields(IRGenModule &IGM, ClassDecl *cls);
llvm::Constant *emitClassPrivateData(IRGenModule &IGM, ClassDecl *theClass);
void emitGenericClassPrivateDataTemplate(IRGenModule &IGM,
ClassDecl *theClass,
llvm::SmallVectorImpl<llvm::Constant*> &fields,
Size &metaclassOffset,
Size &classRODataOffset,
Size &metaclassRODataOffset,
Size &totalSize);
llvm::Constant *emitCategoryData(IRGenModule &IGM, ExtensionDecl *ext);
llvm::Constant *emitObjCProtocolData(IRGenModule &IGM, ProtocolDecl *ext);
/// Emit an allocation of a class.
/// The \p StackAllocSize is an in- and out-parameter. The passed value
/// specifies the maximum object size for stack allocation. A negative value
/// means that no stack allocation is possible.
/// The returned \p StackAllocSize value is the actual size if the object is
/// allocated on the stack or -1, if the object is allocated on the heap.
llvm::Value *emitClassAllocation(IRGenFunction &IGF, SILType selfType,
bool objc, int &StackAllocSize);
/// Emit an allocation of a class using a metadata value.
llvm::Value *emitClassAllocationDynamic(IRGenFunction &IGF,
llvm::Value *metadata,
SILType selfType,
bool objc);
/// Emit class deallocation.
void emitClassDeallocation(IRGenFunction &IGF, SILType selfType,
llvm::Value *selfValue);
/// Emit class deallocation.
void emitPartialClassDeallocation(IRGenFunction &IGF,
SILType selfType,
llvm::Value *selfValue,
llvm::Value *metadataValue);
/// Emit the constant fragile instance size of the class, or null if the class
/// does not have fixed layout. For resilient classes this does not
/// correspond to the runtime alignment of instances of the class.
llvm::Constant *tryEmitClassConstantFragileInstanceSize(IRGenModule &IGM,
ClassDecl *theClass);
/// Emit the constant fragile instance alignment mask of the class, or null if
/// the class does not have fixed layout. For resilient classes this does not
/// correspond to the runtime alignment of instances of the class.
llvm::Constant *tryEmitClassConstantFragileInstanceAlignMask(IRGenModule &IGM,
ClassDecl *theClass);
/// What reference counting mechanism does a class use?
ReferenceCounting getReferenceCountingForClass(IRGenModule &IGM,
ClassDecl *theClass);
/// What isa-encoding mechanism does a type use?
IsaEncoding getIsaEncodingForType(IRGenModule &IGM, CanType type);
ClassDecl *getRootClassForMetaclass(IRGenModule &IGM, ClassDecl *theClass);
/// Does the class metadata for the given class require dynamic
/// initialization beyond what can be achieved automatically by
/// the runtime?
bool doesClassMetadataRequireDynamicInitialization(IRGenModule &IGM,
ClassDecl *theClass);
} // end namespace irgen
} // end namespace swift
#endif