Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Type Class Referenceabstract

Interface class that defines the type abstraction. More...

#include <type.h>

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

Public Member Functions

virtual bool IsBoolType () const =0
 
virtual bool IsFloatType () const =0
 
virtual bool IsIntType () const =0
 
virtual bool IsUnsignedType () const =0
 
bool IsPointerType () const
 
bool IsArrayType () const
 
bool IsReferenceType () const
 
bool IsVoidType () const
 
virtual bool IsConstType () const =0
 
bool IsNumericType () const
 
virtual Variability GetVariability () const =0
 
bool IsUniformType () const
 
bool IsVaryingType () const
 
bool IsSOAType () const
 
int GetSOAWidth () const
 
bool HasUnboundVariability () const
 
virtual const TypeResolveUnboundVariability (Variability v) const =0
 
virtual const TypeGetAsUniformType () const =0
 
virtual const TypeGetAsVaryingType () const =0
 
virtual const TypeGetAsUnboundVariabilityType () const =0
 
virtual const TypeGetAsSOAType (int width) const =0
 
virtual const TypeGetAsUnsignedType () const
 
virtual const TypeGetBaseType () const =0
 
virtual const TypeGetReferenceTarget () const
 
virtual const TypeGetAsConstType () const =0
 
virtual const TypeGetAsNonConstType () const =0
 
virtual std::string GetString () const =0
 
virtual std::string Mangle () const =0
 
virtual std::string GetCDeclaration (const std::string &name) const =0
 
virtual llvm::Type * LLVMType (llvm::LLVMContext *ctx) const =0
 
virtual llvm::Type * LLVMStorageType (llvm::LLVMContext *ctx) const
 
virtual llvm::DIType * GetDIType (llvm::DIScope *scope) const =0
 

Static Public Member Functions

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

const TypeId typeId
 

Protected Member Functions

 Type (TypeId id)
 

Detailed Description

Interface class that defines the type abstraction.

Abstract base class that defines the interface that must be implemented for all types in the language.

Definition at line 90 of file type.h.

Constructor & Destructor Documentation

◆ Type()

Type::Type ( TypeId  id)
inlineprotected

Definition at line 259 of file type.h.

Member Function Documentation

◆ Equal()

bool Type::Equal ( const Type a,
const Type b 
)
static

◆ EqualIgnoringConst()

bool Type::EqualIgnoringConst ( const Type a,
const Type b 
)
static

◆ GetAsConstType()

virtual const Type* Type::GetAsConstType ( ) const
pure virtual

◆ GetAsNonConstType()

virtual const Type* Type::GetAsNonConstType ( ) const
pure virtual

◆ GetAsSOAType()

virtual const Type* Type::GetAsSOAType ( int  width) const
pure virtual

◆ GetAsUnboundVariabilityType()

virtual const Type* Type::GetAsUnboundVariabilityType ( ) const
pure virtual

◆ GetAsUniformType()

virtual const Type* Type::GetAsUniformType ( ) const
pure virtual

◆ GetAsUnsignedType()

const Type * Type::GetAsUnsignedType ( ) const
virtual

If this is a signed integer type, return the unsigned version of the type. Otherwise, return the original type.

Reimplemented in VectorType, ArrayType, and AtomicType.

Definition at line 2569 of file type.cpp.

Referenced by ArrayType::GetAsUnsignedType(), lApplyTypeQualifiers(), and lDeclareSizeAndPtrIntTypes().

◆ GetAsVaryingType()

virtual const Type* Type::GetAsVaryingType ( ) const
pure virtual

◆ GetBaseType()

virtual const Type* Type::GetBaseType ( ) const
pure virtual

◆ GetCDeclaration()

virtual std::string Type::GetCDeclaration ( const std::string &  name) const
pure virtual

◆ GetDIType()

virtual llvm::DIType* Type::GetDIType ( llvm::DIScope *  scope) const
pure virtual

◆ GetReferenceTarget()

const Type * Type::GetReferenceTarget ( ) const
virtual

◆ GetSOAWidth()

int Type::GetSOAWidth ( ) const
inline

◆ GetString()

virtual std::string Type::GetString ( ) const
pure virtual

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

Implemented in FunctionType, ReferenceType, UndefinedStructType, StructType, VectorType, ArrayType, PointerType, EnumType, and AtomicType.

