Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ArrayType Class Reference

One-dimensional array type. More...

#include <type.h>

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

Public Member Functions

 ArrayType (const Type *elementType, int numElements)
 
Variability GetVariability () const
 
bool IsBoolType () const
 
bool IsFloatType () const
 
bool IsIntType () const
 
bool IsUnsignedType () const
 
bool IsConstType () const
 
const TypeGetBaseType () const
 
const ArrayTypeGetAsVaryingType () const
 
const ArrayTypeGetAsUniformType () const
 
const ArrayTypeGetAsUnboundVariabilityType () const
 
const ArrayTypeGetAsSOAType (int width) const
 
const ArrayTypeResolveUnboundVariability (Variability v) const
 
const ArrayTypeGetAsUnsignedType () const
 
const ArrayTypeGetAsConstType () const
 
const ArrayTypeGetAsNonConstType () const
 
std::string GetString () const
 
std::string Mangle () const
 
std::string GetCDeclaration (const std::string &name) const
 
llvm::DIType * GetDIType (llvm::DIScope *scope) const
 
llvm::ArrayType * LLVMType (llvm::LLVMContext *ctx) const
 
int TotalElementCount () const
 
int GetElementCount () const
 
const TypeGetElementType () const
 
virtual ArrayTypeGetSizedArray (int length) 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
 
virtual llvm::Type * LLVMStorageType (llvm::LLVMContext *ctx) const
 

Static Public Member Functions

static const TypeSizeUnsizedArrays (const Type *type, Expr *initExpr)
 
- 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)
 

Private Attributes

const Type *const child
 
const int numElements
 

Additional Inherited Members

- 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

One-dimensional array type.

ArrayType represents a one-dimensional array of instances of some other type. (Multi-dimensional arrays are represented by ArrayTypes that in turn hold ArrayTypes as their child types.)

Definition at line 521 of file type.h.

Constructor & Destructor Documentation

◆ ArrayType()

ArrayType::ArrayType ( const Type elementType,
int  numElements 
)

An ArrayType is created by providing the type of the elements that it stores, and the SOA width to use in laying out the array in memory.

Parameters
elementTypeType of the array elements
numElementsTotal number of elements in the array. This parameter may be zero, in which case this is an "unsized" array type. (Arrays of specific size can be converted to unsized arrays to be passed to functions that take array parameters, for example).

Definition at line 1074 of file type.cpp.

References Assert, Type::IsVoidType(), and numElements.

Referenced by GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsUnsignedType(), GetAsVaryingType(), GetSizedArray(), ResolveUnboundVariability(), and SizeUnsizedArrays().

Member Function Documentation

◆ GetAsConstType()

const ArrayType * ArrayType::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 1167 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsConstType(), m, and numElements.

◆ GetAsNonConstType()

const ArrayType * ArrayType::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 1175 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsNonConstType(), m, and numElements.

◆ GetAsSOAType()

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

Implements Type.

Definition at line 1143 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsSOAType(), m, and numElements.

◆ GetAsUnboundVariabilityType()

const ArrayType * ArrayType::GetAsUnboundVariabilityType ( ) const
virtual

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 1135 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsUnboundVariabilityType(), m, and numElements.

◆ GetAsUniformType()

const ArrayType * ArrayType::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 1127 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsUniformType(), m, and numElements.

◆ GetAsUnsignedType()

const ArrayType * ArrayType::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 1159 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsUnsignedType(), m, and numElements.

◆ GetAsVaryingType()

const ArrayType * ArrayType::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 1119 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsVaryingType(), m, and numElements.

◆ GetBaseType()

const Type * ArrayType::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 1108 of file type.cpp.

References child.

Referenced by GetCDeclaration(), GetString(), and TypeCastExpr::GetValue().

◆ GetCDeclaration()

std::string ArrayType::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 1226 of file type.cpp.

References Assert, child, Module::errorCount, g, Type::GetAsUniformType(), GetBaseType(), Type::GetCDeclaration(), Type::GetSOAWidth(), Target::getVectorWidth(), Type::IsVaryingType(), m, numElements, and Globals::target.

◆ GetDIType()

llvm::DIType * ArrayType::GetDIType ( llvm::DIScope *  scope) const
virtual

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

