Intel SPMD Program Compiler  1.9.1
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::DIDescriptor 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
 

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 555 of file type.h.

Constructor & Destructor Documentation

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 1316 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

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 1450 of file type.cpp.

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

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 1460 of file type.cpp.

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

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

Implements Type.

Definition at line 1420 of file type.cpp.

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

const ArrayType * ArrayType::GetAsUnboundVariabilityType ( ) const
virtual

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 1410 of file type.cpp.

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

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 1400 of file type.cpp.

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

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 1440 of file type.cpp.

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

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 1390 of file type.cpp.

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

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 1377 of file type.cpp.

References child.

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

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 1524 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.

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

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

Implements Type.

Definition at line 1575 of file type.cpp.

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

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

int ArrayType::GetElementCount ( ) const
virtual
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 1476 of file type.cpp.

References child.

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

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

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

Definition at line 1594 of file type.cpp.

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

Referenced by SizeUnsizedArrays().

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 1482 of file type.cpp.

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

Variability ArrayType::GetVariability ( ) const
virtual

Returns the variability of the type.

Implements Type.

Definition at line 1341 of file type.cpp.

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

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 1365 of file type.cpp.

bool ArrayType::IsConstType ( ) const
virtual

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

Implements Type.

Definition at line 1371 of file type.cpp.

References child, and Type::IsConstType().

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 1347 of file type.cpp.

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 1353 of file type.cpp.

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 1359 of file type.cpp.

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

Returns the LLVM type corresponding to this ispc type

Implements Type.

Definition at line 1325 of file type.cpp.

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

Referenced by DeclStmt::EmitCode(), AtomicType::LLVMType(), EnumType::LLVMType(), and PointerType::LLVMType().

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 1507 of file type.cpp.

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

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

Implements Type.

Definition at line 1430 of file type.cpp.

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

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 1601 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().

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 1565 of file type.cpp.

References child, numElements, and TotalElementCount().

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

Member Data Documentation

const Type* const ArrayType::child
private
const int ArrayType::numElements
private

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