Referenced by StructType::checkIfCanBeSOA(), MemberExpr::create(), FunctionEmitContext::CurrentLanesReturned(), ReturnStmt::EmitCode(), emitOffloadParamStruct(), DeclSpecs::GetBaseType(), FunctionType::GetCDeclaration(), FunctionType::GetCDeclarationForDispatch(), FunctionSymbolExpr::GetConstant(), FunctionType::GetReturnTypeString(), PointerType::GetString(), ArrayType::GetString(), ReferenceType::GetString(), FunctionCallExpr::GetValue(), Declarator::InitFromDeclSpecs(), Declarator::InitFromType(), InitSymbol(), lApplyTypeQualifiers(), lCheckForConstStructMember(), lCreateBinaryOperatorCall(), lDoTypeConv(), lGetConstExprConstant(), lGetExprListConstant(), FunctionEmitContext::LoadInst(), lProcessPrintArg(), lVaryingStructHasUniformMember(), lVectorConvert(), MoreGeneralType(), DeclSpecs::Print(), SymbolTable::Print(), ForeachActiveStmt::Print(), ForeachUniqueStmt::Print(), SizeOfExpr::Print(), NewExpr::Print(), FunctionEmitContext::StoreInst(), UnaryExpr::TypeCheck(), BinaryExpr::TypeCheck(), AssignExpr::TypeCheck(), FunctionCallExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), IndexExpr::TypeCheck(), TypeCastExpr::TypeCheck(), DeleteStmt::TypeCheck(), PtrDerefExpr::TypeCheck(), SizeOfExpr::TypeCheck(), NewExpr::TypeCheck(), TypeConvertExpr(), and Module::writeDevStub().

◆ GetVariability()

virtual Variability Type::GetVariability ( ) const
pure virtual

◆ HasUnboundVariability()

bool Type::HasUnboundVariability ( ) const
inline

◆ IsArrayType()

bool Type::IsArrayType ( ) const

Returns true if the underlying type is a array type

Definition at line 163 of file type.cpp.

Referenced by emitOffloadParamStruct(), lEmitStructDecl(), Module::writeDevStub(), and Module::writeHostStub().

◆ IsBasicType()

bool Type::IsBasicType ( const Type type)
static

Returns true if the given type is an atomic, enum, or pointer type (i.e. not an aggregation of multiple instances of a type or types.)

Definition at line 2762 of file type.cpp.

Referenced by FunctionEmitContext::addVaryingOffsetsIfNeeded(), PointerType::GetCDeclaration(), InitSymbol(), lAddVaryingOffsetsIfNeeded(), lFinalSliceOffset(), lMatchingBoolType(), FunctionEmitContext::maskedStore(), FunctionEmitContext::scatter(), FunctionEmitContext::storeUniformToSOA(), and ForeachUniqueStmt::TypeCheck().

◆ IsBoolType()

virtual bool Type::IsBoolType ( ) const
pure 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.

Implemented in FunctionType, ReferenceType, UndefinedStructType, StructType, VectorType, ArrayType, PointerType, EnumType, and AtomicType.

Referenced by FunctionEmitContext::AllocaInst(), TypeCastExpr::GetValue(), ReferenceType::IsBoolType(), lDoTypeConv(), FunctionEmitContext::LoadInst(), lUniformValueToVarying(), FunctionEmitContext::scatter(), FunctionEmitContext::StoreInst(), and BinaryExpr::TypeCheck().

◆ IsConstType()

virtual bool Type::IsConstType ( ) const
pure virtual

◆ IsFloatType()

virtual bool Type::IsFloatType ( ) const
pure 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.

Implemented in FunctionType, ReferenceType, UndefinedStructType, StructType, VectorType, ArrayType, PointerType, EnumType, and AtomicType.

Referenced by ReferenceType::IsFloatType(), lEmitBinaryArith(), lEmitBinaryCmp(), lEmitNegate(), lEmitPrePostIncDec(), BinaryExpr::TypeCheck(), and AssignExpr::TypeCheck().

◆ IsIntType()

virtual bool Type::IsIntType ( ) const
pure 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.

Implemented in FunctionType, ReferenceType, UndefinedStructType, StructType, VectorType, ArrayType, PointerType, EnumType, and AtomicType.

Referenced by ReferenceType::IsIntType(), lApplyTypeQualifiers(), lEmitNegate(), lIsAllIntZeros(), UnaryExpr::TypeCheck(), and BinaryExpr::TypeCheck().

◆ IsNumericType()

bool Type::IsNumericType ( ) const
inline

Returns true if the underlying type is a float or integer type.

Definition at line 128 of file type.h.

