OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
TDGenerator::ValueType Class Reference

#include <TDGen.hh>

Collaboration diagram for TDGenerator::ValueType:
Collaboration graph

Public Member Functions

 ValueType (int subwWidth, int subwCount, bool isFloat)
 
 ValueType (const TCEString &vtStr)
 
 ValueType (const Operand &opnd)
 
 ValueType (const ValueType &other)
 
ValueTypeoperator= (const ValueType &other)
 
bool isSupportedByLLVM () const
 
int width () const
 
int subwordWidth () const
 
int subwordCount () const
 
bool isFloat () const
 
bool isVector () const
 
Operand::OperandType operandType () const
 
TCEString valueTypeStr () const
 

Static Public Member Functions

static TCEString valueTypeStr (const Operand &operand)
 
static ValueType valueType (const TCEString &vtStr)
 
static ValueType valueType (const Operand &operand)
 
static std::vector< ValueTypevectorTypesOfWidth (int width, bool onlyInts=false)
 
static std::vector< ValueTypevectorTypesOfSubwordWidth (int subwordWidth, bool onlyInt=false)
 

Public Attributes

int subwWidth_
 Subword width of the value type.
 
int subwCount_
 Subword count of the value type.
 
bool isFloat_
 If true, the value type is a floating point type.
 

Static Public Attributes

static const std::set< TCEStringSUPPORTED_LLVM_VALUE_TYPES
 Contains all supported LLVM value types (<ValueType>).
 

Detailed Description

Represents an LLVM value type to express different value types.

Definition at line 694 of file TDGen.hh.

Constructor & Destructor Documentation

◆ ValueType() [1/4]

ValueType::ValueType ( int  subwWidth,
int  subwCount,
bool  isFloat 
)

Constructor.

Parameters
subwWidthSubword width.
subwCountSubword count.
isFloatTrue, if is a floating point type.

Definition at line 8702 of file TDGen.cc.

8703 : subwWidth_(subwWidth), subwCount_(subwCount), isFloat_(isFloat) {
8704 assert(subwWidth > 0 && "Invalid value type.");
8705 assert(subwCount > 0 && "Invalid value type.");
8706}
#define assert(condition)
bool isFloat() const
Definition TDGen.cc:8806
int subwCount_
Subword count of the value type.
Definition TDGen.hh:725
bool isFloat_
If true, the value type is a floating point type.
Definition TDGen.hh:727
int subwWidth_
Subword width of the value type.
Definition TDGen.hh:723

References assert.

◆ ValueType() [2/4]

ValueType::ValueType ( const TCEString vtStr)

Constructor.

Parameters
vtStrValue type string in LLVM format.

Definition at line 8713 of file TDGen.cc.

8713 {
8714 ValueType vt = valueType(vtStr);
8715 this->subwWidth_ = vt.subwWidth_;
8716 this->subwCount_ = vt.subwCount_;
8717 this->isFloat_ = vt.isFloat_;
8718}
static ValueType valueType(const TCEString &vtStr)
Definition TDGen.cc:8891

References isFloat_, subwCount_, subwWidth_, and valueType().

Here is the call graph for this function:

◆ ValueType() [3/4]

ValueType::ValueType ( const Operand opnd)

Constructor.

Parameters
opndOperand to be converted to ValueType.

Definition at line 8725 of file TDGen.cc.

8725 {
8726 ValueType vt = valueType(opnd);
8727 this->subwWidth_ = vt.subwWidth_;
8728 this->subwCount_ = vt.subwCount_;
8729 this->isFloat_ = vt.isFloat_;
8730}

References isFloat_, subwCount_, subwWidth_, and valueType().

Here is the call graph for this function:

◆ ValueType() [4/4]

ValueType::ValueType ( const ValueType other)

Copy constructor.

Parameters
otherValue to be copied.

Definition at line 8737 of file TDGen.cc.

8738 : subwWidth_(other.subwWidth_),
8739 subwCount_(other.subwCount_),
8740 isFloat_(other.isFloat_) {}

Member Function Documentation

◆ isFloat()

bool ValueType::isFloat ( ) const

Tells whether ValueType is a floating point type or not.

Returns
True, is ValueType is a float type.

Definition at line 8806 of file TDGen.cc.

8806 {
8807 return isFloat_;
8808}

References isFloat_.

◆ isSupportedByLLVM()

bool ValueType::isSupportedByLLVM ( ) const

Tells whether ValueType is supported by LLVM or not.

