Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Public Member Functions | Public Attributes | Private Attributes | List of all members
EnumType Class Reference

Type implementation for enumerated types. More...

#include <type.h>

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

Public Member Functions

 EnumType (SourcePos pos)
 
 EnumType (const char *name, SourcePos pos)
 
Variability GetVariability () const
 
bool IsBoolType () const
 
bool IsFloatType () const
 
bool IsIntType () const
 
bool IsUnsignedType () const
 
bool IsConstType () const
 
const EnumTypeGetBaseType () const
 
const EnumTypeGetAsVaryingType () const
 
const EnumTypeGetAsUniformType () const
 
const EnumTypeGetAsUnboundVariabilityType () const
 
const EnumTypeGetAsSOAType (int width) const
 
const EnumTypeResolveUnboundVariability (Variability v) const
 
const EnumTypeGetAsConstType () const
 
const EnumTypeGetAsNonConstType () const
 
std::string GetString () const
 
std::string Mangle () const
 
std::string GetCDeclaration (const std::string &name) const
 
const std::string & GetEnumName () const
 
llvm::Type * LLVMType (llvm::LLVMContext *ctx) const
 
llvm::DIType * GetDIType (llvm::DIScope *scope) const
 
void SetEnumerators (const std::vector< Symbol *> &enumerators)
 
int GetEnumeratorCount () const
 
const SymbolGetEnumerator (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
 
virtual llvm::Type * LLVMStorageType (llvm::LLVMContext *ctx) const
 

Public Attributes

const SourcePos pos
 
- Public Attributes inherited from Type
const TypeId typeId
 

Private Attributes

const std::string name
 
Variability variability
 
bool isConst
 
std::vector< Symbol * > enumerators
 

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 implementation for enumerated types.

Note that ISPC enum assumes 32 bit int as underlying type.

Definition at line 347 of file type.h.

Constructor & Destructor Documentation

◆ EnumType() [1/2]

EnumType::EnumType ( SourcePos  pos)

Constructor for anonymous enumerated types

Definition at line 578 of file type.cpp.

References isConst, Variability::Unbound, and variability.

Referenced by GetAsConstType(), GetAsNonConstType(), GetAsSOAType(), GetAsUnboundVariabilityType(), GetAsUniformType(), GetAsVaryingType(), and ResolveUnboundVariability().

◆ EnumType() [2/2]

EnumType::EnumType ( const char *  name,
SourcePos  pos 
)

Constructor for named enumerated types

Definition at line 584 of file type.cpp.

References isConst, Variability::Unbound, and variability.

Member Function Documentation

◆ GetAsConstType()

const EnumType * EnumType::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 653 of file type.cpp.

References EnumType(), and isConst.

◆ GetAsNonConstType()

const EnumType * EnumType::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 663 of file type.cpp.

References EnumType(), and isConst.

◆ GetAsSOAType()

const EnumType * EnumType::GetAsSOAType ( int  width) const
virtual

Implements Type.

Definition at line 643 of file type.cpp.

References EnumType(), Type::GetSOAWidth(), Variability::SOA, and variability.

◆ GetAsUnboundVariabilityType()

const EnumType * EnumType::GetAsUnboundVariabilityType ( ) const
virtual

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 633 of file type.cpp.

References EnumType(), Type::HasUnboundVariability(), Variability::Unbound, and variability.

◆ GetAsUniformType()

const EnumType * EnumType::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 603 of file type.cpp.

References EnumType(), Type::IsUniformType(), Variability::Uniform, and variability.

◆ GetAsVaryingType()

const EnumType * EnumType::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 623 of file type.cpp.

References EnumType(), Type::IsVaryingType(), variability, and Variability::Varying.

◆ GetBaseType()

const EnumType * EnumType::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 601 of file type.cpp.

◆ GetCDeclaration()

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

References Assert, Module::errorCount, g, Target::getVectorWidth(), isConst, lShouldPrintName(), m, name, Variability::SOA, Variability::soaWidth, Globals::target, Variability::Unbound, variability, and Variability::Varying.

◆ GetDIType()

llvm::DIType * EnumType::GetDIType ( llvm::DIScope *  scope) const
virtual

◆ GetEnumerator()

const Symbol * EnumType::GetEnumerator ( int  i) const

Returns the symbol for the given enumerator number.

Definition at line 787 of file type.cpp.

References enumerators, Variability::Uniform, and PointerType::Void.

◆ GetEnumeratorCount()

int EnumType::GetEnumeratorCount ( ) const

Returns the total number of enuemrators in this enum type.

Definition at line 785 of file type.cpp.

References enumerators.

◆ GetEnumName()

const std::string& EnumType::GetEnumName ( ) const
inline

Returns the name of the enum type. (e.g. struct Foo -> "Foo".)

Definition at line 377 of file type.h.

◆ GetString()

std::string EnumType::GetString ( ) const
virtual

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

Implements Type.

Definition at line 673 of file type.cpp.

References Variability::GetString(), isConst, name, and variability.

◆ GetVariability()

Variability EnumType::GetVariability ( ) const
virtual

Returns the variability of the type.

Implements Type.

Definition at line 589 of file type.cpp.

References variability.

Referenced by lCheckTypeEquality().

◆ IsBoolType()

bool EnumType::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 591 of file type.cpp.

◆ IsConstType()

bool EnumType::IsConstType ( ) const
virtual

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

Implements Type.

Definition at line 599 of file type.cpp.

References isConst.

◆ IsFloatType()

bool EnumType::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 593 of file type.cpp.

◆ IsIntType()

bool EnumType::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 595 of file type.cpp.

◆ IsUnsignedType()

bool EnumType::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 597 of file type.cpp.

◆ LLVMType()

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

◆ Mangle()

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

References Assert, isConst, Variability::MangleString(), name, Variability::Unbound, and variability.

◆ ResolveUnboundVariability()

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

Implements Type.

Definition at line 613 of file type.cpp.

References EnumType(), Variability::Unbound, and variability.

◆ SetEnumerators()

void EnumType::SetEnumerators ( const std::vector< Symbol *> &  enumerators)

Provides the enumerators defined in the enum definition.

Definition at line 783 of file type.cpp.

References enumerators.

Member Data Documentation

◆ enumerators

std::vector<Symbol *> EnumType::enumerators
private

Definition at line 396 of file type.h.

Referenced by GetDIType(), GetEnumerator(), GetEnumeratorCount(), and SetEnumerators().

◆ isConst

bool EnumType::isConst
private

◆ name

const std::string EnumType::name
private

Definition at line 393 of file type.h.

Referenced by GetCDeclaration(), GetDIType(), GetString(), and Mangle().

◆ pos

const SourcePos EnumType::pos

Definition at line 390 of file type.h.

Referenced by GetDIType(), and lCheckTypeEquality().

◆ variability

Variability EnumType::variability
private

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