@@ -178,3 +178,41 @@ public enum Linkage {
178
178
return Linkage . linkageMapping [ self ] !
179
179
}
180
180
}
181
+
182
+ /// `StorageClass` enumerates the storage classes for globals in a Portable
183
+ /// Executable file.
184
+ public enum StorageClass {
185
+ /// The default storage class for declarations is neither imported nor
186
+ /// exported to/from a DLL.
187
+ case `default`
188
+ /// The storage class that guarantees the existence of a function in a DLL.
189
+ ///
190
+ /// Using this attribute can produce tighter code because the compiler may
191
+ /// skip emitting a thunk and instead directly jump to a particular address.
192
+ case dllImport
193
+ /// The storage class for symbols that should be exposed outside of this DLL.
194
+ ///
195
+ /// This storage class augments the use of a `.DEF` file, but cannot
196
+ /// completely replace them.
197
+ case dllExport
198
+
199
+ private static let storageMapping : [ StorageClass : LLVMDLLStorageClass ] = [
200
+ . `default`: LLVMDefaultStorageClass,
201
+ . dllImport: LLVMDLLImportStorageClass,
202
+ . dllExport: LLVMDLLExportStorageClass,
203
+ ]
204
+
205
+ internal init ( llvm: LLVMDLLStorageClass ) {
206
+ switch llvm {
207
+ case LLVMDefaultStorageClass: self = . `default`
208
+ case LLVMDLLImportStorageClass: self = . dllImport
209
+ case LLVMDLLExportStorageClass: self = . dllExport
210
+ default : fatalError ( " unknown DLL storage class \( llvm) " )
211
+ }
212
+ }
213
+
214
+ /// Retrieves the corresponding `LLVMDLLStorageClass`.
215
+ public var llvm : LLVMDLLStorageClass {
216
+ return StorageClass . storageMapping [ self ] !
217
+ }
218
+ }
0 commit comments