Commit e9655304 by Nicolas Capens Committed by Jim Stichnoth

Add boolean type property function.

This will be used by a subsequent min/max optimization patch. BUG=swiftshader:19 Change-Id: I524806d478ecc13de539d166940e16764ce4a7d9 Reviewed-on: https://chromium-review.googlesource.com/441215Reviewed-by: 's avatarJim Stichnoth <stichnot@chromium.org>
parent 71f6c8de
...@@ -117,17 +117,17 @@ struct TypePropertyFields { ...@@ -117,17 +117,17 @@ struct TypePropertyFields {
bool TypeIsFloatingType; bool TypeIsFloatingType;
bool TypeIsScalarFloatingType; bool TypeIsScalarFloatingType;
bool TypeIsVectorFloatingType; bool TypeIsVectorFloatingType;
bool TypeIsLoadStoreType; bool TypeIsBooleanType;
bool TypeIsCallParameterType; bool TypeIsCallParameterType;
Type CompareResultType; Type CompareResultType;
}; };
const TypePropertyFields TypePropertiesTable[] = { const TypePropertyFields TypePropertiesTable[] = {
#define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \ #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsBoolean, IsParam, \
CompareResult) \ CompareResult) \
{ \ { \
IsVec, IsInt, IsInt & !IsVec, IsInt & IsVec, IsIntArith, IsFloat, \ IsVec, IsInt, IsInt & !IsVec, IsInt & IsVec, IsIntArith, IsFloat, \
IsFloat & !IsVec, IsFloat & IsVec, IsLoadStore, IsParam, \ IsFloat & !IsVec, IsFloat & IsVec, IsBoolean, IsParam, \
IceType_##CompareResult \ IceType_##CompareResult \
} \ } \
, ,
...@@ -186,6 +186,13 @@ bool isVectorType(Type Ty) { ...@@ -186,6 +186,13 @@ bool isVectorType(Type Ty) {
return false; 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) { bool isIntegerType(Type Ty) {
if (Ty < IceType_NUM) if (Ty < IceType_NUM)
return TypePropertiesTable[Ty].TypeIsIntegerType; return TypePropertiesTable[Ty].TypeIsIntegerType;
...@@ -237,7 +244,7 @@ bool isVectorFloatingType(Type Ty) { ...@@ -237,7 +244,7 @@ bool isVectorFloatingType(Type Ty) {
bool isLoadStoreType(Type Ty) { bool isLoadStoreType(Type Ty) {
if (Ty < IceType_NUM) if (Ty < IceType_NUM)
return TypePropertiesTable[Ty].TypeIsLoadStoreType; return Ty != IceType_void && !isBooleanType(Ty);
llvm_unreachable("Invalid type for isLoadStoreType()"); llvm_unreachable("Invalid type for isLoadStoreType()");
return false; return false;
} }
......
...@@ -58,28 +58,28 @@ ...@@ -58,28 +58,28 @@
// I - Is integer value (scalar or vector). // I - Is integer value (scalar or vector).
// F - Is floating point value (scalar or vector). // F - Is floating point value (scalar or vector).
// IA - Is integer arithmetic type // 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. // P - true if can be used for parameter of call.
// CR - Result type of compare instruction for argument type // CR - Result type of compare instruction for argument type
// (IceType_void if disallowed) // (IceType_void if disallowed)
#define ICETYPE_PROPS_TABLE \ #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(void, 0, 0, 0, 0, 0, 0, void) \
X(i1, 0, 1, 0, 0, 0, 0, i1) \ X(i1, 0, 1, 0, 0, 1, 0, i1) \
X(i8, 0, 1, 0, 1, 1, 0, i1) \ X(i8, 0, 1, 0, 1, 0, 0, i1) \
X(i16, 0, 1, 0, 1, 1, 0, i1) \ X(i16, 0, 1, 0, 1, 0, 0, i1) \
X(i32, 0, 1, 0, 1, 1, 1, i1) \ X(i32, 0, 1, 0, 1, 0, 1, i1) \
X(i64, 0, 1, 0, 1, 1, 1, i1) \ X(i64, 0, 1, 0, 1, 0, 1, i1) \
X(f32, 0, 0, 1, 0, 1, 1, i1) \ X(f32, 0, 0, 1, 0, 0, 1, i1) \
X(f64, 0, 0, 1, 0, 1, 1, i1) \ X(f64, 0, 0, 1, 0, 0, 1, i1) \
X(v4i1, 1, 1, 0, 0, 0, 1, v4i1) \ X(v4i1, 1, 1, 0, 0, 1, 1, v4i1) \
X(v8i1, 1, 1, 0, 0, 0, 1, v8i1) \ X(v8i1, 1, 1, 0, 0, 1, 1, v8i1) \
X(v16i1, 1, 1, 0, 0, 0, 1, v16i1) \ X(v16i1, 1, 1, 0, 0, 1, 1, v16i1) \
X(v16i8, 1, 1, 0, 1, 1, 1, v16i1) \ X(v16i8, 1, 1, 0, 1, 0, 1, v16i1) \
X(v8i16, 1, 1, 0, 1, 1, 1, v8i1) \ X(v8i16, 1, 1, 0, 1, 0, 1, v8i1) \
X(v4i32, 1, 1, 0, 1, 1, 1, v4i1) \ X(v4i32, 1, 1, 0, 1, 0, 1, v4i1) \
X(v4f32, 1, 0, 1, 0, 1, 1, v4i1) \ X(v4f32, 1, 0, 1, 0, 0, 1, v4i1) \
//#define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \ //#define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsBoolean, IsParam, \
// CompareResult) // CompareResult)
#endif // SUBZERO_SRC_ICETYPES_DEF #endif // SUBZERO_SRC_ICETYPES_DEF
...@@ -89,6 +89,7 @@ Type getPointerType(); ...@@ -89,6 +89,7 @@ Type getPointerType();
bool isVectorType(Type Ty); bool isVectorType(Type Ty);
bool isBooleanType(Type Ty); // scalar or vector
bool isIntegerType(Type Ty); // scalar or vector bool isIntegerType(Type Ty); // scalar or vector
bool isScalarIntegerType(Type Ty); bool isScalarIntegerType(Type Ty);
bool isVectorIntegerType(Type Ty); bool isVectorIntegerType(Type Ty);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment