Skip to content

Commit

Permalink
Merge pull request #7081 from gita-omr/vector_datatype_fixes
Browse files Browse the repository at this point in the history
Improve vector opcodes and data types
  • Loading branch information
knn-k authored Aug 16, 2023
2 parents 46eddc6 + dbc59c4 commit ac8ca57
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 30 deletions.
9 changes: 9 additions & 0 deletions compiler/il/OMRDataTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ OMR::DataType::getVectorSize()
return 0;
}

int32_t
OMR::DataType::getVectorNumLanes()
{
TR_ASSERT_FATAL(isVector() || isMask(), "getVectorNumlanes() can only be called on vector or mask type\n");

return getVectorSize() / getSize(getVectorElementType());
}


static int32_t OMRDataTypeSizes[] =
{
0, // TR::NoType
Expand Down
9 changes: 9 additions & 0 deletions compiler/il/OMRDataTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,15 @@ class OMR_EXTENSIBLE DataType
* Vector size in bytes
*/
int32_t getVectorSize();

/** \brief
* Returns number of lanes in a vector
*
* \return
* Number of lanes in a vector
*/
int32_t getVectorNumLanes();

static int32_t getSize(TR::DataType dt);
static void setSize(TR::DataType dt, int32_t newValue);

Expand Down
33 changes: 29 additions & 4 deletions compiler/il/OMRILOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,31 @@ class ILOpCode
(opcode - TR::NumScalarIlOps - TR::NumOneVectorTypeOps) / (TR::NumVectorTypes * TR::NumVectorTypes) + TR::firstTwoTypeVectorOperation);
}

/** \brief
* Returns vector type
*
* \return
* Vector type
*/
TR::DataType getVectorDataType() const
{
return getVectorDataType(_opCode);
}

/** \brief
* Returns vector type
*
* \param op
* Opcode
*
* \return
* Vector type
*/
static TR::DataType getVectorDataType(ILOpCode op)
{
return getVectorResultDataType(op);
}

/** \brief
* Returns vector result type
*
Expand Down Expand Up @@ -342,14 +367,13 @@ class ILOpCode
TR::DataType dt = getVectorResultDataType(op);
return TR::DataType::createMaskType(dt.getVectorElementType(), dt.getVectorLength());
}
else if (opcode.isMaskReduction())
else if (opcode.isVectorElementResult())
{
return _opCodeProperties[opcode.getTableIndex()].dataType;
return getVectorResultDataType(op).getVectorElementType();
}
else
{
// scalar result type (e.g. reduction)
return getVectorResultDataType(op).getVectorElementType();
return _opCodeProperties[opcode.getTableIndex()].dataType;
}
}

Expand Down Expand Up @@ -384,6 +408,7 @@ class ILOpCode
bool isFloatingPoint() const { return typeProperties().testAny(ILTypeProp::Floating_Point); }
bool isVectorResult() const { return typeProperties().testAny(ILTypeProp::VectorResult); }
bool isMaskResult() const { return typeProperties().testAny(ILTypeProp::MaskResult); }
bool isVectorElementResult() const { return typeProperties().testAny(ILTypeProp::VectorElementResult); }
bool isIntegerOrAddress() const { return typeProperties().testAny(ILTypeProp::Integer | ILTypeProp::Address); }
bool is1Byte() const { return typeProperties().testAny(ILTypeProp::Size_1); }
bool is2Byte() const { return typeProperties().testAny(ILTypeProp::Size_2); }
Expand Down
3 changes: 2 additions & 1 deletion compiler/il/OMRILProps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ namespace ILTypeProp
Unsigned = 0x00001000,
VectorResult = 0x00002000,
MaskResult = 0x00004000,
LastOMRILTypeProp = MaskResult
VectorElementResult = 0x00008000,
LastOMRILTypeProp = VectorElementResult
};
}

Expand Down
50 changes: 25 additions & 25 deletions compiler/il/VectorOperations.enum
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -684,7 +684,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -700,7 +700,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -716,7 +716,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -732,7 +732,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -748,7 +748,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -764,7 +764,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -780,7 +780,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -796,7 +796,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ ONE_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand Down Expand Up @@ -987,14 +987,14 @@ VECTOR_OPERATION_MACRO(\
/* .properties2 = */ ILProp2::ValueNumberShare | ILProp2::SupportedForPRE, \
/* .properties3 = */ 0, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::Int32, \
/* .typeProperties = */ TR::NoType, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
/* .booleanCompareOpCode = */ TR::BadILOp, \
/* .ifCompareOpCode = */ TR::BadILOp, \
/* .description = get first non-zero vector element */ \
/* .description = lanewise first non-zero*/ \
)
VECTOR_OPERATION_MACRO(\
/* .operation = */ vgetelem, \
Expand All @@ -1004,7 +1004,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ 0, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand Down Expand Up @@ -1479,7 +1479,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -1495,7 +1495,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -1511,7 +1511,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ 0, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -1527,7 +1527,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -1543,7 +1543,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -1559,7 +1559,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -1575,7 +1575,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -1591,7 +1591,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand All @@ -1607,7 +1607,7 @@ VECTOR_OPERATION_MACRO(\
/* .properties3 = */ ILProp3::VectorReduction, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorElementResult, \
/* .childProperties = */ TWO_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
Expand Down Expand Up @@ -1686,14 +1686,14 @@ VECTOR_OPERATION_MACRO(\
/* .properties2 = */ ILProp2::ValueNumberShare | ILProp2::SupportedForPRE, \
/* .properties3 = */ 0, \
/* .properties4 = */ 0, \
/* .dataType = */ TR::Int32, \
/* .typeProperties = */ TR::NoType, \
/* .dataType = */ TR::NoType, \
/* .typeProperties = */ ILTypeProp::VectorResult, \
/* .childProperties = */ THREE_SAME_CHILD(ILChildProp::UnspecifiedChildType), \
/* .swapChildrenOperation = */ TR::vBadOperation, \
/* .reverseBranchOperation = */ TR::vBadOperation, \
/* .booleanCompareOpCode = */ TR::BadILOp, \
/* .ifCompareOpCode = */ TR::BadILOp, \
/* .description = get first non-zero vector element masked */ \
/* .description = masked lanewise first non-zero */ \
)
VECTOR_OPERATION_MACRO(\
/* .operation = */ vmpopcnt, \
Expand Down

0 comments on commit ac8ca57

Please sign in to comment.