Intel SPMD Program Compiler  1.11.0
Public Member Functions | Private Attributes | List of all members
VectorType Class Reference

A (short) vector of atomic types. More...

#include <type.h>

Inheritance diagram for VectorType:
Inheritance graph
[legend]
Collaboration diagram for VectorType:
Collaboration graph
[legend]

Public Member Functions

 VectorType (const AtomicType *base, int size)
 
Variability GetVariability () const
 
bool IsBoolType () const
 
bool IsFloatType () const
 
bool IsIntType () const
 
bool IsUnsignedType () const
 
bool IsConstType () const
 
const TypeGetBaseType () const
 
const VectorTypeGetAsVaryingType () const
 
const VectorTypeGetAsUniformType () const
 
const VectorTypeGetAsUnboundVariabilityType () const
 
const VectorTypeGetAsSOAType (int width) const
 
const VectorTypeResolveUnboundVariability (Variability v) const
 
const VectorTypeGetAsUnsignedType () const
 
const VectorTypeGetAsConstType () const
 
const VectorTypeGetAsNonConstType () const
 
std::string GetString () const
 
std::string Mangle () const
 
std::string GetCDeclaration (const std::string &name) const
 
llvm::Type * LLVMType (llvm::LLVMContext *ctx) const
 
llvm::DIType GetDIType (llvm::DIDescriptor scope) const
 
int GetElementCount () const
 
const AtomicTypeGetElementType () const
 
int getVectorMemoryCount () const
 
- Public Member Functions inherited from SequentialType
const TypeGetElementType (int index) const
 
- Public Member Functions inherited from Type
bool IsPointerType () const
 
bool IsArrayType () const
 
bool IsReferenceType () const
 
bool IsVoidType () const
 
bool IsNumericType () const
 
bool IsUniformType () const
 
bool IsVaryingType () const
 
bool IsSOAType () const
 
int GetSOAWidth () const
 
bool HasUnboundVariability () const
 
virtual const TypeGetReferenceTarget () const
 

Private Attributes

const AtomicType *const base
 
const int numElements
 

Additional Inherited Members

- Static Public Member Functions inherited from Type
static bool Equal (const Type *a, const Type *b)
 
static bool EqualIgnoringConst (const Type *a, const Type *b)
 
static const TypeMoreGeneralType (const Type *type0, const Type *type1, SourcePos pos, const char *reason, bool forceVarying=false, int vecSize=0)
 
static bool IsBasicType (const Type *type)
 
- Public Attributes inherited from Type
const TypeId typeId
 
- Protected Member Functions inherited from SequentialType
 SequentialType (TypeId id)
 
- Protected Member Functions inherited from CollectionType
 CollectionType (TypeId id)
 
- Protected Member Functions inherited from Type
 Type (TypeId id)
 

Detailed Description

A (short) vector of atomic types.

VectorType is used to represent a fixed-size array of elements of an AtomicType. Vectors are similar to arrays in that they support indexing of the elements, but have two key differences. First, all arithmetic and logical operations that are value for the element type can be performed on corresponding VectorTypes (as long as the two VectorTypes have the same size). Second, VectorTypes of uniform elements are laid out in memory aligned to the target's vector size; this allows them to be packed 'horizontally' into vector registers.

Definition at line 618 of file type.h.

Constructor & Destructor Documentation

◆ VectorType()

VectorType::VectorType ( const AtomicType base,
int  size 
)

Member Function Documentation

◆ GetAsConstType()

const VectorType * VectorType::GetAsConstType ( ) const
virtual

Get a const version of this type. If it's already const, then the old Type pointer is returned.

Implements Type.

Definition at line 1514 of file type.cpp.

References base, AtomicType::GetAsConstType(), numElements, and VectorType().

◆ GetAsNonConstType()

const VectorType * VectorType::GetAsNonConstType ( ) const
virtual

Get a non-const version of this type. If it's already not const, then the old Type pointer is returned.

