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

Expression representing a type cast of the given expression to a probably-different type. More...

#include <expr.h>

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

Public Member Functions

 TypeCastExpr (const Type *t, Expr *e, SourcePos p)
 
llvm::Value * GetValue (FunctionEmitContext *ctx) const
 
llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
const TypeGetType () const
 
const TypeGetLValueType () const
 
void Print () const
 
ExprTypeCheck ()
 
ExprOptimize ()
 
int EstimateCost () const
 
SymbolGetBaseSymbol () const
 
std::pair< llvm::Constant *, bool > GetConstant (const Type *type) const
 
- Public Member Functions inherited from Expr
 Expr (SourcePos p, unsigned scid)
 
virtual std::pair< llvm::Constant *, bool > GetStorageConstant (const Type *type) const
 
- Public Member Functions inherited from ASTNode
 ASTNode (SourcePos p, unsigned scid)
 
virtual ~ASTNode ()
 
unsigned getValueID () const
 

Static Public Member Functions

static bool classof (TypeCastExpr const *)
 
static bool classof (ASTNode const *N)
 
- Static Public Member Functions inherited from Expr
static bool classof (Expr const *)
 
static bool classof (ASTNode const *N)
 
- Static Public Member Functions inherited from ASTNode
static bool classof (ASTNode const *)
 

Public Attributes

const Typetype
 
Exprexpr
 
- Public Attributes inherited from ASTNode
SourcePos pos
 

Additional Inherited Members

- Public Types inherited from ASTNode
enum  ASTNodeTy {
  AddressOfExprID, AssignExprID, BinaryExprID, ConstExprID,
  DerefExprID, PtrDerefExprID, RefDerefExprID, ExprListID,
  FunctionCallExprID, FunctionSymbolExprID, IndexExprID, StructMemberExprID,
  VectorMemberExprID, NewExprID, NullPointerExprID, ReferenceExprID,
  SelectExprID, SizeOfExprID, SymbolExprID, SyncExprID,
  TypeCastExprID, UnaryExprID, MaxExprID, AssertStmtID,
  BreakStmtID, CaseStmtID, ContinueStmtID, DeclStmtID,
  DefaultStmtID, DeleteStmtID, DoStmtID, ExprStmtID,
  ForeachActiveStmtID, ForeachStmtID, ForeachUniqueStmtID, ForStmtID,
  GotoStmtID, IfStmtID, LabeledStmtID, PrintStmtID,
  ReturnStmtID, StmtListID, SwitchStmtID, UnmaskedStmtID
}
 

Detailed Description

Expression representing a type cast of the given expression to a probably-different type.

Definition at line 491 of file expr.h.

Constructor & Destructor Documentation

◆ TypeCastExpr()

TypeCastExpr::TypeCastExpr ( const Type t,
Expr e,
SourcePos  p 
)

Definition at line 6009 of file expr.cpp.

References expr, and type.

Referenced by GetValue(), and TypeCheck().

Member Function Documentation

◆ classof() [1/2]

static bool TypeCastExpr::classof ( TypeCastExpr const *  )
inlinestatic

Definition at line 495 of file expr.h.

◆ classof() [2/2]

static bool TypeCastExpr::classof ( ASTNode const *  N)
inlinestatic

◆ EstimateCost()

int TypeCastExpr::EstimateCost ( ) const
virtual