Implements Type.

Definition at line 1274 of file type.cpp.

References Assert, child, Module::errorCount, Type::GetDIType(), lCreateDIArray(), m, and numElements.

Referenced by AtomicType::GetDIType(), PointerType::GetDIType(), and VectorType::GetDIType().

◆ GetElementCount()

int ArrayType::GetElementCount ( ) const
virtual

Returns the total number of elements in the collection.

Implements CollectionType.

Definition at line 1183 of file type.cpp.

References numElements.

Referenced by ReferenceType::GetCDeclaration(), GetStructTypesNamesPositions(), TypeCastExpr::GetValue(), lCheckTypeEquality(), lDoTypeConv(), lHasUnsizedArrays(), and SizeUnsizedArrays().

◆ GetElementType()

const Type * ArrayType::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 1185 of file type.cpp.

References child.

Referenced by ReferenceType::GetCDeclaration(), Declarator::InitFromType(), lCheckTypeEquality(), lDoTypeConv(), lGetElementStructType(), lGetExportedTypes(), lHasUnsizedArrays(), lVaryingStructHasUniformMember(), and SizeUnsizedArrays().

◆ GetSizedArray()

ArrayType * ArrayType::GetSizedArray ( int  length) const
virtual

Returns a new array of the same child type, but with the given length.

Definition at line 1283 of file type.cpp.

References ArrayType(), Assert, child, and numElements.

Referenced by SizeUnsizedArrays().

◆ GetString()

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

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

Implements Type.

Definition at line 1187 of file type.cpp.

References Assert, child, Module::errorCount, GetBaseType(), Type::GetString(), m, and numElements.

◆ GetVariability()

Variability ArrayType::GetVariability ( ) const
virtual

Returns the variability of the type.

Implements Type.

Definition at line 1094 of file type.cpp.

References child, Type::GetVariability(), and Variability::Uniform.

◆ IsBoolType()

bool ArrayType::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 1104 of file type.cpp.

◆ IsConstType()

bool ArrayType::IsConstType ( ) const
virtual

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

Implements Type.

Definition at line 1106 of file type.cpp.

References child, and Type::IsConstType().

◆ IsFloatType()

bool ArrayType::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 1098 of file type.cpp.

◆ IsIntType()

bool ArrayType::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 1100 of file type.cpp.

◆ IsUnsignedType()

bool ArrayType::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 1102 of file type.cpp.

◆ LLVMType()

llvm::ArrayType * ArrayType::LLVMType ( llvm::LLVMContext *  ctx) const
virtual

Returns the LLVM type corresponding to this ispc type.

Implements Type.

Definition at line 1080 of file type.cpp.

References Assert, child, Module::errorCount, Type::LLVMStorageType(), m, and numElements.

Referenced by lGetAtomicLLVMType(), EnumType::LLVMType(), and PointerType::LLVMType().

◆ Mangle()

std::string ArrayType::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 1211 of file type.cpp.

References Assert, child, Module::errorCount, m, Type::Mangle(), and numElements.

◆ ResolveUnboundVariability()

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

Implements Type.

Definition at line 1151 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, m, numElements, and Type::ResolveUnboundVariability().

◆ SizeUnsizedArrays()

const Type * ArrayType::SizeUnsizedArrays ( const Type type,
Expr initExpr 
)
static

If the given type is a (possibly multi-dimensional) array type and the initializer expression is an expression list, set the size of any array dimensions that are unsized according to the number of elements in the corresponding sectoin of the initializer expression.

Definition at line 1288 of file type.cpp.

References ArrayType(), Assert, Error(), Module::errorCount, ExprList::exprs, GetElementCount(), GetElementType(), GetSizedArray(), m, and Union().

Referenced by Module::AddGlobalVariable(), and DeclStmt::EmitCode().

◆ TotalElementCount()

int ArrayType::TotalElementCount ( ) const

This method returns the total number of elements in the array, including all dimensions if this is a multidimensional array.

Definition at line 1266 of file type.cpp.

References child, numElements, and TotalElementCount().

Referenced by Module::AddGlobalVariable(), and TotalElementCount().

Member Data Documentation

◆ child

const Type* const ArrayType::child
private

◆ numElements

const int ArrayType::numElements
private

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