Implements Type.

Definition at line 1516 of file type.cpp.

References base, AtomicType::GetAsNonConstType(), numElements, and VectorType().

Referenced by lEmitVectorTypedefs().

◆ GetAsSOAType()

const VectorType * VectorType::GetAsSOAType ( int  width) const
virtual

Implements Type.

Definition at line 1498 of file type.cpp.

References base, AtomicType::GetAsSOAType(), numElements, and VectorType().

◆ GetAsUnboundVariabilityType()

const VectorType * VectorType::GetAsUnboundVariabilityType ( ) const
virtual

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 1494 of file type.cpp.

References base, AtomicType::GetAsUnboundVariabilityType(), numElements, and VectorType().

◆ GetAsUniformType()

const VectorType * VectorType::GetAsUniformType ( ) const
virtual

Return a "uniform" instance of this type. If the type is already uniform, its "this" pointer will be returned.

Implements Type.

Definition at line 1492 of file type.cpp.

References base, AtomicType::GetAsUniformType(), numElements, and VectorType().

◆ GetAsUnsignedType()

const VectorType * VectorType::GetAsUnsignedType ( ) const
virtual

If this is a signed integer type, return the unsigned version of the type. Otherwise, return the original type.

Reimplemented from Type.

Definition at line 1506 of file type.cpp.

References Assert, base, Module::errorCount, AtomicType::GetAsUnsignedType(), m, numElements, and VectorType().

◆ GetAsVaryingType()

const VectorType * VectorType::GetAsVaryingType ( ) const
virtual

Return a "varying" instance of this type. If the type is already varying, its "this" pointer will be returned.

Implements Type.

Definition at line 1490 of file type.cpp.

References base, AtomicType::GetAsVaryingType(), numElements, and VectorType().

◆ GetBaseType()

const Type * VectorType::GetBaseType ( ) const
virtual

Returns the basic root type of the given type. For example, for an array or short-vector, this returns the element type. For a struct or atomic type, it returns itself.

Implements Type.

Definition at line 1488 of file type.cpp.

References base.

Referenced by lEmitVectorTypedefs().

◆ GetCDeclaration()

std::string VectorType::GetCDeclaration ( const std::string &  name) const
virtual

Returns a string that is the declaration of the same type in C syntax.

Implements Type.

Definition at line 1534 of file type.cpp.

References base, AtomicType::GetCDeclaration(), and numElements.

◆ GetDIType()

llvm::DIType VectorType::GetDIType ( llvm::DIDescriptor  scope) const
virtual