Returns
True, if ValueType is supported by LLVM.

Definition at line 8762 of file TDGen.cc.

8762 {
8765 return true;
8766 }
8767 return false;
8768}
static const std::set< TCEString > SUPPORTED_LLVM_VALUE_TYPES
Contains all supported LLVM value types (<ValueType>).
Definition TDGen.hh:730
TCEString valueTypeStr() const
Definition TDGen.cc:8846

References SUPPORTED_LLVM_VALUE_TYPES, and valueTypeStr().

Referenced by TDGen::analyzeMachineVectorRegisterClasses(), TDGen::genTCETargetLoweringSIMD_getSetCCResultVT(), vectorTypesOfSubwordWidth(), and vectorTypesOfWidth().

Here is the call graph for this function:

◆ isVector()

bool ValueType::isVector ( ) const

Tells whether ValueType is a vector type or not.

Returns
True, is ValueType is a vector type.

Definition at line 8816 of file TDGen.cc.

8816 {
8817 return subwCount_ > 1;
8818}

References subwCount_.

◆ operandType()

Operand::OperandType ValueType::operandType ( ) const

Returns the Operand::OperandType of ValueType.

Returns
OperandType of ValueType.

Definition at line 8826 of file TDGen.cc.

8826 {
8827 if (!isFloat_ && subwWidth_ == 1) {
8828 return Operand::BOOL;
8829 } else if (isFloat_ && subwWidth_ == 16) {
8831 } else if (isFloat_ && subwWidth_ == 32) {
8832 return Operand::FLOAT_WORD;
8833 } else if (!isFloat_) {
8834 return Operand::UINT_WORD;
8835 }
8836
8837 return Operand::UINT_WORD;
8838}
@ FLOAT_WORD
Definition Operand.hh:61
@ UINT_WORD
Definition Operand.hh:60
@ HALF_FLOAT_WORD
Definition Operand.hh:63

References Operand::BOOL, Operand::FLOAT_WORD, Operand::HALF_FLOAT_WORD, isFloat_, subwWidth_, and Operand::UINT_WORD.

Referenced by TDGen::writeOperationDefUsingGivenOperandTypes().

◆ operator=()

ValueType & ValueType::operator= ( const ValueType other)

Value assignment.

Parameters
otherValue to be assigned.
Returns
Reference with the assigned values.

Definition at line 8749 of file TDGen.cc.

8749 {
8750 this->subwWidth_ = other.subwWidth_;
8751 this->subwCount_ = other.subwCount_;
8752 this->isFloat_ = other.isFloat_;
8753 return *this;
8754}

References isFloat_, subwCount_, and subwWidth_.

◆ subwordCount()

int ValueType::subwordCount ( ) const

Returns ValueType's subword count.

Returns
ValueType's subword count.

Definition at line 8796 of file TDGen.cc.

8796 {
8797 return subwCount_;
8798}

References subwCount_.

◆ subwordWidth()

int ValueType::subwordWidth ( ) const

Returns ValueType's subword bitwidth.

Returns
ValueType's subword bitwidth.

Definition at line 8786 of file TDGen.cc.

8786 {
8787 return subwWidth_;
8788}

References subwWidth_.

Referenced by vectorTypesOfSubwordWidth().

◆ valueType() [1/2]

ValueType ValueType::valueType ( const Operand operand)
static

Returns given Operand as a value type object.

Parameters
operandOperand to be converted to ValueType.
Returns
ValueType presentation of the Operand.

Definition at line 8927 of file TDGen.cc.

8927 {
8928 return valueType(valueTypeStr(operand));
8929}

References valueType(), and valueTypeStr().

Here is the call graph for this function:

◆ valueType() [2/2]

ValueType ValueType::valueType ( const TCEString vtStr)
static

Returns given LLVM value type string (e.g. "v2i32") as ValueType.

Parameters
vtStrLLVM value type string to be converted to ValueType.
Returns
ValueType object of the LLVM value type string.

Definition at line 8891 of file TDGen.cc.

