16
16
#define LLVM_CLANG_BASIC_TARGETCXXABI_H
17
17
18
18
#include " clang/Basic/LLVM.h"
19
- #include " llvm/ADT/StringMap.h"
20
19
#include " llvm/Support/ErrorHandling.h"
21
20
22
21
namespace clang {
@@ -26,8 +25,105 @@ class TargetCXXABI {
26
25
public:
27
26
// / The basic C++ ABI kind.
28
27
enum Kind {
29
- #define CXXABI (Name, Str ) Name,
30
- #include " TargetCXXABI.def"
28
+ // / The generic Itanium ABI is the standard ABI of most open-source
29
+ // / and Unix-like platforms. It is the primary ABI targeted by
30
+ // / many compilers, including Clang and GCC.
31
+ // /
32
+ // / It is documented here:
33
+ // / http://www.codesourcery.com/public/cxx-abi/
34
+ GenericItanium,
35
+
36
+ // / The generic ARM ABI is a modified version of the Itanium ABI
37
+ // / proposed by ARM for use on ARM-based platforms.
38
+ // /
39
+ // / These changes include:
40
+ // / - the representation of member function pointers is adjusted
41
+ // / to not conflict with the 'thumb' bit of ARM function pointers;
42
+ // / - constructors and destructors return 'this';
43
+ // / - guard variables are smaller;
44
+ // / - inline functions are never key functions;
45
+ // / - array cookies have a slightly different layout;
46
+ // / - additional convenience functions are specified;
47
+ // / - and more!
48
+ // /
49
+ // / It is documented here:
50
+ // / http://infocenter.arm.com
51
+ // / /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
52
+ GenericARM,
53
+
54
+ // / The iOS ABI is a partial implementation of the ARM ABI.
55
+ // / Several of the features of the ARM ABI were not fully implemented
56
+ // / in the compilers that iOS was launched with.
57
+ // /
58
+ // / Essentially, the iOS ABI includes the ARM changes to:
59
+ // / - member function pointers,
60
+ // / - guard variables,
61
+ // / - array cookies, and
62
+ // / - constructor/destructor signatures.
63
+ iOS,
64
+
65
+ // / The iOS 64-bit ABI is follows ARM's published 64-bit ABI more
66
+ // / closely, but we don't guarantee to follow it perfectly.
67
+ // /
68
+ // / It is documented here:
69
+ // / http://infocenter.arm.com
70
+ // / /help/topic/com.arm.doc.ihi0059a/IHI0059A_cppabi64.pdf
71
+ iOS64,
72
+
73
+ // / WatchOS is a modernisation of the iOS ABI, which roughly means it's
74
+ // / the iOS64 ABI ported to 32-bits. The primary difference from iOS64 is
75
+ // / that RTTI objects must still be unique at the moment.
76
+ WatchOS,
77
+
78
+ // / The generic AArch64 ABI is also a modified version of the Itanium ABI,
79
+ // / but it has fewer divergences than the 32-bit ARM ABI.
80
+ // /
81
+ // / The relevant changes from the generic ABI in this case are:
82
+ // / - representation of member function pointers adjusted as in ARM.
83
+ // / - guard variables are smaller.
84
+ GenericAArch64,
85
+
86
+ // / The generic Mips ABI is a modified version of the Itanium ABI.
87
+ // /
88
+ // / At the moment, only change from the generic ABI in this case is:
89
+ // / - representation of member function pointers adjusted as in ARM.
90
+ GenericMIPS,
91
+
92
+ // / The WebAssembly ABI is a modified version of the Itanium ABI.
93
+ // /
94
+ // / The changes from the Itanium ABI are:
95
+ // / - representation of member function pointers is adjusted, as in ARM;
96
+ // / - member functions are not specially aligned;
97
+ // / - constructors and destructors return 'this', as in ARM;
98
+ // / - guard variables are 32-bit on wasm32, as in ARM;
99
+ // / - unused bits of guard variables are reserved, as in ARM;
100
+ // / - inline functions are never key functions, as in ARM;
101
+ // / - C++11 POD rules are used for tail padding, as in iOS64.
102
+ // /
103
+ // / TODO: At present the WebAssembly ABI is not considered stable, so none
104
+ // / of these details is necessarily final yet.
105
+ WebAssembly,
106
+
107
+ // / The Fuchsia ABI is a modified version of the Itanium ABI.
108
+ // /
109
+ // / The relevant changes from the Itanium ABI are:
110
+ // / - constructors and destructors return 'this', as in ARM.
111
+ Fuchsia,
112
+
113
+ // / The XL ABI is the ABI used by IBM xlclang compiler and is a modified
114
+ // / version of the Itanium ABI.
115
+ // /
116
+ // / The relevant changes from the Itanium ABI are:
117
+ // / - static initialization is adjusted to use sinit and sterm functions;
118
+ XL,
119
+
120
+ // / The Microsoft ABI is the ABI used by Microsoft Visual Studio (and
121
+ // / compatible compilers).
122
+ // /
123
+ // / FIXME: should this be split into Win32 and Win64 variants?
124
+ // /
125
+ // / Only scattered and incomplete official documentation exists.
126
+ Microsoft
31
127
};
32
128
33
129
private:
@@ -36,20 +132,7 @@ class TargetCXXABI {
36
132
// audit the users to pass it by reference instead.
37
133
Kind TheKind;
38
134
39
- static const auto &getABIMap () {
40
- static llvm::StringMap<Kind> ABIMap = {
41
- #define CXXABI (Name, Str ) {Str, Name},
42
- #include " TargetCXXABI.def"
43
- };
44
- return ABIMap;
45
- }
46
-
47
135
public:
48
- static Kind getKind (StringRef Name) { return getABIMap ().lookup (Name); }
49
- static bool isABI (StringRef Name) {
50
- return getABIMap ().find (Name) != getABIMap ().end ();
51
- }
52
-
53
136
// / A bogus initialization of the platform ABI.
54
137
TargetCXXABI () : TheKind(GenericItanium) {}
55
138
@@ -64,11 +147,19 @@ class TargetCXXABI {
64
147
// / Does this ABI generally fall into the Itanium family of ABIs?
65
148
bool isItaniumFamily () const {
66
149
switch (getKind ()) {
67
- #define CXXABI (Name, Str )
68
- #define ITANIUM_CXXABI (Name, Str ) case Name:
69
- #include " TargetCXXABI.def"
150
+ case Fuchsia:
151
+ case GenericAArch64:
152
+ case GenericItanium:
153
+ case GenericARM:
154
+ case iOS:
155
+ case iOS64:
156
+ case WatchOS:
157
+ case GenericMIPS:
158
+ case WebAssembly:
159
+ case XL:
70
160
return true ;
71
- default :
161
+
162
+ case Microsoft:
72
163
return false ;
73
164
}
74
165
llvm_unreachable (" bad ABI kind" );
@@ -77,12 +168,20 @@ class TargetCXXABI {
77
168
// / Is this ABI an MSVC-compatible ABI?
78
169
bool isMicrosoft () const {
79
170
switch (getKind ()) {
80
- #define CXXABI (Name, Str )
81
- #define MICROSOFT_CXXABI (Name, Str ) case Name:
82
- #include " TargetCXXABI.def"
83
- return true ;
84
- default :
171
+ case Fuchsia:
172
+ case GenericAArch64:
173
+ case GenericItanium:
174
+ case GenericARM:
175
+ case iOS:
176
+ case iOS64:
177
+ case WatchOS:
178
+ case GenericMIPS:
179
+ case WebAssembly:
180
+ case XL:
85
181
return false ;
182
+
183
+ case Microsoft:
184
+ return true ;
86
185
}
87
186
llvm_unreachable (" bad ABI kind" );
88
187
}
0 commit comments