Intel SPMD Program Compiler  1.9.1
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::DIType GetDIType (llvm::DIDescriptor 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 101 of file type.h.

Constructor & Destructor Documentation

Type::Type ( TypeId  id)
inlineprotected

Definition at line 280 of file type.h.

Member Function Documentation

bool Type::Equal ( const Type a,
const Type b 
)
static
bool Type::EqualIgnoringConst ( const Type a,
const Type b 
)
static
virtual const Type* Type::GetAsConstType ( ) const
pure virtual
virtual const Type* Type::GetAsNonConstType ( ) const
pure virtual
virtual const Type* Type::GetAsSOAType ( int  width) const
pure virtual
virtual const Type* Type::GetAsUnboundVariabilityType ( ) const
pure virtual
virtual const Type* Type::GetAsUniformType ( ) const
pure virtual
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 ArrayType, and AtomicType.

Definition at line 3308 of file type.cpp.

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

virtual const Type* Type::GetAsVaryingType ( ) const
pure virtual
virtual const Type* Type::GetBaseType ( ) const
pure virtual
virtual std::string Type::GetCDeclaration ( const std::string &  name) const
pure virtual
virtual llvm::DIType Type::GetDIType ( llvm::DIDescriptor  scope) const
pure virtual
const Type * Type::GetReferenceTarget ( ) const
virtual
int Type::GetSOAWidth ( ) const
inline
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(), ExprList::GetConstant(), ConstExpr::GetConstant(), FunctionSymbolExpr::GetConstant(), FunctionType::GetReturnTypeString(), PointerType::GetString(), ArrayType::GetString(), ReferenceType::GetString(), FunctionCallExpr::GetValue(), Declarator::InitFromDeclSpecs(), Declarator::InitFromType(), InitSymbol(), lApplyTypeQualifiers(), lCheckForConstStructMember(), lCreateBinaryOperatorCall(), lDoTypeConv(), 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(), IndexExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), TypeCastExpr::TypeCheck(), PtrDerefExpr::TypeCheck(), DeleteStmt::TypeCheck(), SizeOfExpr::TypeCheck(), NewExpr::TypeCheck(), TypeConvertExpr(), and Module::writeDevStub().

virtual Variability Type::GetVariability ( ) const
pure virtual
bool Type::HasUnboundVariability ( ) const
inline
bool Type::IsArrayType ( ) const

Returns true if the underlying type is a array type

Definition at line 236 of file type.cpp.

Referenced by Module::AddGlobalVariable(), DeclStmt::EmitCode(), emitOffloadParamStruct(), Declarator::InitFromType(), lEmitStructDecl(), Module::writeDevStub(), and Module::writeHostStub().

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

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

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 TypeCastExpr::GetValue(), ReferenceType::IsBoolType(), lDoTypeConv(), and BinaryExpr::TypeCheck().

virtual bool Type::IsConstType ( ) const
pure virtual
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(), IsNumericType(), lEmitBinaryArith(), lEmitBinaryCmp(), lEmitNegate(), lEmitPrePostIncDec(), BinaryExpr::TypeCheck(), and AssignExpr::TypeCheck().

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(), IsNumericType(), lApplyTypeQualifiers(), lEmitNegate(), lIsAllIntZeros(), UnaryExpr::TypeCheck(), and BinaryExpr::TypeCheck().

bool Type::IsNumericType ( ) const
inline

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

Definition at line 139 of file type.h.

References IsFloatType(), and IsIntType().

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

bool Type::IsPointerType ( ) const

Returns true if the underlying type is either a pointer type

Definition at line 230 of file type.cpp.

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

bool Type::IsReferenceType ( ) const

Returns true if the underlying type is a array type

Definition at line 241 of file type.cpp.

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

bool Type::IsSOAType ( ) const
inline
bool Type::IsUniformType ( ) const
inline

Returns true if the underlying type is uniform

Definition at line 145 of file type.h.

References GetVariability(), and 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(), ExprList::GetConstant(), ConstExpr::GetConstant(), 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(), Declarator::InitFromType(), lAddVaryingOffsetsIfNeeded(), lCheckAllOffSafety(), lCheckTypeEquality(), lConstFoldBinaryLogicalOp(), lConvertPointerConstant(), lDoTypeConv(), lEmitBinaryPointerArith(), lEmitLogicalOp(), lEmitPrePostIncDec(), lEmitVectorTypedefs(), lEncodeType(), lFinalSliceOffset(), lIsDifficultShiftAmount(), lIsMatchWithTypeWidening(), lLLVMConstantValue(), VectorType::LLVMType(), lMatchingBoolType(), FunctionEmitContext::LoadInst(), lProcessPrintArg(), lTypeConvAtomic(), lUniformValueToVarying(), lVaryingStructHasUniformMember(), FunctionEmitContext::maskedStore(), FunctionEmitContext::scatter(), FunctionEmitContext::StoreInst(), IfStmt::TypeCheck(), BinaryExpr::TypeCheck(), DoStmt::TypeCheck(), ForStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), IndexExpr::TypeCheck(), SwitchStmt::TypeCheck(), TypeCastExpr::TypeCheck(), and AssertStmt::TypeCheck().

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().

bool Type::IsVaryingType ( ) const
inline

Returns true if the underlying type is varying

Definition at line 150 of file type.h.

References GetVariability(), and Variability::Varying.

Referenced by Module::AddGlobalVariable(), FunctionEmitContext::addVaryingOffsetsIfNeeded(), FunctionSymbolExpr::computeOverloadCost(), ConstExpr::Count(), DeclSpecs::DeclSpecs(), DeclStmt::EmitCode(), IndexExpr::EstimateCost(), MemberExpr::EstimateCost(), SwitchStmt::EstimateCost(), PtrDerefExpr::EstimateCost(), FunctionEmitContext::gather(), EnumType::GetAsVaryingType(), StructType::GetAsVaryingType(), ReferenceType::GetAsVaryingType(), DeclSpecs::GetBaseType(), PointerType::GetCDeclaration(), ArrayType::GetCDeclaration(), FunctionType::GetCDeclarationForDispatch(), ConstExpr::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(), lAddVaryingOffsetsIfNeeded(), lContainsPtrToVarying(), lConvertPointerConstant(), lDoTypeConv(), lEmitBinaryArith(), lEmitBinaryCmp(), lEmitBinaryPointerArith(), lEmitLogicalOp(), lEmitStructDecl(), lGetVaryingDispatchType(), lIsDifficultShiftAmount(), lIsVaryingFor(), VectorType::LLVMType(), 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(), SizeOfExpr::TypeCheck(), and NewExpr::TypeCheck().

bool Type::IsVoidType ( ) const
virtual llvm::Type* Type::LLVMType ( llvm::LLVMContext *  ctx) const
pure virtual
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().

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

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

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

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

Member Data Documentation

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 277 of file type.h.

Referenced by CastType().


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