| 341 | } |
| 342 | |
| 343 | void QCodarMatch::execute(std::shared_ptr<AbstractQGateNode> cur_node, std::shared_ptr<QNode> parent_node, bool &is_dagger) |
| 344 | { |
| 345 | QVec qgate_ctrl_qubits; |
| 346 | cur_node->getControlVector(qgate_ctrl_qubits); |
| 347 | auto type = cur_node->getQGate()->getGateType(); |
| 348 | if (type != GateType::BARRIER_GATE && !qgate_ctrl_qubits.empty()) |
| 349 | { |
| 350 | QCERR("control qubits in qgate are not supported!"); |
| 351 | throw invalid_argument("control qubits in qgate are not supported!"); |
| 352 | } |
| 353 | |
| 354 | GateInfo g; |
| 355 | QVec qv; |
| 356 | cur_node->getQuBitVector(qv); |
| 357 | |
| 358 | g.type = type; |
| 359 | g.is_dagger = cur_node->isDagger() ^ is_dagger; |
| 360 | auto iter = m_gatetype.find(g.type); |
| 361 | if (iter == m_gatetype.end()) |
| 362 | { |
| 363 | QCERR("invalid gate type."); |
| 364 | throw invalid_argument("invalid gate type."); |
| 365 | } |
| 366 | g.gate_name = iter->second; |
| 367 | g.barrier_id = -1; |
| 368 | switch (type) |
| 369 | { |
| 370 | case GateType::PAULI_X_GATE: |
| 371 | case GateType::PAULI_Y_GATE: |
| 372 | case GateType::PAULI_Z_GATE: |
| 373 | case GateType::X_HALF_PI: |
| 374 | case GateType::Y_HALF_PI: |
| 375 | case GateType::Z_HALF_PI: |
| 376 | case GateType::HADAMARD_GATE: |
| 377 | case GateType::T_GATE: |
| 378 | case GateType::S_GATE: |
| 379 | { |
| 380 | g.control = -1; |
| 381 | g.target = qv[0]->getPhysicalQubitPtr()->getQubitAddr(); |
| 382 | } |
| 383 | break; |
| 384 | case GateType::BARRIER_GATE: |
| 385 | { |
| 386 | g.control = -1; |
| 387 | g.target = qv[0]->getPhysicalQubitPtr()->getQubitAddr(); |
| 388 | g.barrier_id = m_transform_barrier_id; |
| 389 | for (auto iter : qgate_ctrl_qubits) |
| 390 | { |
| 391 | auto temp_g = g; |
| 392 | temp_g.target = iter->get_phy_addr(); |
| 393 | m_original_gates.push_back(temp_g); |
| 394 | } |
| 395 | m_transform_barrier_id++; |
| 396 | } |
| 397 | break; |
| 398 | case GateType::RX_GATE: |
| 399 | case GateType::RY_GATE: |
| 400 | case GateType::RZ_GATE: |
no test coverage detected