OSDN Git Service

Add boolean type property function.
authorNicolas Capens <capn@google.com>
Mon, 13 Feb 2017 15:21:20 +0000 (10:21 -0500)
committerJim Stichnoth <stichnot@chromium.org>
Mon, 13 Feb 2017 16:45:59 +0000 (16:45 +0000)
This will be used by a subsequent min/max optimization patch.

BUG=swiftshader:19

Change-Id: I524806d478ecc13de539d166940e16764ce4a7d9
Reviewed-on: https://chromium-review.googlesource.com/441215
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
src/IceTypes.cpp
src/IceTypes.def
src/IceTypes.h

index db3d93f..cfa8e50 100644 (file)
@@ -117,17 +117,17 @@ struct TypePropertyFields {
   bool TypeIsFloatingType;
   bool TypeIsScalarFloatingType;
   bool TypeIsVectorFloatingType;
-  bool TypeIsLoadStoreType;
+  bool TypeIsBooleanType;
   bool TypeIsCallParameterType;
   Type CompareResultType;
 };
 
 const TypePropertyFields TypePropertiesTable[] = {
-#define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam,        \
+#define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsBoolean, IsParam,          \
           CompareResult)                                                       \
   {                                                                            \
     IsVec, IsInt, IsInt & !IsVec, IsInt & IsVec, IsIntArith, IsFloat,          \
-        IsFloat & !IsVec, IsFloat & IsVec, IsLoadStore, IsParam,               \
+        IsFloat & !IsVec, IsFloat & IsVec, IsBoolean, IsParam,                 \
         IceType_##CompareResult                                                \
   }                                                                            \
   ,
@@ -186,6 +186,13 @@ bool isVectorType(Type Ty) {
   return false;
 }
 
+bool isBooleanType(Type Ty) {
+  if (Ty < IceType_NUM)
+    return TypePropertiesTable[Ty].TypeIsBooleanType;
+  llvm_unreachable("Invalid type for isBooleanType()");
+  return false;
+}
+
 bool isIntegerType(Type Ty) {
   if (Ty < IceType_NUM)
     return TypePropertiesTable[Ty].TypeIsIntegerType;
@@ -237,7 +244,7 @@ bool isVectorFloatingType(Type Ty) {
 
 bool isLoadStoreType(Type Ty) {
   if (Ty < IceType_NUM)
-    return TypePropertiesTable[Ty].TypeIsLoadStoreType;
+    return Ty != IceType_void && !isBooleanType(Ty);
   llvm_unreachable("Invalid type for isLoadStoreType()");
   return false;
 }
index cfc6bd2..da0c7ec 100644 (file)
 //   I - Is integer value (scalar or vector).
 //   F - Is floating point value (scalar or vector).
 //   IA - Is integer arithmetic type
-//   LS - true if load/store allowed on type.
+//   B - Is Boolean type (scalar or vector).
 //   P  - true if can be used for parameter of call.
 //   CR - Result type of compare instruction for argument type
 //        (IceType_void if disallowed)
 #define ICETYPE_PROPS_TABLE                                                    \
-  /* Enum Value    V  I  F IA LS  P  CR */                                     \
+  /* Enum Value    V  I  F IA  B  P  CR */                                     \
   X(void,          0, 0, 0, 0, 0, 0, void)                                     \
-  X(i1,            0, 1, 0, 0, 0, 0, i1)                                       \
-  X(i8,            0, 1, 0, 1, 1, 0, i1)                                       \
-  X(i16,           0, 1, 0, 1, 1, 0, i1)                                       \
-  X(i32,           0, 1, 0, 1, 1, 1, i1)                                       \
-  X(i64,           0, 1, 0, 1, 1, 1, i1)                                       \
-  X(f32,           0, 0, 1, 0, 1, 1, i1)                                       \
-  X(f64,           0, 0, 1, 0, 1, 1, i1)                                       \
-  X(v4i1,          1, 1, 0, 0, 0, 1, v4i1)                                     \
-  X(v8i1,          1, 1, 0, 0, 0, 1, v8i1)                                     \
-  X(v16i1,         1, 1, 0, 0, 0, 1, v16i1)                                    \
-  X(v16i8,         1, 1, 0, 1, 1, 1, v16i1)                                    \
-  X(v8i16,         1, 1, 0, 1, 1, 1, v8i1)                                     \
-  X(v4i32,         1, 1, 0, 1, 1, 1, v4i1)                                     \
-  X(v4f32,         1, 0, 1, 0, 1, 1, v4i1)                                     \
-//#define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam,      \
+  X(i1,            0, 1, 0, 0, 1, 0, i1)                                       \
+  X(i8,            0, 1, 0, 1, 0, 0, i1)                                       \
+  X(i16,           0, 1, 0, 1, 0, 0, i1)                                       \
+  X(i32,           0, 1, 0, 1, 0, 1, i1)                                       \
+  X(i64,           0, 1, 0, 1, 0, 1, i1)                                       \
+  X(f32,           0, 0, 1, 0, 0, 1, i1)                                       \
+  X(f64,           0, 0, 1, 0, 0, 1, i1)                                       \
+  X(v4i1,          1, 1, 0, 0, 1, 1, v4i1)                                     \
+  X(v8i1,          1, 1, 0, 0, 1, 1, v8i1)                                     \
+  X(v16i1,         1, 1, 0, 0, 1, 1, v16i1)                                    \
+  X(v16i8,         1, 1, 0, 1, 0, 1, v16i1)                                    \
+  X(v8i16,         1, 1, 0, 1, 0, 1, v8i1)                                     \
+  X(v4i32,         1, 1, 0, 1, 0, 1, v4i1)                                     \
+  X(v4f32,         1, 0, 1, 0, 0, 1, v4i1)                                     \
+//#define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsBoolean, IsParam,        \
 //          CompareResult)
 
 #endif // SUBZERO_SRC_ICETYPES_DEF
index 8972b08..0558036 100644 (file)
@@ -89,6 +89,7 @@ Type getPointerType();
 
 bool isVectorType(Type Ty);
 
+bool isBooleanType(Type Ty); // scalar or vector
 bool isIntegerType(Type Ty); // scalar or vector
 bool isScalarIntegerType(Type Ty);
 bool isVectorIntegerType(Type Ty);