Intel SPMD Program Compiler  1.3.0
Public Member Functions | Public Attributes | Private Attributes
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]

List of all members.

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
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 Attributes

const bool isTask
const bool isExported
const bool isExternC
const bool isUnmasked
bool isSafe
int costOverride

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

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


Constructor & Destructor Documentation

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

Definition at line 2635 of file type.cpp.

References Assert, costOverride, isSafe, NULL, 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 
)

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

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

Implements Type.

Definition at line 2732 of file type.cpp.

References FATAL, and NULL.

const Type * FunctionType::GetAsUnboundVariabilityType ( ) const [virtual]

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 2725 of file type.cpp.

References FATAL, and NULL.

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

References FATAL, and NULL.

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

References FATAL, and NULL.

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

References FATAL, and NULL.

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

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

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

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

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

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

References GetReturnTypeString(), NULL, and paramTypes.

Referenced by lCreateSymbol(), and lPrintOverloadCandidates().

Variability FunctionType::GetVariability ( ) const [virtual]

Returns the variability of the type.

Implements Type.

Definition at line 2668 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 2686 of file type.cpp.

bool FunctionType::IsConstType ( ) const [virtual]

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

Implements Type.

Definition at line 2698 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 2674 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 2680 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 2692 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 2897 of file type.cpp.

References Assert, Globals::ctx, Type::Equal(), Module::errorCount, g, LLVMTypes::Int32Type, isTask, isUnmasked, Type::LLVMType(), m, LLVMTypes::MaskType, NULL, paramTypes, and returnType.

Referenced by Module::AddFunctionDeclaration(), FunctionEmitContext::CallInst(), 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 2843 of file type.cpp.

References FATAL, and NULL.

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

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

Referenced by Module::AddFunctionDeclaration().

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

Member Data Documentation

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

Definition at line 911 of file type.h.

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

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

Definition at line 894 of file type.h.

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

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

Definition at line 898 of file type.h.

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

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

Definition at line 907 of file type.h.

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

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

Definition at line 890 of file type.h.

Referenced by Module::AddFunctionDeclaration(), GetReturnTypeString(), FunctionCallExpr::GetValue(), lCheckTypeEquality(), LLVMFunctionType(), ResolveUnboundVariability(), and FunctionCallExpr::TypeCheck().

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

Definition at line 903 of file type.h.

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

llvm::SmallVector<Expr *, 8> FunctionType::paramDefaults [mutable, private]

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

Definition at line 922 of file type.h.

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

const llvm::SmallVector<std::string, 8> FunctionType::paramNames [private]

Definition at line 919 of file type.h.

Referenced by FunctionType(), GetCDeclaration(), GetParameterName(), and ResolveUnboundVariability().

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 927 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: