};
-//===----------------------------------------------------------------------===//
-// UnaryOperator Class
-//===----------------------------------------------------------------------===//
-
-class UnaryOperator : public Instruction {
-protected:
- UnaryOperator(Value *S, UnaryOps iType, const std::string &Name = "")
- : Instruction(S->getType(), iType, Name) {
- Operands.reserve(1);
- Operands.push_back(Use(S, this));
- }
-public:
-
- // create() - Construct a unary instruction, given the opcode
- // and its operand.
- //
- static UnaryOperator *create(UnaryOps Op, Value *Source,
- const std::string &Name = "");
-
- inline UnaryOps getOpcode() const {
- return (UnaryOps)Instruction::getOpcode();
- }
-
- virtual Instruction *clone() const {
- return create(getOpcode(), Operands[0]);
- }
-
- // Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const UnaryOperator *) { return true; }
- static inline bool classof(const Instruction *I) {
- return I->getOpcode() >= FirstUnaryOp && I->getOpcode() < NumUnaryOps;
- }
- static inline bool classof(const Value *V) {
- return isa<Instruction>(V) && classof(cast<Instruction>(V));
- }
-};
-
-
-
//===----------------------------------------------------------------------===//
// BinaryOperator Class
//===----------------------------------------------------------------------===//
inline bool isTerminator() const { // Instance of TerminatorInst?
return iType >= FirstTermOp && iType < NumTermOps;
}
- inline bool isUnaryOp() const {
- return iType >= FirstUnaryOp && iType < NumUnaryOps;
- }
inline bool isBinaryOp() const {
return iType >= FirstBinaryOp && iType < NumBinaryOps;
}
#include "llvm/InstrTypes.h"
-//===----------------------------------------------------------------------===//
-// Class to represent Unary operators
-//===----------------------------------------------------------------------===//
-//
-class GenericUnaryInst : public UnaryOperator {
-public:
- GenericUnaryInst(UnaryOps Opcode, Value *S1, const std::string &Name = "")
- : UnaryOperator(S1, Opcode, Name) {
- }
-};
-
//===----------------------------------------------------------------------===//
// Classes to represent Binary operators
//===----------------------------------------------------------------------===//
-//===-- iOperators.cpp - Implement the Binary & Unary Operators --*- C++ -*--=//
+//===-- iOperators.cpp - Implement binary Operators ------------*- C++ -*--===//
//
-// This file implements the nontrivial binary & unary operator instructions.
+// This file implements the nontrivial binary operator instructions.
//
//===----------------------------------------------------------------------===//
#include "llvm/iOperators.h"
#include "llvm/Type.h"
#include "llvm/Constants.h"
-using std::cerr;
-
-//===----------------------------------------------------------------------===//
-// UnaryOperator Class
-//===----------------------------------------------------------------------===//
-
-UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source,
- const std::string &Name) {
- switch (Op) {
- case Not: return new GenericUnaryInst(Op, Source, Name);
- default:
- cerr << "Don't know how to Create UnaryOperator " << Op << "\n";
- return 0;
- }
-}
-
//===----------------------------------------------------------------------===//
// BinaryOperator Class