Intel SPMD Program Compiler  1.9.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
BinaryExpr Class Reference

Binary expression. More...

#include <expr.h>

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

Public Types

enum  Op {
  Add, Sub, Mul, Div,
  Mod, Shl, Shr, Lt,
  Gt, Le, Ge, Equal,
  NotEqual, BitAnd, BitXor, BitOr,
  LogicalAnd, LogicalOr, Comma
}
 
- 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

 BinaryExpr (Op o, Expr *a, Expr *b, SourcePos p)
 
llvm::Value * GetValue (FunctionEmitContext *ctx) const
 
const TypeGetType () const
 
const TypeGetLValueType () 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 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 (BinaryExpr 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
 
Exprarg0
 
Exprarg1
 
- Public Attributes inherited from ASTNode
SourcePos pos
 

Detailed Description

Binary expression.

Definition at line 137 of file expr.h.

Member Enumeration Documentation

Enumerator
Add 

Addition.

Sub 

Subtraction.

Mul 

Multiplication.

Div 

Division.

Mod 

Modulus.

Shl 

Shift left.

Shr 

Shift right.

Lt 

Less than.

Gt 

Greater than.

Le 

Less than or equal.

Ge 

Greater than or equal.

Equal 

Equal.

NotEqual 

Not equal.

BitAnd 

Bitwise AND.

BitXor 

Bitwise XOR.

BitOr 

Bitwise OR.

LogicalAnd 

Logical AND.

LogicalOr 

Logical OR.

Comma 

Comma operator.

Definition at line 139 of file expr.h.

Constructor & Destructor Documentation

BinaryExpr::BinaryExpr ( Op  o,
Expr a,
Expr b,
SourcePos  p 
)

Definition at line 1667 of file expr.cpp.

References arg0, and arg1.

Referenced by Optimize().

Member Function Documentation

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

Definition at line 166 of file expr.h.

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

Definition at line 167 of file expr.h.

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

int BinaryExpr::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 2824 of file expr.cpp.

References arg0, arg1, COST_COMPLEX_ARITH_OP, COST_SIMPLE_ARITH_LOGIC_OP, Div, Mod, and op.

const Type * BinaryExpr::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 2812 of file expr.cpp.

References GetType().

const Type * BinaryExpr::GetType ( ) const
virtual
llvm::Value * BinaryExpr::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 2017 of file expr.cpp.

References Add, arg0, arg1, AssertPos, BitAnd, BitOr, BitXor, Comma, Div, Equal, Module::errorCount, FATAL, Ge, Expr::GetType(), Expr::GetValue(), Gt, Type::IsUnsignedType(), Le, lEmitBinaryArith(), lEmitBinaryBitOp(), lEmitBinaryCmp(), lEmitLogicalOp(), lIsDifficultShiftAmount(), LogicalAnd, LogicalOr, Lt, m, Mod, Mul, NotEqual, op, PerformanceWarning(), ASTNode::pos, FunctionEmitContext::SetDebugPos(), Shl, Shr, and Sub.

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

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

Implements Expr.

Definition at line 2835 of file expr.cpp.

References arg0, arg1, GetType(), lOpString(), op, Expr::Print(), and SourcePos::Print().

Expr * BinaryExpr::TypeCheck ( )
virtual

Member Data Documentation

Expr* BinaryExpr::arg0

Definition at line 181 of file expr.h.

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

Expr * BinaryExpr::arg1

Definition at line 181 of file expr.h.

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

const Op BinaryExpr::op

Definition at line 180 of file expr.h.

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


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