Intel SPMD Program Compiler  1.3.0
Public Member Functions | Static Public Member Functions | Private Attributes
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]

List of all members.

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

Static Public Member Functions

static const TypeSizeUnsizedArrays (const Type *type, Expr *initExpr)

Private Attributes

const Type *const child
const int numElements

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

References Assert, Type::Equal(), 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 1338 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsConstType(), m, NULL, 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 1348 of file type.cpp.

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

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

Implements Type.

Definition at line 1308 of file type.cpp.

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

const ArrayType * ArrayType::GetAsUnboundVariabilityType ( ) const [virtual]

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 1298 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsUnboundVariabilityType(), m, NULL, 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 1288 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsUniformType(), m, NULL, 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 1328 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsUnsignedType(), m, NULL, 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 1278 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, Type::GetAsVaryingType(), m, NULL, 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 1265 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 1411 of file type.cpp.

References Assert, child, Module::errorCount, Type::GetAsUniformType(), GetBaseType(), Type::GetCDeclaration(), Type::GetSOAWidth(), m, NULL, numElements, and s.

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

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

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

int ArrayType::GetElementCount ( ) const [virtual]

Returns the total number of elements in the collection.

Implements CollectionType.

Definition at line 1358 of file type.cpp.

References numElements.

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

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

References child.

Referenced by ReferenceType::GetCDeclaration(), Declarator::InitFromType(), lCheckTypeEquality(), lDoTypeConv(), 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 1467 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 1370 of file type.cpp.

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

Variability ArrayType::GetVariability ( ) const [virtual]

Returns the variability of the type.

Implements Type.

Definition at line 1229 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 1253 of file type.cpp.

bool ArrayType::IsConstType ( ) const [virtual]

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

Implements Type.

Definition at line 1259 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 1235 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 1241 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 1247 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 1213 of file type.cpp.

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

Referenced by 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 1395 of file type.cpp.

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

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

Implements Type.

Definition at line 1318 of file type.cpp.

References ArrayType(), Assert, child, Module::errorCount, m, NULL, 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 1474 of file type.cpp.

References ArrayType(), Assert, Error(), Module::errorCount, ExprList::exprs, GetElementCount(), GetElementType(), GetSizedArray(), m, NULL, 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 1445 of file type.cpp.

References child, NULL, 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: