OpenASIP  2.0
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. More...
 
int subwCount_
 Subword count of the value type. More...
 
bool isFloat_
 If true, the value type is a floating point type. More...
 

Static Public Attributes

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

Detailed Description

Represents an LLVM value type to express different value types.

Definition at line 679 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 8628 of file TDGen.cc.

8629  : subwWidth_(subwWidth), subwCount_(subwCount), isFloat_(isFloat) {
8630  assert(subwWidth > 0 && "Invalid value type.");
8631  assert(subwCount > 0 && "Invalid value type.");
8632 }

References assert.

Referenced by valueType().

◆ ValueType() [2/4]

ValueType::ValueType ( const TCEString vtStr)

Constructor.

Parameters
vtStrValue type string in LLVM format.

Definition at line 8639 of file TDGen.cc.

8639  {
8640  ValueType vt = valueType(vtStr);
8641  this->subwWidth_ = vt.subwWidth_;
8642  this->subwCount_ = vt.subwCount_;
8643  this->isFloat_ = vt.isFloat_;
8644 }

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 8651 of file TDGen.cc.

8651  {
8652  ValueType vt = valueType(opnd);
8653  this->subwWidth_ = vt.subwWidth_;
8654  this->subwCount_ = vt.subwCount_;
8655  this->isFloat_ = vt.isFloat_;
8656 }

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 8663 of file TDGen.cc.

8664  : subwWidth_(other.subwWidth_),
8665  subwCount_(other.subwCount_),
8666  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 8732 of file TDGen.cc.

8732  {
8733  return isFloat_;
8734 }

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 8688 of file TDGen.cc.

8688  {
8691  return true;
8692  }
8693  return false;
8694 }

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 8742 of file TDGen.cc.

8742  {
8743  return subwCount_ > 1;
8744 }

References subwCount_.

◆ operandType()

Operand::OperandType ValueType::operandType ( ) const

Returns the Operand::OperandType of ValueType.

Returns
OperandType of ValueType.

Definition at line 8752 of file TDGen.cc.

8752  {
8753  if (!isFloat_ && subwWidth_ == 1) {
8754  return Operand::BOOL;
8755  } else if (isFloat_ && subwWidth_ == 16) {
8756  return Operand::HALF_FLOAT_WORD;
8757  } else if (isFloat_ && subwWidth_ == 32) {
8758  return Operand::FLOAT_WORD;
8759  } else if (!isFloat_) {
8760  return Operand::UINT_WORD;
8761  }
8762 
8763  return Operand::UINT_WORD;
8764 }

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 8675 of file TDGen.cc.

8675  {
8676  this->subwWidth_ = other.subwWidth_;
8677  this->subwCount_ = other.subwCount_;
8678  this->isFloat_ = other.isFloat_;
8679  return *this;
8680 }

References isFloat_, subwCount_, and subwWidth_.

◆ subwordCount()

int ValueType::subwordCount ( ) const

Returns ValueType's subword count.

Returns
ValueType's subword count.

Definition at line 8722 of file TDGen.cc.

8722  {
8723  return subwCount_;
8724 }

References subwCount_.

◆ subwordWidth()

int ValueType::subwordWidth ( ) const

Returns ValueType's subword bitwidth.

Returns
ValueType's subword bitwidth.

Definition at line 8712 of file TDGen.cc.

8712  {
8713  return subwWidth_;
8714 }

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 8853 of file TDGen.cc.

8853  {
8854  return valueType(valueTypeStr(operand));
8855 }

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 8817 of file TDGen.cc.

8817  {
8818  assert(vtStr.size() > 1);
8819 
8820  // Check if the value type is a scalar.
8821  if (vtStr[0] != 'v') {
8822  int subwWidthStr = Conversion::toInt(vtStr.substr(1));
8823 
8824  if (vtStr[0] == TDGen::OT_REG_FP) {
8825  return ValueType(subwWidthStr, 1, true);
8826  } else {
8827  return ValueType(subwWidthStr, 1, false);
8828  }
8829  }
8830 
8831  // The value type is a vector, find float/integer type ("f"/"i")
8832  // indicator.
8833  size_t vtI = vtStr.length() - 1;
8834  while (vtI > 0 && std::isdigit(vtStr[vtI])) --vtI;
8835 
8836  int subwCount = Conversion::toInt(vtStr.substr(1, vtI - 1));
8837  int subwWidth = Conversion::toInt(vtStr.substr(vtI + 1));
8838 
8839  if (vtStr[vtI] == TDGen::OT_REG_FP) {
8840  return ValueType(subwWidth, subwCount, true);
8841  } else {
8842  return ValueType(subwWidth, subwCount, false);
8843  }
8844 }

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

Referenced by 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 8772 of file TDGen.cc.

8772  {
8773  const TCEString subwWidthStr = Conversion::toString(subwWidth_);
8774 
8775  // Check if the value type is a scalar.
8776  if (subwCount_ == 1) {
8777  if (isFloat_) {
8778  return "f" + subwWidthStr;
8779  } else {
8780  return "i" + subwWidthStr;
8781  }
8782  }
8783 
8784  // The value type is a vector.
8785  if (isFloat_) {
8786  return "v" + Conversion::toString(subwCount_) + "f" + subwWidthStr;
8787  } else {
8788  return "v" + Conversion::toString(subwCount_) + "i" + subwWidthStr;
8789  }
8790 }

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

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

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 8799 of file TDGen.cc.

