瀏覽代碼

[GlobalISel] Add LLT::operator!=().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277162 91177308-0d34-0410-b5e6-96231b3b80d8
Ahmed Bougacha 9 年之前
父節點
當前提交
eda1b46b87
共有 2 個文件被更改,包括 16 次插入1 次删除
  1. 3 1
      include/llvm/CodeGen/LowLevelType.h
  2. 13 0
      unittests/CodeGen/LowLevelTypeTest.cpp

+ 3 - 1
include/llvm/CodeGen/LowLevelType.h

@@ -169,11 +169,13 @@ public:
 
   void print(raw_ostream &OS) const;
 
-  bool operator ==(const LLT &RHS) const {
+  bool operator==(const LLT &RHS) const {
     return Kind == RHS.Kind && SizeOrAddrSpace == RHS.SizeOrAddrSpace &&
            NumElements == RHS.NumElements;
   }
 
+  bool operator!=(const LLT &RHS) const { return !(*this == RHS); }
+
   friend struct DenseMapInfo<LLT>;
 private:
   unsigned SizeOrAddrSpace;

+ 13 - 0
unittests/CodeGen/LowLevelTypeTest.cpp

@@ -60,6 +60,9 @@ TEST(LowLevelTypeTest, Scalar) {
 
     // Test equality operators.
     EXPECT_TRUE(Ty == Ty);
+    EXPECT_FALSE(Ty != Ty);
+
+    EXPECT_NE(Ty, DoubleTy);
 
     // Test Type->LLT conversion.
     const Type *IRTy = IntegerType::get(C, S);
@@ -141,6 +144,15 @@ TEST(LowLevelTypeTest, Vector) {
 
       // Test equality operators.
       EXPECT_TRUE(VTy == VTy);
+      EXPECT_FALSE(VTy != VTy);
+
+      // Test inequality operators on..
+      // ..different kind.
+      EXPECT_NE(VTy, STy);
+      // ..different #elts.
+      EXPECT_NE(VTy, DoubleEltTy);
+      // ..different scalar size.
+      EXPECT_NE(VTy, DoubleSzTy);
 
       // Test Type->LLT conversion.
       Type *IRSTy = IntegerType::get(C, S);
@@ -169,6 +181,7 @@ TEST(LowLevelTypeTest, Pointer) {
 
     // Test equality operators.
     EXPECT_TRUE(Ty == Ty);
+    EXPECT_FALSE(Ty != Ty);
 
     // Test Type->LLT conversion.
     const Type *IRTy = PointerType::get(IntegerType::get(C, 8), AS);