Skip to content

Commit

Permalink
Add non_gate_list.
Browse files Browse the repository at this point in the history
  • Loading branch information
rturrado committed Nov 12, 2024
1 parent e6bec30 commit 38f598b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/libqasm/v3x/instruction_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class InstructionSet {

InstructionListT single_qubit_named_gate_list;
InstructionListT two_qubit_named_gate_list;
InstructionListT non_gate_list;

InstructionSet();

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion src/v3x/instruction_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 38f598b

Please sign in to comment.