ONE - On-device Neural Engine
Loading...
Searching...
No Matches
coco::BinaryOp Class Reference

Op with two arguments. More...

#include <Op.h>

Collaboration diagram for coco::BinaryOp:

Public Member Functions

 BinaryOp ()
 
 BinaryOp (const BinaryOp &)=delete
 
 BinaryOp (BinaryOp &&)=delete
 
virtual ~BinaryOp ()=default
 
uint32_t arity (void) const final
 Return the number of arguments (# of child Ops)
 
Oparg (uint32_t n) const final
 Return N-th argument.
 
std::set< Object * > uses (void) const final
 Return a set of object(s) used during execution.
 
Opleft (void) const
 
void left (Op *op)
 
Opright (void) const
 
void right (Op *op)
 
- Public Member Functions inherited from coco::Op
virtual ~Op ()
 
template<typename T >
accept (IVisitor< T > *v) const
 
template<typename T >
accept (IVisitor< T > &v) const
 
template<typename T >
accept (IVisitor< T > &&v) const
 
void accept (IMutator *m)
 
void accept (IMutator &m)
 
void accept (IMutator &&m)
 
Instrparent (void) const
 
Opup (void) const
 Return a pointer to the parent Op.
 
- Public Member Functions inherited from coco::Entity
virtual ~Entity ()=default
 
Modulemodule (void) const
 

Detailed Description

Op with two arguments.

Definition at line 213 of file Op.h.

Constructor & Destructor Documentation

◆ BinaryOp() [1/3]

coco::BinaryOp::BinaryOp ( )
explicit

Definition at line 100 of file Op.cpp.

100 : _left{this}, _right{this}
101{
102 // DO NOTHING
103}

◆ BinaryOp() [2/3]

coco::BinaryOp::BinaryOp ( const BinaryOp )
delete

◆ BinaryOp() [3/3]

coco::BinaryOp::BinaryOp ( BinaryOp &&  )
delete

◆ ~BinaryOp()

virtual coco::BinaryOp::~BinaryOp ( )
virtualdefault

Member Function Documentation

◆ arg()

Op * coco::BinaryOp::arg ( uint32_t  n) const
finalvirtual

Return N-th argument.

Note
The behavior of arg(n) is defined only when n < artiy()

Implements coco::Op.

Definition at line 111 of file Op.cpp.

112{
113 assert(n < arity());
114
115 return (n == 0) ? left() : right();
116}
Op * right(void) const
Definition Op.h:236
uint32_t arity(void) const final
Return the number of arguments (# of child Ops)
Definition Op.cpp:105
Op * left(void) const
Definition Op.h:232

References arity(), left(), and right().

◆ arity()

uint32_t coco::BinaryOp::arity ( void  ) const
finalvirtual

Return the number of arguments (# of child Ops)

Implements coco::Op.

Definition at line 105 of file Op.cpp.

106{
107 // There are two arguments
108 return 2;
109}

Referenced by arg().

◆ left() [1/2]

void coco::BinaryOp::left ( Op op)
inline

Definition at line 233 of file Op.h.

233{ _left.child(op); }
Op * child(void) const
Definition Part.h:40

References coco::Part::child().

◆ left() [2/2]

Op * coco::BinaryOp::left ( void  ) const
inline

◆ right() [1/2]

void coco::BinaryOp::right ( Op op)
inline

Definition at line 237 of file Op.h.

237{ _right.child(op); }

References coco::Part::child().

◆ right() [2/2]

Op * coco::BinaryOp::right ( void  ) const
inline

Definition at line 236 of file Op.h.

236{ return _right.child(); }

References coco::Part::child().

Referenced by arg(), uses(), OpPrinter::visit(), OpPrinter::visit(), OpPrinter::visit(), OpPrinter::visit(), and OpPrinter::visit().

◆ uses()

std::set< Object * > coco::BinaryOp::uses ( void  ) const
finalvirtual

Return a set of object(s) used during execution.

NOTE There is no 'def' method as Op is not allowed to define a new object

Implements coco::Op.

Definition at line 118 of file Op.cpp.

119{
120 std::set<Object *> res;
121
122 if (auto l = left())
123 {
124 for (auto obj : l->uses())
125 {
126 res.insert(obj);
127 }
128 }
129
130 if (auto r = right())
131 {
132 for (auto obj : r->uses())
133 {
134 res.insert(obj);
135 }
136 }
137
138 return res;
139}
std::set< Object * > uses(void) const final
Return a set of object(s) used during execution.
Definition Op.cpp:118

References left(), and right().


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