Intel SPMD Program Compiler  1.3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions
Type Class Reference

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]

List of all members.

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


Constructor & Destructor Documentation

Type::Type ( TypeId  id) [inline, protected]

Definition at line 269 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]

Checks two types for equality. Returns true if they are exactly the same (ignoring const-ness of the type), false otherwise.

Definition at line 3309 of file type.cpp.

References lCheckTypeEquality().

Referenced by TypeCastExpr::GetValue(), PointerType::IsVoidPointer(), lDoTypeConv(), lEmitBinaryArith(), lEmitStructDecl(), lIsMatchWithUniformToVarying(), MoreGeneralType(), UnaryExpr::Optimize(), BinaryExpr::Optimize(), FunctionEmitContext::storeUniformToSOA(), IndexExpr::TypeCheck(), and SwitchStmt::TypeCheck().

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

References NULL.

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

References NULL.

Referenced by emitOffloadParamStruct(), 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 3193 of file type.cpp.

References NULL.

Referenced by FunctionEmitContext::addVaryingOffsetsIfNeeded(), InitSymbol(), lAddVaryingOffsetsIfNeeded(), lFinalSliceOffset(), 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(), BinaryExpr::TypeCheck(), DoStmt::TypeCheck(), ForStmt::TypeCheck(), and AssertStmt::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 134 of file type.h.

References IsFloatType(), and IsIntType().

Referenced by UnaryExpr::TypeCheck(), BinaryExpr::TypeCheck(), DoStmt::TypeCheck(), ForStmt::TypeCheck(), and AssertStmt::TypeCheck().

bool Type::IsPointerType ( ) const

Returns true if the underlying type is either a pointer type

Definition at line 204 of file type.cpp.

References NULL.

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

bool Type::IsReferenceType ( ) const

Returns true if the underlying type is a array type

Definition at line 215 of file type.cpp.

References NULL.

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

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

Returns true if the underlying type is uniform

Definition at line 140 of file type.h.

References GetVariability(), and Variability::Uniform.

Referenced by FunctionEmitContext::AddElementOffset(), Module::AddFunctionDeclaration(), StructType::checkIfCanBeSOA(), ConstExpr::ConstExpr(), FunctionEmitContext::CurrentLanesReturned(), DeclStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ReturnStmt::EmitCode(), SwitchStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IfStmt::EstimateCost(), DoStmt::EstimateCost(), ForStmt::EstimateCost(), FunctionCallExpr::EstimateCost(), 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(), lAddVaryingOffsetsIfNeeded(), lCheckTypeEquality(), lConstFoldBinLogicalOp(), lConvertPointerConstant(), lDoTypeConv(), lEmitBinaryPointerArith(), lEmitLogicalOp(), lEmitPrePostIncDec(), lEmitVectorTypedefs(), lEncodeType(), lFinalSliceOffset(), lIsMatchWithTypeWidening(), lIsMatchWithUniformToVarying(), lLLVMConstantValue(), VectorType::LLVMType(), lMatchingBoolType(), FunctionEmitContext::LoadInst(), lProcessPrintArg(), lTypeConvAtomic(), lVaryingStructHasUniformMember(), FunctionEmitContext::maskedStore(), FunctionEmitContext::scatter(), FunctionEmitContext::StoreInst(), IfStmt::TypeCheck(), BinaryExpr::TypeCheck(), DoStmt::TypeCheck(), ForStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), IndexExpr::TypeCheck(), SwitchStmt::TypeCheck(), AssertStmt::TypeCheck(), and TypeCastExpr::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 145 of file type.h.

References GetVariability(), and Variability::Varying.

Referenced by FunctionEmitContext::addVaryingOffsetsIfNeeded(), ConstExpr::Count(), IndexExpr::EstimateCost(), MemberExpr::EstimateCost(), SwitchStmt::EstimateCost(), PtrDerefExpr::EstimateCost(), FunctionEmitContext::gather(), EnumType::GetAsVaryingType(), StructType::GetAsVaryingType(), ReferenceType::GetAsVaryingType(), DeclSpecs::GetBaseType(), ConstExpr::GetConstant(), VectorType::GetDIType(), FunctionEmitContext::GetElementPtrInst(), IndexExpr::GetLValueType(), GetStructTypesNamesPositions(), BinaryExpr::GetType(), SelectExpr::GetType(), StructMemberExpr::GetType(), VectorMemberExpr::GetType(), BinaryExpr::GetValue(), FunctionCallExpr::GetValue(), IndexExpr::GetValue(), ConstExpr::GetValue(), TypeCastExpr::GetValue(), VectorType::getVectorMemoryCount(), lAddVaryingOffsetsIfNeeded(), lConvertPointerConstant(), lDoTypeConv(), lEmitBinaryArith(), lEmitBinaryCmp(), lEmitBinaryPointerArith(), lEmitLogicalOp(), lIsMatchWithUniformToVarying(), 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(), and NewExpr::TypeCheck().

bool Type::IsVoidType ( ) const

Returns true if the underlying type is either a pointer or an array

Definition at line 220 of file type.cpp.

Referenced by Module::writeDevStub().

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 3027 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 NULL.

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

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

Referenced by CastType().


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