From 38f598b9cf717ddbeeb806fd74b9b49fd4f35a63 Mon Sep 17 00:00:00 2001 From: rturrado Date: Tue, 12 Nov 2024 17:08:54 +0100 Subject: [PATCH] Add non_gate_list. --- include/libqasm/v3x/instruction_set.hpp | 2 ++ src/v3x/instruction_set.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/libqasm/v3x/instruction_set.hpp b/include/libqasm/v3x/instruction_set.hpp index caaf3ca8..85ac25c8 100644 --- a/include/libqasm/v3x/instruction_set.hpp +++ b/include/libqasm/v3x/instruction_set.hpp @@ -24,6 +24,7 @@ class InstructionSet { InstructionListT single_qubit_named_gate_list; InstructionListT two_qubit_named_gate_list; + InstructionListT non_gate_list; InstructionSet(); @@ -51,6 +52,7 @@ class InstructionSet { [[nodiscard]] const GateModifierMapT& get_gate_modifier_map() const; [[nodiscard]] const InstructionListT& get_single_qubit_named_gate_list() const; [[nodiscard]] const InstructionListT& get_two_qubit_named_gate_list() const; + [[nodiscard]] const InstructionListT& get_non_gate_list() const; [[nodiscard]] bool is_single_qubit_named_gate(const std::string& name) const; [[nodiscard]] bool is_two_qubit_named_gate(const std::string& name) const; diff --git a/src/v3x/instruction_set.cpp b/src/v3x/instruction_set.cpp index c9bfe185..79cb057f 100644 --- a/src/v3x/instruction_set.cpp +++ b/src/v3x/instruction_set.cpp @@ -86,6 +86,9 @@ InstructionSet::InstructionSet() , two_qubit_named_gate_list{ "CNOT", "CR", "CRk", "CZ", "SWAP" } +, non_gate_list{ + "measure", "reset", "init", "barrier", "wait" +} {} [[nodiscard]] /* static */ InstructionSet& InstructionSet::get_instance() { @@ -113,6 +116,10 @@ InstructionSet::InstructionSet() return two_qubit_named_gate_list; } +[[nodiscard]] const InstructionListT& InstructionSet::get_non_gate_list() const { + return non_gate_list; +} + [[nodiscard]] bool InstructionSet::is_single_qubit_named_gate(const std::string& name) const { return single_qubit_named_gate_list.contains(name); } @@ -170,7 +177,7 @@ InstructionSet::InstructionSet() } [[nodiscard]] bool InstructionSet::is_non_gate(const std::string& name) const { - return is_measure(name) || is_reset(name) || is_init(name) || is_barrier(name) || is_wait(name); + return non_gate_list.contains(name); } [[nodiscard]] bool InstructionSet::is_inv_gate_modifier(const std::string& name) const {