Estimate the execution cost of the node (not including the cost of the children. The value returned should be based on the COST_* enumerant values defined in ispc.h.

Implements ASTNode.

Definition at line 7056 of file expr.cpp.

References COST_TYPECAST_SIMPLE, and expr.

◆ GetBaseSymbol()

Symbol * TypeCastExpr::GetBaseSymbol ( ) const
virtual

For expressions that have values based on a symbol (e.g. regular symbol references, array indexing, etc.), this returns a pointer to that symbol.

Reimplemented from Expr.

Definition at line 7071 of file expr.cpp.

References expr, and Expr::GetBaseSymbol().

Referenced by GetConstant().

◆ GetConstant()

std::pair< llvm::Constant *, bool > TypeCastExpr::GetConstant ( const Type type) const
virtual

If this is a constant expression that can be converted to a constant of the given type, this method should return the corresponding llvm::Constant value and a flag denoting if it's valid for multi-target compilation for use as an initializer of a global variable. Otherwise it should return the llvm::constant value as NULL.

Reimplemented from Expr.

Definition at line 7095 of file expr.cpp.

References Globals::ctx, expr, g, Type::GetAsUniformType(), GetBaseSymbol(), Expr::GetConstant(), Expr::GetType(), lConvertPointerConstant(), LLVMInt32(), Type::LLVMType(), PTYPE, and Symbol::storagePtr.

◆ GetLValue()

llvm::Value * TypeCastExpr::GetLValue ( FunctionEmitContext ctx) const
virtual

For expressions that can provide an lvalue (e.g. array indexing), this function should emit IR that computes the expression's lvalue and returns the corresponding llvm::Value. Expressions that can't provide an lvalue should leave this unimplemented; the default implementation returns NULL.

Reimplemented from Expr.

Definition at line 6851 of file expr.cpp.

References GetLValueType(), and GetValue().

◆ GetLValueType()

const Type * TypeCastExpr::GetLValueType ( ) const
virtual

Returns the type of the value returned by GetLValueType(); this should be a pointer type of some sort (uniform or varying).

Reimplemented from Expr.

Definition at line 6878 of file expr.cpp.

References AssertPos, GetType(), Type::HasUnboundVariability(), and type.

Referenced by GetLValue().

◆ GetType()

const Type * TypeCastExpr::GetType ( ) const
virtual

Returns the Type of the expression.

Implements Expr.

Definition at line 6859 of file expr.cpp.

References AssertPos, expr, Expr::GetType(), Type::HasUnboundVariability(), Type::ResolveUnboundVariability(), type, Variability::Uniform, and Variability::Varying.

Referenced by GetLValueType(), GetValue(), Optimize(), and Print().

◆ GetValue()

llvm::Value * TypeCastExpr::GetValue ( FunctionEmitContext ctx) const
virtual

This is the main method for Expr implementations to implement. It should call methods in the FunctionEmitContext to emit LLVM IR instructions to the current basic block in order to generate an llvm::Value that represents the expression's value.

Implements Expr.

Definition at line 6567 of file expr.cpp.

References AssertPos, FunctionEmitContext::BitCastInst(), FunctionEmitContext::BroadcastValue(), FunctionEmitContext::CmpInst(), Globals::ctx, Type::EqualIgnoringConst(), Module::errorCount, expr, FunctionEmitContext::ExtractInst(), FATAL, g, Type::GetAsVaryingType(), StructType::GetAsVaryingType(), Type::GetBaseType(), ArrayType::GetBaseType(), ArrayType::GetElementCount(), VectorType::GetElementCount(), VectorType::GetElementType(), Type::GetReferenceTarget(), ReferenceType::GetReferenceTarget(), Expr::GetType(), GetType(), Expr::GetValue(), FunctionEmitContext::I1VecToBoolVec(), FunctionEmitContext::InsertInst(), FunctionEmitContext::IntToPtrInst(), Type::IsBoolType(), AtomicType::IsBoolType(), PointerType::IsSlice(), Type::IsUniformType(), Type::IsVaryingType(), PointerType::IsVoidPointer(), Type::IsVoidType(), lArrayToPointer(), LLVMInt32(), LLVMInt32Vector(), Type::LLVMStorageType(), AtomicType::LLVMStorageType(), Type::LLVMType(), lTypeConvAtomic(), lUniformValueToVarying(), m, FunctionEmitContext::MakeSlicePointer(), Optimize(), ASTNode::pos, FunctionEmitContext::PtrToIntInst(), FunctionEmitContext::SetDebugPos(), FunctionEmitContext::SmearUniform(), FunctionEmitContext::SwitchBoolSize(), TypeCastExpr(), TypeCheck(), AtomicType::UniformUInt32, AtomicType::VaryingUInt32, and Warning().

Referenced by GetLValue().

◆ Optimize()

Expr * TypeCastExpr::Optimize ( )
virtual

This method should perform early optimizations of the expression (constant folding, etc.) and return a pointer to the resulting expression. If an error is encountered during optimization, NULL should be returned.

Implements Expr.

Definition at line 6973 of file expr.cpp.

References AtomicType::basicType, expr, FATAL, GetType(), ConstExpr::GetValues(), ISPC_MAX_NVEC, Type::IsVaryingType(), AtomicType::TYPE_BOOL, AtomicType::TYPE_DOUBLE, AtomicType::TYPE_FLOAT, AtomicType::TYPE_INT16, AtomicType::TYPE_INT32, AtomicType::TYPE_INT64, AtomicType::TYPE_INT8, AtomicType::TYPE_UINT16, AtomicType::TYPE_UINT32, AtomicType::TYPE_UINT64, and AtomicType::TYPE_UINT8.

Referenced by GetValue().

◆ Print()

void TypeCastExpr::Print ( ) const
virtual

Prints the expression to standard output (used for debugging).

Implements Expr.

Definition at line 7064 of file expr.cpp.

References expr, GetType(), Expr::Print(), and SourcePos::Print().

◆ TypeCheck()

Expr * TypeCastExpr::TypeCheck ( )
virtual

Member Data Documentation

◆ expr

Expr* TypeCastExpr::expr

◆ type

const Type* TypeCastExpr::type

Definition at line 509 of file expr.h.

Referenced by GetLValueType(), GetType(), lUniformValueToVarying(), TypeCastExpr(), and TypeCheck().


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