Intel SPMD Program Compiler  1.9.1
Public Member Functions | Public Attributes | Private Attributes | List of all members
FunctionType Class Reference

Type representing a function (return type + argument types) More...

#include <type.h>

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

Public Member Functions

 FunctionType (const Type *returnType, const llvm::SmallVector< const Type *, 8 > &argTypes, SourcePos pos)
 
 FunctionType (const Type *returnType, const llvm::SmallVector< const Type *, 8 > &argTypes, const llvm::SmallVector< std::string, 8 > &argNames, const llvm::SmallVector< Expr *, 8 > &argDefaults, const llvm::SmallVector< SourcePos, 8 > &argPos, bool isTask, bool isExported, bool isExternC, bool isUnmasked)
 
Variability GetVariability () const
 
bool IsBoolType () const
 
bool IsFloatType () const
 
bool IsIntType () const
 
bool IsUnsignedType () const
 
bool IsConstType () const
 
const TypeGetBaseType () const
 
const TypeGetAsVaryingType () const
 
const TypeGetAsUniformType () const
 
const TypeGetAsUnboundVariabilityType () const
 
const TypeGetAsSOAType (int width) const
 
const FunctionTypeResolveUnboundVariability (Variability v) const
 
const TypeGetAsConstType () const
 
const TypeGetAsNonConstType () const
 
std::string GetString () const
 
std::string Mangle () const
 
std::string GetCDeclaration (const std::string &fname) const
 
std::string GetCDeclarationForDispatch (const std::string &fname) const
 
llvm::Type * LLVMType (llvm::LLVMContext *ctx) const
 
llvm::DIType GetDIType (llvm::DIDescriptor scope) const
 
const TypeGetReturnType () const
 
const std::string GetReturnTypeString () const
 
llvm::FunctionType * LLVMFunctionType (llvm::LLVMContext *ctx, bool disableMask=false) const
 
int GetNumParameters () const
 
const TypeGetParameterType (int i) const
 
ExprGetParameterDefault (int i) const
 
const SourcePosGetParameterSourcePos (int i) const
 
const std::string & GetParameterName (int i) 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
 

Public Attributes

const bool isTask
 
const bool isExported
 
const bool isExternC
 
const bool isUnmasked
 
bool isSafe
 
int costOverride
 
- Public Attributes inherited from Type
const TypeId typeId
 

Private Attributes

const Type *const returnType
 
const llvm::SmallVector< const Type *, 8 > paramTypes
 
const llvm::SmallVector< std::string, 8 > paramNames
 
llvm::SmallVector< Expr *, 8 > paramDefaults
 
const llvm::SmallVector< SourcePos, 8 > paramPositions
 

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

Detailed Description

Type representing a function (return type + argument types)

FunctionType encapsulates the information related to a function's type, including the return type and the types of the arguments.

Todo:
This class has a fair number of methods inherited from Type that don't make sense here (e.g. IsUniformType(), GetBaseType(), LLVMType(), etc. Would be nice to refactor the inheritance hierarchy to move most of those interface methods to a sub-class of Type, which in turn all of the other Type implementations inherit from.

Definition at line 883 of file type.h.

Constructor & Destructor Documentation

FunctionType::FunctionType ( const Type returnType,
const llvm::SmallVector< const Type *, 8 > &  argTypes,
SourcePos  pos 
)

Definition at line 2868 of file type.cpp.

References Assert, costOverride, isSafe, and returnType.

Referenced by ResolveUnboundVariability().

FunctionType::FunctionType ( const Type returnType,
const llvm::SmallVector< const Type *, 8 > &  argTypes,
const llvm::SmallVector< std::string, 8 > &  argNames,
const llvm::SmallVector< Expr *, 8 > &  argDefaults,
const llvm::SmallVector< SourcePos, 8 > &  argPos,
bool  isTask,
bool  isExported,
bool  isExternC,
bool  isUnmasked 
)

Definition at line 2882 of file type.cpp.

References Assert, costOverride, isSafe, paramDefaults, paramNames, paramPositions, paramTypes, and returnType.

Member Function Documentation

const Type * FunctionType::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 2999 of file type.cpp.

const Type * FunctionType::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 3005 of file type.cpp.

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

Implements Type.

Definition at line 2965 of file type.cpp.

References FATAL.

const Type * FunctionType::GetAsUnboundVariabilityType ( ) const
virtual

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 2958 of file type.cpp.

References FATAL.

const Type * FunctionType::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 2951 of file type.cpp.

References FATAL.

const Type * FunctionType::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 2944 of file type.cpp.

References FATAL.

const Type * FunctionType::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 2937 of file type.cpp.

References FATAL.

std::string FunctionType::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 3045 of file type.cpp.

References PointerType::GetBaseType(), Type::GetCDeclaration(), Type::GetString(), paramNames, paramTypes, and returnType.

Referenced by lPrintFunctionDeclarations(), and Module::writeHostStub().

std::string FunctionType::GetCDeclarationForDispatch ( const std::string &  fname) const
llvm::DIType FunctionType::GetDIType ( llvm::DIDescriptor  scope) const
virtual

