@@ -1090,11 +1090,14 @@ public class IRBuilder {
1090
1090
///
1091
1091
/// - parameter type: The sized type used to determine the amount of stack
1092
1092
/// memory to allocate.
1093
+ /// - parameter alignment: The alignment of the access.
1093
1094
/// - parameter name: The name for the newly inserted instruction.
1094
1095
///
1095
1096
/// - returns: A value representing `void`.
1096
- public func buildAlloca( type: IRType , name: String = " " ) -> IRValue {
1097
- return LLVMBuildAlloca ( llvm, type. asLLVM ( ) , name)
1097
+ public func buildAlloca( type: IRType , alignment: Int = 0 , name: String = " " ) -> IRValue {
1098
+ let allocaInst = LLVMBuildAlloca ( llvm, type. asLLVM ( ) , name) !
1099
+ LLVMSetAlignment ( allocaInst, UInt32 ( alignment) )
1100
+ return allocaInst
1098
1101
}
1099
1102
1100
1103
/// Builds a store instruction that stores the first value into the location
@@ -1105,13 +1108,15 @@ public class IRBuilder {
1105
1108
/// - parameter ordering: The ordering effect of the fence for this store,
1106
1109
/// if any. Defaults to a nonatomic store.
1107
1110
/// - parameter volatile: Whether this is a store to a volatile memory location.
1111
+ /// - parameter alignment: The alignment of the access.
1108
1112
///
1109
1113
/// - returns: A value representing `void`.
1110
1114
@discardableResult
1111
- public func buildStore( _ val: IRValue , to ptr: IRValue , ordering: AtomicOrdering = . notAtomic, volatile: Bool = false ) -> IRValue {
1115
+ public func buildStore( _ val: IRValue , to ptr: IRValue , ordering: AtomicOrdering = . notAtomic, volatile: Bool = false , alignment : Int = 0 ) -> IRValue {
1112
1116
let storeInst = LLVMBuildStore ( llvm, val. asLLVM ( ) , ptr. asLLVM ( ) ) !
1113
1117
LLVMSetOrdering ( storeInst, ordering. llvm)
1114
1118
LLVMSetVolatile ( storeInst, volatile. llvm)
1119
+ LLVMSetAlignment ( storeInst, UInt32 ( alignment) )
1115
1120
return storeInst
1116
1121
}
1117
1122
@@ -1122,14 +1127,16 @@ public class IRBuilder {
1122
1127
/// - parameter ordering: The ordering effect of the fence for this load,
1123
1128
/// if any. Defaults to a nonatomic load.
1124
1129
/// - parameter volatile: Whether this is a load from a volatile memory location.
1130
+ /// - parameter alignment: The alignment of the access.
1125
1131
/// - parameter name: The name for the newly inserted instruction.
1126
1132
///
1127
1133
/// - returns: A value representing the result of a load from the given
1128
1134
/// pointer value.
1129
- public func buildLoad( _ ptr: IRValue , ordering: AtomicOrdering = . notAtomic, volatile: Bool = false , name: String = " " ) -> IRValue {
1135
+ public func buildLoad( _ ptr: IRValue , ordering: AtomicOrdering = . notAtomic, volatile: Bool = false , alignment : Int = 0 , name: String = " " ) -> IRValue {
1130
1136
let loadInst = LLVMBuildLoad ( llvm, ptr. asLLVM ( ) , name) !
1131
1137
LLVMSetOrdering ( loadInst, ordering. llvm)
1132
1138
LLVMSetVolatile ( loadInst, volatile. llvm)
1139
+ LLVMSetAlignment ( loadInst, UInt32 ( alignment) )
1133
1140
return loadInst
1134
1141
}
1135
1142
0 commit comments