Intel SPMD Program Compiler  1.12.0
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 858 of file type.h.

Constructor & Destructor Documentation

◆ FunctionType() [1/2]

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

Definition at line 2481 of file type.cpp.

References Assert, costOverride, isSafe, and returnType.

Referenced by ResolveUnboundVariability().

◆ FunctionType() [2/2]

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

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

Member Function Documentation

◆ GetAsConstType()

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

◆ GetAsNonConstType()

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

◆ GetAsSOAType()

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

Implements Type.

Definition at line 2535 of file type.cpp.

References FATAL.

◆ GetAsUnboundVariabilityType()

const Type * FunctionType::GetAsUnboundVariabilityType ( ) const
virtual

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 2530 of file type.cpp.

References FATAL.

◆ GetAsUniformType()

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

References FATAL.

◆ GetAsVaryingType()

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

References FATAL.

◆ GetBaseType()

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

References FATAL.

◆ GetCDeclaration()

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

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

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

◆ GetCDeclarationForDispatch()

std::string FunctionType::GetCDeclarationForDispatch ( const std::string &  fname) const

◆ GetDIType()

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

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

Referenced by FunctionEmitContext::FunctionEmitContext().

◆ GetNumParameters()

int FunctionType::GetNumParameters ( ) const
inline

◆ GetParameterDefault()

Expr * FunctionType::GetParameterDefault ( int  i) const

◆ GetParameterName()

const std::string & FunctionType::GetParameterName ( int  i) const

◆ GetParameterSourcePos()

const SourcePos & FunctionType::GetParameterSourcePos ( int  i) const

Definition at line 2812 of file type.cpp.

References Assert, and paramPositions.

Referenced by Module::AddFunctionDeclaration().

◆ GetParameterType()

const Type * FunctionType::GetParameterType ( int  i) const

◆ GetReturnType()

const Type* FunctionType::GetReturnType ( ) const
inline

◆ GetReturnTypeString()

const std::string FunctionType::GetReturnTypeString ( ) const

◆ GetString()

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

References GetReturnTypeString(), and paramTypes.

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

◆ GetVariability()

Variability FunctionType::GetVariability ( ) const
virtual

Returns the variability of the type.

Implements Type.

Definition at line 2503 of file type.cpp.

References Variability::Uniform.

◆ IsBoolType()

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

◆ IsConstType()

bool FunctionType::IsConstType ( ) const
virtual

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

Implements Type.

Definition at line 2513 of file type.cpp.

◆ IsFloatType()

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

◆ IsIntType()

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

◆ IsUnsignedType()

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

◆ LLVMFunctionType()

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

◆ LLVMType()

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

Returns the LLVM type corresponding to this ispc type

Implements Type.

Definition at line 2664 of file type.cpp.

References FATAL.

◆ Mangle()

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

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

Referenced by Module::AddFunctionDeclaration().

◆ ResolveUnboundVariability()

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

Member Data Documentation

◆ costOverride

int FunctionType::costOverride

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

Definition at line 935 of file type.h.

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

◆ isExported

const bool FunctionType::isExported

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

Definition at line 918 of file type.h.

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

◆ isExternC

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

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

◆ isSafe

bool FunctionType::isSafe

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

Definition at line 931 of file type.h.

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

◆ isTask

const bool FunctionType::isTask

◆ isUnmasked

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

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

◆ paramDefaults

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

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

◆ paramNames

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

◆ paramPositions

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

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

◆ paramTypes

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

◆ returnType

const Type* const FunctionType::returnType
private

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