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
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
 
std::pair< llvm::Constant *, bool > GetStorageConstant (const Type *type) const
 
std::pair< llvm::Constant *, bool > GetConstant (const Type *type) const
 
- Public Member Functions inherited from Expr
 Expr (SourcePos p, unsigned scid)
 
virtual llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
virtual SymbolGetBaseSymbol () 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 140 of file expr.h.

Member Enumeration Documentation

◆ Op

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 142 of file expr.h.

Constructor & Destructor Documentation

◆ BinaryExpr()

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

Definition at line 1571 of file expr.cpp.

References arg0, and arg1.

Referenced by MakeBinaryExpr(), and Optimize().

Member Function Documentation

◆ classof() [1/2]

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

Definition at line 169 of file expr.h.

◆ classof() [2/2]

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

◆ EstimateCost()

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

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

Referenced by lEmitLogicalOp().

◆ GetConstant()

std::pair< llvm::Constant *, bool > BinaryExpr::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 2753 of file expr.cpp.

References lGetBinaryExprStorageConstant().

◆ GetLValueType()

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

References GetType().

Referenced by lGetBinaryExprStorageConstant().

◆ GetStorageConstant()

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

If this is a constant expression that can be converted to a constant of storage type 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 2749 of file expr.cpp.

References lGetBinaryExprStorageConstant().

◆ GetType()

const Type * BinaryExpr::GetType ( ) const
virtual

◆ GetValue()

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

◆ Optimize()

Expr * BinaryExpr::Optimize ( )
virtual

◆ Print()

void BinaryExpr::Print ( ) const
virtual

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

Implements Expr.

Definition at line 2653 of file expr.cpp.

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

◆ TypeCheck()

Expr * BinaryExpr::TypeCheck ( )
virtual

Member Data Documentation

◆ arg0

Expr* BinaryExpr::arg0

◆ arg1

Expr * BinaryExpr::arg1

◆ op

const Op BinaryExpr::op

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