Referenced by UnaryExpr::TypeCheck(), and BinaryExpr::TypeCheck().

◆ IsPointerType()

bool Type::IsPointerType ( ) const

Returns true if the underlying type is either a pointer type

Definition at line 161 of file type.cpp.

Referenced by emitOffloadParamStruct(), FunctionCallExpr::GetLValueType(), lEmitStructDecl(), lGetVaryingDispatchType(), Module::writeDevStub(), and Module::writeHostStub().

◆ IsReferenceType()

bool Type::IsReferenceType ( ) const

Returns true if the underlying type is a array type

Definition at line 165 of file type.cpp.

Referenced by emitOffloadParamStruct(), FunctionCallExpr::GetLValueType(), lMatchingBoolType(), and Module::writeDevStub().

◆ IsSOAType()

bool Type::IsSOAType ( ) const
inline

◆ IsUniformType()

bool Type::IsUniformType ( ) const
inline

Returns true if the underlying type is uniform

Definition at line 134 of file type.h.

References Variability::Uniform.

Referenced by FunctionEmitContext::AddElementOffset(), Module::AddFunctionDeclaration(), StructType::checkIfCanBeSOA(), FunctionSymbolExpr::computeOverloadCost(), ConstExpr::ConstExpr(), FunctionEmitContext::CurrentLanesReturned(), DeclSpecs::DeclSpecs(), DeclStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ReturnStmt::EmitCode(), SwitchStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IfStmt::EstimateCost(), DoStmt::EstimateCost(), ForStmt::EstimateCost(), FunctionCallExpr::EstimateCost(), FunctionEmitContext::gather(), EnumType::GetAsUniformType(), StructType::GetAsUniformType(), ReferenceType::GetAsUniformType(), DeclSpecs::GetBaseType(), VectorType::GetDIType(), FunctionEmitContext::GetElementPtrInst(), IndexExpr::GetLValueType(), StructMemberExpr::GetLValueType(), VectorMemberExpr::GetLValueType(), GetStructTypesNamesPositions(), IndexExpr::GetType(), PtrDerefExpr::GetType(), StructMemberExpr::GetType(), VectorMemberExpr::GetType(), SelectExpr::GetValue(), TypeCastExpr::GetValue(), VectorMemberExpr::GetValue(), VectorType::getVectorMemoryCount(), lAddVaryingOffsetsIfNeeded(), lCheckAllOffSafety(), lCheckTypeEquality(), lConstFoldBinaryLogicalOp(), lConvertPointerConstant(), lDoTypeConv(), lEmitBinaryPointerArith(), lEmitLogicalOp(), lEmitPrePostIncDec(), lEmitVectorTypedefs(), lEncodeType(), lFinalSliceOffset(), lGetConstExprConstant(), lGetExprListConstant(), lGetVectorLLVMType(), lIsDifficultShiftAmount(), lIsMatchWithTypeWidening(), lLLVMConstantValue(), lMatchingBoolType(), FunctionEmitContext::LoadInst(), lProcessPrintArg(), lTypeConvAtomic(), lUniformValueToVarying(), lVaryingStructHasUniformMember(), FunctionEmitContext::maskedStore(), FunctionEmitContext::scatter(), FunctionEmitContext::StoreInst(), IfStmt::TypeCheck(), DoStmt::TypeCheck(), BinaryExpr::TypeCheck(), ForStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), IndexExpr::TypeCheck(), SwitchStmt::TypeCheck(), TypeCastExpr::TypeCheck(), and AssertStmt::TypeCheck().

◆ IsUnsignedType()

virtual bool Type::IsUnsignedType ( ) const
pure 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.

Implemented in FunctionType, ReferenceType, UndefinedStructType, StructType, VectorType, ArrayType, PointerType, EnumType, and AtomicType.

Referenced by BinaryExpr::GetValue(), ReferenceType::IsUnsignedType(), lEmitBinaryArith(), lEmitBinaryCmp(), and lEmitOpAssign().

◆ IsVaryingType()

bool Type::IsVaryingType ( ) const
inline

Returns true if the underlying type is varying

Definition at line 137 of file type.h.

References Variability::Varying.

