Intel SPMD Program Compiler  1.9.1
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
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]

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
 
bool IsDefined () 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
 
const std::string GetCStructName () 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 TypeGetAsUnsignedType () const
 
virtual const TypeGetReferenceTarget () 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
 

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 CollectionType
 CollectionType (TypeId id)
 
- Protected Member Functions inherited from Type
 Type (TypeId id)
 

Detailed Description

Representation of a structure holding a number of members.

Definition at line 690 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)
staticprivate
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 2150 of file type.cpp.

References elementNames, elementPositions, elementTypes, isConst, name, 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 2166 of file type.cpp.

References elementNames, elementPositions, elementTypes, isConst, name, 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 2111 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 2101 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 2091 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 2085 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 2234 of file type.cpp.

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

const std::string StructType::GetCStructName ( ) const

Definition at line 2017 of file type.cpp.

References GetStructName(), lMangleStructName(), name, variability, and Variability::Varying.

Referenced by GetCDeclaration(), and lEmitStructDecl().

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 2267 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
inlinevirtual
const std::string& StructType::GetElementName ( int  i) const
inline

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

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

References elementNames.

Referenced by StructMemberExpr::getElementNumber().

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

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

References elementNames.

Referenced by GetDIType(), StructMemberExpr::getElementType(), StructMemberExpr::GetType(), IsDefined(), lCheckForConstStructMember(), lContainsPtrToVarying(), lEmitStructDecl(), lRecursiveCheckValidParamType(), lUniformValueToVarying(), 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 2348 of file type.cpp.

References Assert, elementTypes, Module::errorCount, finalElementTypes, Type::GetAsConstType(), isConst, m, 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 2182 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 748 of file type.h.

References name.

Referenced by GetCStructName(), and lCheckTypeEquality().

Variability StructType::GetVariability ( ) const
virtual

Returns the variability of the type.

Implements Type.

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

bool StructType::IsConstType ( ) const
virtual

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

Implements Type.

Definition at line 2060 of file type.cpp.

References isConst.

bool StructType::IsDefined ( ) const

Definition at line 2066 of file type.cpp.

References GetElementCount(), GetElementType(), and IsDefined().

Referenced by MemberExpr::create(), IsDefined(), and NewExpr::TypeCheck().

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 2042 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 2048 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 2054 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 2255 of file type.cpp.

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

Referenced by FunctionEmitContext::AddElementOffset(), and lEmitStructDecl().

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 2228 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 769 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 765 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
mutableprivate

Definition at line 774 of file type.h.

Referenced by GetElementType(), and StructType().

const bool StructType::isConst
private
std::string StructType::name
private
const StructType* StructType::oppositeConstStructType
mutableprivate

Definition at line 776 of file type.h.

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

const SourcePos StructType::pos
private
const Variability StructType::variability
private

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