Intel SPMD Program Compiler  1.3.0
Public Member Functions | Static Private Member Functions | Private Attributes
StructType Class Reference

Representation of a structure holding a number of members. More...

#include <type.h>

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

List of all members.

Public Member Functions

 StructType (const std::string &name, const llvm::SmallVector< const Type *, 8 > &elts, const llvm::SmallVector< std::string, 8 > &eltNames, const llvm::SmallVector< SourcePos, 8 > &eltPositions, bool isConst, Variability variability, SourcePos pos)
Variability GetVariability () const
bool IsBoolType () const
bool IsFloatType () const
bool IsIntType () const
bool IsUnsignedType () const
bool IsConstType () const
const TypeGetBaseType () const
const StructTypeGetAsVaryingType () const
const StructTypeGetAsUniformType () const
const StructTypeGetAsUnboundVariabilityType () const
const StructTypeGetAsSOAType (int width) const
const StructTypeResolveUnboundVariability (Variability v) const
const StructTypeGetAsConstType () const
const StructTypeGetAsNonConstType () 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
const TypeGetElementType (const std::string &name) const
const TypeGetElementType (int i) const
int GetElementNumber (const std::string &name) const
const std::string & GetElementName (int i) const
int GetElementCount () const
const SourcePosGetElementPosition (int i) const
const std::string & GetStructName () const

Static Private Member Functions

static bool checkIfCanBeSOA (const StructType *st)

Private Attributes

std::string name
const llvm::SmallVector< const
Type *, 8 > 
elementTypes
const llvm::SmallVector
< std::string, 8 > 
elementNames
const llvm::SmallVector
< SourcePos, 8 > 
elementPositions
const Variability variability
const bool isConst
const SourcePos pos
llvm::SmallVector< const Type *, 8 > finalElementTypes
const StructTypeoppositeConstStructType

Detailed Description

Representation of a structure holding a number of members.

Definition at line 656 of file type.h.


Constructor & Destructor Documentation

StructType::StructType ( const std::string &  name,
const llvm::SmallVector< const Type *, 8 > &  elts,
const llvm::SmallVector< std::string, 8 > &  eltNames,
const llvm::SmallVector< SourcePos, 8 > &  eltPositions,
bool  isConst,
Variability  variability,
SourcePos  pos 
)

Member Function Documentation

bool StructType::checkIfCanBeSOA ( const StructType st) [static, private]
const StructType * StructType::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 1972 of file type.cpp.

References elementNames, elementPositions, elementTypes, isConst, name, NULL, oppositeConstStructType, pos, StructType(), and variability.

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

References elementNames, elementPositions, elementTypes, isConst, name, NULL, oppositeConstStructType, pos, StructType(), and variability.

const StructType * StructType::GetAsSOAType ( int  width) const [virtual]
const StructType * StructType::GetAsUnboundVariabilityType ( ) const [virtual]

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 1933 of file type.cpp.

References elementNames, elementPositions, elementTypes, Type::HasUnboundVariability(), isConst, name, pos, StructType(), and Variability::Unbound.

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

References elementNames, elementPositions, elementTypes, isConst, Type::IsUniformType(), name, pos, StructType(), and Variability::Uniform.

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

References elementNames, elementPositions, elementTypes, isConst, Type::IsVaryingType(), name, pos, StructType(), and Variability::Varying.

Referenced by TypeCastExpr::GetValue().

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

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

References isConst, lShouldPrintName(), name, Variability::soaWidth, and variability.

llvm::DIType StructType::GetDIType ( llvm::DIDescriptor  scope) const [virtual]

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

Implements Type.

Definition at line 2087 of file type.cpp.

References Assert, Module::diBuilder, elementNames, elementPositions, elementTypes, SourcePos::first_line, SourcePos::GetDIFile(), Type::GetDIType(), GetElementType(), m, name, and pos.

int StructType::GetElementCount ( ) const [inline, virtual]

Returns the total number of elements in the structure.

Implements CollectionType.

Definition at line 704 of file type.h.

References elementTypes.

Referenced by MemberExpr::getCandidateNearMatches(), lCheckForConstStructMember(), lEmitStructDecl(), lRecursiveCheckValidParamType(), lVaryingStructHasUniformMember(), and StructType().

const std::string& StructType::GetElementName ( int  i) const [inline]

Returns the name of the i'th element of the structure.

Definition at line 701 of file type.h.

References elementNames.