8891 {
8892 assert(vtStr.size() > 1);
8893
8894 // Check if the value type is a scalar.
8895 if (vtStr[0] != 'v') {
8896 int subwWidthStr = Conversion::toInt(vtStr.substr(1));
8897
8898 if (vtStr[0] == TDGen::OT_REG_FP) {
8899 return ValueType(subwWidthStr, 1, true);
8900 } else {
8901 return ValueType(subwWidthStr, 1, false);
8902 }
8903 }
8904
8905 // The value type is a vector, find float/integer type ("f"/"i")
8906 // indicator.
8907 size_t vtI = vtStr.length() - 1;
8908 while (vtI > 0 && std::isdigit(vtStr[vtI])) --vtI;
8909
8910 int subwCount = Conversion::toInt(vtStr.substr(1, vtI - 1));
8911 int subwWidth = Conversion::toInt(vtStr.substr(vtI + 1));
8912
8913 if (vtStr[vtI] == TDGen::OT_REG_FP) {
8914 return ValueType(subwWidth, subwCount, true);
8915 } else {
8916 return ValueType(subwWidth, subwCount, false);
8917 }
8918}
static int toInt(const T &source)
static const char OT_REG_FP
Definition TDGen.hh:500

References assert, TDGen::OT_REG_FP, and Conversion::toInt().

Referenced by valueType(), ValueType(), and ValueType().

Here is the call graph for this function:

◆ valueTypeStr() [1/2]

TCEString ValueType::valueTypeStr ( ) const

Returns ValueType in LLVM value type string format, e.g. "v2i32".

Returns
Value type string in LLVM format.

Definition at line 8846 of file TDGen.cc.

8846 {
8847 const TCEString subwWidthStr = Conversion::toString(subwWidth_);
8848
8849 // Check if the value type is a scalar.
8850 if (subwCount_ == 1) {
8851 if (isFloat_) {
8852 return "f" + subwWidthStr;
8853 } else {
8854 return "i" + subwWidthStr;
8855 }
8856 }
8857
8858 // The value type is a vector.
8859 if (isFloat_) {
8860 return "v" + Conversion::toString(subwCount_) + "f" + subwWidthStr;
8861 } else {
8862 return "v" + Conversion::toString(subwCount_) + "i" + subwWidthStr;
8863 }
8864}
static std::string toString(const T &source)

References isFloat_, subwCount_, subwWidth_, and Conversion::toString().

Referenced by TDGen::analyzeMachineVectorRegisterClasses(), TDGen::associatedVectorRegisterClass(), TDGen::createSelectPatterns(), TDGen::genGeneratedTCEPlugin_getVectorImmediateOpcode(), TDGen::genTCETargetLoweringSIMD_addVectorRegisterClasses(), TDGen::hasRegisterClassSupport(), TDGen::hasRegisterClassSupport(), isSupportedByLLVM(), valueType(), valueTypeStr(), TDGen::writeScalarOperationExploitations(), TDGen::writeScalarToVectorDefs(), TDGen::writeVectorBitwiseOperationDefs(), TDGen::writeVectorImmediateWriteDefs(), TDGen::writeVectorRegisterClasses(), TDGen::writeVectorRegisterMoveDefs(), and TDGen::writeVectorTruncStoreDefs().

Here is the call graph for this function:

◆ valueTypeStr() [2/2]

TCEString ValueType::valueTypeStr ( const Operand operand)
static

Returns Operand in LLVM value type string format, e.g. "v2i32".

Parameters
operandOperand that will be transformed to value type string.
Returns
Value type string in LLVM format.

Definition at line 8873 of file TDGen.cc.

8873 {
8874 if (operand.type() == Operand::FLOAT_WORD ||
8875 operand.type() == Operand::HALF_FLOAT_WORD) {
8876 ValueType vt(operand.elementWidth(), operand.elementCount(), true);
8877 return vt.valueTypeStr();
8878 } else {
8879 ValueType vt(operand.elementWidth(), operand.elementCount(), false);
8880 return vt.valueTypeStr();
8881 }
8882}
virtual int elementCount() const
Definition Operand.cc:298
virtual OperandType type() const
Definition Operand.cc:165
virtual int elementWidth() const
Definition Operand.cc:278

References Operand::elementCount(), Operand::elementWidth(), Operand::FLOAT_WORD, Operand::HALF_FLOAT_WORD, Operand::type(), and valueTypeStr().

Here is the call graph for this function:

◆ vectorTypesOfSubwordWidth()

std::vector< ValueType > ValueType::vectorTypesOfSubwordWidth ( int  subwordWidth,
bool  onlyInts = false 
)
static

Returns a list of vector value types that match the given subword width.

Currently filters out unsupported LLVM value types.

Parameters
subwordWidthThe subword width of the desired value types.
onlyIntsIf true, floating point types are not included to output.
Returns
Value types for given subword width in a container.

Definition at line 8977 of file TDGen.cc.

