Skip to content

Commit 8dbc651

Browse files
committed
Upgrade a bunch of Ints to Alignment
1 parent ddd0839 commit 8dbc651

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Sources/LLVM/Call.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public struct Call: IRValue {
3737
///
3838
/// - parameter i: The index of the parameter to retrieve.
3939
/// - parameter alignment: The alignment to apply to the parameter.
40-
public func setParameterAlignment(at i : Int, to alignment: Int) {
41-
LLVMSetInstrParamAlignment(self.llvm, UInt32(i), UInt32(alignment))
40+
public func setParameterAlignment(at i : Int, to alignment: Alignment) {
41+
LLVMSetInstrParamAlignment(self.llvm, UInt32(i), alignment.rawValue)
4242
}
4343
}
4444

Sources/LLVM/IRBuilder.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ extension Module {
398398
var global = addGlobal(name, type:
399399
ArrayType(elementType: IntType.int8, count: length + 1))
400400

401-
global.alignment = 1
401+
global.alignment = Alignment(1)
402402
global.initializer = value
403403

404404
return global
@@ -1247,14 +1247,14 @@ public class IRBuilder {
12471247
///
12481248
/// - returns: A value representing `void`.
12491249
public func buildAlloca(type: IRType, count: IRValue? = nil,
1250-
alignment: Int = 0, name: String = "") -> IRValue {
1250+
alignment: Alignment = .zero, name: String = "") -> IRValue {
12511251
let allocaInst: LLVMValueRef
12521252
if let count = count {
12531253
allocaInst = LLVMBuildArrayAlloca(llvm, type.asLLVM(), count.asLLVM(), name)
12541254
} else {
12551255
allocaInst = LLVMBuildAlloca(llvm, type.asLLVM(), name)!
12561256
}
1257-
LLVMSetAlignment(allocaInst, UInt32(alignment))
1257+
LLVMSetAlignment(allocaInst, alignment.rawValue)
12581258
return allocaInst
12591259
}
12601260

@@ -1270,11 +1270,11 @@ public class IRBuilder {
12701270
///
12711271
/// - returns: A value representing `void`.
12721272
@discardableResult
1273-
public func buildStore(_ val: IRValue, to ptr: IRValue, ordering: AtomicOrdering = .notAtomic, volatile: Bool = false, alignment: Int = 0) -> IRValue {
1273+
public func buildStore(_ val: IRValue, to ptr: IRValue, ordering: AtomicOrdering = .notAtomic, volatile: Bool = false, alignment: Alignment = .zero) -> IRValue {
12741274
let storeInst = LLVMBuildStore(llvm, val.asLLVM(), ptr.asLLVM())!
12751275
LLVMSetOrdering(storeInst, ordering.llvm)
12761276
LLVMSetVolatile(storeInst, volatile.llvm)
1277-
LLVMSetAlignment(storeInst, UInt32(alignment))
1277+
LLVMSetAlignment(storeInst, alignment.rawValue)
12781278
return storeInst
12791279
}
12801280

@@ -1290,11 +1290,11 @@ public class IRBuilder {
12901290
///
12911291
/// - returns: A value representing the result of a load from the given
12921292
/// pointer value.
1293-
public func buildLoad(_ ptr: IRValue, ordering: AtomicOrdering = .notAtomic, volatile: Bool = false, alignment: Int = 0, name: String = "") -> IRValue {
1293+
public func buildLoad(_ ptr: IRValue, ordering: AtomicOrdering = .notAtomic, volatile: Bool = false, alignment: Alignment = .zero, name: String = "") -> IRValue {
12941294
let loadInst = LLVMBuildLoad(llvm, ptr.asLLVM(), name)!
12951295
LLVMSetOrdering(loadInst, ordering.llvm)
12961296
LLVMSetVolatile(loadInst, volatile.llvm)
1297-
LLVMSetAlignment(loadInst, UInt32(alignment))
1297+
LLVMSetAlignment(loadInst, alignment.rawValue)
12981298
return loadInst
12991299
}
13001300

Sources/LLVM/IRGlobal.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public protocol IRGlobal: IRConstant {}
88

99
extension IRGlobal {
1010
/// Retrieves the alignment of this value.
11-
public var alignment: Int {
12-
get { return Int(LLVMGetAlignment(asLLVM())) }
13-
set { LLVMSetAlignment(asLLVM(), UInt32(newValue)) }
11+
public var alignment: Alignment {
12+
get { return Alignment(LLVMGetAlignment(asLLVM())) }
13+
set { LLVMSetAlignment(asLLVM(), newValue.rawValue) }
1414
}
1515

1616
/// Retrieves the linkage information for this global.

0 commit comments

Comments
 (0)