Skip to content

Commit bfc59cd

Browse files
authored
Merge pull request #169 from CodaFi/egalite
Add Equatable instances for all IRTypes
2 parents fca99fe + 1a27b87 commit bfc59cd

12 files changed

+72
-0
lines changed

Sources/LLVM/ArrayType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ public struct ArrayType: IRType {
4949
return LLVMArrayType(elementType.asLLVM(), UInt32(count))
5050
}
5151
}
52+
53+
extension ArrayType: Equatable {
54+
public static func == (lhs: ArrayType, rhs: ArrayType) -> Bool {
55+
return lhs.asLLVM() == rhs.asLLVM()
56+
}
57+
}

Sources/LLVM/FloatType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,9 @@ public struct FloatType: IRType {
8585
}
8686
}
8787
}
88+
89+
extension FloatType: Equatable {
90+
public static func == (lhs: FloatType, rhs: FloatType) -> Bool {
91+
return lhs.asLLVM() == rhs.asLLVM()
92+
}
93+
}

Sources/LLVM/FunctionType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ public struct FunctionType: IRType {
3838
}
3939
}
4040
}
41+
42+
extension FunctionType: Equatable {
43+
public static func == (lhs: FunctionType, rhs: FunctionType) -> Bool {
44+
return lhs.asLLVM() == rhs.asLLVM()
45+
}
46+
}

Sources/LLVM/IntType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,9 @@ public struct IntType: IRType {
100100
return LLVMIntTypeInContext(context.llvm, UInt32(width))
101101
}
102102
}
103+
104+
extension IntType: Equatable {
105+
public static func == (lhs: IntType, rhs: IntType) -> Bool {
106+
return lhs.asLLVM() == rhs.asLLVM()
107+
}
108+
}

Sources/LLVM/LabelType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ public struct LabelType: IRType {
2121
return LLVMLabelTypeInContext(context.llvm)
2222
}
2323
}
24+
25+
extension LabelType: Equatable {
26+
public static func == (lhs: LabelType, rhs: LabelType) -> Bool {
27+
return lhs.asLLVM() == rhs.asLLVM()
28+
}
29+
}

Sources/LLVM/MetadataType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ public struct MetadataType: IRType {
2121
return LLVMMetadataTypeInContext(context.llvm)
2222
}
2323
}
24+
25+
extension MetadataType: Equatable {
26+
public static func == (lhs: MetadataType, rhs: MetadataType) -> Bool {
27+
return lhs.asLLVM() == rhs.asLLVM()
28+
}
29+
}

Sources/LLVM/PointerType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ public struct PointerType: IRType {
4343
return LLVMPointerType(pointee.asLLVM(), UInt32(addressSpace))
4444
}
4545
}
46+
47+
extension PointerType: Equatable {
48+
public static func == (lhs: PointerType, rhs: PointerType) -> Bool {
49+
return lhs.asLLVM() == rhs.asLLVM()
50+
}
51+
}

Sources/LLVM/StructType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,9 @@ public struct StructType: IRType {
134134
return LLVMIsPackedStruct(self.llvm) != 0
135135
}
136136
}
137+
138+
extension StructType: Equatable {
139+
public static func == (lhs: StructType, rhs: StructType) -> Bool {
140+
return lhs.asLLVM() == rhs.asLLVM()
141+
}
142+
}

Sources/LLVM/TokenType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ public struct TokenType: IRType {
2222
return LLVMTokenTypeInContext(context.llvm)
2323
}
2424
}
25+
26+
extension TokenType: Equatable {
27+
public static func == (lhs: TokenType, rhs: TokenType) -> Bool {
28+
return lhs.asLLVM() == rhs.asLLVM()
29+
}
30+
}

Sources/LLVM/VectorType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ public struct VectorType: IRType {
4444
return LLVMVectorType(elementType.asLLVM(), UInt32(count))
4545
}
4646
}
47+
48+
extension VectorType: Equatable {
49+
public static func == (lhs: VectorType, rhs: VectorType) -> Bool {
50+
return lhs.asLLVM() == rhs.asLLVM()
51+
}
52+
}

Sources/LLVM/VoidType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ public struct VoidType: IRType {
2121
return LLVMVoidTypeInContext(context.llvm)
2222
}
2323
}
24+
25+
extension VoidType: Equatable {
26+
public static func == (lhs: VoidType, rhs: VoidType) -> Bool {
27+
return lhs.asLLVM() == rhs.asLLVM()
28+
}
29+
}

Sources/LLVM/X86MMXType.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ public struct X86MMXType: IRType {
2626
return LLVMX86MMXTypeInContext(context.llvm)
2727
}
2828
}
29+
30+
extension X86MMXType: Equatable {
31+
public static func == (lhs: X86MMXType, rhs: X86MMXType) -> Bool {
32+
return lhs.asLLVM() == rhs.asLLVM()
33+
}
34+
}

0 commit comments

Comments
 (0)