From 1a27b87a871cf4460d50091fc9d05596f25a0a56 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Fri, 21 Dec 2018 16:46:18 -0500 Subject: [PATCH] Add Equatable instances for all IRTypes --- Sources/LLVM/ArrayType.swift | 6 ++++++ Sources/LLVM/FloatType.swift | 6 ++++++ Sources/LLVM/FunctionType.swift | 6 ++++++ Sources/LLVM/IntType.swift | 6 ++++++ Sources/LLVM/LabelType.swift | 6 ++++++ Sources/LLVM/MetadataType.swift | 6 ++++++ Sources/LLVM/PointerType.swift | 6 ++++++ Sources/LLVM/StructType.swift | 6 ++++++ Sources/LLVM/TokenType.swift | 6 ++++++ Sources/LLVM/VectorType.swift | 6 ++++++ Sources/LLVM/VoidType.swift | 6 ++++++ Sources/LLVM/X86MMXType.swift | 6 ++++++ 12 files changed, 72 insertions(+) diff --git a/Sources/LLVM/ArrayType.swift b/Sources/LLVM/ArrayType.swift index b9919bac..f199486b 100644 --- a/Sources/LLVM/ArrayType.swift +++ b/Sources/LLVM/ArrayType.swift @@ -49,3 +49,9 @@ public struct ArrayType: IRType { return LLVMArrayType(elementType.asLLVM(), UInt32(count)) } } + +extension ArrayType: Equatable { + public static func == (lhs: ArrayType, rhs: ArrayType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/FloatType.swift b/Sources/LLVM/FloatType.swift index 6e90f199..c70fced5 100644 --- a/Sources/LLVM/FloatType.swift +++ b/Sources/LLVM/FloatType.swift @@ -85,3 +85,9 @@ public struct FloatType: IRType { } } } + +extension FloatType: Equatable { + public static func == (lhs: FloatType, rhs: FloatType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/FunctionType.swift b/Sources/LLVM/FunctionType.swift index 14d2415a..097c3f67 100644 --- a/Sources/LLVM/FunctionType.swift +++ b/Sources/LLVM/FunctionType.swift @@ -38,3 +38,9 @@ public struct FunctionType: IRType { } } } + +extension FunctionType: Equatable { + public static func == (lhs: FunctionType, rhs: FunctionType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/IntType.swift b/Sources/LLVM/IntType.swift index 168a0e80..85170d09 100644 --- a/Sources/LLVM/IntType.swift +++ b/Sources/LLVM/IntType.swift @@ -100,3 +100,9 @@ public struct IntType: IRType { return LLVMIntTypeInContext(context.llvm, UInt32(width)) } } + +extension IntType: Equatable { + public static func == (lhs: IntType, rhs: IntType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/LabelType.swift b/Sources/LLVM/LabelType.swift index 974ecc4d..acb36ae8 100644 --- a/Sources/LLVM/LabelType.swift +++ b/Sources/LLVM/LabelType.swift @@ -21,3 +21,9 @@ public struct LabelType: IRType { return LLVMLabelTypeInContext(context.llvm) } } + +extension LabelType: Equatable { + public static func == (lhs: LabelType, rhs: LabelType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/MetadataType.swift b/Sources/LLVM/MetadataType.swift index a72780fd..c8ba148e 100644 --- a/Sources/LLVM/MetadataType.swift +++ b/Sources/LLVM/MetadataType.swift @@ -21,3 +21,9 @@ public struct MetadataType: IRType { return LLVMMetadataTypeInContext(context.llvm) } } + +extension MetadataType: Equatable { + public static func == (lhs: MetadataType, rhs: MetadataType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/PointerType.swift b/Sources/LLVM/PointerType.swift index 77c4a957..c24c1362 100644 --- a/Sources/LLVM/PointerType.swift +++ b/Sources/LLVM/PointerType.swift @@ -43,3 +43,9 @@ public struct PointerType: IRType { return LLVMPointerType(pointee.asLLVM(), UInt32(addressSpace)) } } + +extension PointerType: Equatable { + public static func == (lhs: PointerType, rhs: PointerType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/StructType.swift b/Sources/LLVM/StructType.swift index 0a1f0c1f..6eaea7b0 100644 --- a/Sources/LLVM/StructType.swift +++ b/Sources/LLVM/StructType.swift @@ -134,3 +134,9 @@ public struct StructType: IRType { return LLVMIsPackedStruct(self.llvm) != 0 } } + +extension StructType: Equatable { + public static func == (lhs: StructType, rhs: StructType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/TokenType.swift b/Sources/LLVM/TokenType.swift index afc32dcb..77df8fc5 100644 --- a/Sources/LLVM/TokenType.swift +++ b/Sources/LLVM/TokenType.swift @@ -22,3 +22,9 @@ public struct TokenType: IRType { return LLVMTokenTypeInContext(context.llvm) } } + +extension TokenType: Equatable { + public static func == (lhs: TokenType, rhs: TokenType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/VectorType.swift b/Sources/LLVM/VectorType.swift index e73dbfd8..a502a19e 100644 --- a/Sources/LLVM/VectorType.swift +++ b/Sources/LLVM/VectorType.swift @@ -44,3 +44,9 @@ public struct VectorType: IRType { return LLVMVectorType(elementType.asLLVM(), UInt32(count)) } } + +extension VectorType: Equatable { + public static func == (lhs: VectorType, rhs: VectorType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/VoidType.swift b/Sources/LLVM/VoidType.swift index ee395559..806cf2fd 100644 --- a/Sources/LLVM/VoidType.swift +++ b/Sources/LLVM/VoidType.swift @@ -21,3 +21,9 @@ public struct VoidType: IRType { return LLVMVoidTypeInContext(context.llvm) } } + +extension VoidType: Equatable { + public static func == (lhs: VoidType, rhs: VoidType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +} diff --git a/Sources/LLVM/X86MMXType.swift b/Sources/LLVM/X86MMXType.swift index 4136e689..1078d48e 100644 --- a/Sources/LLVM/X86MMXType.swift +++ b/Sources/LLVM/X86MMXType.swift @@ -26,3 +26,9 @@ public struct X86MMXType: IRType { return LLVMX86MMXTypeInContext(context.llvm) } } + +extension X86MMXType: Equatable { + public static func == (lhs: X86MMXType, rhs: X86MMXType) -> Bool { + return lhs.asLLVM() == rhs.asLLVM() + } +}