@@ -197,79 +197,6 @@ public class TargetData {
197197 }
198198}
199199
200- extension TargetData {
201- /// Computes the preferred alignment of the given global for this target
202- ///
203- /// - parameter global: The global variable
204- /// - returns: The variable's preferred alignment in this target
205- @available ( * , message: " Prefer the overload of prefferedAlignment(of:) that returns an Alignment " )
206- public func preferredAlignment( of global: Global ) -> Int {
207- return Int ( LLVMPreferredAlignmentOfGlobal ( llvm, global. asLLVM ( ) ) )
208- }
209-
210- /// Computes the preferred alignment of the given type for this target
211- ///
212- /// - parameter type: The type for which you're computing the alignment
213- /// - returns: The type's preferred alignment in this target
214- @available ( * , message: " Prefer the overload of prefferedAlignment(of:) that returns an Alignment " )
215- public func preferredAlignment( of type: IRType ) -> Int {
216- return Int ( LLVMPreferredAlignmentOfType ( llvm, type. asLLVM ( ) ) )
217- }
218-
219- /// Computes the minimum ABI-required alignment for the specified type.
220- ///
221- /// - parameter type: The type to whose ABI alignment you wish to compute.
222- /// - returns: The minimum ABI-required alignment for the specified type.
223- @available ( * , message: " Prefer the overload of abiAlignment(of:) that returns an Alignment " )
224- public func abiAlignment( of type: IRType ) -> Int {
225- return Int ( LLVMABIAlignmentOfType ( llvm, type. asLLVM ( ) ) )
226- }
227-
228- /// Computes the minimum ABI-required alignment for the specified type.
229- ///
230- /// This function is equivalent to `TargetData.abiAlignment(of:)`.
231- ///
232- /// - parameter type: The type to whose ABI alignment you wish to compute.
233- /// - returns: The minimum ABI-required alignment for the specified type.
234- @available ( * , message: " Prefer the overload of callFrameAlignment(of:) that returns an Alignment " )
235- public func callFrameAlignment( of type: IRType ) -> Int {
236- return Int ( LLVMCallFrameAlignmentOfType ( llvm, type. asLLVM ( ) ) )
237- }
238-
239- /// Computes the ABI size of a type in bytes for a target.
240- ///
241- /// - parameter type: The type to whose ABI size you wish to compute.
242- /// - returns: The ABI size for the specified type.
243- @available ( * , message: " Prefer the overload of abiSize(of:) that returns a Size " )
244- public func abiSize( of type: IRType ) -> Int {
245- return Int ( LLVMABISizeOfType ( llvm, type. asLLVM ( ) ) )
246- }
247- /// Computes the maximum number of bytes that may be overwritten by
248- /// storing the specified type.
249- ///
250- /// - parameter type: The type to whose store size you wish to compute.
251- /// - returns: The store size of the type in the given target.
252- @available ( * , message: " Prefer the overload of storeSize(of:) that returns a Size " )
253- public func storeSize( of type: IRType ) -> Int {
254- return Int ( LLVMStoreSizeOfType ( llvm, type. asLLVM ( ) ) )
255- }
256-
257- /// Computes the pointer size for the platform, optionally in a given
258- /// address space.
259- ///
260- /// - parameter addressSpace: The address space in which to compute
261- /// pointer size.
262- /// - returns: The size of a pointer in the target address space.
263- @available ( * , message: " Prefer the overload of pointerSize(addressSpace:) that returns a Size " )
264- public func pointerSize( addressSpace: Int ? = nil ) -> Int {
265- if let addressSpace = addressSpace {
266- return Int ( LLVMPointerSizeForAS ( llvm, UInt32 ( addressSpace) ) )
267- } else {
268- return Int ( LLVMPointerSize ( llvm) )
269- }
270- }
271- }
272-
273200/// A `StructLayout` encapsulates information about the layout of a `StructType`.
274201public struct StructLayout {
275202 /// Returns the total size of the struct in bytes.
@@ -304,7 +231,7 @@ public struct StructLayout {
304231
305232 // Loop over each of the elements, placing them in memory.
306233 for ty in st. elementTypes {
307- let tyAlign = Alignment ( UInt32 ( st. isPacked ? 1 : dl. abiAlignment ( of: ty) ) )
234+ let tyAlign = st. isPacked ? Alignment . one : dl. abiAlignment ( of: ty)
308235
309236 // Add padding if necessary to align the data element properly.
310237 if ( structSize. rawValue & UInt64 ( tyAlign. rawValue- 1 ) ) != 0 {
0 commit comments