Skip to content

Commit 2ce14c8

Browse files
authored
Merge pull request #26 from CodaFi/full-employment
100% Documentation Coverage
2 parents 2b59ed0 + 4a7a165 commit 2ce14c8

File tree

138 files changed

+11166
-3851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+11166
-3851
lines changed

Sources/LLVM/FloatType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import cllvm
22

33
/// `FloatType` enumerates representations of a floating value of a particular
4-
// bit width and semantics.
4+
/// bit width and semantics.
55
public enum FloatType: IRType {
66
/// 16-bit floating point value
77
case half

Sources/LLVM/Instruction.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public struct Instruction: IRValue {
3131
return Instruction(llvm: val)
3232
}
3333

34+
/// Retrieves the first use of this instruction.
3435
public var firstUse: Use? {
3536
guard let use = LLVMGetFirstUse(llvm) else { return nil }
3637
return Use(llvm: use)

Sources/LLVM/OpCode.swift

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,153 +7,153 @@ import cllvm
77
public enum OpCode: UInt32 {
88
// MARK: Terminator Instructions
99

10-
// The opcode for the `ret` instruction.
10+
/// The opcode for the `ret` instruction.
1111
case ret = 1
12-
// The opcode for the `br` instruction.
12+
/// The opcode for the `br` instruction.
1313
case br = 2
14-
// The opcode for the `switch` instruction.
14+
/// The opcode for the `switch` instruction.
1515
case `switch` = 3
16-
// The opcode for the `indirectBr` instruction.
16+
/// The opcode for the `indirectBr` instruction.
1717
case indirectBr = 4
18-
// The opcode for the `invoke` instruction.
18+
/// The opcode for the `invoke` instruction.
1919
case invoke = 5
20-
// The opcode for the `unreachable` instruction.
20+
/// The opcode for the `unreachable` instruction.
2121
case unreachable = 7
2222

2323
// MARK: Standard Binary Operators
2424

25-
// The opcode for the `add` instruction.
25+
/// The opcode for the `add` instruction.
2626
case add = 8
27-
// The opcode for the `fadd` instruction.
27+
/// The opcode for the `fadd` instruction.
2828
case fadd = 9
29-
// The opcode for the `sub` instruction.
29+
/// The opcode for the `sub` instruction.
3030
case sub = 10
31-
// The opcode for the `fsub` instruction.
31+
/// The opcode for the `fsub` instruction.
3232
case fsub = 11
33-
// The opcode for the `mul` instruction.
33+
/// The opcode for the `mul` instruction.
3434
case mul = 12
35-
// The opcode for the `fmul` instruction.
35+
/// The opcode for the `fmul` instruction.
3636
case fmul = 13
37-
// The opcode for the `udiv` instruction.
37+
/// The opcode for the `udiv` instruction.
3838
case udiv = 14
39-
// The opcode for the `sdiv` instruction.
39+
/// The opcode for the `sdiv` instruction.
4040
case sdiv = 15
41-
// The opcode for the `fdiv` instruction.
41+
/// The opcode for the `fdiv` instruction.
4242
case fdiv = 16
43-
// The opcode for the `urem` instruction.
43+
/// The opcode for the `urem` instruction.
4444
case urem = 17
45-
// The opcode for the `srem` instruction.
45+
/// The opcode for the `srem` instruction.
4646
case srem = 18
47-
// The opcode for the `frem` instruction.
47+
/// The opcode for the `frem` instruction.
4848
case frem = 19
4949

5050
// MARK: Logical Operators
5151

52-
// The opcode for the `shl` instruction.
52+
/// The opcode for the `shl` instruction.
5353
case shl = 20
54-
// The opcode for the `lshr` instruction.
54+
/// The opcode for the `lshr` instruction.
5555
case lshr = 21
56-
// The opcode for the `ashr` instruction.
56+
/// The opcode for the `ashr` instruction.
5757
case ashr = 22
58-
// The opcode for the `and` instruction.
58+
/// The opcode for the `and` instruction.
5959
case and = 23
60-
// The opcode for the `or` instruction.
60+
/// The opcode for the `or` instruction.
6161
case or = 24
62-
// The opcode for the `xor` instruction.
62+
/// The opcode for the `xor` instruction.
6363
case xor = 25
6464

6565
// MARK: Memory Operators
6666

67-
// The opcode for the `alloca` instruction.
67+
/// The opcode for the `alloca` instruction.
6868
case alloca = 26
69-
// The opcode for the `load` instruction.
69+
/// The opcode for the `load` instruction.
7070
case load = 27
71-
// The opcode for the `store` instruction.
71+
/// The opcode for the `store` instruction.
7272
case store = 28
73-
// The opcode for the `getElementPtr` instruction.
73+
/// The opcode for the `getElementPtr` instruction.
7474
case getElementPtr = 29
7575

7676
// MARK: Cast Operators
7777

78-
// The opcode for the `trunc` instruction.
78+
/// The opcode for the `trunc` instruction.
7979
case trunc = 30
80-
// The opcode for the `zext` instruction.
80+
/// The opcode for the `zext` instruction.
8181
case zext = 31
82-
// The opcode for the `sext` instruction.
82+
/// The opcode for the `sext` instruction.
8383
case sext = 32
84-
// The opcode for the `fpToUI` instruction.
84+
/// The opcode for the `fpToUI` instruction.
8585
case fpToUI = 33
86-
// The opcode for the `fpToSI` instruction.
86+
/// The opcode for the `fpToSI` instruction.
8787
case fpToSI = 34
88-
// The opcode for the `uiToFP` instruction.
88+
/// The opcode for the `uiToFP` instruction.
8989
case uiToFP = 35
90-
// The opcode for the `siToFP` instruction.
90+
/// The opcode for the `siToFP` instruction.
9191
case siToFP = 36
92-
// The opcode for the `fpTrunc` instruction.
92+
/// The opcode for the `fpTrunc` instruction.
9393
case fpTrunc = 37
94-
// The opcode for the `fpExt` instruction.
94+
/// The opcode for the `fpExt` instruction.
9595
case fpExt = 38
96-
// The opcode for the `ptrToInt` instruction.
96+
/// The opcode for the `ptrToInt` instruction.
9797
case ptrToInt = 39
98-
// The opcode for the `intToPtr` instruction.
98+
/// The opcode for the `intToPtr` instruction.
9999
case intToPtr = 40
100-
// The opcode for the `bitCast` instruction.
100+
/// The opcode for the `bitCast` instruction.
101101
case bitCast = 41
102-
// The opcode for the `addrSpaceCast` instruction.
102+
/// The opcode for the `addrSpaceCast` instruction.
103103
case addrSpaceCast = 60
104104

105105
// MARK: Other Operators
106106

107-
// The opcode for the `icmp` instruction.
107+
/// The opcode for the `icmp` instruction.
108108
case icmp = 42
109-
// The opcode for the `fcmp` instruction.
109+
/// The opcode for the `fcmp` instruction.
110110
case fcmp = 43
111-
// The opcode for the `PHI` instruction.
111+
/// The opcode for the `PHI` instruction.
112112
case PHI = 44
113-
// The opcode for the `call` instruction.
113+
/// The opcode for the `call` instruction.
114114
case call = 45
115-
// The opcode for the `select` instruction.
115+
/// The opcode for the `select` instruction.
116116
case select = 46
117-
// The opcode for the `userOp1` instruction.
117+
/// The opcode for the `userOp1` instruction.
118118
case userOp1 = 47
119-
// The opcode for the `userOp2` instruction.
119+
/// The opcode for the `userOp2` instruction.
120120
case userOp2 = 48
121-
// The opcode for the `vaArg` instruction.
121+
/// The opcode for the `vaArg` instruction.
122122
case vaArg = 49
123-
// The opcode for the `extractElement` instruction.
123+
/// The opcode for the `extractElement` instruction.
124124
case extractElement = 50
125-
// The opcode for the `insertElement` instruction.
125+
/// The opcode for the `insertElement` instruction.
126126
case insertElement = 51
127-
// The opcode for the `shuffleVector` instruction.
127+
/// The opcode for the `shuffleVector` instruction.
128128
case shuffleVector = 52
129-
// The opcode for the `extractValue` instruction.
129+
/// The opcode for the `extractValue` instruction.
130130
case extractValue = 53
131-
// The opcode for the `insertValue` instruction.
131+
/// The opcode for the `insertValue` instruction.
132132
case insertValue = 54
133133

134134
// MARK: Atomic operators
135135

136-
// The opcode for the `fence` instruction.
136+
/// The opcode for the `fence` instruction.
137137
case fence = 55
138-
// The opcode for the `atomicCmpXchg` instruction.
138+
/// The opcode for the `atomicCmpXchg` instruction.
139139
case atomicCmpXchg = 56
140-
// The opcode for the `atomicRMW` instruction.
140+
/// The opcode for the `atomicRMW` instruction.
141141
case atomicRMW = 57
142142

143143
// MARK: Exception Handling Operators
144144

145-
// The opcode for the `resume` instruction.
145+
/// The opcode for the `resume` instruction.
146146
case resume = 58
147-
// The opcode for the `landingPad` instruction.
147+
/// The opcode for the `landingPad` instruction.
148148
case landingPad = 59
149-
// The opcode for the `cleanupRet` instruction.
149+
/// The opcode for the `cleanupRet` instruction.
150150
case cleanupRet = 61
151-
// The opcode for the `catchRet` instruction.
151+
/// The opcode for the `catchRet` instruction.
152152
case catchRet = 62
153-
// The opcode for the `catchPad` instruction.
153+
/// The opcode for the `catchPad` instruction.
154154
case catchPad = 63
155-
// The opcode for the `cleanupPad` instruction.
155+
/// The opcode for the `cleanupPad` instruction.
156156
case cleanupPad = 64
157-
// The opcode for the `catchSwitch` instruction.
157+
/// The opcode for the `catchSwitch` instruction.
158158
case catchSwitch = 65
159159
}

Sources/LLVM/StructType.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public struct StructType: IRType {
2828
self.llvm = llvm
2929
}
3030

31+
/// Creates a structure type from an array of component element types.
32+
///
33+
/// - parameter elementTypes: A list of types of members of this structure.
34+
/// - parameter isPacked: Whether or not this structure is 1-byte aligned with
35+
/// no packing between fields. Defaults to `false`.
3136
public init(elementTypes: [IRType], isPacked: Bool = false) {
3237
var irTypes = elementTypes.map { $0.asLLVM() as Optional }
3338
self.llvm = irTypes.withUnsafeMutableBufferPointer { buf in
@@ -39,7 +44,7 @@ public struct StructType: IRType {
3944
///
4045
/// - parameter types: A list of types of members of this structure.
4146
/// - parameter isPacked: Whether or not this structure is 1-byte aligned with
42-
/// - no packing between fields. Defaults to `false`.
47+
/// no packing between fields. Defaults to `false`.
4348
public func setBody(_ types: [IRType], isPacked: Bool = false) {
4449
var _types = types.map { $0.asLLVM() as Optional }
4550
_types.withUnsafeMutableBufferPointer { buf in
@@ -52,7 +57,7 @@ public struct StructType: IRType {
5257
///
5358
/// - parameter values: A list of values of members of this structure.
5459
/// - parameter isPacked: Whether or not this structure is 1-byte aligned with
55-
/// - no packing between fields. Defaults to `false`.
60+
/// no packing between fields. Defaults to `false`.
5661
///
5762
/// - returns: A value representing a constant value of this structure type.
5863
public static func constant(values: [IRValue], isPacked: Bool = false) -> IRValue {

Sources/LLVM/TargetData.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,33 @@ public class TargetData {
106106
}
107107

108108
/// Computes the minimum ABI-required alignment for the specified type.
109+
///
109110
/// - parameter type: The type to whose ABI alignment you wish to compute.
110111
/// - returns: The minimum ABI-required alignment for the specified type.
111112
public func abiAlignment(of type: IRType) -> Int {
112113
return Int(LLVMABIAlignmentOfType(llvm, type.asLLVM()))
113114
}
114115

116+
/// Computes the minimum ABI-required alignment for the specified type.
117+
///
118+
/// This function is equivalent to `TargetData.abiAlignment(of:)`.
119+
///
120+
/// - parameter type: The type to whose ABI alignment you wish to compute.
121+
/// - returns: The minimum ABI-required alignment for the specified type.
115122
public func callFrameAlignment(of type: IRType) -> Int {
116123
return Int(LLVMCallFrameAlignmentOfType(llvm, type.asLLVM()))
117124
}
118125

119126
/// Computes the ABI size of a type in bytes for a target.
127+
///
120128
/// - parameter type: The type to whose ABI size you wish to compute.
121129
/// - returns: The ABI size for the specified type.
122130
public func abiSize(of type: IRType) -> Int {
123131
return Int(LLVMABISizeOfType(llvm, type.asLLVM()))
124132
}
125133
/// Computes the maximum number of bytes that may be overwritten by
126134
/// storing the specified type.
135+
///
127136
/// - parameter type: The type to whose store size you wish to compute.
128137
/// - returns: The store size of the type in the given target.
129138
public func storeSize(of type: IRType) -> Int {
@@ -149,6 +158,8 @@ public class TargetData {
149158
}
150159
}
151160

161+
/// `ByteOrder` enumerates the ordering semantics of sequences of bytes on a
162+
/// particular target architecture.
152163
public enum ByteOrder {
153164
/// Little-endian byte order. In a little-endian platform, the _least_
154165
/// significant bytes come before the _most_ significant bytes in a series,

Sources/LLVM/TargetMachine.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public enum TargetMachineError: Error, CustomStringConvertible {
6868
/// a host architecture, vendor, ABI, etc.
6969
public class Target {
7070
internal let llvm: LLVMTargetRef
71+
72+
/// Creates a `Target` object from an LLVM target object.
7173
public init(llvm: LLVMTargetRef) {
7274
self.llvm = llvm
7375
}

0 commit comments

Comments
 (0)