8799  {
8800  if (operand.type() == Operand::FLOAT_WORD ||
8801  operand.type() == Operand::HALF_FLOAT_WORD) {
8802  ValueType vt(operand.elementWidth(), operand.elementCount(), true);
8803  return vt.valueTypeStr();
8804  } else {
8805  ValueType vt(operand.elementWidth(), operand.elementCount(), false);
8806  return vt.valueTypeStr();
8807  }
8808 }

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 8903 of file TDGen.cc.

8903  {
8904  std::vector<ValueType> vts;
8905 
8906  int subwCount = 2;
8907  int subwWidth = subwordWidth;
8908  int MAX_SUBW_COUNT = SIMD_WORD_WIDTH / BYTE_BITWIDTH;
8909 
8910  while (subwWidth * subwCount <= SIMD_WORD_WIDTH &&
8911  subwCount <= MAX_SUBW_COUNT) {
8912  ValueType intVt(subwWidth, subwCount, false);
8913  if (intVt.isSupportedByLLVM()) {
8914  vts.push_back(intVt);
8915  }
8916 
8917  if (!onlyInts) {
8918  ValueType floatVt(subwWidth, subwCount, true);
8919  if (floatVt.isSupportedByLLVM()) {
8920  vts.push_back(floatVt);
8921  }
8922  }
8923 
8924  subwCount *= 2;
8925  }
8926 
8927  return vts;
8928 }

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 8867 of file TDGen.cc.

8867  {
8868  std::vector<ValueType> vts;
8869 
8870  int subwCount = 2;
8871  int subwWidth = width / subwCount;
8872 
8873  while (subwWidth > 0) {
8874  ValueType intVt(subwWidth, subwCount, false);
8875  if (intVt.isSupportedByLLVM()) {
8876  vts.push_back(intVt);
8877  }
8878 
8879  if (!onlyInts) {
8880  ValueType floatVt(subwWidth, subwCount, true);
8881  if (floatVt.isSupportedByLLVM()) {
8882  vts.push_back(floatVt);
8883  }
8884  }
8885 
8886  subwWidth /= 2;
8887  subwCount *= 2;
8888  }
8889 
8890  return vts;
8891 }

References isSupportedByLLVM(), and width().

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 712 of file TDGen.hh.

Referenced by TDGen::analyzeMachineVectorRegisterClasses(), isFloat(), operandType(), operator=(), 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 715 of file TDGen.hh.

Referenced by isSupportedByLLVM().


The documentation for this class was generated from the following files:
TDGen::OT_REG_FP
static const char OT_REG_FP
Definition: TDGen.hh:485
Operand::BOOL
@ BOOL
Definition: Operand.hh:64
Operand::HALF_FLOAT_WORD
@ HALF_FLOAT_WORD
Definition: Operand.hh:63
Operand::elementCount
virtual int elementCount() const
Definition: Operand.cc:298
TDGenerator::ValueType::SUPPORTED_LLVM_VALUE_TYPES
static const std::set< TCEString > SUPPORTED_LLVM_VALUE_TYPES
Contains all supported LLVM value types (<ValueType>).
Definition: TDGen.hh:715
TDGenerator::ValueType::subwCount_
int subwCount_
Subword count of the value type.
Definition: TDGen.hh:710
Operand::UINT_WORD
@ UINT_WORD
Definition: Operand.hh:60
Operand::elementWidth
virtual int elementWidth() const
Definition: Operand.cc:278
Conversion::toString
static std::string toString(const T &source)
TDGenerator::ValueType
Definition: TDGen.hh:679
TDGenerator::ValueType::valueType
static ValueType valueType(const TCEString &vtStr)
Definition: TDGen.cc:8817
assert
#define assert(condition)
Definition: Application.hh:86
TDGenerator::ValueType::subwordWidth
int subwordWidth() const
Definition: TDGen.cc:8712
TDGenerator::ValueType::subwWidth_
int subwWidth_
Subword width of the value type.
Definition: TDGen.hh:708
TDGenerator::ValueType::width
int width() const
Definition: TDGen.cc:8702
Operand::FLOAT_WORD
@ FLOAT_WORD
Definition: Operand.hh:61
TDGenerator::ValueType::isFloat_
bool isFloat_
If true, the value type is a floating point type.
Definition: TDGen.hh:712
TDGenerator::ValueType::isFloat
bool isFloat() const
Definition: TDGen.cc:8732
TDGenerator::ValueType::ValueType
ValueType(int subwWidth, int subwCount, bool isFloat)
Definition: TDGen.cc:8628
Operand::type
virtual OperandType type() const
Definition: Operand.cc:165
BYTE_BITWIDTH
const Byte BYTE_BITWIDTH
Definition: BaseType.hh:136
TCEString
Definition: TCEString.hh:53
Conversion::toInt
static int toInt(const T &source)
TDGenerator::ValueType::valueTypeStr
TCEString valueTypeStr() const
Definition: TDGen.cc:8772
SIMD_WORD_WIDTH
#define SIMD_WORD_WIDTH
Definition: SimValue.hh:42