Intel SPMD Program Compiler  1.9.2
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::DIDescriptor 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
 

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.

Definition at line 370 of file type.h.

Constructor & Destructor Documentation

EnumType::EnumType ( SourcePos  pos)

Constructor for anonymous enumerated types

Definition at line 682 of file type.cpp.

References isConst, Variability::Unbound, and variability.

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

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

Constructor for named enumerated types

Definition at line 690 of file type.cpp.

References isConst, Variability::Unbound, and variability.

Member Function Documentation

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

References EnumType(), and isConst.

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

References EnumType(), and isConst.

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

Implements Type.

Definition at line 788 of file type.cpp.

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

const EnumType * EnumType::GetAsUnboundVariabilityType ( ) const
virtual

Get an instance of the type with unbound variability.

Implements Type.

Definition at line 776 of file type.cpp.

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

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

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

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

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

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

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 850 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.

llvm::DIType EnumType::GetDIType ( llvm::DIDescriptor  scope) const
virtual
const Symbol * EnumType::GetEnumerator ( int  i) const

Returns the symbol for the given enumerator number.

Definition at line 995 of file type.cpp.

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

int EnumType::GetEnumeratorCount ( ) const

Returns the total number of enuemrators in this enum type.

Definition at line 989 of file type.cpp.

References enumerators.

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

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

Definition at line 400 of file type.h.

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

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

Variability EnumType::GetVariability ( ) const
virtual

Returns the variability of the type.

Implements Type.

Definition at line 698 of file type.cpp.

References variability.

Referenced by lCheckTypeEquality().

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

bool EnumType::IsConstType ( ) const
virtual

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

Implements Type.

Definition at line 728 of file type.cpp.

References isConst.

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

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

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

llvm::Type * EnumType::LLVMType ( llvm::LLVMContext *  ctx) const
virtual
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 837 of file type.cpp.

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

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

Implements Type.

Definition at line 752 of file type.cpp.

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

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

Provides the enumerators defined in the enum definition.

Definition at line 983 of file type.cpp.

References enumerators.

Member Data Documentation

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

Definition at line 422 of file type.h.

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

bool EnumType::isConst
private
const std::string EnumType::name
private

Definition at line 419 of file type.h.

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

const SourcePos EnumType::pos

Definition at line 416 of file type.h.

Referenced by GetDIType(), and lCheckTypeEquality().

Variability EnumType::variability
private

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