Referenced by FunctionEmitContext::addVaryingOffsetsIfNeeded(), FunctionSymbolExpr::computeOverloadCost(), ConstExpr::Count(), DeclSpecs::DeclSpecs(), IndexExpr::EstimateCost(), MemberExpr::EstimateCost(), SwitchStmt::EstimateCost(), PtrDerefExpr::EstimateCost(), FunctionEmitContext::gather(), EnumType::GetAsVaryingType(), StructType::GetAsVaryingType(), ReferenceType::GetAsVaryingType(), DeclSpecs::GetBaseType(), PointerType::GetCDeclaration(), ArrayType::GetCDeclaration(), FunctionType::GetCDeclarationForDispatch(), SizeOfExpr::GetConstant(), VectorType::GetDIType(), FunctionEmitContext::GetElementPtrInst(), IndexExpr::GetLValueType(), GetStructTypesNamesPositions(), BinaryExpr::GetType(), SelectExpr::GetType(), StructMemberExpr::GetType(), VectorMemberExpr::GetType(), FunctionCallExpr::GetValue(), IndexExpr::GetValue(), ConstExpr::GetValue(), TypeCastExpr::GetValue(), VectorType::getVectorMemoryCount(), InitSymbol(), lAddVaryingOffsetsIfNeeded(), lContainsPtrToVarying(), lConvertPointerConstant(), lDoTypeConv(), lEmitBinaryArith(), lEmitBinaryCmp(), lEmitBinaryPointerArith(), lEmitLogicalOp(), lEmitStructDecl(), lGetConstExprConstant(), lGetExprListConstant(), lGetVaryingDispatchType(), lGetVectorLLVMType(), lIsDifficultShiftAmount(), lIsVaryingFor(), FunctionEmitContext::LoadInst(), lRecursiveCheckValidParamType(), lTypeConvAtomic(), lUniformValueToVarying(), lVaryingStructHasUniformMember(), FunctionEmitContext::maskedStore(), MoreGeneralType(), SelectExpr::Optimize(), TypeCastExpr::Optimize(), FunctionEmitContext::scatter(), FunctionEmitContext::StoreInst(), BinaryExpr::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), FunctionCallExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), and NewExpr::TypeCheck().

◆ IsVoidType()

bool Type::IsVoidType ( ) const

◆ LLVMStorageType()

llvm::Type * Type::LLVMStorageType ( llvm::LLVMContext *  ctx) const
virtual

◆ LLVMType()

virtual llvm::Type* Type::LLVMType ( llvm::LLVMContext *  ctx) const
pure virtual

◆ Mangle()

virtual std::string Type::Mangle ( ) const
pure 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.

Implemented in FunctionType, ReferenceType, UndefinedStructType, StructType, VectorType, ArrayType, PointerType, EnumType, and AtomicType.

Referenced by PointerType::Mangle(), ArrayType::Mangle(), and ReferenceType::Mangle().

◆ MoreGeneralType()

const Type * Type::MoreGeneralType ( const Type type0,
const Type type1,
SourcePos  pos,
const char *  reason,
bool  forceVarying = false,
int  vecSize = 0 
)
static

Given two types, returns the least general Type that is more general than both of them. (i.e. that can represent their values without any loss of data.) If there is no such Type, return NULL.

Parameters
type0First of the two types
type1Second of the two types
posSource file position where the general type is needed.
reasonString describing the context of why the general type is needed (e.g. "+ operator").
forceVaryingIf true, then make sure that the returned type is "varying".
vecSizeThe vector size of the returned type. If non-zero, the returned type will be a VectorType of the more general type with given length. If zero, this parameter has no effect.
Returns
The more general type, based on the provided parameters.
Todo:
the vecSize and forceVarying parts of this should probably be factored out and done separately in the cases when needed.

Definition at line 2602 of file type.cpp.

References Assert, Equal(), EqualIgnoringConst(), Error(), GetAsNonConstType(), GetAsVaryingType(), VectorType::GetElementCount(), VectorType::GetElementType(), GetReferenceTarget(), GetString(), PointerType::GetUniform(), IsVaryingType(), PointerType::IsVoidPointer(), lVectorConvert(), AtomicType::UniformUInt32, and AtomicType::VaryingUInt32.

Referenced by BinaryExpr::GetType(), SelectExpr::GetType(), lEmitLogicalOp(), BinaryExpr::TypeCheck(), and SelectExpr::TypeCheck().

◆ ResolveUnboundVariability()

virtual const Type* Type::ResolveUnboundVariability ( Variability  v) const
pure virtual

Member Data Documentation

◆ typeId

const TypeId Type::typeId

Indicates which Type implementation this type is. This value can be used to determine the actual type much more efficiently than using dynamic_cast.

Definition at line 256 of file type.h.

Referenced by CastType().


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