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

Unary expression. More...

#include <expr.h>

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

Public Types

enum  Op {
  PreInc, PreDec, PostInc, PostDec,
  Negate, LogicalNot, BitNot
}
 
- 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
}
 

Public Member Functions

 UnaryExpr (Op op, Expr *expr, SourcePos pos)
 
llvm::Value * GetValue (FunctionEmitContext *ctx) const
 
const TypeGetType () const
 
void Print () const
 
ExprOptimize ()
 
ExprTypeCheck ()
 
int EstimateCost () const
 
- Public Member Functions inherited from Expr
 Expr (SourcePos p, unsigned scid)
 
virtual llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
virtual const TypeGetLValueType () const
 
virtual SymbolGetBaseSymbol () const
 
virtual std::pair< llvm::Constant *, bool > GetStorageConstant (const Type *type) const
 
virtual std::pair< llvm::Constant *, bool > GetConstant (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 (UnaryExpr 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 Op op
 
Exprexpr
 
- Public Attributes inherited from ASTNode
SourcePos pos
 

Detailed Description

Unary expression.

Definition at line 111 of file expr.h.

Member Enumeration Documentation

◆ Op

Enumerator
PreInc 

Pre-increment.

PreDec 

Pre-decrement.

PostInc 

Post-increment.

PostDec 

Post-decrement.

Negate 

Negation.

LogicalNot 

Logical not.

BitNot 

Bit not.

Definition at line 113 of file expr.h.

Constructor & Destructor Documentation

◆ UnaryExpr()

UnaryExpr::UnaryExpr ( Op  op,
Expr expr,
SourcePos  pos 
)

Definition at line 1027 of file expr.cpp.

References expr.

Member Function Documentation

◆ classof() [1/2]

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

Definition at line 125 of file expr.h.

◆ classof() [2/2]

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

◆ EstimateCost()

int UnaryExpr::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 1272 of file expr.cpp.

References COST_SIMPLE_ARITH_LOGIC_OP, and expr.

◆ GetType()

const Type * UnaryExpr::GetType ( ) const
virtual

Returns the Type of the expression.

Implements Expr.

Definition at line 1057 of file expr.cpp.

References BitNot, expr, FATAL, Expr::GetType(), lMatchingBoolType(), LogicalNot, Negate, op, PostDec, PostInc, PreDec, and PreInc.

Referenced by Print().

◆ GetValue()

llvm::Value * UnaryExpr::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 1029 of file expr.cpp.

References BitNot, expr, FATAL, Expr::GetValue(), lEmitNegate(), lEmitPrePostIncDec(), LLVMGetName(), LogicalNot, Negate, FunctionEmitContext::NotOperator(), op, PostDec, PostInc, PreDec, PreInc, and FunctionEmitContext::SetDebugPos().

◆ Optimize()

Expr * UnaryExpr::Optimize ( )
virtual

◆ Print()

void UnaryExpr::Print ( ) const
virtual

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

Implements Expr.

Definition at line 1279 of file expr.cpp.

References BitNot, expr, GetType(), LogicalNot, Negate, op, PostDec, PostInc, PreDec, PreInc, Expr::Print(), and SourcePos::Print().

◆ TypeCheck()

Expr * UnaryExpr::TypeCheck ( )
virtual

This method should perform type checking of the expression and return a pointer to the resulting expression. If an error is encountered, NULL should be returned.

Implements Expr.

Definition at line 1197 of file expr.cpp.

References BitNot, Error(), expr, PointerType::GetBaseType(), Type::GetString(), Expr::GetType(), Type::IsConstType(), Type::IsIntType(), Type::IsNumericType(), Type::IsSOAType(), PointerType::IsVoidPointer(), lMatchingBoolType(), LogicalNot, Negate, op, ASTNode::pos, PostDec, PostInc, PreDec, PreInc, and TypeConvertExpr().

Member Data Documentation

◆ expr

Expr* UnaryExpr::expr

Definition at line 136 of file expr.h.

Referenced by EstimateCost(), GetType(), GetValue(), Optimize(), Print(), TypeCheck(), UnaryExpr(), and WalkAST().

◆ op

const Op UnaryExpr::op

Definition at line 135 of file expr.h.

Referenced by GetType(), GetValue(), Optimize(), Print(), and TypeCheck().


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