Referenced by MemberExpr::getCandidateNearMatches(), lCheckForConstStructMember(), lEmitStructDecl(), and lVaryingStructHasUniformMember().

int StructType::GetElementNumber ( const std::string &  name) const

Returns which structure element number (starting from zero) that has the given name. If there is no such element, return -1.

Definition at line 2167 of file type.cpp.

References elementNames.

Referenced by StructMemberExpr::getElementNumber().

const SourcePos& StructType::GetElementPosition ( int  i) const [inline]

Definition at line 706 of file type.h.

References elementPositions.

const Type * StructType::GetElementType ( const std::string &  name) const

Returns the type of the structure element with the given name (if any). Returns NULL if there is no such named element.

Definition at line 2158 of file type.cpp.

References elementNames, and NULL.

Referenced by GetDIType(), StructMemberExpr::getElementType(), StructMemberExpr::GetType(), lCheckForConstStructMember(), lEmitStructDecl(), lRecursiveCheckValidParamType(), lVaryingStructHasUniformMember(), and StructType().

const Type * StructType::GetElementType ( int  i) const [virtual]

Returns the type of the i'th structure element. The value of i must be between 0 and NumElements()-1.

Implements CollectionType.

Definition at line 2134 of file type.cpp.

References Assert, elementTypes, Module::errorCount, finalElementTypes, Type::GetAsConstType(), isConst, m, NULL, Type::ResolveUnboundVariability(), Variability::Unbound, and variability.

std::string StructType::GetString ( ) const [virtual]

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

Implements Type.

Definition at line 2004 of file type.cpp.

References elementNames, elementTypes, Variability::GetString(), isConst, name, and variability.

Referenced by StructMemberExpr::getElementNumber(), StructMemberExpr::GetType(), lCheckForConstStructMember(), lVaryingStructHasUniformMember(), and AssignExpr::TypeCheck().

const std::string& StructType::GetStructName ( ) const [inline]

Returns the name of the structure type. (e.g. struct Foo -> "Foo".)

Definition at line 709 of file type.h.

References name.

Referenced by lCheckTypeEquality(), and lEmitStructDecl().

Variability StructType::GetVariability ( ) const [virtual]

Returns the variability of the type.

Implements Type.

Definition at line 1871 of file type.cpp.

References variability.

bool StructType::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 1877 of file type.cpp.

bool StructType::IsConstType ( ) const [virtual]

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

Implements Type.

Definition at line 1901 of file type.cpp.

References isConst.

bool StructType::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 1883 of file type.cpp.

bool StructType::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 1889 of file type.cpp.

bool StructType::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 1895 of file type.cpp.

llvm::Type * StructType::LLVMType ( llvm::LLVMContext *  ctx) const [virtual]

Returns the LLVM type corresponding to this ispc type

Implements Type.

Definition at line 2075 of file type.cpp.

References Assert, Module::errorCount, lMangleStructName(), m, name, NULL, Variability::Unbound, and variability.

Referenced by FunctionEmitContext::AddElementOffset().

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

References isConst, lMangleStruct(), name, and variability.

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

Member Data Documentation

const llvm::SmallVector<std::string, 8> StructType::elementNames [private]
const llvm::SmallVector<SourcePos, 8> StructType::elementPositions [private]

Source file position at which each structure element declaration appeared.

Definition at line 729 of file type.h.

Referenced by checkIfCanBeSOA(), GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), GetDIType(), GetElementPosition(), ResolveUnboundVariability(), and StructType().

const llvm::SmallVector<const Type *, 8> StructType::elementTypes [private]

The types of the struct elements. Note that we store these with uniform/varying exactly as they were declared in the source file. (In other words, even if this struct has a varying qualifier and thus all of its members are going to be widened out to be varying, we still store any members that were declared as uniform as uniform types in the elementTypes array, converting them to varying as needed in the implementation.) This is so that if we later need to make a uniform version of the struct, we've maintained the original information about the member types.

Definition at line 725 of file type.h.

Referenced by checkIfCanBeSOA(), GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), GetDIType(), GetElementCount(), GetElementType(), GetString(), ResolveUnboundVariability(), and StructType().

llvm::SmallVector<const Type *, 8> StructType::finalElementTypes [mutable, private]

Definition at line 734 of file type.h.

Referenced by GetElementType(), and StructType().

const bool StructType::isConst [private]
std::string StructType::name [private]

Definition at line 736 of file type.h.

Referenced by GetAsConstType(), GetAsNonConstType(), and StructType().

const SourcePos StructType::pos [private]

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