8977 {
8978 std::vector<ValueType> vts;
8979
8980 int subwCount = 2;
8981 int subwWidth = subwordWidth;
8982 int MAX_SUBW_COUNT = SIMD_WORD_WIDTH / BYTE_BITWIDTH;
8983
8984 while (subwWidth * subwCount <= SIMD_WORD_WIDTH &&
8985 subwCount <= MAX_SUBW_COUNT) {
8986 ValueType intVt(subwWidth, subwCount, false);
8987 if (intVt.isSupportedByLLVM()) {
8988 vts.push_back(intVt);
8989 }
8990
8991 if (!onlyInts) {
8992 ValueType floatVt(subwWidth, subwCount, true);
8993 if (floatVt.isSupportedByLLVM()) {
8994 vts.push_back(floatVt);
8995 }
8996 }
8997
8998 subwCount *= 2;
8999 }
9000
9001 return vts;
9002}
const Byte BYTE_BITWIDTH
Definition BaseType.hh:136
#define SIMD_WORD_WIDTH
Definition SimValue.hh:42
int subwordWidth() const
Definition TDGen.cc:8786

References BYTE_BITWIDTH, isSupportedByLLVM(), SIMD_WORD_WIDTH, and subwordWidth().

Here is the call graph for this function:

◆ vectorTypesOfWidth()

std::vector< ValueType > ValueType::vectorTypesOfWidth ( int  width,
bool  onlyInts = false 
)
static

Returns a list of vector value types that match the given width.

Currently filters out unsupported LLVM value types.

Parameters
widthThe width of the desired value types.
onlyIntsIf true, floating point types are not included to output.
Returns
Value types for given width in a container.

Definition at line 8941 of file TDGen.cc.

8941 {
8942 std::vector<ValueType> vts;
8943
8944 int subwCount = 2;
8945 int subwWidth = width / subwCount;
8946
8947 while (subwWidth > 0) {
8948 ValueType intVt(subwWidth, subwCount, false);
8949 if (intVt.isSupportedByLLVM()) {
8950 vts.push_back(intVt);
8951 }
8952
8953 if (!onlyInts) {
8954 ValueType floatVt(subwWidth, subwCount, true);
8955 if (floatVt.isSupportedByLLVM()) {
8956 vts.push_back(floatVt);
8957 }
8958 }
8959
8960 subwWidth /= 2;
8961 subwCount *= 2;
8962 }
8963
8964 return vts;
8965}
int width() const
Definition TDGen.cc:8776

References isSupportedByLLVM(), and width().

Referenced by TDGen::writeScalarOperationExploitations(), and TDGen::writeVectorBitwiseOperationDefs().

Here is the call graph for this function:

◆ width()

int ValueType::width ( ) const

Member Data Documentation

◆ isFloat_

bool TDGenerator::ValueType::isFloat_

If true, the value type is a floating point type.

Definition at line 727 of file TDGen.hh.

Referenced by TDGen::analyzeMachineVectorRegisterClasses(), isFloat(), operandType(), operator=(), ValueType(), ValueType(), valueTypeStr(), and TDGen::writeVectorBitwiseOperationDefs().

◆ subwCount_

int TDGenerator::ValueType::subwCount_

◆ subwWidth_

int TDGenerator::ValueType::subwWidth_

◆ SUPPORTED_LLVM_VALUE_TYPES

const std::set< TCEString > ValueType::SUPPORTED_LLVM_VALUE_TYPES
static
Initial value:
=
list_of
("v2i1") ("v4i1") ("v8i1") ("v16i1")
("v2i8") ("v4i8") ("v8i8") ("v16i8") ("v32i8")
("v2i16") ("v4i16") ("v8i16") ("v16i16")
("v1i32") ("v2i32") ("v4i32") ("v8i32") ("v16i32")
("v2f16") ("v4f16") ("v8f16")
("v2f32") ("v4f32") ("v8f32") ("v16f32")
("v32i1") ("v64i1")
("v64i8")
("v32i16")
("v512i1") ("v1024i1") ("v128i8") ("v256i8")
("v64i16") ("v128i16") ("v32i32") ("v64i32")
("v128i1")
("v2048i1")
("v256i8")

Contains all supported LLVM value types (<ValueType>).

Definition at line 730 of file TDGen.hh.

Referenced by TDGen::genTCETargetLoweringSIMD_addVectorRegisterClasses(), and isSupportedByLLVM().


The documentation for this class was generated from the following files: