Intel® Implicit SPMD Program Compiler (Intel® ISPC)
1.13.0
|
Representation of a structure holding a number of members. More...
#include <type.h>
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 Type * | GetBaseType () const |
const StructType * | GetAsVaryingType () const |
const StructType * | GetAsUniformType () const |
const StructType * | GetAsUnboundVariabilityType () const |
const StructType * | GetAsSOAType (int width) const |
const StructType * | ResolveUnboundVariability (Variability v) const |
const StructType * | GetAsConstType () const |
const StructType * | GetAsNonConstType () 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::DIScope *scope) const |
const Type * | GetElementType (const std::string &name) const |
const Type * | GetElementType (int i) const |
int | GetElementNumber (const std::string &name) const |
const std::string & | GetElementName (int i) const |
int | GetElementCount () const |
const SourcePos & | GetElementPosition (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 Type * | GetAsUnsignedType () const |
virtual const Type * | GetReferenceTarget () const |
virtual llvm::Type * | LLVMStorageType (llvm::LLVMContext *ctx) 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 StructType * | oppositeConstStructType |
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 Type * | MoreGeneralType (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) | |
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 | ||
) |
Definition at line 1568 of file type.cpp.
References Assert, Globals::ctx, elementPositions, elementTypes, Error(), Module::errorCount, finalElementTypes, g, GetElementCount(), GetElementType(), LLVMTypes::Int8Type, Type::LLVMStorageType(), lMangleStructName(), lStructTypeMap, m, name, oppositeConstStructType, Variability::Unbound, and variability.
Referenced by GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), and ResolveUnboundVariability().
|
staticprivate |
Definition at line 1895 of file type.cpp.
References elementNames, elementPositions, elementTypes, Error(), Type::GetString(), Type::HasUnboundVariability(), and Type::IsUniformType().
Referenced by GetAsSOAType().
|
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 1720 of file type.cpp.
References elementNames, elementPositions, elementTypes, isConst, name, oppositeConstStructType, pos, StructType(), and variability.
|
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 1733 of file type.cpp.
References elementNames, elementPositions, elementTypes, isConst, name, oppositeConstStructType, pos, StructType(), and variability.
|
virtual |
Implements Type.
Definition at line 1696 of file type.cpp.
References checkIfCanBeSOA(), elementNames, elementPositions, elementTypes, Type::GetSOAWidth(), isConst, name, pos, Variability::SOA, and StructType().
Referenced by DeclSpecs::GetBaseType().
|
virtual |
Get an instance of the type with unbound variability.
Implements Type.
Definition at line 1688 of file type.cpp.
References elementNames, elementPositions, elementTypes, Type::HasUnboundVariability(), isConst, name, pos, StructType(), and Variability::Unbound.
|
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 1680 of file type.cpp.
References elementNames, elementPositions, elementTypes, isConst, Type::IsUniformType(), name, pos, StructType(), and Variability::Uniform.
|
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 1672 of file type.cpp.
References elementNames, elementPositions, elementTypes, isConst, Type::IsVaryingType(), name, pos, StructType(), and Variability::Varying.
Referenced by TypeCastExpr::GetValue().
|
virtual |
|
virtual |
Returns a string that is the declaration of the same type in C syntax.
Implements Type.
Definition at line 1789 of file type.cpp.
References GetCStructName(), isConst, lShouldPrintName(), Variability::soaWidth, and variability.
const std::string StructType::GetCStructName | ( | ) | const |
Definition at line 1630 of file type.cpp.
References GetStructName(), lMangleStructName(), name, variability, and Variability::Varying.
Referenced by GetCDeclaration(), and lEmitStructDecl().
|
virtual |
Returns the DIType (LLVM's debugging information structure), corresponding to this type.
Implements Type.
Definition at line 1820 of file type.cpp.
References Assert, Globals::ctx, Module::diBuilder, elementNames, elementPositions, elementTypes, SourcePos::first_line, g, SourcePos::GetDIFile(), Type::GetDIType(), GetElementType(), Type::LLVMStorageType(), m, Module::module, name, and pos.
|
inlinevirtual |
Returns the total number of elements in the structure.
Implements CollectionType.
Definition at line 699 of file type.h.
Referenced by checkInit(), MemberExpr::getCandidateNearMatches(), IsDefined(), lCheckForConstStructMember(), lContainsPtrToVarying(), lEmitStructDecl(), lRecursiveCheckValidParamType(), lVaryingStructHasUniformMember(), and StructType().
|
inline |
Returns the name of the i'th element of the structure.
Definition at line 696 of file type.h.
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 1888 of file type.cpp.
References elementNames.
Referenced by StructMemberExpr::getElementNumber().
|
inline |
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 1881 of file type.cpp.
References elementNames.
Referenced by checkInit(), GetDIType(), StructMemberExpr::getElementType(), StructMemberExpr::GetType(), IsDefined(), lCheckForConstStructMember(), lContainsPtrToVarying(), lEmitStructDecl(), lRecursiveCheckValidParamType(), lUniformValueToVarying(), lVaryingStructHasUniformMember(), and StructType().
|
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 1859 of file type.cpp.
References Assert, elementTypes, Module::errorCount, finalElementTypes, Type::GetAsConstType(), isConst, m, Type::ResolveUnboundVariability(), Variability::Unbound, and variability.
|
virtual |
Returns a text representation of the type (for example, for use in warning and error messages).
Implements Type.
Definition at line 1746 of file type.cpp.
References elementNames, elementTypes, Variability::GetString(), isConst, name, and variability.
Referenced by StructMemberExpr::getElementNumber(), StructMemberExpr::GetType(), lCheckForConstStructMember(), lVaryingStructHasUniformMember(), and AssignExpr::TypeCheck().
|
inline |
Returns the name of the structure type. (e.g. struct Foo -> "Foo".)
Definition at line 704 of file type.h.
Referenced by GetCStructName(), and lCheckTypeEquality().
|
virtual |
Returns the variability of the type.
Implements Type.
Definition at line 1641 of file type.cpp.
References variability.
|
virtual |
|
virtual |
bool StructType::IsDefined | ( | ) | const |
Definition at line 1653 of file type.cpp.
References GetElementCount(), GetElementType(), and IsDefined().
Referenced by MemberExpr::create(), IsDefined(), and NewExpr::TypeCheck().
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Returns the LLVM type corresponding to this ispc type.
Implements Type.
Definition at line 1809 of file type.cpp.
References Assert, Module::errorCount, lMangleStructName(), lStructTypeMap, m, name, Variability::Unbound, and variability.
Referenced by FunctionEmitContext::AddElementOffset(), and lEmitStructDecl().
|
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 1787 of file type.cpp.
References isConst, lMangleStruct(), name, and variability.
|
virtual |
Implements Type.
Definition at line 1707 of file type.cpp.
References Assert, elementNames, elementPositions, elementTypes, isConst, name, pos, StructType(), Variability::Unbound, and variability.
|
private |
Definition at line 722 of file type.h.
Referenced by checkIfCanBeSOA(), GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), GetDIType(), GetElementNumber(), GetElementType(), GetString(), and ResolveUnboundVariability().
|
private |
Source file position at which each structure element declaration appeared.
Definition at line 725 of file type.h.
Referenced by checkIfCanBeSOA(), GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), GetDIType(), ResolveUnboundVariability(), and StructType().
|
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 721 of file type.h.
Referenced by checkIfCanBeSOA(), GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), GetDIType(), GetElementType(), GetString(), ResolveUnboundVariability(), and StructType().
|
mutableprivate |
Definition at line 730 of file type.h.
Referenced by GetElementType(), and StructType().
|
private |
Definition at line 727 of file type.h.
Referenced by GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), GetCDeclaration(), GetElementType(), GetString(), IsConstType(), Mangle(), and ResolveUnboundVariability().
|
private |
Definition at line 710 of file type.h.
Referenced by GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), GetCStructName(), GetDIType(), GetString(), LLVMType(), Mangle(), ResolveUnboundVariability(), and StructType().
|
mutableprivate |
Definition at line 732 of file type.h.
Referenced by GetAsConstType(), GetAsNonConstType(), and StructType().
|
private |
Definition at line 728 of file type.h.
Referenced by GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), GetDIType(), and ResolveUnboundVariability().
|
private |
Definition at line 726 of file type.h.
Referenced by GetAsConstType(), GetAsNonConstType(), GetCDeclaration(), GetCStructName(), GetElementType(), GetString(), GetVariability(), LLVMType(), Mangle(), ResolveUnboundVariability(), and StructType().