Lines Matching defs:gate

20 int32_t CombinedPassVisitor::GetGateOrder(GateRef gate)
22 auto id = acc_.GetId(gate);
26 return orderList_[acc_.GetId(gate)];
29 void CombinedPassVisitor::SetGateOrder(GateRef gate, int32_t orderId)
31 auto id = acc_.GetId(gate);
35 orderList_[acc_.GetId(gate)] = orderId;
48 void CombinedPassVisitor::LogicallyReplaceGate(GateRef gate, GateRef replacement)
50 auto uses = acc_.Uses(gate);
58 void CombinedPassVisitor::RelaxStateAndDepend(GateRef gate)
60 ReplaceGate(gate, StateDepend {acc_.GetState(gate), acc_.GetDep(gate)}, gate);
63 void CombinedPassVisitor::ReplaceGate(GateRef gate, GateRef replacement)
66 if (acc_.GetDependCount(gate) > 0) {
67 ASSERT(acc_.GetDependCount(gate) == 1 || acc_.GetOpCode(replacement) == OpCode::DEAD); // 1: one dep
68 depend = acc_.GetDep(gate);
71 if (acc_.GetStateCount(gate) > 0) {
72 ASSERT(acc_.GetStateCount(gate) == 1 || acc_.GetOpCode(replacement) == OpCode::DEAD); // 1: one state
73 state = acc_.GetState(gate);
75 ReplaceGate(gate, StateDepend {state, depend}, replacement);
76 acc_.DeleteGate(gate);
79 void CombinedPassVisitor::ReplaceGate(GateRef gate, StateDepend stateDepend, GateRef replacement)
83 auto uses = acc_.Uses(gate);
101 acc_.GetCircuit()->AddComment(replacement, "old V " + std::to_string(acc_.GetId(gate)));
105 void CombinedPassVisitor::VistDependSelectorForLoop(GateRef gate)
107 auto use = acc_.Uses(gate);
125 for (auto gate : gateList) {
126 if (acc_.GetOpCode(gate) == OpCode::LOOP_BEGIN) {
127 PushChangedGate(gate);
129 VistDependSelectorForLoop(gate);
132 // Visit gate needing to start from RETURN, otherwise it may lead to incomplete early elimination in some scenarios.
144 GateRef gate = changedList_.back();
146 if (acc_.GetMark(gate) == MarkCode::PREVISIT) {
147 PushGate(gate, 0);
158 void CombinedPassVisitor::ReVisitGate(GateRef gate)
160 if (acc_.GetMark(gate) == MarkCode::FINISHED) {
161 PushChangedGate(gate);
166 GateRef CombinedPassVisitor::VisitGate(GateRef gate)
168 [[maybe_unused]] auto scopedGate = circuit_->VisitGateBegin(gate);
175 GateRef replacement = (*i)->VisitGate(gate);
176 if (replacement == gate) {
188 return gate;
193 GateRef gate = current.GetGate();
194 // gate is delete or dead
195 if (acc_.IsNop(gate)) {
196 PopGate(gate);
199 auto numIns = acc_.GetNumIns(gate);
205 GateRef input = acc_.GetIn(gate, i);
206 if (input == gate) {
209 // find not visited gate, push stack
218 GateRef input = acc_.GetIn(gate, i);
219 if (input == gate) {
222 // find not visited gate, push stack
231 if (GetGateOrder(gate) == -1) { // -1 : not visited before
232 SetGateOrder(gate, ++orderCount_);
234 GateRef replacement = VisitGate(gate);
235 PopGate(gate);
239 if (replacement != gate) {
240 ReplaceGate(gate, replacement);
242 // revisit not on stack gate.
243 auto uses = acc_.Uses(gate);
257 GateRef gate = current.GetGate();
258 log += std::to_string(acc_.GetId(gate)) + ", ";