From a6dee376d84e8ac267a49aac1c95333631132c8e Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Wed, 8 Nov 2023 09:30:29 +0000 Subject: [PATCH] refactor: remove add_op_ by generalizing add_node_ with "impl Into" (#642) * Add a mildly-funky `Into` conversion from OpType to NodeType using the `new_auto` added in #635 * Generalize add_node_(with_parent,etc.) methods to take `impl Into`, and then remove corresponding `add_op_....` * `add_op_after` had no corresponding `add_node_after`, so just turn it into that * leave Hugr::add_node in simple form, without the `impl Into" BREAKING CHANGE: add_op_{with_parent,before,after} removed => use add_node_.... --- src/builder.rs | 4 +- src/builder/build_traits.rs | 17 ++-- src/builder/cfg.rs | 6 +- src/builder/conditional.rs | 2 +- src/extension/infer.rs | 52 +++++------ src/extension/op_def.rs | 8 +- src/extension/prelude.rs | 2 +- src/hugr.rs | 17 +--- src/hugr/hugrmut.rs | 77 ++++++++--------- src/hugr/rewrite/insert_identity.rs | 2 +- src/hugr/rewrite/simple_replace.rs | 2 +- src/hugr/serialize.rs | 2 +- src/hugr/validate.rs | 55 ++++++------ src/std_extensions/arithmetic/conversions.rs | 8 +- src/std_extensions/arithmetic/float_ops.rs | 32 +++---- src/std_extensions/arithmetic/int_ops.rs | 90 ++++++++++---------- src/std_extensions/collections.rs | 4 +- src/std_extensions/logic.rs | 6 +- src/std_extensions/quantum.rs | 18 ++-- 19 files changed, 190 insertions(+), 214 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index b2b8d7371..5e437bcbc 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -149,14 +149,14 @@ pub(crate) mod test { let mut hugr = Hugr::new(NodeType::new_pure(ops::DFG { signature: signature.clone(), })); - hugr.add_op_with_parent( + hugr.add_node_with_parent( hugr.root(), ops::Input { types: signature.input, }, ) .unwrap(); - hugr.add_op_with_parent( + hugr.add_node_with_parent( hugr.root(), ops::Output { types: signature.output, diff --git a/src/builder/build_traits.rs b/src/builder/build_traits.rs index 950a85903..9b27c9ef9 100644 --- a/src/builder/build_traits.rs +++ b/src/builder/build_traits.rs @@ -47,7 +47,7 @@ pub trait Container { /// Add an [`OpType`] as the final child of the container. fn add_child_op(&mut self, op: impl Into) -> Result { let parent = self.container_node(); - Ok(self.hugr_mut().add_op_with_parent(parent, op)?) + Ok(self.hugr_mut().add_node_with_parent(parent, op)?) } /// Add a [`NodeType`] as the final child of the container. fn add_child_node(&mut self, node: NodeType) -> Result { @@ -416,7 +416,7 @@ pub trait Dataflow: Container { rest: rest_types.into(), }; // TODO: Make input extensions a parameter - let (loop_node, _) = add_op_with_wires(self, tail_loop.clone(), input_wires)?; + let (loop_node, _) = add_node_with_wires(self, tail_loop.clone(), input_wires)?; TailLoopBuilder::create_with_io(self.hugr_mut(), loop_node, &tail_loop) } @@ -623,21 +623,14 @@ pub trait Dataflow: Container { } } -fn add_op_with_wires( - data_builder: &mut T, - optype: impl Into, - inputs: Vec, -) -> Result<(Node, usize), BuildError> { - add_node_with_wires(data_builder, NodeType::new_auto(optype), inputs) -} - fn add_node_with_wires( data_builder: &mut T, - nodetype: NodeType, + nodetype: impl Into, inputs: Vec, ) -> Result<(Node, usize), BuildError> { - let op_node = data_builder.add_child_node(nodetype.clone())?; + let nodetype = nodetype.into(); let sig = nodetype.op_signature(); + let op_node = data_builder.add_child_node(nodetype)?; wire_up_inputs(inputs, op_node, data_builder)?; diff --git a/src/builder/cfg.rs b/src/builder/cfg.rs index 809093652..de99f5de9 100644 --- a/src/builder/cfg.rs +++ b/src/builder/cfg.rs @@ -92,7 +92,7 @@ impl + AsRef> CFGBuilder { let exit_node = base .as_mut() // Make the extensions a parameter - .add_op_with_parent(cfg_node, exit_block_type)?; + .add_node_with_parent(cfg_node, exit_block_type)?; Ok(Self { base, cfg_node, @@ -144,10 +144,10 @@ impl + AsRef> CFGBuilder { let block_n = if entry { let exit = self.exit_node; // TODO: Make extensions a parameter - self.hugr_mut().add_op_before(exit, op) + self.hugr_mut().add_node_before(exit, op) } else { // TODO: Make extensions a parameter - self.hugr_mut().add_op_with_parent(parent, op) + self.hugr_mut().add_node_with_parent(parent, op) }?; BlockBuilder::create( diff --git a/src/builder/conditional.rs b/src/builder/conditional.rs index 6a46b5e55..e6219f46a 100644 --- a/src/builder/conditional.rs +++ b/src/builder/conditional.rs @@ -126,7 +126,7 @@ impl + AsRef> ConditionalBuilder { let case_node = // add case before any existing subsequent cases if let Some(&sibling_node) = self.case_nodes[case + 1..].iter().flatten().next() { - self.hugr_mut().add_op_before(sibling_node, case_op)? + self.hugr_mut().add_node_before(sibling_node, case_op)? } else { self.add_child_op(case_op)? }; diff --git a/src/extension/infer.rs b/src/extension/infer.rs index 47eb88e67..b9525a18a 100644 --- a/src/extension/infer.rs +++ b/src/extension/infer.rs @@ -698,8 +698,8 @@ mod test { let input = ops::Input::new(type_row![NAT, NAT]); let output = ops::Output::new(type_row![NAT]); - let input = hugr.add_op_with_parent(hugr.root(), input)?; - let output = hugr.add_op_with_parent(hugr.root(), output)?; + let input = hugr.add_node_with_parent(hugr.root(), input)?; + let output = hugr.add_node_with_parent(hugr.root(), output)?; assert_matches!(hugr.get_io(hugr.root()), Some(_)); @@ -715,25 +715,25 @@ mod test { let mult_c_sig = FunctionType::new(type_row![NAT, NAT], type_row![NAT]) .with_extension_delta(&ExtensionSet::singleton(&C)); - let add_a = hugr.add_op_with_parent( + let add_a = hugr.add_node_with_parent( hugr.root(), ops::DFG { signature: add_a_sig, }, )?; - let add_b = hugr.add_op_with_parent( + let add_b = hugr.add_node_with_parent( hugr.root(), ops::DFG { signature: add_b_sig, }, )?; - let add_ab = hugr.add_op_with_parent( + let add_ab = hugr.add_node_with_parent( hugr.root(), ops::DFG { signature: add_ab_sig, }, )?; - let mult_c = hugr.add_op_with_parent( + let mult_c = hugr.add_node_with_parent( hugr.root(), ops::DFG { signature: mult_c_sig, @@ -877,7 +877,7 @@ mod test { let [input, output] = hugr.get_io(hugr.root()).unwrap(); let add_r_sig = FunctionType::new(type_row![NAT], type_row![NAT]).with_extension_delta(&rs); - let add_r = hugr.add_op_with_parent( + let add_r = hugr.add_node_with_parent( hugr.root(), ops::DFG { signature: add_r_sig, @@ -888,11 +888,11 @@ mod test { let src_sig = FunctionType::new(type_row![], type_row![NAT]) .with_extension_delta(&ExtensionSet::new()); - let src = hugr.add_op_with_parent(hugr.root(), ops::DFG { signature: src_sig })?; + let src = hugr.add_node_with_parent(hugr.root(), ops::DFG { signature: src_sig })?; let mult_sig = FunctionType::new(type_row![NAT, NAT], type_row![NAT]); // Mult has open extension requirements, which we should solve to be "R" - let mult = hugr.add_op_with_parent( + let mult = hugr.add_node_with_parent( hugr.root(), ops::DFG { signature: mult_sig, @@ -956,14 +956,14 @@ mod test { ) -> Result<[Node; 3], Box> { let op: OpType = op.into(); - let node = hugr.add_op_with_parent(parent, op)?; - let input = hugr.add_op_with_parent( + let node = hugr.add_node_with_parent(parent, op)?; + let input = hugr.add_node_with_parent( node, ops::Input { types: op_sig.input, }, )?; - let output = hugr.add_op_with_parent( + let output = hugr.add_node_with_parent( node, ops::Output { types: op_sig.output, @@ -988,7 +988,7 @@ mod test { Into::::into(op).signature(), )?; - let lift1 = hugr.add_op_with_parent( + let lift1 = hugr.add_node_with_parent( case, ops::LeafOp::Lift { type_row: type_row![NAT], @@ -996,7 +996,7 @@ mod test { }, )?; - let lift2 = hugr.add_op_with_parent( + let lift2 = hugr.add_node_with_parent( case, ops::LeafOp::Lift { type_row: type_row![NAT], @@ -1066,13 +1066,13 @@ mod test { })); let root = hugr.root(); - let input = hugr.add_op_with_parent( + let input = hugr.add_node_with_parent( root, ops::Input { types: type_row![NAT], }, )?; - let output = hugr.add_op_with_parent( + let output = hugr.add_node_with_parent( root, ops::Output { types: type_row![NAT], @@ -1097,7 +1097,7 @@ mod test { .unwrap(); let lift = hugr - .add_op_with_parent( + .add_node_with_parent( node, ops::LeafOp::Lift { type_row: type_row![NAT], @@ -1149,7 +1149,7 @@ mod test { let [bb, bb_in, bb_out] = create_with_io(hugr, bb_parent, dfb, dfb_sig)?; - let dfg = hugr.add_op_with_parent(bb, op)?; + let dfg = hugr.add_node_with_parent(bb, op)?; hugr.connect(bb_in, 0, dfg, 0)?; hugr.connect(dfg, 0, bb_out, 0)?; @@ -1181,16 +1181,16 @@ mod test { extension_delta: entry_extensions, }; - let exit = hugr.add_op_with_parent( + let exit = hugr.add_node_with_parent( root, ops::BasicBlock::Exit { cfg_outputs: exit_types.into(), }, )?; - let entry = hugr.add_op_before(exit, dfb)?; - let entry_in = hugr.add_op_with_parent(entry, ops::Input { types: inputs })?; - let entry_out = hugr.add_op_with_parent( + let entry = hugr.add_node_before(exit, dfb)?; + let entry_in = hugr.add_node_with_parent(entry, ops::Input { types: inputs })?; + let entry_out = hugr.add_node_with_parent( entry, ops::Output { types: vec![entry_tuple_sum].into(), @@ -1245,7 +1245,7 @@ mod test { type_row![NAT], )?; - let mkpred = hugr.add_op_with_parent( + let mkpred = hugr.add_node_with_parent( entry, make_opaque( A, @@ -1341,7 +1341,7 @@ mod test { type_row![NAT], )?; - let entry_mid = hugr.add_op_with_parent( + let entry_mid = hugr.add_node_with_parent( entry, make_opaque(UNKNOWN_EXTENSION, FunctionType::new(vec![NAT], twoway(NAT))), )?; @@ -1427,7 +1427,7 @@ mod test { type_row![NAT], )?; - let entry_dfg = hugr.add_op_with_parent( + let entry_dfg = hugr.add_node_with_parent( entry, make_opaque( UNKNOWN_EXTENSION, @@ -1508,7 +1508,7 @@ mod test { type_row![NAT], )?; - let entry_mid = hugr.add_op_with_parent( + let entry_mid = hugr.add_node_with_parent( entry, make_opaque(UNKNOWN_EXTENSION, FunctionType::new(vec![NAT], oneway(NAT))), )?; diff --git a/src/extension/op_def.rs b/src/extension/op_def.rs index 8fe92e4fc..7975c1df2 100644 --- a/src/extension/op_def.rs +++ b/src/extension/op_def.rs @@ -270,7 +270,7 @@ impl Extension { } /// Create an OpDef with custom binary code to compute the signature - pub fn add_op_custom_sig( + pub fn add_node_custom_sig( &mut self, name: SmolStr, description: String, @@ -291,14 +291,14 @@ impl Extension { /// Create an OpDef with custom binary code to compute the signature, and no "misc" or "lowering /// functions" defined. - pub fn add_op_custom_sig_simple( + pub fn add_node_custom_sig_simple( &mut self, name: SmolStr, description: String, params: Vec, signature_func: impl CustomSignatureFunc + 'static, ) -> Result<&OpDef, ExtensionBuildError> { - self.add_op_custom_sig( + self.add_node_custom_sig( name, description, params, @@ -310,7 +310,7 @@ impl Extension { /// Create an OpDef with a signature (inputs+outputs) read from the /// declarative YAML - pub fn add_op_decl_sig( + pub fn add_node_decl_sig( &mut self, name: SmolStr, description: String, diff --git a/src/extension/prelude.rs b/src/extension/prelude.rs index 07e88ddb8..0ceb625d7 100644 --- a/src/extension/prelude.rs +++ b/src/extension/prelude.rs @@ -41,7 +41,7 @@ lazy_static! { .unwrap(); prelude - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( SmolStr::new_inline(NEW_ARRAY_OP_ID), "Create a new array from elements".to_string(), vec![TypeParam::Type(TypeBound::Any), TypeParam::max_nat()], diff --git a/src/hugr.rs b/src/hugr.rs index 128eee522..0081e9743 100644 --- a/src/hugr.rs +++ b/src/hugr.rs @@ -150,13 +150,9 @@ impl NodeType { } } -impl OpType { - /// Convert an OpType to a NodeType by giving it some input extensions - pub fn with_extensions(self, rs: ExtensionSet) -> NodeType { - NodeType { - op: self, - input_extensions: Some(rs), - } +impl> From for NodeType { + fn from(value: T) -> Self { + NodeType::new_auto(value.into()) } } @@ -246,11 +242,6 @@ impl Hugr { } } - /// Add a node to the graph, with the default conversion from OpType to NodeType - pub(crate) fn add_op(&mut self, op: impl Into) -> Node { - self.add_node(NodeType::new_auto(op)) - } - /// Add a node to the graph. pub(crate) fn add_node(&mut self, nodetype: NodeType) -> Node { let node = self @@ -400,7 +391,7 @@ mod test { FunctionType::new(type_row![BIT], type_row![BIT]).with_extension_delta(&r), ); let [input, output] = hugr.get_io(hugr.root()).unwrap(); - let lift = hugr.add_op_with_parent( + let lift = hugr.add_node_with_parent( hugr.root(), ops::LeafOp::Lift { type_row: type_row![BIT], diff --git a/src/hugr/hugrmut.rs b/src/hugr/hugrmut.rs index 3e1ef81dc..868d5daf0 100644 --- a/src/hugr/hugrmut.rs +++ b/src/hugr/hugrmut.rs @@ -9,7 +9,6 @@ use portgraph::{LinkMut, NodeIndex, PortMut, PortView, SecondaryMap}; use crate::hugr::views::SiblingSubgraph; use crate::hugr::{Direction, HugrError, HugrView, Node, NodeType, RootTagged}; use crate::hugr::{NodeMetadata, Rewrite}; -use crate::ops::OpType; use crate::{Hugr, IncomingPort, OutgoingPort, Port, PortIndex}; use self::sealed::HugrMutInternals; @@ -32,19 +31,11 @@ pub trait HugrMut: HugrMutInternals { /// /// The node becomes the parent's last child. #[inline] - fn add_op_with_parent( + fn add_node_with_parent( &mut self, parent: Node, - op: impl Into, + op: impl Into, ) -> Result { - self.add_node_with_parent(parent, NodeType::new_auto(op)) - } - - /// Add a node to the graph with a parent in the hierarchy. - /// - /// The node becomes the parent's last child. - #[inline] - fn add_node_with_parent(&mut self, parent: Node, op: NodeType) -> Result { self.valid_node(parent)?; self.hugr_mut().add_node_with_parent(parent, op) } @@ -52,22 +43,12 @@ pub trait HugrMut: HugrMutInternals { /// Add a node to the graph as the previous sibling of another node. /// /// The sibling node's parent becomes the new node's parent. - /// - /// # Errors - /// - /// - If the sibling node does not have a parent. - /// - If the attachment would introduce a cycle. #[inline] - fn add_op_before(&mut self, sibling: Node, op: impl Into) -> Result { - self.valid_non_root(sibling)?; - self.hugr_mut().add_op_before(sibling, op) - } - - /// Add a node to the graph as the previous sibling of another node. - /// - /// The sibling node's parent becomes the new node's parent. - #[inline] - fn add_node_before(&mut self, sibling: Node, nodetype: NodeType) -> Result { + fn add_node_before( + &mut self, + sibling: Node, + nodetype: impl Into, + ) -> Result { self.valid_non_root(sibling)?; self.hugr_mut().add_node_before(sibling, nodetype) } @@ -81,9 +62,13 @@ pub trait HugrMut: HugrMutInternals { /// - If the sibling node does not have a parent. /// - If the attachment would introduce a cycle. #[inline] - fn add_op_after(&mut self, sibling: Node, op: impl Into) -> Result { + fn add_node_after( + &mut self, + sibling: Node, + op: impl Into, + ) -> Result { self.valid_non_root(sibling)?; - self.hugr_mut().add_op_after(sibling, op) + self.hugr_mut().add_node_after(sibling, op) } /// Remove a node from the graph. @@ -208,28 +193,36 @@ fn translate_indices(node_map: HashMap) -> HashMap + AsMut> HugrMut for T { - fn add_node_with_parent(&mut self, parent: Node, node: NodeType) -> Result { - let node = self.as_mut().add_node(node); + fn add_node_with_parent( + &mut self, + parent: Node, + node: impl Into, + ) -> Result { + let node = self.as_mut().add_node(node.into()); self.as_mut() .hierarchy .push_child(node.pg_index(), parent.pg_index())?; Ok(node) } - fn add_op_before(&mut self, sibling: Node, op: impl Into) -> Result { - self.add_node_before(sibling, NodeType::new_auto(op)) - } - - fn add_node_before(&mut self, sibling: Node, nodetype: NodeType) -> Result { - let node = self.as_mut().add_node(nodetype); + fn add_node_before( + &mut self, + sibling: Node, + nodetype: impl Into, + ) -> Result { + let node = self.as_mut().add_node(nodetype.into()); self.as_mut() .hierarchy .insert_before(node.pg_index(), sibling.pg_index())?; Ok(node) } - fn add_op_after(&mut self, sibling: Node, op: impl Into) -> Result { - let node = self.as_mut().add_op(op); + fn add_node_after( + &mut self, + sibling: Node, + op: impl Into, + ) -> Result { + let node = self.as_mut().add_node(op.into()); self.as_mut() .hierarchy .insert_after(node.pg_index(), sibling.pg_index())?; @@ -606,10 +599,8 @@ mod test { let module: Node = hugr.root(); // Start a main function with two nat inputs. - // - // `add_op` is equivalent to `add_root_op` followed by `set_parent` let f: Node = hugr - .add_op_with_parent( + .add_node_with_parent( module, ops::FuncDefn { name: "main".into(), @@ -623,10 +614,10 @@ mod test { .add_node_with_parent(f, NodeType::new_pure(ops::Input::new(type_row![NAT]))) .unwrap(); let f_out = hugr - .add_op_with_parent(f, ops::Output::new(type_row![NAT, NAT])) + .add_node_with_parent(f, ops::Output::new(type_row![NAT, NAT])) .unwrap(); let noop = hugr - .add_op_with_parent(f, LeafOp::Noop { ty: NAT }) + .add_node_with_parent(f, LeafOp::Noop { ty: NAT }) .unwrap(); hugr.connect(f_in, 0, noop, 0).unwrap(); diff --git a/src/hugr/rewrite/insert_identity.rs b/src/hugr/rewrite/insert_identity.rs index 4ac3331e8..d5613a59f 100644 --- a/src/hugr/rewrite/insert_identity.rs +++ b/src/hugr/rewrite/insert_identity.rs @@ -86,7 +86,7 @@ impl Rewrite for IdentityInsertion { return Err(IdentityInsertionError::InvalidParentNode); } let new_node = h - .add_op_with_parent(parent, LeafOp::Noop { ty }) + .add_node_with_parent(parent, LeafOp::Noop { ty }) .expect("Parent validity already checked."); h.connect(pre_node, pre_port, new_node, 0) .expect("Should only fail if ports don't exist."); diff --git a/src/hugr/rewrite/simple_replace.rs b/src/hugr/rewrite/simple_replace.rs index 9b661c8bd..d3c3a504b 100644 --- a/src/hugr/rewrite/simple_replace.rs +++ b/src/hugr/rewrite/simple_replace.rs @@ -103,7 +103,7 @@ impl Rewrite for SimpleReplacement { for &node in replacement_inner_nodes { // Add the nodes. let op: &OpType = self.replacement.get_optype(node); - let new_node = h.add_op_after(self_output_node, op.clone()).unwrap(); + let new_node = h.add_node_after(self_output_node, op.clone()).unwrap(); index_map.insert(node, new_node); // Move the metadata diff --git a/src/hugr/serialize.rs b/src/hugr/serialize.rs index edc517b0c..e8f715b1f 100644 --- a/src/hugr/serialize.rs +++ b/src/hugr/serialize.rs @@ -456,7 +456,7 @@ pub mod test { hugr.connect(old_in, 0, out, 0).unwrap(); // Now add a new input - let new_in = hugr.add_op(Input::new([QB].to_vec())); + let new_in = hugr.add_node(Input::new([QB].to_vec()).into()); hugr.disconnect(old_in, OutgoingPort::from(0)).unwrap(); hugr.connect(new_in, 0, out, 0).unwrap(); hugr.move_before_sibling(new_in, old_in).unwrap(); diff --git a/src/hugr/validate.rs b/src/hugr/validate.rs index 9cca30c54..7f5a8bbe8 100644 --- a/src/hugr/validate.rs +++ b/src/hugr/validate.rs @@ -774,7 +774,7 @@ mod test { let mut b = Hugr::default(); let root = b.root(); - let def = b.add_op_with_parent(root, def_op).unwrap(); + let def = b.add_node_with_parent(root, def_op).unwrap(); let _ = add_df_children(&mut b, def, copies); (b, def) @@ -785,13 +785,13 @@ mod test { /// Returns the node indices of each of the operations. fn add_df_children(b: &mut Hugr, parent: Node, copies: usize) -> (Node, Node, Node) { let input = b - .add_op_with_parent(parent, ops::Input::new(type_row![BOOL_T])) + .add_node_with_parent(parent, ops::Input::new(type_row![BOOL_T])) .unwrap(); let output = b - .add_op_with_parent(parent, ops::Output::new(vec![BOOL_T; copies])) + .add_node_with_parent(parent, ops::Output::new(vec![BOOL_T; copies])) .unwrap(); let copy = b - .add_op_with_parent(parent, LeafOp::Noop { ty: BOOL_T }) + .add_node_with_parent(parent, LeafOp::Noop { ty: BOOL_T }) .unwrap(); b.connect(input, 0, copy, 0).unwrap(); @@ -816,14 +816,14 @@ mod test { let tag_type = Type::new_unit_sum(tuple_sum_size as u8); let input = b - .add_op_with_parent(parent, ops::Input::new(type_row![BOOL_T])) + .add_node_with_parent(parent, ops::Input::new(type_row![BOOL_T])) .unwrap(); let output = b - .add_op_with_parent(parent, ops::Output::new(vec![tag_type.clone(), BOOL_T])) + .add_node_with_parent(parent, ops::Output::new(vec![tag_type.clone(), BOOL_T])) .unwrap(); - let tag_def = b.add_op_with_parent(b.root(), const_op).unwrap(); + let tag_def = b.add_node_with_parent(b.root(), const_op).unwrap(); let tag = b - .add_op_with_parent(parent, ops::LoadConstant { datatype: tag_type }) + .add_node_with_parent(parent, ops::LoadConstant { datatype: tag_type }) .unwrap(); b.connect(tag_def, 0, tag, 0).unwrap(); @@ -847,7 +847,7 @@ mod test { assert_eq!(b.validate(&EMPTY_REG), Ok(())); // Add another hierarchy root - let other = b.add_op(ops::Module); + let other = b.add_node(ops::Module.into()); assert_matches!( b.validate(&EMPTY_REG), Err(ValidationError::NoParent { node }) => assert_eq!(node, other) @@ -910,7 +910,7 @@ mod test { // Add a definition without children let def_sig = FunctionType::new(type_row![BOOL_T], type_row![BOOL_T, BOOL_T]); let new_def = b - .add_op_with_parent( + .add_node_with_parent( root, ops::FuncDefn { signature: def_sig, @@ -936,7 +936,7 @@ mod test { // After moving the previous definition to a valid place, // add an input node to the module subgraph let new_input = b - .add_op_with_parent(root, ops::Input::new(type_row![])) + .add_node_with_parent(root, ops::Input::new(type_row![])) .unwrap(); assert_matches!( b.validate_with_extension_closure(closure, &EMPTY_REG), @@ -1023,7 +1023,7 @@ mod test { // Construct a valid CFG, with one BasicBlock node and one exit node let block = b - .add_op_with_parent( + .add_node_with_parent( cfg, ops::BasicBlock::DFB { inputs: type_row![BOOL_T], @@ -1035,7 +1035,7 @@ mod test { .unwrap(); add_block_children(&mut b, block, 1); let exit = b - .add_op_with_parent( + .add_node_with_parent( cfg, ops::BasicBlock::Exit { cfg_outputs: type_row![BOOL_T], @@ -1049,7 +1049,7 @@ mod test { // Add an internal exit node let exit2 = b - .add_op_after( + .add_node_after( exit, ops::BasicBlock::Exit { cfg_outputs: type_row![BOOL_T], @@ -1103,7 +1103,7 @@ mod test { let [input, output] = h.get_io(h.root()).unwrap(); // Nested DFG BOOL_T -> BOOL_T - let sub_dfg = h.add_op_with_parent( + let sub_dfg = h.add_node_with_parent( h.root(), ops::DFG { signature: FunctionType::new_linear(type_row![BOOL_T]), @@ -1111,9 +1111,10 @@ mod test { )?; // this Xor has its 2nd input unconnected let sub_op = { - let sub_input = h.add_op_with_parent(sub_dfg, ops::Input::new(type_row![BOOL_T]))?; - let sub_output = h.add_op_with_parent(sub_dfg, ops::Output::new(type_row![BOOL_T]))?; - let sub_op = h.add_op_with_parent(sub_dfg, and_op())?; + let sub_input = h.add_node_with_parent(sub_dfg, ops::Input::new(type_row![BOOL_T]))?; + let sub_output = + h.add_node_with_parent(sub_dfg, ops::Output::new(type_row![BOOL_T]))?; + let sub_op = h.add_node_with_parent(sub_dfg, and_op())?; h.connect(sub_input, 0, sub_op, 0)?; h.connect(sub_op, 0, sub_output, 0)?; sub_op @@ -1149,7 +1150,7 @@ mod test { fn test_local_const() -> Result<(), HugrError> { let mut h = closed_dfg_root_hugr(FunctionType::new(type_row![BOOL_T], type_row![BOOL_T])); let [input, output] = h.get_io(h.root()).unwrap(); - let and = h.add_op_with_parent(h.root(), and_op())?; + let and = h.add_node_with_parent(h.root(), and_op())?; h.connect(input, 0, and, 0)?; h.connect(and, 0, output, 0)?; assert_eq!( @@ -1166,8 +1167,8 @@ mod test { .typed_value() .clone(); // Second input of Xor from a constant - let cst = h.add_op_with_parent(h.root(), const_op)?; - let lcst = h.add_op_with_parent(h.root(), ops::LoadConstant { datatype: BOOL_T })?; + let cst = h.add_node_with_parent(h.root(), const_op)?; + let lcst = h.add_node_with_parent(h.root(), ops::LoadConstant { datatype: BOOL_T })?; h.connect(cst, 0, lcst, 0)?; h.connect(lcst, 0, and, 1)?; // There is no edge from Input to LoadConstant, but that's OK: @@ -1352,9 +1353,9 @@ mod test { type_row![BOOL_T], )); let [input, output] = h.get_io(h.root()).unwrap(); - let and = h.add_op_with_parent(h.root(), and_op())?; - let not1 = h.add_op_with_parent(h.root(), not_op())?; - let not2 = h.add_op_with_parent(h.root(), not_op())?; + let and = h.add_node_with_parent(h.root(), and_op())?; + let not1 = h.add_node_with_parent(h.root(), not_op())?; + let not2 = h.add_node_with_parent(h.root(), not_op())?; h.connect(input, 0, and, 0)?; h.connect(and, 0, not1, 0)?; h.connect(not1, 0, and, 1)?; @@ -1370,7 +1371,7 @@ mod test { let row: TypeRow = vec![t].into(); let def = b - .add_op_with_parent( + .add_node_with_parent( b.root(), ops::FuncDefn { name: "main".into(), @@ -1380,9 +1381,9 @@ mod test { .unwrap(); let input = b - .add_op_with_parent(def, ops::Input::new(row.clone())) + .add_node_with_parent(def, ops::Input::new(row.clone())) .unwrap(); - let output = b.add_op_with_parent(def, ops::Output::new(row)).unwrap(); + let output = b.add_node_with_parent(def, ops::Output::new(row)).unwrap(); b.connect(input, 0, output, 0).unwrap(); (b, def) } diff --git a/src/std_extensions/arithmetic/conversions.rs b/src/std_extensions/arithmetic/conversions.rs index d07b97f62..235117317 100644 --- a/src/std_extensions/arithmetic/conversions.rs +++ b/src/std_extensions/arithmetic/conversions.rs @@ -44,7 +44,7 @@ pub fn extension() -> Extension { ); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "trunc_u".into(), "float to unsigned int".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -52,7 +52,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "trunc_s".into(), "float to signed int".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -60,7 +60,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "convert_u".into(), "unsigned int to float".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -68,7 +68,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "convert_s".into(), "signed int to float".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], diff --git a/src/std_extensions/arithmetic/float_ops.rs b/src/std_extensions/arithmetic/float_ops.rs index 5a8907300..5eabfa98d 100644 --- a/src/std_extensions/arithmetic/float_ops.rs +++ b/src/std_extensions/arithmetic/float_ops.rs @@ -41,16 +41,16 @@ pub fn extension() -> Extension { ); extension - .add_op_custom_sig_simple("feq".into(), "equality test".to_owned(), vec![], fcmp_sig) + .add_node_custom_sig_simple("feq".into(), "equality test".to_owned(), vec![], fcmp_sig) .unwrap(); extension - .add_op_custom_sig_simple("fne".into(), "inequality test".to_owned(), vec![], fcmp_sig) + .add_node_custom_sig_simple("fne".into(), "inequality test".to_owned(), vec![], fcmp_sig) .unwrap(); extension - .add_op_custom_sig_simple("flt".into(), "\"less than\"".to_owned(), vec![], fcmp_sig) + .add_node_custom_sig_simple("flt".into(), "\"less than\"".to_owned(), vec![], fcmp_sig) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "fgt".into(), "\"greater than\"".to_owned(), vec![], @@ -58,7 +58,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "fle".into(), "\"less than or equal\"".to_owned(), vec![], @@ -66,7 +66,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "fge".into(), "\"greater than or equal\"".to_owned(), vec![], @@ -74,22 +74,22 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple("fmax".into(), "maximum".to_owned(), vec![], fbinop_sig) + .add_node_custom_sig_simple("fmax".into(), "maximum".to_owned(), vec![], fbinop_sig) .unwrap(); extension - .add_op_custom_sig_simple("fmin".into(), "minimum".to_owned(), vec![], fbinop_sig) + .add_node_custom_sig_simple("fmin".into(), "minimum".to_owned(), vec![], fbinop_sig) .unwrap(); extension - .add_op_custom_sig_simple("fadd".into(), "addition".to_owned(), vec![], fbinop_sig) + .add_node_custom_sig_simple("fadd".into(), "addition".to_owned(), vec![], fbinop_sig) .unwrap(); extension - .add_op_custom_sig_simple("fsub".into(), "subtraction".to_owned(), vec![], fbinop_sig) + .add_node_custom_sig_simple("fsub".into(), "subtraction".to_owned(), vec![], fbinop_sig) .unwrap(); extension - .add_op_custom_sig_simple("fneg".into(), "negation".to_owned(), vec![], funop_sig) + .add_node_custom_sig_simple("fneg".into(), "negation".to_owned(), vec![], funop_sig) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "fabs".into(), "absolute value".to_owned(), vec![], @@ -97,7 +97,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "fmul".into(), "multiplication".to_owned(), vec![], @@ -105,13 +105,13 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple("fdiv".into(), "division".to_owned(), vec![], fbinop_sig) + .add_node_custom_sig_simple("fdiv".into(), "division".to_owned(), vec![], fbinop_sig) .unwrap(); extension - .add_op_custom_sig_simple("ffloor".into(), "floor".to_owned(), vec![], funop_sig) + .add_node_custom_sig_simple("ffloor".into(), "floor".to_owned(), vec![], funop_sig) .unwrap(); extension - .add_op_custom_sig_simple("fceil".into(), "ceiling".to_owned(), vec![], funop_sig) + .add_node_custom_sig_simple("fceil".into(), "ceiling".to_owned(), vec![], funop_sig) .unwrap(); extension diff --git a/src/std_extensions/arithmetic/int_ops.rs b/src/std_extensions/arithmetic/int_ops.rs index 4a6aae198..f1993b1f6 100644 --- a/src/std_extensions/arithmetic/int_ops.rs +++ b/src/std_extensions/arithmetic/int_ops.rs @@ -144,7 +144,7 @@ pub fn extension() -> Extension { ); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "iwiden_u".into(), "widen an unsigned integer to a wider one with the same value".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -152,7 +152,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "iwiden_s".into(), "widen a signed integer to a wider one with the same value".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -160,7 +160,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "inarrow_u".into(), "narrow an unsigned integer to a narrower one with the same value if possible" .to_owned(), @@ -169,7 +169,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "inarrow_s".into(), "narrow a signed integer to a narrower one with the same value if possible".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -177,7 +177,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "itobool".into(), "convert to bool (1 is true, 0 is false)".to_owned(), vec![], @@ -185,7 +185,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ifrombool".into(), "convert from bool (1 is true, 0 is false)".to_owned(), vec![], @@ -193,7 +193,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ieq".into(), "equality test".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -201,7 +201,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ine".into(), "inequality test".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -209,7 +209,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ilt_u".into(), "\"less than\" as unsigned integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -217,7 +217,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ilt_s".into(), "\"less than\" as signed integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -225,7 +225,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "igt_u".into(), "\"greater than\" as unsigned integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -233,7 +233,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "igt_s".into(), "\"greater than\" as signed integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -241,7 +241,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ile_u".into(), "\"less than or equal\" as unsigned integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -249,7 +249,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ile_s".into(), "\"less than or equal\" as signed integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -257,7 +257,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ige_u".into(), "\"greater than or equal\" as unsigned integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -265,7 +265,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ige_s".into(), "\"greater than or equal\" as signed integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -273,7 +273,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imax_u".into(), "maximum of unsigned integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -281,7 +281,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imax_s".into(), "maximum of signed integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -289,7 +289,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imin_u".into(), "minimum of unsigned integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -297,7 +297,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imin_s".into(), "minimum of signed integers".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -305,7 +305,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "iadd".into(), "addition modulo 2^N (signed and unsigned versions are the same op)".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -313,7 +313,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "isub".into(), "subtraction modulo 2^N (signed and unsigned versions are the same op)".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -321,7 +321,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ineg".into(), "negation modulo 2^N (signed and unsigned versions are the same op)".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -329,7 +329,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imul".into(), "multiplication modulo 2^N (signed and unsigned versions are the same op)".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -337,7 +337,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "idivmod_checked_u".into(), "given unsigned integers 0 <= n < 2^N, 0 <= m < 2^M, generates unsigned q, r where \ q*m+r=n, 0<=r Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "idivmod_u".into(), "given unsigned integers 0 <= n < 2^N, 0 <= m < 2^M, generates unsigned q, r where \ q*m+r=n, 0<=r Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "idivmod_checked_s".into(), "given signed integer -2^{N-1} <= n < 2^{N-1} and unsigned 0 <= m < 2^M, generates \ signed q and unsigned r where q*m+r=n, 0<=r Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "idivmod_s".into(), "given signed integer -2^{N-1} <= n < 2^{N-1} and unsigned 0 <= m < 2^M, generates \ signed q and unsigned r where q*m+r=n, 0<=r Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "idiv_checked_u".into(), "as idivmod_checked_u but discarding the second output".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -385,7 +385,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "idiv_u".into(), "as idivmod_u but discarding the second output".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -393,7 +393,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imod_checked_u".into(), "as idivmod_checked_u but discarding the first output".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -401,7 +401,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imod_u".into(), "as idivmod_u but discarding the first output".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -409,7 +409,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "idiv_checked_s".into(), "as idivmod_checked_s but discarding the second output".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -417,7 +417,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "idiv_s".into(), "as idivmod_s but discarding the second output".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -425,7 +425,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imod_checked_s".into(), "as idivmod_checked_s but discarding the first output".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -433,7 +433,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "imod_s".into(), "as idivmod_s but discarding the first output".to_owned(), vec![LOG_WIDTH_TYPE_PARAM, LOG_WIDTH_TYPE_PARAM], @@ -441,7 +441,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "iabs".into(), "convert signed to unsigned by taking absolute value".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -449,7 +449,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "iand".into(), "bitwise AND".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -457,7 +457,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ior".into(), "bitwise OR".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -465,7 +465,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ixor".into(), "bitwise XOR".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -473,7 +473,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "inot".into(), "bitwise NOT".to_owned(), vec![LOG_WIDTH_TYPE_PARAM], @@ -481,7 +481,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ishl".into(), "shift first input left by k bits where k is unsigned interpretation of second input \ (leftmost bits dropped, rightmost bits set to zero" @@ -491,7 +491,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "ishr".into(), "shift first input right by k bits where k is unsigned interpretation of second input \ (rightmost bits dropped, leftmost bits set to zero)" @@ -501,7 +501,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "irotl".into(), "rotate first input left by k bits where k is unsigned interpretation of second input \ (leftmost bits replace rightmost bits)" @@ -511,7 +511,7 @@ pub fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "irotr".into(), "rotate first input right by k bits where k is unsigned interpretation of second input \ (rightmost bits replace leftmost bits)" diff --git a/src/std_extensions/collections.rs b/src/std_extensions/collections.rs index facd4fce9..7e38305dd 100644 --- a/src/std_extensions/collections.rs +++ b/src/std_extensions/collections.rs @@ -72,7 +72,7 @@ fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig( + .add_node_custom_sig( POP_NAME, "Pop from back of list".into(), vec![TypeParam::Type(TypeBound::Any)], @@ -89,7 +89,7 @@ fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig( + .add_node_custom_sig( PUSH_NAME, "Push to back of list".into(), vec![TypeParam::Type(TypeBound::Any)], diff --git a/src/std_extensions/logic.rs b/src/std_extensions/logic.rs index 978c520c8..a2a59007e 100644 --- a/src/std_extensions/logic.rs +++ b/src/std_extensions/logic.rs @@ -34,7 +34,7 @@ fn extension() -> Extension { let mut extension = Extension::new(EXTENSION_ID); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( SmolStr::new_inline(NOT_NAME), "logical 'not'".into(), vec![], @@ -43,7 +43,7 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( SmolStr::new_inline(AND_NAME), "logical 'and'".into(), vec![H_INT], @@ -68,7 +68,7 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( SmolStr::new_inline(OR_NAME), "logical 'or'".into(), vec![H_INT], diff --git a/src/std_extensions/quantum.rs b/src/std_extensions/quantum.rs index 2c8d67498..92034d96c 100644 --- a/src/std_extensions/quantum.rs +++ b/src/std_extensions/quantum.rs @@ -199,7 +199,7 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "atrunc".into(), "truncate an angle to one with a lower log-denominator with the same value, rounding \ down in [0, 2π) if necessary" @@ -210,7 +210,7 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "aconvert".into(), "convert an angle to one with another log-denominator having the same value, if \ possible, otherwise return an error" @@ -221,7 +221,7 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "aadd".into(), "addition of angles".to_owned(), vec![LOG_DENOM_TYPE_PARAM], @@ -230,7 +230,7 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "asub".into(), "subtraction of the second angle from the first".to_owned(), vec![LOG_DENOM_TYPE_PARAM], @@ -239,7 +239,7 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( "aneg".into(), "negation of an angle".to_owned(), vec![LOG_DENOM_TYPE_PARAM], @@ -248,7 +248,7 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( SmolStr::new_inline("H"), "Hadamard".into(), vec![], @@ -256,7 +256,7 @@ fn extension() -> Extension { ) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( SmolStr::new_inline("RzF64"), "Rotation specified by float".into(), vec![], @@ -270,11 +270,11 @@ fn extension() -> Extension { .unwrap(); extension - .add_op_custom_sig_simple(SmolStr::new_inline("CX"), "CX".into(), vec![], two_qb_func) + .add_node_custom_sig_simple(SmolStr::new_inline("CX"), "CX".into(), vec![], two_qb_func) .unwrap(); extension - .add_op_custom_sig_simple( + .add_node_custom_sig_simple( SmolStr::new_inline("Measure"), "Measure a qubit, returning the qubit and the measurement result.".into(), vec![],