LLVM API Documentation

llvm::BinaryOperator Class Reference

#include <InstrTypes.h>

Inheritance diagram for llvm::BinaryOperator:

Inheritance graph
[legend]
Collaboration diagram for llvm::BinaryOperator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

ValuegetOperand (unsigned i) const
 Transparently provide more efficient getOperand methods.
void setOperand (unsigned i, Value *Val)
unsigned getNumOperands () const
 HANDLE_MEMORY_INST (21, Malloc, MallocInst) HANDLE_MEMORY_INST(23
AllocaInst HANDLE_MEMORY_INST (24, Load, LoadInst) HANDLE_OTHER_INST(27
AllocaInst PHINode HANDLE_OTHER_INST (28, Cast, CastInst) HANDLE_OTHER_INST(29
AllocaInst PHINode CallInst HANDLE_OTHER_INST (30, Shl, ShiftInst) HANDLE_OTHER_INST(34
AllocaInst PHINode CallInst
SelectInst 
HANDLE_OTHER_INST (35, UserOp1, Instruction) HANDLE_OTHER_INST(37
AllocaInst PHINode CallInst
SelectInst VAArgInst 
HANDLE_OTHER_INST (38, ExtractElement, ExtractElementInst) HANDLE_OTHER_INST(39
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst 
HANDLE_OTHER_INST (40, ShuffleVector, ShuffleVectorInst) HANDLE_MEMORY_INST(21
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst 
HANDLE_MEMORY_INST (23, Alloca, AllocaInst) HANDLE_MEMORY_INST(24
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst 
HANDLE_OTHER_INST (27, PHI, PHINode) HANDLE_OTHER_INST(28
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst CastInst 
HANDLE_OTHER_INST (29, Call, CallInst) HANDLE_OTHER_INST(30
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst CastInst
ShiftInst 
HANDLE_OTHER_INST (34, Select, SelectInst) HANDLE_OTHER_INST(35
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst CastInst
ShiftInst Instruction 
HANDLE_OTHER_INST (37, VAArg, VAArgInst) HANDLE_OTHER_INST(38
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst CastInst
ShiftInst Instruction ExtractElementInst 
HANDLE_OTHER_INST (39, InsertElement, InsertElementInst) HANDLE_OTHER_INST(40
 HANDLE_MEMORY_INST (21, Malloc, MallocInst) HANDLE_MEMORY_INST(23
AllocaInst HANDLE_MEMORY_INST (24, Load, LoadInst) HANDLE_OTHER_INST(27
AllocaInst PHINode HANDLE_OTHER_INST (28, Cast, CastInst) HANDLE_OTHER_INST(29
AllocaInst PHINode CallInst HANDLE_OTHER_INST (30, Shl, ShiftInst) HANDLE_OTHER_INST(34
AllocaInst PHINode CallInst
SelectInst 
HANDLE_OTHER_INST (35, UserOp1, Instruction) HANDLE_OTHER_INST(37
AllocaInst PHINode CallInst
SelectInst VAArgInst 
HANDLE_OTHER_INST (38, ExtractElement, ExtractElementInst) HANDLE_OTHER_INST(39
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst 
HANDLE_OTHER_INST (40, ShuffleVector, ShuffleVectorInst) static BinaryOperator *createNeg(Value *Op
BinaryOps getOpcode () const
virtual BinaryOperatorclone () const
bool swapOperands ()

Static Public Member Functions

static BinaryOperatorcreate (BinaryOps Op, Value *S1, Value *S2, const std::string &Name="", Instruction *InsertBefore=0)
static BinaryOperatorcreate (BinaryOps Op, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd)
static BinaryOperatorcreateNeg (Value *Op, const std::string &Name, BasicBlock *InsertAtEnd)
static BinaryOperatorcreateNot (Value *Op, const std::string &Name="", Instruction *InsertBefore=0)
static BinaryOperatorcreateNot (Value *Op, const std::string &Name, BasicBlock *InsertAtEnd)
static bool isNeg (const Value *V)
static bool isNot (const Value *V)
static const ValuegetNegArgument (const Value *BinOp)
static ValuegetNegArgument (Value *BinOp)
static const ValuegetNotArgument (const Value *BinOp)
static ValuegetNotArgument (Value *BinOp)
static bool classof (const BinaryOperator *)
static bool classof (const Instruction *I)
 Methods for support type inquiry through isa, cast, and dyn_cast:.
static bool classof (const Value *V)

Public Attributes

 Alloca
AllocaInst PHI
AllocaInst PHINode Call
AllocaInst PHINode CallInst Select
AllocaInst PHINode CallInst
SelectInst 
VAArg
AllocaInst PHINode CallInst
SelectInst VAArgInst 
InsertElement
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst 
Malloc
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst 
Load
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst 
Cast
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst CastInst 
Shl
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst CastInst
ShiftInst 
UserOp1
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst CastInst
ShiftInst Instruction 
ExtractElement
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
MallocInst LoadInst CastInst
ShiftInst Instruction ExtractElementInst 
ShuffleVector
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
const std::string & 
Name = ""
AllocaInst PHINode CallInst
SelectInst VAArgInst InsertElementInst
const std::string Instruction
InsertBefore = 0)

Protected Member Functions

void init (BinaryOps iType)
 BinaryOperator (BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, Instruction *InsertBefore)
 BinaryOperator (BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)

Detailed Description

Definition at line 121 of file InstrTypes.h.


Constructor & Destructor Documentation

llvm::BinaryOperator::BinaryOperator ( BinaryOps  iType,
Value S1,
Value S2,
const Type Ty,
const std::string &  Name,
Instruction InsertBefore 
) [inline, protected]

Definition at line 125 of file InstrTypes.h.

References init(), and llvm::Use::init().

Referenced by create(), createNeg(), and createNot().

llvm::BinaryOperator::BinaryOperator ( BinaryOps  iType,
Value S1,
Value S2,
const Type Ty,
const std::string &  Name,
BasicBlock InsertAtEnd 
) [inline, protected]

Definition at line 132 of file InstrTypes.h.

References init(), and llvm::Use::init().


Member Function Documentation

void BinaryOperator::init ( BinaryOps  iType  )  [protected]

Definition at line 964 of file Instructions.cpp.

References llvm::Type::BoolTy, getOperand(), llvm::Value::getType(), llvm::MVT::isFloatingPoint(), and llvm::MVT::isInteger().

Referenced by BinaryOperator().

Value* llvm::BinaryOperator::getOperand ( unsigned  i  )  const [inline]

Transparently provide more efficient getOperand methods.

Reimplemented from llvm::User.

Definition at line 143 of file InstrTypes.h.

Referenced by FoldSetCCLogical::apply(), AddMaskingAnd::apply(), AddRHS::apply(), dyn_castFoldableMul(), FindSingleUseMultiplyFactors(), getNegArgument(), getNotArgument(), init(), NegateValue(), and llvm::Interpreter::visitBinaryOperator().

void llvm::BinaryOperator::setOperand ( unsigned  i,
Value Val 
) [inline]

Reimplemented from llvm::User.

Definition at line 147 of file InstrTypes.h.

References Val.

Referenced by NegateValue().

unsigned llvm::BinaryOperator::getNumOperands (  )  const [inline]

Reimplemented from llvm::User.

Definition at line 151 of file InstrTypes.h.

BinaryOperator * BinaryOperator::create ( BinaryOps  Op,
Value S1,
Value S2,
const std::string &  Name = "",
Instruction InsertBefore = 0 
) [static]

create() - Construct a binary instruction, given the opcode and the two operands. Optionally (if InstBefore is specified) insert the instruction into a BasicBlock right before the specified instruction. The specified Instruction is allowed to be a dereferenced end iterator.

Definition at line 998 of file Instructions.cpp.

References BinaryOperator(), llvm::Value::getType(), and InsertBefore.

Referenced by clone(), llvm::ConvertExpressionToType(), create(), llvm::IncrementCounterInBlock(), llvm::DefaultIntrinsicLowering::LowerIntrinsicCall(), llvm::BytecodeReader::ParseInstruction(), and llvm::SimplifyCFG().

BinaryOperator * BinaryOperator::create ( BinaryOps  Op,
Value S1,
Value S2,
const std::string &  Name,
BasicBlock InsertAtEnd 
) [static]

create() - Construct a binary instruction, given the opcode and the two operands. Also automatically insert this instruction to the end of the BasicBlock specified.

Definition at line 1014 of file Instructions.cpp.

References create(), and llvm::BasicBlock::getInstList().

llvm::BinaryOperator::HANDLE_MEMORY_INST ( 21  ,
Malloc  ,
MallocInst   
)

AllocaInst llvm::BinaryOperator::HANDLE_MEMORY_INST ( 24  ,
Load  ,
LoadInst   
)

AllocaInst PHINode llvm::BinaryOperator::HANDLE_OTHER_INST ( 28  ,
Cast  ,
CastInst   
)

AllocaInst PHINode CallInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 30  ,
Shl  ,
ShiftInst   
)

AllocaInst PHINode CallInst SelectInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 35  ,
UserOp1  ,
Instruction   
)

AllocaInst PHINode CallInst SelectInst VAArgInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 38  ,
ExtractElement  ,
ExtractElementInst   
)

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 40  ,
ShuffleVector  ,
ShuffleVectorInst   
)

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst llvm::BinaryOperator::HANDLE_MEMORY_INST ( 23  ,
Alloca  ,
AllocaInst   
)

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 27  ,
PHI  ,
PHINode   
)

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst CastInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 29  ,
Call  ,
CallInst   
)

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst CastInst ShiftInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 34  ,
Select  ,
SelectInst   
)

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst CastInst ShiftInst Instruction llvm::BinaryOperator::HANDLE_OTHER_INST ( 37  ,
VAArg  ,
VAArgInst   
)

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst CastInst ShiftInst Instruction ExtractElementInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 39  ,
InsertElement  ,
InsertElementInst   
)

llvm::BinaryOperator::HANDLE_MEMORY_INST ( 21  ,
Malloc  ,
MallocInst   
)

AllocaInst llvm::BinaryOperator::HANDLE_MEMORY_INST ( 24  ,
Load  ,
LoadInst   
)

AllocaInst PHINode llvm::BinaryOperator::HANDLE_OTHER_INST ( 28  ,
Cast  ,
CastInst   
)

AllocaInst PHINode CallInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 30  ,
Shl  ,
ShiftInst   
)

AllocaInst PHINode CallInst SelectInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 35  ,
UserOp1  ,
Instruction   
)

AllocaInst PHINode CallInst SelectInst VAArgInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 38  ,
ExtractElement  ,
ExtractElementInst   
)

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst llvm::BinaryOperator::HANDLE_OTHER_INST ( 40  ,
ShuffleVector  ,
ShuffleVectorInst   
)

Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and XOR:

createNeg, createNot - Create the NEG and NOT instructions out of SUB and XOR instructions.

BinaryOperator * BinaryOperator::createNeg ( Value Op,
const std::string &  Name,
BasicBlock InsertAtEnd 
) [static]

Definition at line 1034 of file Instructions.cpp.

References BinaryOperator(), llvm::ConstantFP::get(), llvm::Constant::getNullValue(), and Op.

Referenced by llvm::SCEVExpander::visitMulExpr().

BinaryOperator * BinaryOperator::createNot ( Value Op,
const std::string &  Name = "",
Instruction InsertBefore = 0 
) [static]

Definition at line 1046 of file Instructions.cpp.

References BinaryOperator(), C, llvm::ConstantPacked::get(), llvm::ConstantIntegral::getAllOnesValue(), InsertBefore, and Op.

Referenced by LowerCTLZ(), llvm::DefaultIntrinsicLowering::LowerIntrinsicCall(), and llvm::SimplifyCFG().

BinaryOperator * BinaryOperator::createNot ( Value Op,
const std::string &  Name,
BasicBlock InsertAtEnd 
) [static]

Definition at line 1060 of file Instructions.cpp.

References BinaryOperator(), llvm::ConstantPacked::get(), llvm::ConstantIntegral::getAllOnesValue(), and Op.

bool BinaryOperator::isNeg ( const Value V  )  [static]

isNeg, isNot - Check if the given Value is a NEG or NOT instruction.

Definition at line 1082 of file Instructions.cpp.

References llvm::ConstantFP::get(), llvm::Constant::getNullValue(), llvm::Constant::getOperand(), and V.

Referenced by getNegArgument().

bool BinaryOperator::isNot ( const Value V  )  [static]

Definition at line 1092 of file Instructions.cpp.

References isConstantAllOnes(), and V.

Referenced by getNotArgument().

const Value * BinaryOperator::getNegArgument ( const Value BinOp  )  [static]

getNegArgument, getNotArgument - Helper functions to extract the unary argument of a NEG or NOT operation implemented via Sub or Xor.

Definition at line 1105 of file Instructions.cpp.

Value * BinaryOperator::getNegArgument ( Value BinOp  )  [static]

Definition at line 1100 of file Instructions.cpp.

References getOperand(), and isNeg().

const Value * BinaryOperator::getNotArgument ( const Value BinOp  )  [static]

Definition at line 1120 of file Instructions.cpp.

Value * BinaryOperator::getNotArgument ( Value BinOp  )  [static]

Definition at line 1109 of file Instructions.cpp.

References getOperand(), isConstantAllOnes(), and isNot().

BinaryOps llvm::BinaryOperator::getOpcode (  )  const [inline]

Subclass classification... getOpcode() returns a member of one of the enums that is coming soon (down below)...

Reimplemented from llvm::Instruction.

Definition at line 701 of file InstrTypes.h.

Referenced by FoldSetCCLogical::apply(), clone(), dyn_castFoldableMul(), FindSingleUseMultiplyFactors(), llvm::SetCondInst::getInverseCondition(), getSetCondCode(), llvm::SetCondInst::getSwappedCondition(), NegateValue(), OptimizeGlobalAddressOfMalloc(), and llvm::Interpreter::visitBinaryOperator().

BinaryOperator * BinaryOperator::clone (  )  const [virtual]

clone() - Create a copy of 'this' instruction that is identical in all ways except the following: The instruction has no parent The instruction has no name

Implements llvm::Instruction.

Definition at line 1313 of file Instructions.cpp.

References create(), and getOpcode().

Referenced by llvm::SimplifyCFG().

bool BinaryOperator::swapOperands (  ) 

swapOperands - Exchange the two operands to this instruction. This instruction is safe to use on any binary instruction and does not modify the semantics of the instruction. If the instruction is order dependent (SetLT f.e.) the opcode is changed. If the instruction cannot be reversed (ie, it's a Div), then return true.

FIXME: SetCC instructions shouldn't all have different opcodes.

Definition at line 1130 of file Instructions.cpp.

References llvm::Instruction::isCommutative().

Referenced by FoldSetCCLogical::apply().

static bool llvm::BinaryOperator::classof ( const BinaryOperator  )  [inline, static]

Definition at line 717 of file InstrTypes.h.

static bool llvm::BinaryOperator::classof ( const Instruction I  )  [inline, static]

Methods for support type inquiry through isa, cast, and dyn_cast:.

Reimplemented from llvm::Instruction.

Reimplemented in llvm::SetCondInst.

Definition at line 718 of file InstrTypes.h.

static bool llvm::BinaryOperator::classof ( const Value V  )  [inline, static]

Reimplemented from llvm::Instruction.

Reimplemented in llvm::SetCondInst.

Definition at line 721 of file InstrTypes.h.


Member Data Documentation

llvm::BinaryOperator::Alloca

Reimplemented from llvm::Instruction.

Definition at line 294 of file InstrTypes.h.

AllocaInst llvm::BinaryOperator::PHI

Reimplemented from llvm::Instruction.

Definition at line 302 of file InstrTypes.h.

AllocaInst PHINode llvm::BinaryOperator::Call

Reimplemented from llvm::Instruction.

Definition at line 304 of file InstrTypes.h.

AllocaInst PHINode CallInst llvm::BinaryOperator::Select

Reimplemented from llvm::Instruction.

Definition at line 310 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst llvm::BinaryOperator::VAArg

Reimplemented from llvm::Instruction.

Definition at line 314 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst llvm::BinaryOperator::InsertElement

Reimplemented from llvm::Instruction.

Definition at line 316 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst llvm::BinaryOperator::Malloc

Reimplemented from llvm::Instruction.

Definition at line 458 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst llvm::BinaryOperator::Load

Reimplemented from llvm::Instruction.

Definition at line 461 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst llvm::BinaryOperator::Cast

Reimplemented from llvm::Instruction.

Definition at line 469 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst CastInst llvm::BinaryOperator::Shl

Reimplemented from llvm::Instruction.

Definition at line 472 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst CastInst ShiftInst llvm::BinaryOperator::UserOp1

Reimplemented from llvm::Instruction.

Definition at line 478 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst CastInst ShiftInst Instruction llvm::BinaryOperator::ExtractElement

Reimplemented from llvm::Instruction.

Definition at line 481 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst MallocInst LoadInst CastInst ShiftInst Instruction ExtractElementInst llvm::BinaryOperator::ShuffleVector

Reimplemented from llvm::Instruction.

Definition at line 483 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst const std::string& llvm::BinaryOperator::Name = ""

Reimplemented from llvm::Value.

Definition at line 679 of file InstrTypes.h.

AllocaInst PHINode CallInst SelectInst VAArgInst InsertElementInst const std::string Instruction* llvm::BinaryOperator::InsertBefore = 0)

Definition at line 680 of file InstrTypes.h.

Referenced by create(), and createNot().


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