Intel SPMD Program Compiler  1.9.1
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 llvm::Constant * 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 105 of file expr.h.

Member Enumeration Documentation

Enumerator
PreInc 

Pre-increment.

PreDec 

Pre-decrement.

PostInc 

Post-increment.

PostDec 

Post-decrement.

Negate 

Negation.

LogicalNot 

Logical not.

BitNot 

Bit not.

Definition at line 107 of file expr.h.

Constructor & Destructor Documentation

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

Definition at line 1110 of file expr.cpp.

References expr.

Member Function Documentation

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

Definition at line 119 of file expr.h.

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

Definition at line 120 of file expr.h.

References ASTNode::getValueID(), and ASTNode::UnaryExprID.

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 1360 of file expr.cpp.

References COST_SIMPLE_ARITH_LOGIC_OP, and expr.

const Type * UnaryExpr::GetType ( ) const
virtual

Returns the Type of the expression.

Implements Expr.

Definition at line 1146 of file expr.cpp.

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

Referenced by Print().

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

Expr * UnaryExpr::Optimize ( )
virtual
void UnaryExpr::Print ( ) const
virtual

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

Implements Expr.

Definition at line 1369 of file expr.cpp.

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

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 1286 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* UnaryExpr::expr

Definition at line 132 of file expr.h.

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

const Op UnaryExpr::op

Definition at line 131 of file expr.h.

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


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