Returns the DIType (LLVM's debugging information structure), corresponding to this type.

Implements Type.

Definition at line 1576 of file type.cpp.

References base, Globals::ctx, Module::diBuilder, FATAL, g, Target::getDataLayout(), AtomicType::GetDIType(), ArrayType::GetDIType(), Type::IsSOAType(), Type::IsUniformType(), Type::IsVaryingType(), LLVMType(), m, numElements, and Globals::target.

◆ GetElementCount()

int VectorType::GetElementCount ( ) const
virtual

Returns the total number of elements in the collection.

Implements CollectionType.

Definition at line 1541 of file type.cpp.

References numElements.

Referenced by SelectExpr::GetValue(), TypeCastExpr::GetValue(), lCheckTypeEquality(), lEmitVectorTypedefs(), lMatchingBoolType(), lVectorConvert(), Type::MoreGeneralType(), and BinaryExpr::TypeCheck().

◆ GetElementType()

const AtomicType * VectorType::GetElementType ( ) const
virtual

Returns the Type of the elements that the sequence stores; for SequentialTypes, all elements have the same type .

Implements SequentialType.

Definition at line 1543 of file type.cpp.

References base.

Referenced by VectorMemberExpr::GetType(), SelectExpr::GetValue(), TypeCastExpr::GetValue(), VectorMemberExpr::GetValue(), lCheckTypeEquality(), Type::MoreGeneralType(), and VectorMemberExpr::VectorMemberExpr().

◆ GetString()

std::string VectorType::GetString ( ) const
virtual

Returns a text representation of the type (for example, for use in warning and error messages).

Implements Type.

Definition at line 1520 of file type.cpp.

References base, AtomicType::GetString(), and numElements.

◆ GetVariability()

Variability VectorType::GetVariability ( ) const
virtual

Returns the variability of the type.

Implements Type.

Definition at line 1476 of file type.cpp.

References base, and AtomicType::GetVariability().

◆ getVectorMemoryCount()

int VectorType::getVectorMemoryCount ( ) const

Returns the number of elements stored in memory for the vector. For uniform vectors, this is rounded up so that the number of elements evenly divides the target's native vector width.

Definition at line 1623 of file type.cpp.

References base, FATAL, g, Target::getDataTypeWidth(), Type::IsSOAType(), Type::IsUniformType(), Type::IsVaryingType(), numElements, and Globals::target.

Referenced by ExprList::GetConstant(), and LLVMType().

◆ IsBoolType()

bool VectorType::IsBoolType ( ) const
virtual

Returns true if the underlying type is boolean. In other words, this is true for individual bools and for short-vectors with underlying bool type, but not for arrays of bools.

Implements Type.

Definition at line 1484 of file type.cpp.

References base, and AtomicType::IsBoolType().

◆ IsConstType()

bool VectorType::IsConstType ( ) const
virtual

Returns true if this type is 'const'-qualified.

Implements Type.

Definition at line 1486 of file type.cpp.

References base, and AtomicType::IsConstType().

◆ IsFloatType()

bool VectorType::IsFloatType ( ) const
virtual

Returns true if the underlying type is float or double. In other words, this is true for individual floats/doubles and for short-vectors of them, but not for arrays of them.

Implements Type.

Definition at line 1478 of file type.cpp.

References base, and AtomicType::IsFloatType().

◆ IsIntType()

bool VectorType::IsIntType ( ) const
virtual

Returns true if the underlying type is an integer type. In other words, this is true for individual integers and for short-vectors of integer types, but not for arrays of integer types.

Implements Type.

Definition at line 1480 of file type.cpp.

References base, and AtomicType::IsIntType().

◆ IsUnsignedType()

bool VectorType::IsUnsignedType ( ) const
virtual

Returns true if the underlying type is unsigned. In other words, this is true for unsigned integers and short vectors of unsigned integer types.

Implements Type.

Definition at line 1482 of file type.cpp.

References base, and AtomicType::IsUnsignedType().

◆ LLVMType()

llvm::Type * VectorType::LLVMType ( llvm::LLVMContext *  ctx) const
virtual

Returns the LLVM type corresponding to this ispc type

Implements Type.

Definition at line 1545 of file type.cpp.

References Assert, base, Module::errorCount, FATAL, getVectorMemoryCount(), Type::IsSOAType(), Type::IsUniformType(), Type::IsVaryingType(), AtomicType::LLVMType(), m, and numElements.

Referenced by GetDIType(), VectorMemberExpr::GetValue(), and lEmitVectorTypedefs().

◆ Mangle()

std::string VectorType::Mangle ( ) const
virtual

Returns a string that represents the mangled type (for use in mangling function symbol names for function overloading). The various Types implementations of this method should collectively ensure that all of them use mangling schemes that are guaranteed not to clash.

Implements Type.

Definition at line 1527 of file type.cpp.

References base, AtomicType::Mangle(), and numElements.

◆ ResolveUnboundVariability()

const VectorType * VectorType::ResolveUnboundVariability ( Variability  v) const
virtual

Implements Type.

Definition at line 1502 of file type.cpp.

References base, numElements, AtomicType::ResolveUnboundVariability(), and VectorType().

Member Data Documentation

◆ base

const AtomicType* const VectorType::base
private

◆ numElements

const int VectorType::numElements
private

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