Returns the DIType (LLVM's debugging information structure), corresponding to this type.

Implements Type.

Definition at line 3125 of file type.cpp.

References Module::diBuilder, Type::GetDIType(), GetNumParameters(), GetParameterType(), m, and returnType.

Referenced by FunctionEmitContext::FunctionEmitContext().

int FunctionType::GetNumParameters ( ) const
inline
Expr * FunctionType::GetParameterDefault ( int  i) const
const std::string & FunctionType::GetParameterName ( int  i) const
const SourcePos & FunctionType::GetParameterSourcePos ( int  i) const

Definition at line 3284 of file type.cpp.

References Assert, and paramPositions.

Referenced by Module::AddFunctionDeclaration().

const Type * FunctionType::GetParameterType ( int  i) const
const Type* FunctionType::GetReturnType ( ) const
inline
const std::string FunctionType::GetReturnTypeString ( ) const
std::string FunctionType::GetString ( ) const
virtual

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

Implements Type.

Definition at line 3011 of file type.cpp.

References GetReturnTypeString(), and paramTypes.

Referenced by Function::emitCode(), lCreateSymbol(), and lGetOverloadCandidateMessage().

Variability FunctionType::GetVariability ( ) const
virtual

Returns the variability of the type.

Implements Type.

Definition at line 2901 of file type.cpp.

References Variability::Uniform.

bool FunctionType::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 2919 of file type.cpp.

bool FunctionType::IsConstType ( ) const
virtual

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

Implements Type.

Definition at line 2931 of file type.cpp.

bool FunctionType::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 2907 of file type.cpp.

bool FunctionType::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 2913 of file type.cpp.

bool FunctionType::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 2925 of file type.cpp.

llvm::FunctionType * FunctionType::LLVMFunctionType ( llvm::LLVMContext *  ctx,
bool  disableMask = false 
) const

This method returns the LLVM FunctionType that corresponds to this function type. The disableMask parameter indicates whether the llvm::FunctionType should have the trailing mask parameter, if present, removed from the return function signature.

Definition at line 3203 of file type.cpp.

References Assert, Globals::ctx, Module::errorCount, g, Target::getISA(), LLVMTypes::Int32Type, isTask, isUnmasked, Type::IsVoidType(), Type::LLVMType(), m, LLVMTypes::MaskType, paramTypes, returnType, and Globals::target.

Referenced by Module::AddFunctionDeclaration(), FunctionEmitContext::CallInst(), Function::GenerateIR(), and PointerType::LLVMType().

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

Returns the LLVM type corresponding to this ispc type

Implements Type.

Definition at line 3118 of file type.cpp.

References FATAL.

std::string FunctionType::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 3029 of file type.cpp.

References Assert, Module::errorCount, isUnmasked, m, and paramTypes.

Referenced by Module::AddFunctionDeclaration().

const FunctionType * FunctionType::ResolveUnboundVariability ( Variability  v) const
virtual

Member Data Documentation

int FunctionType::costOverride

If non-negative, this provides a user-supplied override to the cost function estimate for the function.

Definition at line 964 of file type.h.

Referenced by FunctionCallExpr::EstimateCost(), FunctionType(), GetReturnTypeString(), and ResolveUnboundVariability().

const bool FunctionType::isExported

This value is true if the function had a 'export' qualifier in the source program.

Definition at line 947 of file type.h.

Referenced by Module::AddFunctionDeclaration(), Function::emitCode(), Function::GenerateIR(), GetReturnTypeString(), lCheckTypeEquality(), lIsExported(), and ResolveUnboundVariability().

const bool FunctionType::isExternC

This value is true if the function was declared as an 'extern "C"' function in the source program.

Definition at line 951 of file type.h.

Referenced by Module::AddFunctionDeclaration(), GetReturnTypeString(), lCheckTypeEquality(), lIsExternC(), and ResolveUnboundVariability().

bool FunctionType::isSafe

Indicates whether this function has been declared to be safe to run with an all-off mask.

Definition at line 960 of file type.h.

Referenced by FunctionType(), GetReturnTypeString(), lCheckAllOffSafety(), and ResolveUnboundVariability().

const bool FunctionType::isTask
const bool FunctionType::isUnmasked

Indicates whether the function doesn't take an implicit mask parameter (and thus should start execution with an "all on" mask).

Definition at line 956 of file type.h.

Referenced by Function::emitCode(), GetReturnTypeString(), lCheckTypeEquality(), LLVMFunctionType(), Mangle(), and ResolveUnboundVariability().

llvm::SmallVector<Expr *, 8> FunctionType::paramDefaults
mutableprivate

Default values of the function's arguments. For arguments without default values provided, NULL is stored.

Definition at line 975 of file type.h.

Referenced by FunctionType(), GetParameterDefault(), and ResolveUnboundVariability().

const llvm::SmallVector<std::string, 8> FunctionType::paramNames
private
const llvm::SmallVector<SourcePos, 8> FunctionType::paramPositions
private

The names provided (if any) with the function arguments in the function's signature. These should only be used for error messages and the like and so not affect testing function types for equality, etc.

Definition at line 980 of file type.h.

Referenced by FunctionType(), GetParameterSourcePos(), and ResolveUnboundVariability().

const llvm::SmallVector<const Type *, 8> FunctionType::paramTypes
private
const Type* const FunctionType::returnType
private

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