@@ -1094,25 +1094,40 @@ public class IRBuilder {
1094
1094
return LLVMBuildAlloca ( llvm, type. asLLVM ( ) , name)
1095
1095
}
1096
1096
1097
- /// Build a store instruction that stores the first value into the location
1097
+ /// Builds a store instruction that stores the first value into the location
1098
1098
/// given in the second value.
1099
1099
///
1100
+ /// - parameter val: The source value.
1101
+ /// - parameter ptr: The destination pointer to store into.
1102
+ /// - parameter ordering: The ordering effect of the fence for this store,
1103
+ /// if any. Defaults to a nonatomic store.
1104
+ /// - parameter volatile: Whether this is a store to a volatile memory location.
1105
+ ///
1100
1106
/// - returns: A value representing `void`.
1101
1107
@discardableResult
1102
- public func buildStore( _ val: IRValue , to ptr: IRValue ) -> IRValue {
1103
- return LLVMBuildStore ( llvm, val. asLLVM ( ) , ptr. asLLVM ( ) )
1108
+ public func buildStore( _ val: IRValue , to ptr: IRValue , ordering: AtomicOrdering = . notAtomic, volatile: Bool = false ) -> IRValue {
1109
+ let storeInst = LLVMBuildStore ( llvm, val. asLLVM ( ) , ptr. asLLVM ( ) ) !
1110
+ LLVMSetOrdering ( storeInst, ordering. llvm)
1111
+ LLVMSetVolatile ( storeInst, volatile. llvm)
1112
+ return storeInst
1104
1113
}
1105
1114
1106
1115
/// Builds a load instruction that loads a value from the location in the
1107
1116
/// given value.
1108
1117
///
1109
1118
/// - parameter ptr: The pointer value to load from.
1119
+ /// - parameter ordering: The ordering effect of the fence for this load,
1120
+ /// if any. Defaults to a nonatomic load.
1121
+ /// - parameter volatile: Whether this is a load from a volatile memory location.
1110
1122
/// - parameter name: The name for the newly inserted instruction.
1111
1123
///
1112
1124
/// - returns: A value representing the result of a load from the given
1113
1125
/// pointer value.
1114
- public func buildLoad( _ ptr: IRValue , name: String = " " ) -> IRValue {
1115
- return LLVMBuildLoad ( llvm, ptr. asLLVM ( ) , name)
1126
+ public func buildLoad( _ ptr: IRValue , ordering: AtomicOrdering = . notAtomic, volatile: Bool = false , name: String = " " ) -> IRValue {
1127
+ let loadInst = LLVMBuildLoad ( llvm, ptr. asLLVM ( ) , name) !
1128
+ LLVMSetOrdering ( loadInst, ordering. llvm)
1129
+ LLVMSetVolatile ( loadInst, volatile. llvm)
1130
+ return loadInst
1116
1131
}
1117
1132
1118
1133
/// Builds a `GEP` (Get Element Pointer) instruction with a resultant value
0 commit comments