diff --git a/.gitignore b/.gitignore index 485dee6..41ef32c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,18 @@ +### Rust template +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb +out + .idea diff --git a/.rusty-hook.toml b/.rusty-hook.toml new file mode 100644 index 0000000..7f5ba9c --- /dev/null +++ b/.rusty-hook.toml @@ -0,0 +1,5 @@ +[hooks] +pre-commit = "cargo fmt --all" +pre-push = "cargo build" +[logging] +verbose = true diff --git a/ir/Cargo.toml b/Cargo.toml similarity index 71% rename from ir/Cargo.toml rename to Cargo.toml index 136b1c0..181221f 100644 --- a/ir/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,12 @@ [workspace] resolver = "2" members = [ - "crates/back", - "crates/compiler", - "crates/front", - "crates/middle"] + "ir/crates/back", + "ir/crates/compiler", + "ir/crates/front", + "ir/crates/middle", + "lang" +] [profile.release] opt-level = 3 @@ -15,7 +17,6 @@ strip = "symbols" [profile.dev.package."*"] opt-level = 3 - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index f8c5510..5a1e5fe 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,21 @@ See [here](./lang/README.md) for more information. ## Example Package Manager Yet to be implemented. + +## Project setup + +### Setup git commit hooks + +To manage git hooks, we use [Rusty Hook](https://github.com/swellaby/rusty-hook). + +To install Rusty Hook, run the following command: + +```bash +cargo install rusty-hook +``` + +To install the git hooks, run the following command: + +```bash +rusty-hook init +``` diff --git a/ir/clippy.toml b/clippy.toml similarity index 100% rename from ir/clippy.toml rename to clippy.toml diff --git a/ir/crates/back/src/codegen/machine/abi/calling_convention.rs b/ir/crates/back/src/codegen/machine/abi/calling_convention.rs index 690b371..9d5454b 100644 --- a/ir/crates/back/src/codegen/machine/abi/calling_convention.rs +++ b/ir/crates/back/src/codegen/machine/abi/calling_convention.rs @@ -6,8 +6,8 @@ use crate::codegen::{ pub trait CallingConvention { type Reg: machine::PhysicalRegister; - fn parameter_slots(params: impl Iterator) - -> impl Iterator>; + fn parameter_slots(params: impl Iterator) + -> impl Iterator>; fn return_slot(size: Size) -> Slot; } diff --git a/ir/crates/back/src/codegen/machine/abi/mod.rs b/ir/crates/back/src/codegen/machine/abi/mod.rs index 658f7be..5528870 100644 --- a/ir/crates/back/src/codegen/machine/abi/mod.rs +++ b/ir/crates/back/src/codegen/machine/abi/mod.rs @@ -1,3 +1,3 @@ pub use calling_convention::CallingConvention; -pub mod calling_convention; \ No newline at end of file +pub mod calling_convention; diff --git a/ir/crates/back/src/codegen/machine/backend.rs b/ir/crates/back/src/codegen/machine/backend.rs index 48f08b4..7ca3e9a 100644 --- a/ir/crates/back/src/codegen/machine/backend.rs +++ b/ir/crates/back/src/codegen/machine/backend.rs @@ -11,11 +11,11 @@ use crate::codegen::{ }, Function, }, + Instr, TargetMachine, }, selection_dag::Immediate, }; -use crate::codegen::machine::Instr; type Reg = <::TM as TargetMachine>::Reg; type BackInstr = <::TM as TargetMachine>::Instr; @@ -23,7 +23,7 @@ type BackInstr = <::TM as TargetMachine>::Instr; pub trait Backend { type TM: TargetMachine; - type P: Pattern; + type P: Pattern; fn patterns() -> &'static [Self::P]; diff --git a/ir/crates/back/src/codegen/machine/function/builder.rs b/ir/crates/back/src/codegen/machine/function/builder.rs index 0bcc768..01db69c 100644 --- a/ir/crates/back/src/codegen/machine/function/builder.rs +++ b/ir/crates/back/src/codegen/machine/function/builder.rs @@ -2,11 +2,10 @@ use daggy::{ petgraph::prelude::Bfs, Walker, }; +use natrix_middle::instruction::CmpOp; use rustc_hash::FxHashMap; use tracing::debug; -use natrix_middle::instruction::CmpOp; - use crate::codegen::{ machine::{ backend::{ @@ -21,6 +20,7 @@ use crate::codegen::{ InstrOperand, PseudoInstr, }, + Instr, MachInstr, Register, Size, @@ -35,7 +35,6 @@ use crate::codegen::{ PseudoOp, }, }; -use crate::codegen::machine::Instr; #[derive(Debug)] pub struct FunctionBuilder { @@ -226,10 +225,7 @@ impl FunctionBuilder { mbb } - fn operand_to_matched_pattern_operand( - &self, - src: &Operand, - ) -> MatchedPatternOperand { + fn operand_to_matched_pattern_operand(&self, src: &Operand) -> MatchedPatternOperand { match src { Operand::Reg(reg) => MatchedPatternOperand::Reg(*reg), Operand::Imm(imm) => MatchedPatternOperand::Imm(imm.clone()), diff --git a/ir/crates/back/src/codegen/machine/function/cfg.rs b/ir/crates/back/src/codegen/machine/function/cfg.rs index f3ae92d..9d4aa25 100644 --- a/ir/crates/back/src/codegen/machine/function/cfg.rs +++ b/ir/crates/back/src/codegen/machine/function/cfg.rs @@ -1,14 +1,14 @@ use daggy::{ - NodeIndex, petgraph::{ - Directed, - Direction, prelude::{ Bfs, DfsPostOrder, StableGraph, }, + Directed, + Direction, }, + NodeIndex, Walker, }; use index_vec::IndexVec; @@ -18,8 +18,10 @@ use rustc_hash::FxHashMap; use crate::codegen::{ machine::{ instr::InstrOperand, + Instr, InstrId, MachInstr, + TargetMachine, }, register_allocator::{ InstrNumbering, @@ -28,7 +30,6 @@ use crate::codegen::{ ProgPoint, }, }; -use crate::codegen::machine::{Instr, TargetMachine}; index_vec::define_index_type! { pub struct BasicBlockId = u32; @@ -83,25 +84,25 @@ impl Cfg { } /// Traverses the cfg using a post order depth first traversal - pub fn dfs_postorder(&self) -> impl Iterator + '_ { + pub fn dfs_postorder(&self) -> impl Iterator + '_ { DfsPostOrder::new(&self.graph, self.entry_node()) .iter(&self.graph) .map(|node| self.node_to_block_map[&node]) } - pub fn bfs(&self) -> impl Iterator + '_ { + pub fn bfs(&self) -> impl Iterator + '_ { Bfs::new(&self.graph, self.entry_node()) .iter(&self.graph) .map(|node| self.node_to_block_map[&node]) } - pub fn predecessors(&self, bb: BasicBlockId) -> impl Iterator + '_ { + pub fn predecessors(&self, bb: BasicBlockId) -> impl Iterator + '_ { self.graph .neighbors_directed(self.block_to_node_map[&bb], Direction::Incoming) .map(|node| self.node_to_block_map[&node]) } - pub fn successors(&self, bb: BasicBlockId) -> impl Iterator + '_ { + pub fn successors(&self, bb: BasicBlockId) -> impl Iterator + '_ { self.graph .neighbors(self.block_to_node_map[&bb]) .map(|node| self.node_to_block_map[&node]) diff --git a/ir/crates/back/src/codegen/machine/function/mod.rs b/ir/crates/back/src/codegen/machine/function/mod.rs index 120b7e5..d77bc66 100644 --- a/ir/crates/back/src/codegen/machine/function/mod.rs +++ b/ir/crates/back/src/codegen/machine/function/mod.rs @@ -3,6 +3,11 @@ use std::fmt::{ Formatter, }; +pub use cfg::{ + BasicBlock, + BasicBlockId, + Cfg, +}; use cranelift_entity::{ entity_impl, PrimaryMap, @@ -15,28 +20,26 @@ use smallvec::{ }; use tracing::debug; -pub use cfg::{BasicBlock, BasicBlockId, Cfg}; - use crate::codegen::machine::{ abi::{ calling_convention::Slot, CallingConvention, }, + asm::Assembler, backend::Backend, instr::{ InstrOperand, PseudoInstr, }, - InstrId, isa::PhysicalRegister, - MachInstr, reg::VRegInfo, + Instr, + InstrId, + MachInstr, Size, TargetMachine, VReg, }; -use crate::codegen::machine::asm::Assembler; -use crate::codegen::machine::Instr; pub mod builder; pub mod cfg; @@ -114,8 +117,8 @@ impl Function { } pub fn expand_pseudo_instructions(&mut self) - where - B: Backend, + where + B: Backend, { debug!("Expanding pseudo instructions for function {}", self.name); for bb in &mut self.basic_blocks { @@ -139,14 +142,11 @@ impl Function { smallvec![B::ret()] } Some(value) => { - let return_slot = - TM::CallingConvention::return_slot(match value { - InstrOperand::Reg(reg) => { - reg.try_as_physical().unwrap().size() - } - InstrOperand::Imm(imm) => imm.size, - InstrOperand::Label(_) => unreachable!(), - }); + let return_slot = TM::CallingConvention::return_slot(match value { + InstrOperand::Reg(reg) => reg.try_as_physical().unwrap().size(), + InstrOperand::Imm(imm) => imm.size, + InstrOperand::Label(_) => unreachable!(), + }); match return_slot { Slot::Register(dest) => { let instr = match value { @@ -233,7 +233,7 @@ impl Function { impl Display for Function { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { writeln!(f, "function {}:", self.name)?; - let bbs: Box> = match &self.cfg { + let bbs: Box> = match &self.cfg { Some(cfg) => Box::new(cfg.ordered().into_iter()), None => Box::new(self.basic_blocks.indices().into_iter()), }; diff --git a/ir/crates/back/src/codegen/machine/instr.rs b/ir/crates/back/src/codegen/machine/instr.rs index 2806352..1f074cd 100644 --- a/ir/crates/back/src/codegen/machine/instr.rs +++ b/ir/crates/back/src/codegen/machine/instr.rs @@ -9,12 +9,14 @@ use smallvec::{ }; use crate::codegen::{ - machine::Register, + machine::{ + function::BasicBlockId, + isa::MachInstr as MInstr, + Register, + TargetMachine, + }, selection_dag::Immediate, }; -use crate::codegen::machine::function::BasicBlockId; -use crate::codegen::machine::isa::MachInstr as MInstr; -use crate::codegen::machine::TargetMachine; index_vec::define_index_type! { pub struct InstrId = u32; diff --git a/ir/crates/back/src/codegen/machine/isa.rs b/ir/crates/back/src/codegen/machine/isa.rs index 3a8ce12..ce98950 100644 --- a/ir/crates/back/src/codegen/machine/isa.rs +++ b/ir/crates/back/src/codegen/machine/isa.rs @@ -9,8 +9,8 @@ use crate::codegen::machine::{ instr::InstrOperand, reg::Register, Size, + TargetMachine, }; -use crate::codegen::machine::TargetMachine; pub trait PhysicalRegister: Debug + Clone + Copy + PartialEq + Eq + Sized + Hash + 'static { fn name(&self) -> &'static str; @@ -30,9 +30,9 @@ pub trait PhysicalRegister: Debug + Clone + Copy + PartialEq + Eq + Sized + Hash fn superregs(&self) -> Option<&'static [Self]>; - fn regclass(&self) -> impl Iterator - where - Self: 'static, + fn regclass(&self) -> impl Iterator + where + Self: 'static, { self.subregs() .into_iter() @@ -43,16 +43,16 @@ pub trait PhysicalRegister: Debug + Clone + Copy + PartialEq + Eq + Sized + Hash } fn has_subreg(&self, other: Self) -> bool - where - Self: 'static, + where + Self: 'static, { self.subregs() .map_or(false, |subregs| subregs.contains(&other)) } fn interferes_with(self, other: Self) -> bool - where - Self: 'static, + where + Self: 'static, { if self == other { return true; diff --git a/ir/crates/back/src/codegen/machine/mod.rs b/ir/crates/back/src/codegen/machine/mod.rs index 7ef81b1..aab0a81 100644 --- a/ir/crates/back/src/codegen/machine/mod.rs +++ b/ir/crates/back/src/codegen/machine/mod.rs @@ -1,8 +1,7 @@ use std::fmt::Debug; -pub use cranelift_entity::EntityRef; - pub use backend::Backend; +pub use cranelift_entity::EntityRef; pub use function::{ Function, FunctionId, @@ -22,8 +21,10 @@ pub use reg::{ VReg, }; -use crate::codegen::machine::abi::CallingConvention; -use crate::codegen::machine::asm::Assembler; +use crate::codegen::machine::{ + abi::CallingConvention, + asm::Assembler, +}; pub mod abi; pub mod asm; @@ -98,13 +99,13 @@ pub enum Architecture { pub trait TargetMachine: Debug + Default + Copy + Clone + PartialEq + Eq { type Reg: PhysicalRegister; - type Instr: MachInstr; + type Instr: MachInstr; - type CallingConvention: CallingConvention; + type CallingConvention: CallingConvention; - type Backend: Backend; + type Backend: Backend; - type Assembler: Assembler; + type Assembler: Assembler; fn endianness() -> Endianness; diff --git a/ir/crates/back/src/codegen/machine/module/asm.rs b/ir/crates/back/src/codegen/machine/module/asm.rs index 73a8aa0..958fab6 100644 --- a/ir/crates/back/src/codegen/machine/module/asm.rs +++ b/ir/crates/back/src/codegen/machine/module/asm.rs @@ -2,7 +2,11 @@ use std::ops::Range; use cranelift_entity::SecondaryMap; -use crate::codegen::machine::{FunctionId, Module, TargetMachine}; +use crate::codegen::machine::{ + FunctionId, + Module, + TargetMachine, +}; #[derive(Debug, Clone, Eq, PartialEq, Default)] pub struct FunctionSymbolTableEntry { diff --git a/ir/crates/back/src/codegen/machine/module/builder.rs b/ir/crates/back/src/codegen/machine/module/builder.rs index a5247bc..a89067d 100644 --- a/ir/crates/back/src/codegen/machine/module/builder.rs +++ b/ir/crates/back/src/codegen/machine/module/builder.rs @@ -2,8 +2,8 @@ use crate::codegen::machine::{ backend::Backend, function::builder::FunctionBuilder, Module, + TargetMachine, }; -use crate::codegen::machine::TargetMachine; #[derive(Debug)] pub struct Builder<'module, TM: TargetMachine> { diff --git a/ir/crates/back/src/codegen/machine/module/mod.rs b/ir/crates/back/src/codegen/machine/module/mod.rs index ef0d09c..039f363 100644 --- a/ir/crates/back/src/codegen/machine/module/mod.rs +++ b/ir/crates/back/src/codegen/machine/module/mod.rs @@ -1,13 +1,15 @@ +pub use asm::AsmModule; +use asm::{ + FunctionSymbolTable, + FunctionSymbolTableEntry, +}; +pub use builder::Builder; use cranelift_entity::PrimaryMap; use tracing::{ debug, info, }; -use asm::{FunctionSymbolTable, FunctionSymbolTableEntry}; -pub use asm::AsmModule; -pub use builder::Builder; - use crate::codegen::{ machine::{ backend::Backend, @@ -15,14 +17,14 @@ use crate::codegen::{ Function, FunctionId, }, + TargetMachine, }, register_allocator, register_allocator::RegAllocAlgorithm, }; -use crate::codegen::machine::TargetMachine; -mod builder; pub mod asm; +mod builder; #[derive(Debug, Clone)] pub struct Module { @@ -42,7 +44,7 @@ impl Module { self.functions.push(function) } - pub fn functions(&self) -> impl ExactSizeIterator)> { + pub fn functions(&self) -> impl ExactSizeIterator)> { self.functions.iter() } diff --git a/ir/crates/back/src/codegen/machine/reg.rs b/ir/crates/back/src/codegen/machine/reg.rs index 242e510..0cb0124 100644 --- a/ir/crates/back/src/codegen/machine/reg.rs +++ b/ir/crates/back/src/codegen/machine/reg.rs @@ -5,7 +5,12 @@ use std::fmt::{ use cranelift_entity::entity_impl; -use crate::codegen::machine::{function::Function, isa::PhysicalRegister, Size, TargetMachine}; +use crate::codegen::machine::{ + function::Function, + isa::PhysicalRegister, + Size, + TargetMachine, +}; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum Register { diff --git a/ir/crates/back/src/codegen/register_allocator/coalescer.rs b/ir/crates/back/src/codegen/register_allocator/coalescer.rs index 7ce69b3..c8a8f7d 100644 --- a/ir/crates/back/src/codegen/register_allocator/coalescer.rs +++ b/ir/crates/back/src/codegen/register_allocator/coalescer.rs @@ -9,8 +9,8 @@ use crate::codegen::machine::{ PseudoInstr, }, Module, + TargetMachine, }; -use crate::codegen::machine::TargetMachine; pub struct Coalescer<'module, TM: TargetMachine> { module: &'module mut Module, diff --git a/ir/crates/back/src/codegen/register_allocator/linear_scan.rs b/ir/crates/back/src/codegen/register_allocator/linear_scan.rs index 552983d..53a9ceb 100644 --- a/ir/crates/back/src/codegen/register_allocator/linear_scan.rs +++ b/ir/crates/back/src/codegen/register_allocator/linear_scan.rs @@ -5,6 +5,7 @@ use crate::codegen::{ machine::{ isa::PhysicalRegister, Size, + TargetMachine, }, register_allocator::{ Lifetime, @@ -15,7 +16,6 @@ use crate::codegen::{ RegAllocVReg, }, }; -use crate::codegen::machine::TargetMachine; #[derive(Debug)] pub struct RegAlloc<'liveness, TM: TargetMachine> { diff --git a/ir/crates/back/src/codegen/register_allocator/mod.rs b/ir/crates/back/src/codegen/register_allocator/mod.rs index 07ee303..816b10a 100644 --- a/ir/crates/back/src/codegen/register_allocator/mod.rs +++ b/ir/crates/back/src/codegen/register_allocator/mod.rs @@ -7,6 +7,7 @@ use std::{ }, }; +pub use coalescer::Coalescer; use cranelift_entity::SecondaryMap; use daggy::Walker; use iter_tools::Itertools; @@ -20,28 +21,28 @@ use smallvec::{ }; use tracing::debug; -pub use coalescer::Coalescer; - use crate::codegen::machine::{ abi::{ calling_convention::Slot, CallingConvention, }, - function::Function, + function::{ + BasicBlockId, + Function, + }, instr::{ Instr, PseudoInstr, }, - InstrId, isa::PhysicalRegister, reg::{ Register, VReg, }, + InstrId, Size, + TargetMachine, }; -use crate::codegen::machine::function::BasicBlockId; -use crate::codegen::machine::TargetMachine; mod coalescer; pub mod linear_scan; @@ -358,7 +359,7 @@ impl InstrNumbering { InstrNumberingIter::new(self) } - pub fn iter_enumerated(&self) -> impl Iterator + '_ { + pub fn iter_enumerated(&self) -> impl Iterator + '_ { self.iter() .enumerate() .map(|(nr, instr_uid)| (nr as InstrNr, instr_uid)) @@ -417,7 +418,10 @@ impl LivenessRepr { } } -struct LivenessReprDisplay<'func, 'liveness, A: TargetMachine>(&'liveness LivenessRepr, &'func Function); +struct LivenessReprDisplay<'func, 'liveness, A: TargetMachine>( + &'liveness LivenessRepr, + &'func Function, +); impl Display for LivenessReprDisplay<'_, '_, A> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -540,7 +544,12 @@ impl<'liveness, A: TargetMachine> VRegAllocations<'liveness, A> { } } -pub struct RegisterAllocator<'liveness, 'func, A: TargetMachine, RegAlloc: RegAllocAlgorithm<'liveness, A>> { +pub struct RegisterAllocator< + 'liveness, + 'func, + A: TargetMachine, + RegAlloc: RegAllocAlgorithm<'liveness, A>, +> { algo: RegAlloc, func: &'func mut Function, marker: std::marker::PhantomData, @@ -549,7 +558,7 @@ pub struct RegisterAllocator<'liveness, 'func, A: TargetMachine, RegAlloc: RegAl } impl<'liveness, 'func, TM: TargetMachine, RegAlloc: RegAllocAlgorithm<'liveness, TM>> -RegisterAllocator<'liveness, 'func, TM, RegAlloc> + RegisterAllocator<'liveness, 'func, TM, RegAlloc> { pub fn new(func: &'func mut Function, liveness_repr: &'liveness LivenessRepr) -> Self { Self { @@ -703,7 +712,7 @@ RegisterAllocator<'liveness, 'func, TM, RegAlloc> .iter() .map(|param| self.func.vregs[*param].size), ) - .collect_vec(); + .collect_vec(); for (arg, slot) in self.func.params.iter().copied().zip(slots) { match slot { Slot::Register(reg) => { @@ -731,7 +740,7 @@ impl Function { self.0.entry(bb).or_default(); } - fn liveins(&self, bb: BasicBlockId) -> impl Iterator + '_ { + fn liveins(&self, bb: BasicBlockId) -> impl Iterator + '_ { self.0[&bb].iter().copied() } } diff --git a/ir/crates/back/src/codegen/selection_dag/builder.rs b/ir/crates/back/src/codegen/selection_dag/builder.rs index efa5332..66f858a 100644 --- a/ir/crates/back/src/codegen/selection_dag/builder.rs +++ b/ir/crates/back/src/codegen/selection_dag/builder.rs @@ -1,17 +1,14 @@ +use codegen::selection_dag; use cranelift_entity::{ EntityRef, SecondaryMap, }; use daggy::{ - NodeIndex, petgraph::visit::IntoNodeIdentifiers, + NodeIndex, Walker, }; use iter_tools::Itertools; -use rustc_hash::FxHashMap; -use tracing::debug; - -use codegen::selection_dag; use natrix_middle::{ cfg::{ BasicBlockId, @@ -26,7 +23,9 @@ use natrix_middle::{ }, ty::Type, }; +use rustc_hash::FxHashMap; use selection_dag::SelectionDAG; +use tracing::debug; use crate::{ codegen, @@ -37,6 +36,7 @@ use crate::{ Register, VReg, }, + TargetMachine, }, selection_dag::{ Immediate, @@ -47,7 +47,6 @@ use crate::{ }, }, }; -use crate::codegen::machine::TargetMachine; #[derive(Debug)] pub struct Builder<'func, TM: TargetMachine> { diff --git a/ir/crates/back/src/codegen/selection_dag/mod.rs b/ir/crates/back/src/codegen/selection_dag/mod.rs index 32d642d..4eace12 100644 --- a/ir/crates/back/src/codegen/selection_dag/mod.rs +++ b/ir/crates/back/src/codegen/selection_dag/mod.rs @@ -6,30 +6,29 @@ use std::{ }, }; +pub use builder::Builder; use daggy::petgraph::dot::{ Config, Dot, }; +use natrix_middle::{ + cfg::BasicBlockId, + instruction::CmpOp, +}; use rustc_hash::FxHashMap; use smallvec::{ smallvec, SmallVec, }; -pub use builder::Builder; -use natrix_middle::{ - cfg::BasicBlockId, - instruction::CmpOp, -}; - use crate::codegen::machine::{ reg::{ Register, VReg, }, Size, + TargetMachine, }; -use crate::codegen::machine::TargetMachine; pub mod builder; diff --git a/ir/crates/back/src/codegen/targets/calling_convention/mod.rs b/ir/crates/back/src/codegen/targets/calling_convention/mod.rs index 9f4d835..723004c 100644 --- a/ir/crates/back/src/codegen/targets/calling_convention/mod.rs +++ b/ir/crates/back/src/codegen/targets/calling_convention/mod.rs @@ -1 +1 @@ -pub mod systemv; \ No newline at end of file +pub mod systemv; diff --git a/ir/crates/back/src/codegen/targets/calling_convention/systemv.rs b/ir/crates/back/src/codegen/targets/calling_convention/systemv.rs index f95a03c..acc5426 100644 --- a/ir/crates/back/src/codegen/targets/calling_convention/systemv.rs +++ b/ir/crates/back/src/codegen/targets/calling_convention/systemv.rs @@ -1,11 +1,13 @@ -use crate::codegen::machine::{ - abi::{ - calling_convention::Slot, - CallingConvention, +use crate::codegen::{ + machine::{ + abi::{ + calling_convention::Slot, + CallingConvention, + }, + Size, }, - Size, + targets::x86_64, }; -use crate::codegen::targets::x86_64; #[derive(Default)] pub struct SystemV; @@ -13,8 +15,8 @@ pub struct SystemV; impl CallingConvention for SystemV { type Reg = x86_64::PhysicalRegister; fn parameter_slots( - params: impl Iterator, - ) -> impl Iterator> { + params: impl Iterator, + ) -> impl Iterator> { let mut used_regs = 0; params.map(move |size| { let slot = if used_regs < 6 { diff --git a/ir/crates/back/src/codegen/targets/mod.rs b/ir/crates/back/src/codegen/targets/mod.rs index 3fc2bde..9a1807b 100644 --- a/ir/crates/back/src/codegen/targets/mod.rs +++ b/ir/crates/back/src/codegen/targets/mod.rs @@ -1,2 +1,2 @@ -pub mod x86_64; pub mod calling_convention; +pub mod x86_64; diff --git a/ir/crates/back/src/codegen/targets/x86_64/asm.rs b/ir/crates/back/src/codegen/targets/x86_64/asm.rs index 8f1035d..ad8982a 100644 --- a/ir/crates/back/src/codegen/targets/x86_64/asm.rs +++ b/ir/crates/back/src/codegen/targets/x86_64/asm.rs @@ -4,11 +4,11 @@ use std::ops::{ }; use iced_x86::{ - Code, code_asm::{ CodeAssembler, CodeLabel, }, + Code, Formatter, Instruction, IntelFormatter, @@ -17,10 +17,17 @@ use iced_x86::{ }; use rustc_hash::FxHashMap; -use crate::codegen::machine; -use crate::codegen::machine::function::cfg::BasicBlockId; -use crate::codegen::targets::x86_64; -use crate::codegen::targets::x86_64::{CC, PhysicalRegister}; +use crate::codegen::{ + machine, + machine::function::cfg::BasicBlockId, + targets::{ + x86_64, + x86_64::{ + PhysicalRegister, + CC, + }, + }, +}; pub struct Assembler { assembler: CodeAssembler, @@ -125,9 +132,9 @@ impl machine::asm::Assembler for Assembler { dest, immediate.as_encoded_dword().unwrap(), ) - .unwrap(), + .unwrap(), ) - .unwrap(); + .unwrap(); } x86_64::Instr::SUB32rr { src, dest } => { let dest: Register = dest.try_as_physical().unwrap().into(); @@ -143,9 +150,9 @@ impl machine::asm::Assembler for Assembler { dest, immediate.as_encoded_dword().unwrap(), ) - .unwrap(), + .unwrap(), ) - .unwrap(); + .unwrap(); } x86_64::Instr::ADD32rr { src, dest } => { let dest: Register = dest.try_as_physical().unwrap().into(); @@ -161,9 +168,9 @@ impl machine::asm::Assembler for Assembler { dest, immediate.as_encoded_dword().unwrap(), ) - .unwrap(), + .unwrap(), ) - .unwrap(); + .unwrap(); } x86_64::Instr::MOV8rr { src, dest } => { let dest: Register = dest.try_as_physical().unwrap().into(); @@ -179,9 +186,9 @@ impl machine::asm::Assembler for Assembler { dest, immediate.as_encoded_dword().unwrap(), ) - .unwrap(), + .unwrap(), ) - .unwrap(); + .unwrap(); } x86_64::Instr::MOV16rr { src, dest } => { let dest: Register = dest.try_as_physical().unwrap().into(); @@ -197,9 +204,9 @@ impl machine::asm::Assembler for Assembler { dest, immediate.as_encoded_dword().unwrap(), ) - .unwrap(), + .unwrap(), ) - .unwrap(); + .unwrap(); } x86_64::Instr::MOV32rr { src, dest } => { let dest: Register = dest.try_as_physical().unwrap().into(); @@ -217,9 +224,9 @@ impl machine::asm::Assembler for Assembler { .as_encoded_dword() .expect("64-bit immediates are too large. Should be stored in memory"), ) - .unwrap(), + .unwrap(), ) - .unwrap(); + .unwrap(); } x86_64::Instr::MOV64rr { src, dest } => { let dest: Register = dest.try_as_physical().unwrap().into(); @@ -246,7 +253,7 @@ impl machine::asm::Assembler for Assembler { Instruction::with2(Code::Cmp_rm32_imm32, lhs, rhs.as_encoded_dword().unwrap()) .unwrap(), ) - .unwrap(); + .unwrap(); } x86_64::Instr::CMP8ri { lhs, rhs } => { let lhs: Register = lhs.try_as_physical().unwrap().into(); @@ -254,7 +261,7 @@ impl machine::asm::Assembler for Assembler { Instruction::with2(Code::Cmp_rm8_imm8, lhs, rhs.as_encoded_dword().unwrap()) .unwrap(), ) - .unwrap(); + .unwrap(); } x86_64::Instr::SETCC { dest, cc } => { let dest: Register = dest.try_as_physical().unwrap().into(); diff --git a/ir/crates/back/src/codegen/targets/x86_64/mod.rs b/ir/crates/back/src/codegen/targets/x86_64/mod.rs index 5c0b458..54e3902 100644 --- a/ir/crates/back/src/codegen/targets/x86_64/mod.rs +++ b/ir/crates/back/src/codegen/targets/x86_64/mod.rs @@ -1,25 +1,23 @@ +use machine::instr::Instr as MInstr; +use natrix_middle::instruction::CmpOp; use smallvec::{ smallvec, SmallVec, }; use strum::VariantArray; -use machine::instr::Instr as MInstr; -use natrix_middle::instruction::CmpOp; - use crate::codegen::{ machine, machine::{ - Architecture, backend, - Endianness, function::{ - BasicBlockId, builder::{ MatchedPattern, + PatternIn, PatternInOperand, PatternInOutput, }, + BasicBlockId, Function, }, instr::{ @@ -27,13 +25,14 @@ use crate::codegen::{ PseudoInstr, }, isa::PhysicalRegister as MachPhysicalRegister, + Architecture, + Endianness, Size, TargetMachine, }, selection_dag::Immediate, + targets::calling_convention::systemv::SystemV, }; -use crate::codegen::machine::function::builder::PatternIn; -use crate::codegen::targets::calling_convention::systemv::SystemV; mod asm; @@ -421,7 +420,6 @@ impl MachPhysicalRegister for PhysicalRegister { } } - impl machine::isa::MachInstr for Instr { type TM = Target; diff --git a/ir/crates/back/src/emu.rs b/ir/crates/back/src/emu.rs index 03de7d7..6b6338f 100644 --- a/ir/crates/back/src/emu.rs +++ b/ir/crates/back/src/emu.rs @@ -10,13 +10,13 @@ use tracing::{ warn, }; use unicorn_engine::{ - SECOND_SCALE, unicorn_const::{ + uc_error, Arch, Mode, Permission, - uc_error, }, + SECOND_SCALE, }; use crate::codegen::machine::{ @@ -24,10 +24,10 @@ use crate::codegen::machine::{ calling_convention::Slot, CallingConvention, }, - Architecture, function::FunctionId, isa::PhysicalRegister, module::asm::AsmModule, + Architecture, TargetMachine, }; diff --git a/ir/crates/back/src/lib.rs b/ir/crates/back/src/lib.rs index 33b4080..be7efb0 100644 --- a/ir/crates/back/src/lib.rs +++ b/ir/crates/back/src/lib.rs @@ -8,4 +8,3 @@ extern crate strum; pub mod codegen; pub mod emu; - diff --git a/ir/crates/compiler/src/main.rs b/ir/crates/compiler/src/main.rs index 6f93fbb..1f7cb74 100644 --- a/ir/crates/compiler/src/main.rs +++ b/ir/crates/compiler/src/main.rs @@ -2,13 +2,19 @@ use std::path::PathBuf; use anyhow::Result; use clap::Parser; +use natrix_back::{ + codegen::{ + register_allocator, + targets::x86_64, + }, + emu::Emulator, +}; +use natrix_middle::{ + optimization, + FrontBridge, +}; use tracing::debug; -use natrix_back::codegen::register_allocator; -use natrix_back::codegen::targets::x86_64; -use natrix_back::emu::Emulator; -use natrix_middle::{FrontBridge, optimization}; - #[derive(Parser, Debug)] #[clap(name = "natrix")] #[command(version, about)] @@ -22,19 +28,23 @@ fn valid_source_file_extension(file_path: &str) -> Result { let file_path = PathBuf::from(file_path); let extension = file_path.extension().ok_or("No file extension")?; if extension != "nx" { - return Err(format!("Invalid file extension: {} (expected .nx)", extension.to_string_lossy())); + return Err(format!( + "Invalid file extension: {} (expected .nx)", + extension.to_string_lossy() + )); } Ok(file_path) } fn main() -> Result<()> { - tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).init(); + tracing_subscriber::fmt() + .with_max_level(tracing::Level::DEBUG) + .init(); let args = Args::parse(); let file_path = args.source_file; let file_contents = std::fs::read_to_string(file_path)?; - let module = natrix_front::module::parse(&file_contents).map_err( - |e| anyhow::anyhow!("Failed to parse module: {}", e) - )?; + let module = natrix_front::module::parse(&file_contents) + .map_err(|e| anyhow::anyhow!("Failed to parse module: {}", e))?; println!("{:?}", module); let mut module = FrontBridge::new().bridge(module); println!("{:?}", module); @@ -42,7 +52,8 @@ fn main() -> Result<()> { config.dead_code_elimination = false; // module.optimize(config); println!("{module}"); - let mut x86_mod = natrix_back::codegen::machine::module::Builder::::new(&mut module).build(); + let mut x86_mod = + natrix_back::codegen::machine::module::Builder::::new(&mut module).build(); x86_mod.run_register_allocator(); x86_mod.run_register_coalescer(); x86_mod.remove_fallthrough_jumps(); @@ -50,16 +61,10 @@ fn main() -> Result<()> { debug!("{x86_mod}"); let base_addr = 0x1000; let asm_module = x86_mod.assemble(base_addr); - let mut emu = Emulator::new( - &asm_module - ); - let result = emu.run_function( - x86_mod.functions().next().unwrap().0, - &[ - 30000, - 20000 - ] - ).unwrap(); + let mut emu = Emulator::new(&asm_module); + let result = emu + .run_function(x86_mod.functions().next().unwrap().0, &[30000, 20000]) + .unwrap(); println!("Result: {}", result); Ok(()) } diff --git a/ir/crates/front/src/grammar.rs b/ir/crates/front/src/grammar.rs index becbe71..ffd8a33 100644 --- a/ir/crates/front/src/grammar.rs +++ b/ir/crates/front/src/grammar.rs @@ -1,16 +1,30 @@ -// auto-generated: "lalrpop 0.20.0" +// auto-generated: "lalrpop 0.20.2" // sha3: 3da911f4b02d38610275c87137f6513578343b93a23eb2ce9725bf48b56e6208 use std::str::FromStr; -use crate::module::{Instruction, Operand, Literal, BasicBlock, Function, Type, Arg, Module, RegId, Target, BasicBlockId, CmpOp}; + +use crate::module::{ + Arg, + BasicBlock, + BasicBlockId, + CmpOp, + Function, + Instruction, + Literal, + Module, + Operand, + RegId, + Target, + Type, +}; #[allow(unused_extern_crates)] extern crate lalrpop_util as __lalrpop_util; #[allow(unused_imports)] use self::__lalrpop_util::state_machine as __state_machine; -extern crate core; extern crate alloc; +extern crate core; #[rustfmt::skip] -#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] +#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)] mod __parse__BasicBlock { use std::str::FromStr; @@ -527,7 +541,7 @@ mod __parse__BasicBlock { } }).collect() } - pub(crate) struct __StateMachine<'input> + struct __StateMachine<'input> where { input: &'input str, @@ -680,7 +694,7 @@ mod __parse__BasicBlock { _: core::marker::PhantomData<(&'input ())>, ) -> __Symbol<'input> { - match __token_index { + #[allow(clippy::manual_range_patterns)]match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), @@ -1299,6 +1313,7 @@ mod __parse__BasicBlock { _priv: (), } + impl Default for BasicBlockParser { fn default() -> Self { Self::new() } } impl BasicBlockParser { pub fn new() -> BasicBlockParser { let __builder = super::__intern_token::new_builder(); @@ -1359,7 +1374,7 @@ mod __parse__BasicBlock { __states.push(__next_state); } } - pub(crate) fn __reduce< + fn __reduce< 'input, >( input: &'input str, @@ -2030,7 +2045,7 @@ mod __parse__BasicBlock { _ => __symbol_type_mismatch() } } - pub(crate) fn __reduce0< + fn __reduce0< 'input, >( input: &'input str, @@ -2047,7 +2062,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } - pub(crate) fn __reduce1< + fn __reduce1< 'input, >( input: &'input str, @@ -2057,13 +2072,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // "-"? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action45::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (0, 0) } - pub(crate) fn __reduce2< + fn __reduce2< 'input, >( input: &'input str, @@ -2082,7 +2097,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } - pub(crate) fn __reduce3< + fn __reduce3< 'input, >( input: &'input str, @@ -2092,13 +2107,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // ( ",")* = => ActionFn(72); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action72::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 2) } - pub(crate) fn __reduce4< + fn __reduce4< 'input, >( input: &'input str, @@ -2115,7 +2130,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } - pub(crate) fn __reduce5< + fn __reduce5< 'input, >( input: &'input str, @@ -2134,7 +2149,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } - pub(crate) fn __reduce6< + fn __reduce6< 'input, >( input: &'input str, @@ -2154,7 +2169,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (3, 3) } - pub(crate) fn __reduce7< + fn __reduce7< 'input, >( input: &'input str, @@ -2173,7 +2188,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } - pub(crate) fn __reduce8< + fn __reduce8< 'input, >( input: &'input str, @@ -2183,13 +2198,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // ( ",")* = => ActionFn(75); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action75::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } - pub(crate) fn __reduce9< + fn __reduce9< 'input, >( input: &'input str, @@ -2206,7 +2221,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } - pub(crate) fn __reduce10< + fn __reduce10< 'input, >( input: &'input str, @@ -2225,7 +2240,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (2, 6) } - pub(crate) fn __reduce11< + fn __reduce11< 'input, >( input: &'input str, @@ -2245,7 +2260,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (3, 6) } - pub(crate) fn __reduce12< + fn __reduce12< 'input, >( input: &'input str, @@ -2264,7 +2279,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } - pub(crate) fn __reduce13< + fn __reduce13< 'input, >( input: &'input str, @@ -2274,13 +2289,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // ( ",")* = => ActionFn(63); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action63::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 8) } - pub(crate) fn __reduce14< + fn __reduce14< 'input, >( input: &'input str, @@ -2297,7 +2312,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } - pub(crate) fn __reduce15< + fn __reduce15< 'input, >( input: &'input str, @@ -2316,7 +2331,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 9) } - pub(crate) fn __reduce16< + fn __reduce16< 'input, >( input: &'input str, @@ -2336,7 +2351,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (3, 9) } - pub(crate) fn __reduce17< + fn __reduce17< 'input, >( input: &'input str, @@ -2355,7 +2370,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 10) } - pub(crate) fn __reduce18< + fn __reduce18< 'input, >( input: &'input str, @@ -2372,7 +2387,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 11) } - pub(crate) fn __reduce19< + fn __reduce19< 'input, >( input: &'input str, @@ -2382,13 +2397,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // Arg? = => ActionFn(71); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action71::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce20< + fn __reduce20< 'input, >( input: &'input str, @@ -2408,7 +2423,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce21< + fn __reduce21< 'input, >( input: &'input str, @@ -2429,7 +2444,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } - pub(crate) fn __reduce22< + fn __reduce22< 'input, >( input: &'input str, @@ -2448,7 +2463,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 12) } - pub(crate) fn __reduce23< + fn __reduce23< 'input, >( input: &'input str, @@ -2468,7 +2483,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce24< + fn __reduce24< 'input, >( input: &'input str, @@ -2478,13 +2493,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // BasicBlock* = => ActionFn(56); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action56::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (0, 13) } - pub(crate) fn __reduce25< + fn __reduce25< 'input, >( input: &'input str, @@ -2501,7 +2516,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 13) } - pub(crate) fn __reduce26< + fn __reduce26< 'input, >( input: &'input str, @@ -2518,7 +2533,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 14) } - pub(crate) fn __reduce27< + fn __reduce27< 'input, >( input: &'input str, @@ -2537,7 +2552,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 14) } - pub(crate) fn __reduce28< + fn __reduce28< 'input, >( input: &'input str, @@ -2557,7 +2572,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (3, 15) } - pub(crate) fn __reduce29< + fn __reduce29< 'input, >( input: &'input str, @@ -2574,7 +2589,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 16) } - pub(crate) fn __reduce30< + fn __reduce30< 'input, >( input: &'input str, @@ -2584,13 +2599,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // BasicBlockArgList? = => ActionFn(55); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action55::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (0, 16) } - pub(crate) fn __reduce31< + fn __reduce31< 'input, >( input: &'input str, @@ -2607,7 +2622,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 17) } - pub(crate) fn __reduce32< + fn __reduce32< 'input, >( input: &'input str, @@ -2624,7 +2639,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce33< + fn __reduce33< 'input, >( input: &'input str, @@ -2641,7 +2656,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce34< + fn __reduce34< 'input, >( input: &'input str, @@ -2658,7 +2673,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce35< + fn __reduce35< 'input, >( input: &'input str, @@ -2668,13 +2683,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // Comma = => ActionFn(99); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action99::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (0, 19) } - pub(crate) fn __reduce36< + fn __reduce36< 'input, >( input: &'input str, @@ -2693,7 +2708,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 19) } - pub(crate) fn __reduce37< + fn __reduce37< 'input, >( input: &'input str, @@ -2710,7 +2725,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce38< + fn __reduce38< 'input, >( input: &'input str, @@ -2727,7 +2742,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce39< + fn __reduce39< 'input, >( input: &'input str, @@ -2737,13 +2752,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // Comma = => ActionFn(111); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action111::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (0, 20) } - pub(crate) fn __reduce40< + fn __reduce40< 'input, >( input: &'input str, @@ -2762,7 +2777,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 20) } - pub(crate) fn __reduce41< + fn __reduce41< 'input, >( input: &'input str, @@ -2779,7 +2794,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce42< + fn __reduce42< 'input, >( input: &'input str, @@ -2796,7 +2811,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce43< + fn __reduce43< 'input, >( input: &'input str, @@ -2806,13 +2821,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // Comma = => ActionFn(119); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action119::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 21) } - pub(crate) fn __reduce44< + fn __reduce44< 'input, >( input: &'input str, @@ -2831,7 +2846,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } - pub(crate) fn __reduce45< + fn __reduce45< 'input, >( input: &'input str, @@ -2848,7 +2863,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce46< + fn __reduce46< 'input, >( input: &'input str, @@ -2865,7 +2880,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 22) } - pub(crate) fn __reduce47< + fn __reduce47< 'input, >( input: &'input str, @@ -2890,7 +2905,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (8, 23) } - pub(crate) fn __reduce48< + fn __reduce48< 'input, >( input: &'input str, @@ -2916,7 +2931,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (9, 23) } - pub(crate) fn __reduce49< + fn __reduce49< 'input, >( input: &'input str, @@ -2933,7 +2948,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (1, 24) } - pub(crate) fn __reduce50< + fn __reduce50< 'input, >( input: &'input str, @@ -2952,7 +2967,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (2, 24) } - pub(crate) fn __reduce51< + fn __reduce51< 'input, >( input: &'input str, @@ -2971,7 +2986,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 25) } - pub(crate) fn __reduce52< + fn __reduce52< 'input, >( input: &'input str, @@ -2981,13 +2996,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // Instruction* = => ActionFn(52); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action52::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (0, 26) } - pub(crate) fn __reduce53< + fn __reduce53< 'input, >( input: &'input str, @@ -3004,7 +3019,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 26) } - pub(crate) fn __reduce54< + fn __reduce54< 'input, >( input: &'input str, @@ -3021,7 +3036,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 27) } - pub(crate) fn __reduce55< + fn __reduce55< 'input, >( input: &'input str, @@ -3040,7 +3055,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 27) } - pub(crate) fn __reduce56< + fn __reduce56< 'input, >( input: &'input str, @@ -3064,7 +3079,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce57< + fn __reduce57< 'input, >( input: &'input str, @@ -3088,7 +3103,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce58< + fn __reduce58< 'input, >( input: &'input str, @@ -3109,7 +3124,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (4, 28) } - pub(crate) fn __reduce59< + fn __reduce59< 'input, >( input: &'input str, @@ -3134,7 +3149,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (8, 28) } - pub(crate) fn __reduce60< + fn __reduce60< 'input, >( input: &'input str, @@ -3156,7 +3171,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (5, 28) } - pub(crate) fn __reduce61< + fn __reduce61< 'input, >( input: &'input str, @@ -3175,7 +3190,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce62< + fn __reduce62< 'input, >( input: &'input str, @@ -3195,7 +3210,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } - pub(crate) fn __reduce63< + fn __reduce63< 'input, >( input: &'input str, @@ -3214,7 +3229,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce64< + fn __reduce64< 'input, >( input: &'input str, @@ -3231,7 +3246,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 29) } - pub(crate) fn __reduce65< + fn __reduce65< 'input, >( input: &'input str, @@ -3248,7 +3263,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 30) } - pub(crate) fn __reduce66< + fn __reduce66< 'input, >( input: &'input str, @@ -3265,7 +3280,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce67< + fn __reduce67< 'input, >( input: &'input str, @@ -3282,7 +3297,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce68< + fn __reduce68< 'input, >( input: &'input str, @@ -3299,7 +3314,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (1, 32) } - pub(crate) fn __reduce69< + fn __reduce69< 'input, >( input: &'input str, @@ -3309,13 +3324,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // Operand? = => ActionFn(50); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action50::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (0, 32) } - pub(crate) fn __reduce70< + fn __reduce70< 'input, >( input: &'input str, @@ -3332,7 +3347,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (1, 33) } - pub(crate) fn __reduce71< + fn __reduce71< 'input, >( input: &'input str, @@ -3351,7 +3366,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (2, 34) } - pub(crate) fn __reduce72< + fn __reduce72< 'input, >( input: &'input str, @@ -3368,7 +3383,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (1, 34) } - pub(crate) fn __reduce73< + fn __reduce73< 'input, >( input: &'input str, @@ -3387,7 +3402,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (2, 35) } - pub(crate) fn __reduce74< + fn __reduce74< 'input, >( input: &'input str, @@ -3404,7 +3419,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (1, 35) } - pub(crate) fn __reduce75< + fn __reduce75< 'input, >( input: &'input str, @@ -3424,7 +3439,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (3, 36) } - pub(crate) fn __reduce76< + fn __reduce76< 'input, >( input: &'input str, @@ -3441,7 +3456,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (1, 37) } - pub(crate) fn __reduce77< + fn __reduce77< 'input, >( input: &'input str, @@ -3451,13 +3466,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // TargetArgList? = => ActionFn(48); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action48::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (0, 37) } - pub(crate) fn __reduce78< + fn __reduce78< 'input, >( input: &'input str, @@ -3474,7 +3489,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce79< + fn __reduce79< 'input, >( input: &'input str, @@ -3491,7 +3506,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce80< + fn __reduce80< 'input, >( input: &'input str, @@ -3508,7 +3523,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce81< + fn __reduce81< 'input, >( input: &'input str, @@ -3525,7 +3540,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce82< + fn __reduce82< 'input, >( input: &'input str, @@ -3542,7 +3557,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce83< + fn __reduce83< 'input, >( input: &'input str, @@ -3559,7 +3574,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce84< + fn __reduce84< 'input, >( input: &'input str, @@ -3576,7 +3591,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce85< + fn __reduce85< 'input, >( input: &'input str, @@ -3593,7 +3608,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce86< + fn __reduce86< 'input, >( input: &'input str, @@ -3610,7 +3625,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce87< + fn __reduce87< 'input, >( input: &'input str, @@ -3627,7 +3642,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce88< + fn __reduce88< 'input, >( input: &'input str, @@ -3644,7 +3659,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (1, 39) } - pub(crate) fn __reduce89< + fn __reduce89< 'input, >( input: &'input str, @@ -3654,13 +3669,13 @@ mod __parse__BasicBlock { ) -> (usize, usize) { // Type? = => ActionFn(62); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action62::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (0, 39) } - pub(crate) fn __reduce90< + fn __reduce90< 'input, >( input: &'input str, @@ -3677,7 +3692,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce91< + fn __reduce91< 'input, >( input: &'input str, @@ -3694,7 +3709,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce93< + fn __reduce93< 'input, >( input: &'input str, @@ -3711,7 +3726,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 42) } - pub(crate) fn __reduce94< + fn __reduce94< 'input, >( input: &'input str, @@ -3728,7 +3743,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (1, 43) } - pub(crate) fn __reduce95< + fn __reduce95< 'input, >( input: &'input str, @@ -3745,7 +3760,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 44) } - pub(crate) fn __reduce96< + fn __reduce96< 'input, >( input: &'input str, @@ -3762,7 +3777,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 45) } - pub(crate) fn __reduce97< + fn __reduce97< 'input, >( input: &'input str, @@ -3779,7 +3794,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 46) } - pub(crate) fn __reduce98< + fn __reduce98< 'input, >( input: &'input str, @@ -3796,7 +3811,7 @@ mod __parse__BasicBlock { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 47) } - pub(crate) fn __reduce99< + fn __reduce99< 'input, >( input: &'input str, @@ -3814,10 +3829,11 @@ mod __parse__BasicBlock { (1, 48) } } +#[allow(unused_imports)] pub use self::__parse__BasicBlock::BasicBlockParser; #[rustfmt::skip] -#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] +#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)] mod __parse__CmpOp { use std::str::FromStr; @@ -3953,7 +3969,7 @@ mod __parse__CmpOp { } }).collect() } - pub(crate) struct __StateMachine<'input> + struct __StateMachine<'input> where { input: &'input str, @@ -4106,7 +4122,7 @@ mod __parse__CmpOp { _: core::marker::PhantomData<(&'input ())>, ) -> __Symbol<'input> { - match __token_index { + #[allow(clippy::manual_range_patterns)]match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), @@ -4725,6 +4741,7 @@ mod __parse__CmpOp { _priv: (), } + impl Default for CmpOpParser { fn default() -> Self { Self::new() } } impl CmpOpParser { pub fn new() -> CmpOpParser { let __builder = super::__intern_token::new_builder(); @@ -4785,7 +4802,7 @@ mod __parse__CmpOp { __states.push(__next_state); } } - pub(crate) fn __reduce< + fn __reduce< 'input, >( input: &'input str, @@ -5456,7 +5473,7 @@ mod __parse__CmpOp { _ => __symbol_type_mismatch() } } - pub(crate) fn __reduce0< + fn __reduce0< 'input, >( input: &'input str, @@ -5473,7 +5490,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } - pub(crate) fn __reduce1< + fn __reduce1< 'input, >( input: &'input str, @@ -5483,13 +5500,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // "-"? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action45::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (0, 0) } - pub(crate) fn __reduce2< + fn __reduce2< 'input, >( input: &'input str, @@ -5508,7 +5525,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } - pub(crate) fn __reduce3< + fn __reduce3< 'input, >( input: &'input str, @@ -5518,13 +5535,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // ( ",")* = => ActionFn(72); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action72::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 2) } - pub(crate) fn __reduce4< + fn __reduce4< 'input, >( input: &'input str, @@ -5541,7 +5558,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } - pub(crate) fn __reduce5< + fn __reduce5< 'input, >( input: &'input str, @@ -5560,7 +5577,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } - pub(crate) fn __reduce6< + fn __reduce6< 'input, >( input: &'input str, @@ -5580,7 +5597,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (3, 3) } - pub(crate) fn __reduce7< + fn __reduce7< 'input, >( input: &'input str, @@ -5599,7 +5616,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } - pub(crate) fn __reduce8< + fn __reduce8< 'input, >( input: &'input str, @@ -5609,13 +5626,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // ( ",")* = => ActionFn(75); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action75::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } - pub(crate) fn __reduce9< + fn __reduce9< 'input, >( input: &'input str, @@ -5632,7 +5649,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } - pub(crate) fn __reduce10< + fn __reduce10< 'input, >( input: &'input str, @@ -5651,7 +5668,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (2, 6) } - pub(crate) fn __reduce11< + fn __reduce11< 'input, >( input: &'input str, @@ -5671,7 +5688,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (3, 6) } - pub(crate) fn __reduce12< + fn __reduce12< 'input, >( input: &'input str, @@ -5690,7 +5707,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } - pub(crate) fn __reduce13< + fn __reduce13< 'input, >( input: &'input str, @@ -5700,13 +5717,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // ( ",")* = => ActionFn(63); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action63::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 8) } - pub(crate) fn __reduce14< + fn __reduce14< 'input, >( input: &'input str, @@ -5723,7 +5740,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } - pub(crate) fn __reduce15< + fn __reduce15< 'input, >( input: &'input str, @@ -5742,7 +5759,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 9) } - pub(crate) fn __reduce16< + fn __reduce16< 'input, >( input: &'input str, @@ -5762,7 +5779,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (3, 9) } - pub(crate) fn __reduce17< + fn __reduce17< 'input, >( input: &'input str, @@ -5781,7 +5798,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 10) } - pub(crate) fn __reduce18< + fn __reduce18< 'input, >( input: &'input str, @@ -5798,7 +5815,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 11) } - pub(crate) fn __reduce19< + fn __reduce19< 'input, >( input: &'input str, @@ -5808,13 +5825,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // Arg? = => ActionFn(71); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action71::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce20< + fn __reduce20< 'input, >( input: &'input str, @@ -5834,7 +5851,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce21< + fn __reduce21< 'input, >( input: &'input str, @@ -5855,7 +5872,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } - pub(crate) fn __reduce22< + fn __reduce22< 'input, >( input: &'input str, @@ -5874,7 +5891,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 12) } - pub(crate) fn __reduce23< + fn __reduce23< 'input, >( input: &'input str, @@ -5894,7 +5911,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce24< + fn __reduce24< 'input, >( input: &'input str, @@ -5904,13 +5921,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // BasicBlock* = => ActionFn(56); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action56::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (0, 13) } - pub(crate) fn __reduce25< + fn __reduce25< 'input, >( input: &'input str, @@ -5927,7 +5944,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 13) } - pub(crate) fn __reduce26< + fn __reduce26< 'input, >( input: &'input str, @@ -5944,7 +5961,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 14) } - pub(crate) fn __reduce27< + fn __reduce27< 'input, >( input: &'input str, @@ -5963,7 +5980,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 14) } - pub(crate) fn __reduce28< + fn __reduce28< 'input, >( input: &'input str, @@ -5983,7 +6000,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (3, 15) } - pub(crate) fn __reduce29< + fn __reduce29< 'input, >( input: &'input str, @@ -6000,7 +6017,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 16) } - pub(crate) fn __reduce30< + fn __reduce30< 'input, >( input: &'input str, @@ -6010,13 +6027,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // BasicBlockArgList? = => ActionFn(55); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action55::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (0, 16) } - pub(crate) fn __reduce31< + fn __reduce31< 'input, >( input: &'input str, @@ -6033,7 +6050,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 17) } - pub(crate) fn __reduce32< + fn __reduce32< 'input, >( input: &'input str, @@ -6050,7 +6067,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce33< + fn __reduce33< 'input, >( input: &'input str, @@ -6067,7 +6084,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce34< + fn __reduce34< 'input, >( input: &'input str, @@ -6084,7 +6101,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce35< + fn __reduce35< 'input, >( input: &'input str, @@ -6094,13 +6111,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // Comma = => ActionFn(99); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action99::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (0, 19) } - pub(crate) fn __reduce36< + fn __reduce36< 'input, >( input: &'input str, @@ -6119,7 +6136,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 19) } - pub(crate) fn __reduce37< + fn __reduce37< 'input, >( input: &'input str, @@ -6136,7 +6153,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce38< + fn __reduce38< 'input, >( input: &'input str, @@ -6153,7 +6170,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce39< + fn __reduce39< 'input, >( input: &'input str, @@ -6163,13 +6180,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // Comma = => ActionFn(111); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action111::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (0, 20) } - pub(crate) fn __reduce40< + fn __reduce40< 'input, >( input: &'input str, @@ -6188,7 +6205,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 20) } - pub(crate) fn __reduce41< + fn __reduce41< 'input, >( input: &'input str, @@ -6205,7 +6222,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce42< + fn __reduce42< 'input, >( input: &'input str, @@ -6222,7 +6239,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce43< + fn __reduce43< 'input, >( input: &'input str, @@ -6232,13 +6249,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // Comma = => ActionFn(119); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action119::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 21) } - pub(crate) fn __reduce44< + fn __reduce44< 'input, >( input: &'input str, @@ -6257,7 +6274,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } - pub(crate) fn __reduce45< + fn __reduce45< 'input, >( input: &'input str, @@ -6274,7 +6291,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce46< + fn __reduce46< 'input, >( input: &'input str, @@ -6291,7 +6308,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 22) } - pub(crate) fn __reduce47< + fn __reduce47< 'input, >( input: &'input str, @@ -6316,7 +6333,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (8, 23) } - pub(crate) fn __reduce48< + fn __reduce48< 'input, >( input: &'input str, @@ -6342,7 +6359,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (9, 23) } - pub(crate) fn __reduce49< + fn __reduce49< 'input, >( input: &'input str, @@ -6359,7 +6376,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (1, 24) } - pub(crate) fn __reduce50< + fn __reduce50< 'input, >( input: &'input str, @@ -6378,7 +6395,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (2, 24) } - pub(crate) fn __reduce51< + fn __reduce51< 'input, >( input: &'input str, @@ -6397,7 +6414,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 25) } - pub(crate) fn __reduce52< + fn __reduce52< 'input, >( input: &'input str, @@ -6407,13 +6424,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // Instruction* = => ActionFn(52); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action52::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (0, 26) } - pub(crate) fn __reduce53< + fn __reduce53< 'input, >( input: &'input str, @@ -6430,7 +6447,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 26) } - pub(crate) fn __reduce54< + fn __reduce54< 'input, >( input: &'input str, @@ -6447,7 +6464,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 27) } - pub(crate) fn __reduce55< + fn __reduce55< 'input, >( input: &'input str, @@ -6466,7 +6483,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 27) } - pub(crate) fn __reduce56< + fn __reduce56< 'input, >( input: &'input str, @@ -6490,7 +6507,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce57< + fn __reduce57< 'input, >( input: &'input str, @@ -6514,7 +6531,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce58< + fn __reduce58< 'input, >( input: &'input str, @@ -6535,7 +6552,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (4, 28) } - pub(crate) fn __reduce59< + fn __reduce59< 'input, >( input: &'input str, @@ -6560,7 +6577,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (8, 28) } - pub(crate) fn __reduce60< + fn __reduce60< 'input, >( input: &'input str, @@ -6582,7 +6599,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (5, 28) } - pub(crate) fn __reduce61< + fn __reduce61< 'input, >( input: &'input str, @@ -6601,7 +6618,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce62< + fn __reduce62< 'input, >( input: &'input str, @@ -6621,7 +6638,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } - pub(crate) fn __reduce63< + fn __reduce63< 'input, >( input: &'input str, @@ -6640,7 +6657,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce64< + fn __reduce64< 'input, >( input: &'input str, @@ -6657,7 +6674,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 29) } - pub(crate) fn __reduce65< + fn __reduce65< 'input, >( input: &'input str, @@ -6674,7 +6691,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 30) } - pub(crate) fn __reduce66< + fn __reduce66< 'input, >( input: &'input str, @@ -6691,7 +6708,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce67< + fn __reduce67< 'input, >( input: &'input str, @@ -6708,7 +6725,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce68< + fn __reduce68< 'input, >( input: &'input str, @@ -6725,7 +6742,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (1, 32) } - pub(crate) fn __reduce69< + fn __reduce69< 'input, >( input: &'input str, @@ -6735,13 +6752,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // Operand? = => ActionFn(50); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action50::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (0, 32) } - pub(crate) fn __reduce70< + fn __reduce70< 'input, >( input: &'input str, @@ -6758,7 +6775,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (1, 33) } - pub(crate) fn __reduce71< + fn __reduce71< 'input, >( input: &'input str, @@ -6777,7 +6794,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (2, 34) } - pub(crate) fn __reduce72< + fn __reduce72< 'input, >( input: &'input str, @@ -6794,7 +6811,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (1, 34) } - pub(crate) fn __reduce73< + fn __reduce73< 'input, >( input: &'input str, @@ -6813,7 +6830,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (2, 35) } - pub(crate) fn __reduce74< + fn __reduce74< 'input, >( input: &'input str, @@ -6830,7 +6847,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (1, 35) } - pub(crate) fn __reduce75< + fn __reduce75< 'input, >( input: &'input str, @@ -6850,7 +6867,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (3, 36) } - pub(crate) fn __reduce76< + fn __reduce76< 'input, >( input: &'input str, @@ -6867,7 +6884,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (1, 37) } - pub(crate) fn __reduce77< + fn __reduce77< 'input, >( input: &'input str, @@ -6877,13 +6894,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // TargetArgList? = => ActionFn(48); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action48::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (0, 37) } - pub(crate) fn __reduce78< + fn __reduce78< 'input, >( input: &'input str, @@ -6900,7 +6917,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce79< + fn __reduce79< 'input, >( input: &'input str, @@ -6917,7 +6934,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce80< + fn __reduce80< 'input, >( input: &'input str, @@ -6934,7 +6951,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce81< + fn __reduce81< 'input, >( input: &'input str, @@ -6951,7 +6968,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce82< + fn __reduce82< 'input, >( input: &'input str, @@ -6968,7 +6985,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce83< + fn __reduce83< 'input, >( input: &'input str, @@ -6985,7 +7002,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce84< + fn __reduce84< 'input, >( input: &'input str, @@ -7002,7 +7019,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce85< + fn __reduce85< 'input, >( input: &'input str, @@ -7019,7 +7036,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce86< + fn __reduce86< 'input, >( input: &'input str, @@ -7036,7 +7053,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce87< + fn __reduce87< 'input, >( input: &'input str, @@ -7053,7 +7070,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce88< + fn __reduce88< 'input, >( input: &'input str, @@ -7070,7 +7087,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (1, 39) } - pub(crate) fn __reduce89< + fn __reduce89< 'input, >( input: &'input str, @@ -7080,13 +7097,13 @@ mod __parse__CmpOp { ) -> (usize, usize) { // Type? = => ActionFn(62); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action62::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (0, 39) } - pub(crate) fn __reduce90< + fn __reduce90< 'input, >( input: &'input str, @@ -7103,7 +7120,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce91< + fn __reduce91< 'input, >( input: &'input str, @@ -7120,7 +7137,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce92< + fn __reduce92< 'input, >( input: &'input str, @@ -7137,7 +7154,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 41) } - pub(crate) fn __reduce94< + fn __reduce94< 'input, >( input: &'input str, @@ -7154,7 +7171,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (1, 43) } - pub(crate) fn __reduce95< + fn __reduce95< 'input, >( input: &'input str, @@ -7171,7 +7188,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 44) } - pub(crate) fn __reduce96< + fn __reduce96< 'input, >( input: &'input str, @@ -7188,7 +7205,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 45) } - pub(crate) fn __reduce97< + fn __reduce97< 'input, >( input: &'input str, @@ -7205,7 +7222,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 46) } - pub(crate) fn __reduce98< + fn __reduce98< 'input, >( input: &'input str, @@ -7222,7 +7239,7 @@ mod __parse__CmpOp { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 47) } - pub(crate) fn __reduce99< + fn __reduce99< 'input, >( input: &'input str, @@ -7240,10 +7257,11 @@ mod __parse__CmpOp { (1, 48) } } +#[allow(unused_imports)] pub use self::__parse__CmpOp::CmpOpParser; #[rustfmt::skip] -#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] +#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)] mod __parse__Function { use std::str::FromStr; @@ -7843,7 +7861,7 @@ mod __parse__Function { } }).collect() } - pub(crate) struct __StateMachine<'input> + struct __StateMachine<'input> where { input: &'input str, @@ -7996,7 +8014,7 @@ mod __parse__Function { _: core::marker::PhantomData<(&'input ())>, ) -> __Symbol<'input> { - match __token_index { + #[allow(clippy::manual_range_patterns)]match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), @@ -8615,6 +8633,7 @@ mod __parse__Function { _priv: (), } + impl Default for FunctionParser { fn default() -> Self { Self::new() } } impl FunctionParser { pub fn new() -> FunctionParser { let __builder = super::__intern_token::new_builder(); @@ -8675,7 +8694,7 @@ mod __parse__Function { __states.push(__next_state); } } - pub(crate) fn __reduce< + fn __reduce< 'input, >( input: &'input str, @@ -9346,7 +9365,7 @@ mod __parse__Function { _ => __symbol_type_mismatch() } } - pub(crate) fn __reduce0< + fn __reduce0< 'input, >( input: &'input str, @@ -9363,7 +9382,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } - pub(crate) fn __reduce1< + fn __reduce1< 'input, >( input: &'input str, @@ -9373,13 +9392,13 @@ mod __parse__Function { ) -> (usize, usize) { // "-"? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action45::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (0, 0) } - pub(crate) fn __reduce2< + fn __reduce2< 'input, >( input: &'input str, @@ -9398,7 +9417,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } - pub(crate) fn __reduce3< + fn __reduce3< 'input, >( input: &'input str, @@ -9408,13 +9427,13 @@ mod __parse__Function { ) -> (usize, usize) { // ( ",")* = => ActionFn(72); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action72::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 2) } - pub(crate) fn __reduce4< + fn __reduce4< 'input, >( input: &'input str, @@ -9431,7 +9450,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } - pub(crate) fn __reduce5< + fn __reduce5< 'input, >( input: &'input str, @@ -9450,7 +9469,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } - pub(crate) fn __reduce6< + fn __reduce6< 'input, >( input: &'input str, @@ -9470,7 +9489,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (3, 3) } - pub(crate) fn __reduce7< + fn __reduce7< 'input, >( input: &'input str, @@ -9489,7 +9508,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } - pub(crate) fn __reduce8< + fn __reduce8< 'input, >( input: &'input str, @@ -9499,13 +9518,13 @@ mod __parse__Function { ) -> (usize, usize) { // ( ",")* = => ActionFn(75); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action75::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } - pub(crate) fn __reduce9< + fn __reduce9< 'input, >( input: &'input str, @@ -9522,7 +9541,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } - pub(crate) fn __reduce10< + fn __reduce10< 'input, >( input: &'input str, @@ -9541,7 +9560,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (2, 6) } - pub(crate) fn __reduce11< + fn __reduce11< 'input, >( input: &'input str, @@ -9561,7 +9580,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (3, 6) } - pub(crate) fn __reduce12< + fn __reduce12< 'input, >( input: &'input str, @@ -9580,7 +9599,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } - pub(crate) fn __reduce13< + fn __reduce13< 'input, >( input: &'input str, @@ -9590,13 +9609,13 @@ mod __parse__Function { ) -> (usize, usize) { // ( ",")* = => ActionFn(63); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action63::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 8) } - pub(crate) fn __reduce14< + fn __reduce14< 'input, >( input: &'input str, @@ -9613,7 +9632,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } - pub(crate) fn __reduce15< + fn __reduce15< 'input, >( input: &'input str, @@ -9632,7 +9651,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 9) } - pub(crate) fn __reduce16< + fn __reduce16< 'input, >( input: &'input str, @@ -9652,7 +9671,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (3, 9) } - pub(crate) fn __reduce17< + fn __reduce17< 'input, >( input: &'input str, @@ -9671,7 +9690,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 10) } - pub(crate) fn __reduce18< + fn __reduce18< 'input, >( input: &'input str, @@ -9688,7 +9707,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 11) } - pub(crate) fn __reduce19< + fn __reduce19< 'input, >( input: &'input str, @@ -9698,13 +9717,13 @@ mod __parse__Function { ) -> (usize, usize) { // Arg? = => ActionFn(71); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action71::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce20< + fn __reduce20< 'input, >( input: &'input str, @@ -9724,7 +9743,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce21< + fn __reduce21< 'input, >( input: &'input str, @@ -9745,7 +9764,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } - pub(crate) fn __reduce22< + fn __reduce22< 'input, >( input: &'input str, @@ -9764,7 +9783,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 12) } - pub(crate) fn __reduce23< + fn __reduce23< 'input, >( input: &'input str, @@ -9784,7 +9803,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce24< + fn __reduce24< 'input, >( input: &'input str, @@ -9794,13 +9813,13 @@ mod __parse__Function { ) -> (usize, usize) { // BasicBlock* = => ActionFn(56); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action56::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (0, 13) } - pub(crate) fn __reduce25< + fn __reduce25< 'input, >( input: &'input str, @@ -9817,7 +9836,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 13) } - pub(crate) fn __reduce26< + fn __reduce26< 'input, >( input: &'input str, @@ -9834,7 +9853,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 14) } - pub(crate) fn __reduce27< + fn __reduce27< 'input, >( input: &'input str, @@ -9853,7 +9872,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 14) } - pub(crate) fn __reduce28< + fn __reduce28< 'input, >( input: &'input str, @@ -9873,7 +9892,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (3, 15) } - pub(crate) fn __reduce29< + fn __reduce29< 'input, >( input: &'input str, @@ -9890,7 +9909,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 16) } - pub(crate) fn __reduce30< + fn __reduce30< 'input, >( input: &'input str, @@ -9900,13 +9919,13 @@ mod __parse__Function { ) -> (usize, usize) { // BasicBlockArgList? = => ActionFn(55); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action55::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (0, 16) } - pub(crate) fn __reduce31< + fn __reduce31< 'input, >( input: &'input str, @@ -9923,7 +9942,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 17) } - pub(crate) fn __reduce32< + fn __reduce32< 'input, >( input: &'input str, @@ -9940,7 +9959,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce33< + fn __reduce33< 'input, >( input: &'input str, @@ -9957,7 +9976,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce34< + fn __reduce34< 'input, >( input: &'input str, @@ -9974,7 +9993,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce35< + fn __reduce35< 'input, >( input: &'input str, @@ -9984,13 +10003,13 @@ mod __parse__Function { ) -> (usize, usize) { // Comma = => ActionFn(99); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action99::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (0, 19) } - pub(crate) fn __reduce36< + fn __reduce36< 'input, >( input: &'input str, @@ -10009,7 +10028,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 19) } - pub(crate) fn __reduce37< + fn __reduce37< 'input, >( input: &'input str, @@ -10026,7 +10045,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce38< + fn __reduce38< 'input, >( input: &'input str, @@ -10043,7 +10062,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce39< + fn __reduce39< 'input, >( input: &'input str, @@ -10053,13 +10072,13 @@ mod __parse__Function { ) -> (usize, usize) { // Comma = => ActionFn(111); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action111::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (0, 20) } - pub(crate) fn __reduce40< + fn __reduce40< 'input, >( input: &'input str, @@ -10078,7 +10097,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 20) } - pub(crate) fn __reduce41< + fn __reduce41< 'input, >( input: &'input str, @@ -10095,7 +10114,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce42< + fn __reduce42< 'input, >( input: &'input str, @@ -10112,7 +10131,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce43< + fn __reduce43< 'input, >( input: &'input str, @@ -10122,13 +10141,13 @@ mod __parse__Function { ) -> (usize, usize) { // Comma = => ActionFn(119); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action119::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 21) } - pub(crate) fn __reduce44< + fn __reduce44< 'input, >( input: &'input str, @@ -10147,7 +10166,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } - pub(crate) fn __reduce45< + fn __reduce45< 'input, >( input: &'input str, @@ -10164,7 +10183,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce46< + fn __reduce46< 'input, >( input: &'input str, @@ -10181,7 +10200,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 22) } - pub(crate) fn __reduce47< + fn __reduce47< 'input, >( input: &'input str, @@ -10206,7 +10225,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (8, 23) } - pub(crate) fn __reduce48< + fn __reduce48< 'input, >( input: &'input str, @@ -10232,7 +10251,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (9, 23) } - pub(crate) fn __reduce49< + fn __reduce49< 'input, >( input: &'input str, @@ -10249,7 +10268,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (1, 24) } - pub(crate) fn __reduce50< + fn __reduce50< 'input, >( input: &'input str, @@ -10268,7 +10287,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (2, 24) } - pub(crate) fn __reduce51< + fn __reduce51< 'input, >( input: &'input str, @@ -10287,7 +10306,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 25) } - pub(crate) fn __reduce52< + fn __reduce52< 'input, >( input: &'input str, @@ -10297,13 +10316,13 @@ mod __parse__Function { ) -> (usize, usize) { // Instruction* = => ActionFn(52); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action52::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (0, 26) } - pub(crate) fn __reduce53< + fn __reduce53< 'input, >( input: &'input str, @@ -10320,7 +10339,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 26) } - pub(crate) fn __reduce54< + fn __reduce54< 'input, >( input: &'input str, @@ -10337,7 +10356,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 27) } - pub(crate) fn __reduce55< + fn __reduce55< 'input, >( input: &'input str, @@ -10356,7 +10375,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 27) } - pub(crate) fn __reduce56< + fn __reduce56< 'input, >( input: &'input str, @@ -10380,7 +10399,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce57< + fn __reduce57< 'input, >( input: &'input str, @@ -10404,7 +10423,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce58< + fn __reduce58< 'input, >( input: &'input str, @@ -10425,7 +10444,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (4, 28) } - pub(crate) fn __reduce59< + fn __reduce59< 'input, >( input: &'input str, @@ -10450,7 +10469,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (8, 28) } - pub(crate) fn __reduce60< + fn __reduce60< 'input, >( input: &'input str, @@ -10472,7 +10491,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (5, 28) } - pub(crate) fn __reduce61< + fn __reduce61< 'input, >( input: &'input str, @@ -10491,7 +10510,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce62< + fn __reduce62< 'input, >( input: &'input str, @@ -10511,7 +10530,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } - pub(crate) fn __reduce63< + fn __reduce63< 'input, >( input: &'input str, @@ -10530,7 +10549,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce64< + fn __reduce64< 'input, >( input: &'input str, @@ -10547,7 +10566,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 29) } - pub(crate) fn __reduce65< + fn __reduce65< 'input, >( input: &'input str, @@ -10564,7 +10583,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 30) } - pub(crate) fn __reduce66< + fn __reduce66< 'input, >( input: &'input str, @@ -10581,7 +10600,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce67< + fn __reduce67< 'input, >( input: &'input str, @@ -10598,7 +10617,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce68< + fn __reduce68< 'input, >( input: &'input str, @@ -10615,7 +10634,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (1, 32) } - pub(crate) fn __reduce69< + fn __reduce69< 'input, >( input: &'input str, @@ -10625,13 +10644,13 @@ mod __parse__Function { ) -> (usize, usize) { // Operand? = => ActionFn(50); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action50::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (0, 32) } - pub(crate) fn __reduce70< + fn __reduce70< 'input, >( input: &'input str, @@ -10648,7 +10667,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (1, 33) } - pub(crate) fn __reduce71< + fn __reduce71< 'input, >( input: &'input str, @@ -10667,7 +10686,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (2, 34) } - pub(crate) fn __reduce72< + fn __reduce72< 'input, >( input: &'input str, @@ -10684,7 +10703,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (1, 34) } - pub(crate) fn __reduce73< + fn __reduce73< 'input, >( input: &'input str, @@ -10703,7 +10722,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (2, 35) } - pub(crate) fn __reduce74< + fn __reduce74< 'input, >( input: &'input str, @@ -10720,7 +10739,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (1, 35) } - pub(crate) fn __reduce75< + fn __reduce75< 'input, >( input: &'input str, @@ -10740,7 +10759,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (3, 36) } - pub(crate) fn __reduce76< + fn __reduce76< 'input, >( input: &'input str, @@ -10757,7 +10776,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (1, 37) } - pub(crate) fn __reduce77< + fn __reduce77< 'input, >( input: &'input str, @@ -10767,13 +10786,13 @@ mod __parse__Function { ) -> (usize, usize) { // TargetArgList? = => ActionFn(48); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action48::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (0, 37) } - pub(crate) fn __reduce78< + fn __reduce78< 'input, >( input: &'input str, @@ -10790,7 +10809,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce79< + fn __reduce79< 'input, >( input: &'input str, @@ -10807,7 +10826,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce80< + fn __reduce80< 'input, >( input: &'input str, @@ -10824,7 +10843,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce81< + fn __reduce81< 'input, >( input: &'input str, @@ -10841,7 +10860,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce82< + fn __reduce82< 'input, >( input: &'input str, @@ -10858,7 +10877,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce83< + fn __reduce83< 'input, >( input: &'input str, @@ -10875,7 +10894,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce84< + fn __reduce84< 'input, >( input: &'input str, @@ -10892,7 +10911,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce85< + fn __reduce85< 'input, >( input: &'input str, @@ -10909,7 +10928,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce86< + fn __reduce86< 'input, >( input: &'input str, @@ -10926,7 +10945,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce87< + fn __reduce87< 'input, >( input: &'input str, @@ -10943,7 +10962,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce88< + fn __reduce88< 'input, >( input: &'input str, @@ -10960,7 +10979,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (1, 39) } - pub(crate) fn __reduce89< + fn __reduce89< 'input, >( input: &'input str, @@ -10970,13 +10989,13 @@ mod __parse__Function { ) -> (usize, usize) { // Type? = => ActionFn(62); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action62::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (0, 39) } - pub(crate) fn __reduce90< + fn __reduce90< 'input, >( input: &'input str, @@ -10993,7 +11012,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce91< + fn __reduce91< 'input, >( input: &'input str, @@ -11010,7 +11029,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce92< + fn __reduce92< 'input, >( input: &'input str, @@ -11027,7 +11046,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 41) } - pub(crate) fn __reduce93< + fn __reduce93< 'input, >( input: &'input str, @@ -11044,7 +11063,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 42) } - pub(crate) fn __reduce95< + fn __reduce95< 'input, >( input: &'input str, @@ -11061,7 +11080,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 44) } - pub(crate) fn __reduce96< + fn __reduce96< 'input, >( input: &'input str, @@ -11078,7 +11097,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 45) } - pub(crate) fn __reduce97< + fn __reduce97< 'input, >( input: &'input str, @@ -11095,7 +11114,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 46) } - pub(crate) fn __reduce98< + fn __reduce98< 'input, >( input: &'input str, @@ -11112,7 +11131,7 @@ mod __parse__Function { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 47) } - pub(crate) fn __reduce99< + fn __reduce99< 'input, >( input: &'input str, @@ -11130,10 +11149,11 @@ mod __parse__Function { (1, 48) } } +#[allow(unused_imports)] pub use self::__parse__Function::FunctionParser; #[rustfmt::skip] -#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] +#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)] mod __parse__Instruction { use std::str::FromStr; @@ -11558,7 +11578,7 @@ mod __parse__Instruction { } }).collect() } - pub(crate) struct __StateMachine<'input> + struct __StateMachine<'input> where { input: &'input str, @@ -11711,7 +11731,7 @@ mod __parse__Instruction { _: core::marker::PhantomData<(&'input ())>, ) -> __Symbol<'input> { - match __token_index { + #[allow(clippy::manual_range_patterns)]match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), @@ -12330,6 +12350,7 @@ mod __parse__Instruction { _priv: (), } + impl Default for InstructionParser { fn default() -> Self { Self::new() } } impl InstructionParser { pub fn new() -> InstructionParser { let __builder = super::__intern_token::new_builder(); @@ -12390,7 +12411,7 @@ mod __parse__Instruction { __states.push(__next_state); } } - pub(crate) fn __reduce< + fn __reduce< 'input, >( input: &'input str, @@ -13061,7 +13082,7 @@ mod __parse__Instruction { _ => __symbol_type_mismatch() } } - pub(crate) fn __reduce0< + fn __reduce0< 'input, >( input: &'input str, @@ -13078,7 +13099,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } - pub(crate) fn __reduce1< + fn __reduce1< 'input, >( input: &'input str, @@ -13088,13 +13109,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // "-"? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action45::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (0, 0) } - pub(crate) fn __reduce2< + fn __reduce2< 'input, >( input: &'input str, @@ -13113,7 +13134,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } - pub(crate) fn __reduce3< + fn __reduce3< 'input, >( input: &'input str, @@ -13123,13 +13144,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // ( ",")* = => ActionFn(72); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action72::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 2) } - pub(crate) fn __reduce4< + fn __reduce4< 'input, >( input: &'input str, @@ -13146,7 +13167,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } - pub(crate) fn __reduce5< + fn __reduce5< 'input, >( input: &'input str, @@ -13165,7 +13186,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } - pub(crate) fn __reduce6< + fn __reduce6< 'input, >( input: &'input str, @@ -13185,7 +13206,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (3, 3) } - pub(crate) fn __reduce7< + fn __reduce7< 'input, >( input: &'input str, @@ -13204,7 +13225,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } - pub(crate) fn __reduce8< + fn __reduce8< 'input, >( input: &'input str, @@ -13214,13 +13235,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // ( ",")* = => ActionFn(75); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action75::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } - pub(crate) fn __reduce9< + fn __reduce9< 'input, >( input: &'input str, @@ -13237,7 +13258,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } - pub(crate) fn __reduce10< + fn __reduce10< 'input, >( input: &'input str, @@ -13256,7 +13277,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (2, 6) } - pub(crate) fn __reduce11< + fn __reduce11< 'input, >( input: &'input str, @@ -13276,7 +13297,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (3, 6) } - pub(crate) fn __reduce12< + fn __reduce12< 'input, >( input: &'input str, @@ -13295,7 +13316,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } - pub(crate) fn __reduce13< + fn __reduce13< 'input, >( input: &'input str, @@ -13305,13 +13326,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // ( ",")* = => ActionFn(63); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action63::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 8) } - pub(crate) fn __reduce14< + fn __reduce14< 'input, >( input: &'input str, @@ -13328,7 +13349,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } - pub(crate) fn __reduce15< + fn __reduce15< 'input, >( input: &'input str, @@ -13347,7 +13368,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 9) } - pub(crate) fn __reduce16< + fn __reduce16< 'input, >( input: &'input str, @@ -13367,7 +13388,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (3, 9) } - pub(crate) fn __reduce17< + fn __reduce17< 'input, >( input: &'input str, @@ -13386,7 +13407,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 10) } - pub(crate) fn __reduce18< + fn __reduce18< 'input, >( input: &'input str, @@ -13403,7 +13424,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 11) } - pub(crate) fn __reduce19< + fn __reduce19< 'input, >( input: &'input str, @@ -13413,13 +13434,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // Arg? = => ActionFn(71); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action71::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce20< + fn __reduce20< 'input, >( input: &'input str, @@ -13439,7 +13460,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce21< + fn __reduce21< 'input, >( input: &'input str, @@ -13460,7 +13481,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } - pub(crate) fn __reduce22< + fn __reduce22< 'input, >( input: &'input str, @@ -13479,7 +13500,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 12) } - pub(crate) fn __reduce23< + fn __reduce23< 'input, >( input: &'input str, @@ -13499,7 +13520,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce24< + fn __reduce24< 'input, >( input: &'input str, @@ -13509,13 +13530,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // BasicBlock* = => ActionFn(56); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action56::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (0, 13) } - pub(crate) fn __reduce25< + fn __reduce25< 'input, >( input: &'input str, @@ -13532,7 +13553,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 13) } - pub(crate) fn __reduce26< + fn __reduce26< 'input, >( input: &'input str, @@ -13549,7 +13570,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 14) } - pub(crate) fn __reduce27< + fn __reduce27< 'input, >( input: &'input str, @@ -13568,7 +13589,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 14) } - pub(crate) fn __reduce28< + fn __reduce28< 'input, >( input: &'input str, @@ -13588,7 +13609,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (3, 15) } - pub(crate) fn __reduce29< + fn __reduce29< 'input, >( input: &'input str, @@ -13605,7 +13626,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 16) } - pub(crate) fn __reduce30< + fn __reduce30< 'input, >( input: &'input str, @@ -13615,13 +13636,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // BasicBlockArgList? = => ActionFn(55); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action55::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (0, 16) } - pub(crate) fn __reduce31< + fn __reduce31< 'input, >( input: &'input str, @@ -13638,7 +13659,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 17) } - pub(crate) fn __reduce32< + fn __reduce32< 'input, >( input: &'input str, @@ -13655,7 +13676,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce33< + fn __reduce33< 'input, >( input: &'input str, @@ -13672,7 +13693,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce34< + fn __reduce34< 'input, >( input: &'input str, @@ -13689,7 +13710,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce35< + fn __reduce35< 'input, >( input: &'input str, @@ -13699,13 +13720,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // Comma = => ActionFn(99); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action99::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (0, 19) } - pub(crate) fn __reduce36< + fn __reduce36< 'input, >( input: &'input str, @@ -13724,7 +13745,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 19) } - pub(crate) fn __reduce37< + fn __reduce37< 'input, >( input: &'input str, @@ -13741,7 +13762,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce38< + fn __reduce38< 'input, >( input: &'input str, @@ -13758,7 +13779,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce39< + fn __reduce39< 'input, >( input: &'input str, @@ -13768,13 +13789,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // Comma = => ActionFn(111); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action111::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (0, 20) } - pub(crate) fn __reduce40< + fn __reduce40< 'input, >( input: &'input str, @@ -13793,7 +13814,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 20) } - pub(crate) fn __reduce41< + fn __reduce41< 'input, >( input: &'input str, @@ -13810,7 +13831,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce42< + fn __reduce42< 'input, >( input: &'input str, @@ -13827,7 +13848,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce43< + fn __reduce43< 'input, >( input: &'input str, @@ -13837,13 +13858,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // Comma = => ActionFn(119); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action119::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 21) } - pub(crate) fn __reduce44< + fn __reduce44< 'input, >( input: &'input str, @@ -13862,7 +13883,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } - pub(crate) fn __reduce45< + fn __reduce45< 'input, >( input: &'input str, @@ -13879,7 +13900,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce46< + fn __reduce46< 'input, >( input: &'input str, @@ -13896,7 +13917,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 22) } - pub(crate) fn __reduce47< + fn __reduce47< 'input, >( input: &'input str, @@ -13921,7 +13942,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (8, 23) } - pub(crate) fn __reduce48< + fn __reduce48< 'input, >( input: &'input str, @@ -13947,7 +13968,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (9, 23) } - pub(crate) fn __reduce49< + fn __reduce49< 'input, >( input: &'input str, @@ -13964,7 +13985,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (1, 24) } - pub(crate) fn __reduce50< + fn __reduce50< 'input, >( input: &'input str, @@ -13983,7 +14004,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (2, 24) } - pub(crate) fn __reduce51< + fn __reduce51< 'input, >( input: &'input str, @@ -14002,7 +14023,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 25) } - pub(crate) fn __reduce52< + fn __reduce52< 'input, >( input: &'input str, @@ -14012,13 +14033,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // Instruction* = => ActionFn(52); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action52::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (0, 26) } - pub(crate) fn __reduce53< + fn __reduce53< 'input, >( input: &'input str, @@ -14035,7 +14056,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 26) } - pub(crate) fn __reduce54< + fn __reduce54< 'input, >( input: &'input str, @@ -14052,7 +14073,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 27) } - pub(crate) fn __reduce55< + fn __reduce55< 'input, >( input: &'input str, @@ -14071,7 +14092,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 27) } - pub(crate) fn __reduce56< + fn __reduce56< 'input, >( input: &'input str, @@ -14095,7 +14116,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce57< + fn __reduce57< 'input, >( input: &'input str, @@ -14119,7 +14140,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce58< + fn __reduce58< 'input, >( input: &'input str, @@ -14140,7 +14161,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (4, 28) } - pub(crate) fn __reduce59< + fn __reduce59< 'input, >( input: &'input str, @@ -14165,7 +14186,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (8, 28) } - pub(crate) fn __reduce60< + fn __reduce60< 'input, >( input: &'input str, @@ -14187,7 +14208,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (5, 28) } - pub(crate) fn __reduce61< + fn __reduce61< 'input, >( input: &'input str, @@ -14206,7 +14227,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce62< + fn __reduce62< 'input, >( input: &'input str, @@ -14226,7 +14247,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } - pub(crate) fn __reduce63< + fn __reduce63< 'input, >( input: &'input str, @@ -14245,7 +14266,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce64< + fn __reduce64< 'input, >( input: &'input str, @@ -14262,7 +14283,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 29) } - pub(crate) fn __reduce65< + fn __reduce65< 'input, >( input: &'input str, @@ -14279,7 +14300,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 30) } - pub(crate) fn __reduce66< + fn __reduce66< 'input, >( input: &'input str, @@ -14296,7 +14317,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce67< + fn __reduce67< 'input, >( input: &'input str, @@ -14313,7 +14334,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce68< + fn __reduce68< 'input, >( input: &'input str, @@ -14330,7 +14351,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (1, 32) } - pub(crate) fn __reduce69< + fn __reduce69< 'input, >( input: &'input str, @@ -14340,13 +14361,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // Operand? = => ActionFn(50); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action50::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (0, 32) } - pub(crate) fn __reduce70< + fn __reduce70< 'input, >( input: &'input str, @@ -14363,7 +14384,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (1, 33) } - pub(crate) fn __reduce71< + fn __reduce71< 'input, >( input: &'input str, @@ -14382,7 +14403,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (2, 34) } - pub(crate) fn __reduce72< + fn __reduce72< 'input, >( input: &'input str, @@ -14399,7 +14420,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (1, 34) } - pub(crate) fn __reduce73< + fn __reduce73< 'input, >( input: &'input str, @@ -14418,7 +14439,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (2, 35) } - pub(crate) fn __reduce74< + fn __reduce74< 'input, >( input: &'input str, @@ -14435,7 +14456,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (1, 35) } - pub(crate) fn __reduce75< + fn __reduce75< 'input, >( input: &'input str, @@ -14455,7 +14476,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (3, 36) } - pub(crate) fn __reduce76< + fn __reduce76< 'input, >( input: &'input str, @@ -14472,7 +14493,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (1, 37) } - pub(crate) fn __reduce77< + fn __reduce77< 'input, >( input: &'input str, @@ -14482,13 +14503,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // TargetArgList? = => ActionFn(48); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action48::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (0, 37) } - pub(crate) fn __reduce78< + fn __reduce78< 'input, >( input: &'input str, @@ -14505,7 +14526,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce79< + fn __reduce79< 'input, >( input: &'input str, @@ -14522,7 +14543,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce80< + fn __reduce80< 'input, >( input: &'input str, @@ -14539,7 +14560,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce81< + fn __reduce81< 'input, >( input: &'input str, @@ -14556,7 +14577,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce82< + fn __reduce82< 'input, >( input: &'input str, @@ -14573,7 +14594,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce83< + fn __reduce83< 'input, >( input: &'input str, @@ -14590,7 +14611,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce84< + fn __reduce84< 'input, >( input: &'input str, @@ -14607,7 +14628,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce85< + fn __reduce85< 'input, >( input: &'input str, @@ -14624,7 +14645,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce86< + fn __reduce86< 'input, >( input: &'input str, @@ -14641,7 +14662,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce87< + fn __reduce87< 'input, >( input: &'input str, @@ -14658,7 +14679,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce88< + fn __reduce88< 'input, >( input: &'input str, @@ -14675,7 +14696,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (1, 39) } - pub(crate) fn __reduce89< + fn __reduce89< 'input, >( input: &'input str, @@ -14685,13 +14706,13 @@ mod __parse__Instruction { ) -> (usize, usize) { // Type? = => ActionFn(62); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action62::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (0, 39) } - pub(crate) fn __reduce90< + fn __reduce90< 'input, >( input: &'input str, @@ -14708,7 +14729,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce91< + fn __reduce91< 'input, >( input: &'input str, @@ -14725,7 +14746,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce92< + fn __reduce92< 'input, >( input: &'input str, @@ -14742,7 +14763,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 41) } - pub(crate) fn __reduce93< + fn __reduce93< 'input, >( input: &'input str, @@ -14759,7 +14780,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 42) } - pub(crate) fn __reduce94< + fn __reduce94< 'input, >( input: &'input str, @@ -14776,7 +14797,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (1, 43) } - pub(crate) fn __reduce96< + fn __reduce96< 'input, >( input: &'input str, @@ -14793,7 +14814,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 45) } - pub(crate) fn __reduce97< + fn __reduce97< 'input, >( input: &'input str, @@ -14810,7 +14831,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 46) } - pub(crate) fn __reduce98< + fn __reduce98< 'input, >( input: &'input str, @@ -14827,7 +14848,7 @@ mod __parse__Instruction { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 47) } - pub(crate) fn __reduce99< + fn __reduce99< 'input, >( input: &'input str, @@ -14845,10 +14866,11 @@ mod __parse__Instruction { (1, 48) } } +#[allow(unused_imports)] pub use self::__parse__Instruction::InstructionParser; #[rustfmt::skip] -#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] +#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)] mod __parse__InstructionInner { use std::str::FromStr; @@ -15264,7 +15286,7 @@ mod __parse__InstructionInner { } }).collect() } - pub(crate) struct __StateMachine<'input> + struct __StateMachine<'input> where { input: &'input str, @@ -15417,7 +15439,7 @@ mod __parse__InstructionInner { _: core::marker::PhantomData<(&'input ())>, ) -> __Symbol<'input> { - match __token_index { + #[allow(clippy::manual_range_patterns)]match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), @@ -16036,6 +16058,7 @@ mod __parse__InstructionInner { _priv: (), } + impl Default for InstructionInnerParser { fn default() -> Self { Self::new() } } impl InstructionInnerParser { pub fn new() -> InstructionInnerParser { let __builder = super::__intern_token::new_builder(); @@ -16096,7 +16119,7 @@ mod __parse__InstructionInner { __states.push(__next_state); } } - pub(crate) fn __reduce< + fn __reduce< 'input, >( input: &'input str, @@ -16767,7 +16790,7 @@ mod __parse__InstructionInner { _ => __symbol_type_mismatch() } } - pub(crate) fn __reduce0< + fn __reduce0< 'input, >( input: &'input str, @@ -16784,7 +16807,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } - pub(crate) fn __reduce1< + fn __reduce1< 'input, >( input: &'input str, @@ -16794,13 +16817,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // "-"? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action45::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (0, 0) } - pub(crate) fn __reduce2< + fn __reduce2< 'input, >( input: &'input str, @@ -16819,7 +16842,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } - pub(crate) fn __reduce3< + fn __reduce3< 'input, >( input: &'input str, @@ -16829,13 +16852,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // ( ",")* = => ActionFn(72); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action72::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 2) } - pub(crate) fn __reduce4< + fn __reduce4< 'input, >( input: &'input str, @@ -16852,7 +16875,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } - pub(crate) fn __reduce5< + fn __reduce5< 'input, >( input: &'input str, @@ -16871,7 +16894,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } - pub(crate) fn __reduce6< + fn __reduce6< 'input, >( input: &'input str, @@ -16891,7 +16914,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (3, 3) } - pub(crate) fn __reduce7< + fn __reduce7< 'input, >( input: &'input str, @@ -16910,7 +16933,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } - pub(crate) fn __reduce8< + fn __reduce8< 'input, >( input: &'input str, @@ -16920,13 +16943,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // ( ",")* = => ActionFn(75); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action75::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } - pub(crate) fn __reduce9< + fn __reduce9< 'input, >( input: &'input str, @@ -16943,7 +16966,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } - pub(crate) fn __reduce10< + fn __reduce10< 'input, >( input: &'input str, @@ -16962,7 +16985,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (2, 6) } - pub(crate) fn __reduce11< + fn __reduce11< 'input, >( input: &'input str, @@ -16982,7 +17005,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (3, 6) } - pub(crate) fn __reduce12< + fn __reduce12< 'input, >( input: &'input str, @@ -17001,7 +17024,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } - pub(crate) fn __reduce13< + fn __reduce13< 'input, >( input: &'input str, @@ -17011,13 +17034,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // ( ",")* = => ActionFn(63); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action63::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 8) } - pub(crate) fn __reduce14< + fn __reduce14< 'input, >( input: &'input str, @@ -17034,7 +17057,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } - pub(crate) fn __reduce15< + fn __reduce15< 'input, >( input: &'input str, @@ -17053,7 +17076,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 9) } - pub(crate) fn __reduce16< + fn __reduce16< 'input, >( input: &'input str, @@ -17073,7 +17096,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (3, 9) } - pub(crate) fn __reduce17< + fn __reduce17< 'input, >( input: &'input str, @@ -17092,7 +17115,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 10) } - pub(crate) fn __reduce18< + fn __reduce18< 'input, >( input: &'input str, @@ -17109,7 +17132,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 11) } - pub(crate) fn __reduce19< + fn __reduce19< 'input, >( input: &'input str, @@ -17119,13 +17142,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // Arg? = => ActionFn(71); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action71::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce20< + fn __reduce20< 'input, >( input: &'input str, @@ -17145,7 +17168,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce21< + fn __reduce21< 'input, >( input: &'input str, @@ -17166,7 +17189,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } - pub(crate) fn __reduce22< + fn __reduce22< 'input, >( input: &'input str, @@ -17185,7 +17208,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 12) } - pub(crate) fn __reduce23< + fn __reduce23< 'input, >( input: &'input str, @@ -17205,7 +17228,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce24< + fn __reduce24< 'input, >( input: &'input str, @@ -17215,13 +17238,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // BasicBlock* = => ActionFn(56); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action56::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (0, 13) } - pub(crate) fn __reduce25< + fn __reduce25< 'input, >( input: &'input str, @@ -17238,7 +17261,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 13) } - pub(crate) fn __reduce26< + fn __reduce26< 'input, >( input: &'input str, @@ -17255,7 +17278,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 14) } - pub(crate) fn __reduce27< + fn __reduce27< 'input, >( input: &'input str, @@ -17274,7 +17297,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 14) } - pub(crate) fn __reduce28< + fn __reduce28< 'input, >( input: &'input str, @@ -17294,7 +17317,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (3, 15) } - pub(crate) fn __reduce29< + fn __reduce29< 'input, >( input: &'input str, @@ -17311,7 +17334,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 16) } - pub(crate) fn __reduce30< + fn __reduce30< 'input, >( input: &'input str, @@ -17321,13 +17344,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // BasicBlockArgList? = => ActionFn(55); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action55::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (0, 16) } - pub(crate) fn __reduce31< + fn __reduce31< 'input, >( input: &'input str, @@ -17344,7 +17367,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 17) } - pub(crate) fn __reduce32< + fn __reduce32< 'input, >( input: &'input str, @@ -17361,7 +17384,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce33< + fn __reduce33< 'input, >( input: &'input str, @@ -17378,7 +17401,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce34< + fn __reduce34< 'input, >( input: &'input str, @@ -17395,7 +17418,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce35< + fn __reduce35< 'input, >( input: &'input str, @@ -17405,13 +17428,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // Comma = => ActionFn(99); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action99::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (0, 19) } - pub(crate) fn __reduce36< + fn __reduce36< 'input, >( input: &'input str, @@ -17430,7 +17453,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 19) } - pub(crate) fn __reduce37< + fn __reduce37< 'input, >( input: &'input str, @@ -17447,7 +17470,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce38< + fn __reduce38< 'input, >( input: &'input str, @@ -17464,7 +17487,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce39< + fn __reduce39< 'input, >( input: &'input str, @@ -17474,13 +17497,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // Comma = => ActionFn(111); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action111::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (0, 20) } - pub(crate) fn __reduce40< + fn __reduce40< 'input, >( input: &'input str, @@ -17499,7 +17522,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 20) } - pub(crate) fn __reduce41< + fn __reduce41< 'input, >( input: &'input str, @@ -17516,7 +17539,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce42< + fn __reduce42< 'input, >( input: &'input str, @@ -17533,7 +17556,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce43< + fn __reduce43< 'input, >( input: &'input str, @@ -17543,13 +17566,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // Comma = => ActionFn(119); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action119::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 21) } - pub(crate) fn __reduce44< + fn __reduce44< 'input, >( input: &'input str, @@ -17568,7 +17591,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } - pub(crate) fn __reduce45< + fn __reduce45< 'input, >( input: &'input str, @@ -17585,7 +17608,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce46< + fn __reduce46< 'input, >( input: &'input str, @@ -17602,7 +17625,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 22) } - pub(crate) fn __reduce47< + fn __reduce47< 'input, >( input: &'input str, @@ -17627,7 +17650,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (8, 23) } - pub(crate) fn __reduce48< + fn __reduce48< 'input, >( input: &'input str, @@ -17653,7 +17676,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (9, 23) } - pub(crate) fn __reduce49< + fn __reduce49< 'input, >( input: &'input str, @@ -17670,7 +17693,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (1, 24) } - pub(crate) fn __reduce50< + fn __reduce50< 'input, >( input: &'input str, @@ -17689,7 +17712,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (2, 24) } - pub(crate) fn __reduce51< + fn __reduce51< 'input, >( input: &'input str, @@ -17708,7 +17731,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 25) } - pub(crate) fn __reduce52< + fn __reduce52< 'input, >( input: &'input str, @@ -17718,13 +17741,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // Instruction* = => ActionFn(52); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action52::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (0, 26) } - pub(crate) fn __reduce53< + fn __reduce53< 'input, >( input: &'input str, @@ -17741,7 +17764,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 26) } - pub(crate) fn __reduce54< + fn __reduce54< 'input, >( input: &'input str, @@ -17758,7 +17781,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 27) } - pub(crate) fn __reduce55< + fn __reduce55< 'input, >( input: &'input str, @@ -17777,7 +17800,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 27) } - pub(crate) fn __reduce56< + fn __reduce56< 'input, >( input: &'input str, @@ -17801,7 +17824,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce57< + fn __reduce57< 'input, >( input: &'input str, @@ -17825,7 +17848,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce58< + fn __reduce58< 'input, >( input: &'input str, @@ -17846,7 +17869,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (4, 28) } - pub(crate) fn __reduce59< + fn __reduce59< 'input, >( input: &'input str, @@ -17871,7 +17894,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (8, 28) } - pub(crate) fn __reduce60< + fn __reduce60< 'input, >( input: &'input str, @@ -17893,7 +17916,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (5, 28) } - pub(crate) fn __reduce61< + fn __reduce61< 'input, >( input: &'input str, @@ -17912,7 +17935,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce62< + fn __reduce62< 'input, >( input: &'input str, @@ -17932,7 +17955,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } - pub(crate) fn __reduce63< + fn __reduce63< 'input, >( input: &'input str, @@ -17951,7 +17974,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce64< + fn __reduce64< 'input, >( input: &'input str, @@ -17968,7 +17991,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 29) } - pub(crate) fn __reduce65< + fn __reduce65< 'input, >( input: &'input str, @@ -17985,7 +18008,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 30) } - pub(crate) fn __reduce66< + fn __reduce66< 'input, >( input: &'input str, @@ -18002,7 +18025,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce67< + fn __reduce67< 'input, >( input: &'input str, @@ -18019,7 +18042,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce68< + fn __reduce68< 'input, >( input: &'input str, @@ -18036,7 +18059,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (1, 32) } - pub(crate) fn __reduce69< + fn __reduce69< 'input, >( input: &'input str, @@ -18046,13 +18069,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // Operand? = => ActionFn(50); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action50::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (0, 32) } - pub(crate) fn __reduce70< + fn __reduce70< 'input, >( input: &'input str, @@ -18069,7 +18092,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (1, 33) } - pub(crate) fn __reduce71< + fn __reduce71< 'input, >( input: &'input str, @@ -18088,7 +18111,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (2, 34) } - pub(crate) fn __reduce72< + fn __reduce72< 'input, >( input: &'input str, @@ -18105,7 +18128,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (1, 34) } - pub(crate) fn __reduce73< + fn __reduce73< 'input, >( input: &'input str, @@ -18124,7 +18147,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (2, 35) } - pub(crate) fn __reduce74< + fn __reduce74< 'input, >( input: &'input str, @@ -18141,7 +18164,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (1, 35) } - pub(crate) fn __reduce75< + fn __reduce75< 'input, >( input: &'input str, @@ -18161,7 +18184,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (3, 36) } - pub(crate) fn __reduce76< + fn __reduce76< 'input, >( input: &'input str, @@ -18178,7 +18201,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (1, 37) } - pub(crate) fn __reduce77< + fn __reduce77< 'input, >( input: &'input str, @@ -18188,13 +18211,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // TargetArgList? = => ActionFn(48); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action48::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (0, 37) } - pub(crate) fn __reduce78< + fn __reduce78< 'input, >( input: &'input str, @@ -18211,7 +18234,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce79< + fn __reduce79< 'input, >( input: &'input str, @@ -18228,7 +18251,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce80< + fn __reduce80< 'input, >( input: &'input str, @@ -18245,7 +18268,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce81< + fn __reduce81< 'input, >( input: &'input str, @@ -18262,7 +18285,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce82< + fn __reduce82< 'input, >( input: &'input str, @@ -18279,7 +18302,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce83< + fn __reduce83< 'input, >( input: &'input str, @@ -18296,7 +18319,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce84< + fn __reduce84< 'input, >( input: &'input str, @@ -18313,7 +18336,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce85< + fn __reduce85< 'input, >( input: &'input str, @@ -18330,7 +18353,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce86< + fn __reduce86< 'input, >( input: &'input str, @@ -18347,7 +18370,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce87< + fn __reduce87< 'input, >( input: &'input str, @@ -18364,7 +18387,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce88< + fn __reduce88< 'input, >( input: &'input str, @@ -18381,7 +18404,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (1, 39) } - pub(crate) fn __reduce89< + fn __reduce89< 'input, >( input: &'input str, @@ -18391,13 +18414,13 @@ mod __parse__InstructionInner { ) -> (usize, usize) { // Type? = => ActionFn(62); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action62::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (0, 39) } - pub(crate) fn __reduce90< + fn __reduce90< 'input, >( input: &'input str, @@ -18414,7 +18437,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce91< + fn __reduce91< 'input, >( input: &'input str, @@ -18431,7 +18454,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce92< + fn __reduce92< 'input, >( input: &'input str, @@ -18448,7 +18471,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 41) } - pub(crate) fn __reduce93< + fn __reduce93< 'input, >( input: &'input str, @@ -18465,7 +18488,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 42) } - pub(crate) fn __reduce94< + fn __reduce94< 'input, >( input: &'input str, @@ -18482,7 +18505,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (1, 43) } - pub(crate) fn __reduce95< + fn __reduce95< 'input, >( input: &'input str, @@ -18499,7 +18522,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 44) } - pub(crate) fn __reduce97< + fn __reduce97< 'input, >( input: &'input str, @@ -18516,7 +18539,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 46) } - pub(crate) fn __reduce98< + fn __reduce98< 'input, >( input: &'input str, @@ -18533,7 +18556,7 @@ mod __parse__InstructionInner { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 47) } - pub(crate) fn __reduce99< + fn __reduce99< 'input, >( input: &'input str, @@ -18551,10 +18574,11 @@ mod __parse__InstructionInner { (1, 48) } } +#[allow(unused_imports)] pub use self::__parse__InstructionInner::InstructionInnerParser; #[rustfmt::skip] -#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] +#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)] mod __parse__Module { use std::str::FromStr; @@ -19171,7 +19195,7 @@ mod __parse__Module { } }).collect() } - pub(crate) struct __StateMachine<'input> + struct __StateMachine<'input> where { input: &'input str, @@ -19324,7 +19348,7 @@ mod __parse__Module { _: core::marker::PhantomData<(&'input ())>, ) -> __Symbol<'input> { - match __token_index { + #[allow(clippy::manual_range_patterns)]match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), @@ -19943,6 +19967,7 @@ mod __parse__Module { _priv: (), } + impl Default for ModuleParser { fn default() -> Self { Self::new() } } impl ModuleParser { pub fn new() -> ModuleParser { let __builder = super::__intern_token::new_builder(); @@ -20003,7 +20028,7 @@ mod __parse__Module { __states.push(__next_state); } } - pub(crate) fn __reduce< + fn __reduce< 'input, >( input: &'input str, @@ -20674,7 +20699,7 @@ mod __parse__Module { _ => __symbol_type_mismatch() } } - pub(crate) fn __reduce0< + fn __reduce0< 'input, >( input: &'input str, @@ -20691,7 +20716,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } - pub(crate) fn __reduce1< + fn __reduce1< 'input, >( input: &'input str, @@ -20701,13 +20726,13 @@ mod __parse__Module { ) -> (usize, usize) { // "-"? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action45::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (0, 0) } - pub(crate) fn __reduce2< + fn __reduce2< 'input, >( input: &'input str, @@ -20726,7 +20751,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } - pub(crate) fn __reduce3< + fn __reduce3< 'input, >( input: &'input str, @@ -20736,13 +20761,13 @@ mod __parse__Module { ) -> (usize, usize) { // ( ",")* = => ActionFn(72); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action72::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 2) } - pub(crate) fn __reduce4< + fn __reduce4< 'input, >( input: &'input str, @@ -20759,7 +20784,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } - pub(crate) fn __reduce5< + fn __reduce5< 'input, >( input: &'input str, @@ -20778,7 +20803,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } - pub(crate) fn __reduce6< + fn __reduce6< 'input, >( input: &'input str, @@ -20798,7 +20823,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (3, 3) } - pub(crate) fn __reduce7< + fn __reduce7< 'input, >( input: &'input str, @@ -20817,7 +20842,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } - pub(crate) fn __reduce8< + fn __reduce8< 'input, >( input: &'input str, @@ -20827,13 +20852,13 @@ mod __parse__Module { ) -> (usize, usize) { // ( ",")* = => ActionFn(75); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action75::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } - pub(crate) fn __reduce9< + fn __reduce9< 'input, >( input: &'input str, @@ -20850,7 +20875,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } - pub(crate) fn __reduce10< + fn __reduce10< 'input, >( input: &'input str, @@ -20869,7 +20894,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (2, 6) } - pub(crate) fn __reduce11< + fn __reduce11< 'input, >( input: &'input str, @@ -20889,7 +20914,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (3, 6) } - pub(crate) fn __reduce12< + fn __reduce12< 'input, >( input: &'input str, @@ -20908,7 +20933,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } - pub(crate) fn __reduce13< + fn __reduce13< 'input, >( input: &'input str, @@ -20918,13 +20943,13 @@ mod __parse__Module { ) -> (usize, usize) { // ( ",")* = => ActionFn(63); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action63::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 8) } - pub(crate) fn __reduce14< + fn __reduce14< 'input, >( input: &'input str, @@ -20941,7 +20966,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } - pub(crate) fn __reduce15< + fn __reduce15< 'input, >( input: &'input str, @@ -20960,7 +20985,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 9) } - pub(crate) fn __reduce16< + fn __reduce16< 'input, >( input: &'input str, @@ -20980,7 +21005,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (3, 9) } - pub(crate) fn __reduce17< + fn __reduce17< 'input, >( input: &'input str, @@ -20999,7 +21024,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 10) } - pub(crate) fn __reduce18< + fn __reduce18< 'input, >( input: &'input str, @@ -21016,7 +21041,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 11) } - pub(crate) fn __reduce19< + fn __reduce19< 'input, >( input: &'input str, @@ -21026,13 +21051,13 @@ mod __parse__Module { ) -> (usize, usize) { // Arg? = => ActionFn(71); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action71::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce20< + fn __reduce20< 'input, >( input: &'input str, @@ -21052,7 +21077,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce21< + fn __reduce21< 'input, >( input: &'input str, @@ -21073,7 +21098,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } - pub(crate) fn __reduce22< + fn __reduce22< 'input, >( input: &'input str, @@ -21092,7 +21117,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 12) } - pub(crate) fn __reduce23< + fn __reduce23< 'input, >( input: &'input str, @@ -21112,7 +21137,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce24< + fn __reduce24< 'input, >( input: &'input str, @@ -21122,13 +21147,13 @@ mod __parse__Module { ) -> (usize, usize) { // BasicBlock* = => ActionFn(56); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action56::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (0, 13) } - pub(crate) fn __reduce25< + fn __reduce25< 'input, >( input: &'input str, @@ -21145,7 +21170,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 13) } - pub(crate) fn __reduce26< + fn __reduce26< 'input, >( input: &'input str, @@ -21162,7 +21187,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 14) } - pub(crate) fn __reduce27< + fn __reduce27< 'input, >( input: &'input str, @@ -21181,7 +21206,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 14) } - pub(crate) fn __reduce28< + fn __reduce28< 'input, >( input: &'input str, @@ -21201,7 +21226,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (3, 15) } - pub(crate) fn __reduce29< + fn __reduce29< 'input, >( input: &'input str, @@ -21218,7 +21243,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 16) } - pub(crate) fn __reduce30< + fn __reduce30< 'input, >( input: &'input str, @@ -21228,13 +21253,13 @@ mod __parse__Module { ) -> (usize, usize) { // BasicBlockArgList? = => ActionFn(55); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action55::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (0, 16) } - pub(crate) fn __reduce31< + fn __reduce31< 'input, >( input: &'input str, @@ -21251,7 +21276,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 17) } - pub(crate) fn __reduce32< + fn __reduce32< 'input, >( input: &'input str, @@ -21268,7 +21293,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce33< + fn __reduce33< 'input, >( input: &'input str, @@ -21285,7 +21310,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce34< + fn __reduce34< 'input, >( input: &'input str, @@ -21302,7 +21327,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce35< + fn __reduce35< 'input, >( input: &'input str, @@ -21312,13 +21337,13 @@ mod __parse__Module { ) -> (usize, usize) { // Comma = => ActionFn(99); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action99::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (0, 19) } - pub(crate) fn __reduce36< + fn __reduce36< 'input, >( input: &'input str, @@ -21337,7 +21362,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 19) } - pub(crate) fn __reduce37< + fn __reduce37< 'input, >( input: &'input str, @@ -21354,7 +21379,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce38< + fn __reduce38< 'input, >( input: &'input str, @@ -21371,7 +21396,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce39< + fn __reduce39< 'input, >( input: &'input str, @@ -21381,13 +21406,13 @@ mod __parse__Module { ) -> (usize, usize) { // Comma = => ActionFn(111); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action111::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (0, 20) } - pub(crate) fn __reduce40< + fn __reduce40< 'input, >( input: &'input str, @@ -21406,7 +21431,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 20) } - pub(crate) fn __reduce41< + fn __reduce41< 'input, >( input: &'input str, @@ -21423,7 +21448,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce42< + fn __reduce42< 'input, >( input: &'input str, @@ -21440,7 +21465,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce43< + fn __reduce43< 'input, >( input: &'input str, @@ -21450,13 +21475,13 @@ mod __parse__Module { ) -> (usize, usize) { // Comma = => ActionFn(119); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action119::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 21) } - pub(crate) fn __reduce44< + fn __reduce44< 'input, >( input: &'input str, @@ -21475,7 +21500,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } - pub(crate) fn __reduce45< + fn __reduce45< 'input, >( input: &'input str, @@ -21492,7 +21517,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce46< + fn __reduce46< 'input, >( input: &'input str, @@ -21509,7 +21534,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 22) } - pub(crate) fn __reduce47< + fn __reduce47< 'input, >( input: &'input str, @@ -21534,7 +21559,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (8, 23) } - pub(crate) fn __reduce48< + fn __reduce48< 'input, >( input: &'input str, @@ -21560,7 +21585,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (9, 23) } - pub(crate) fn __reduce49< + fn __reduce49< 'input, >( input: &'input str, @@ -21577,7 +21602,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (1, 24) } - pub(crate) fn __reduce50< + fn __reduce50< 'input, >( input: &'input str, @@ -21596,7 +21621,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (2, 24) } - pub(crate) fn __reduce51< + fn __reduce51< 'input, >( input: &'input str, @@ -21615,7 +21640,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 25) } - pub(crate) fn __reduce52< + fn __reduce52< 'input, >( input: &'input str, @@ -21625,13 +21650,13 @@ mod __parse__Module { ) -> (usize, usize) { // Instruction* = => ActionFn(52); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action52::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (0, 26) } - pub(crate) fn __reduce53< + fn __reduce53< 'input, >( input: &'input str, @@ -21648,7 +21673,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 26) } - pub(crate) fn __reduce54< + fn __reduce54< 'input, >( input: &'input str, @@ -21665,7 +21690,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 27) } - pub(crate) fn __reduce55< + fn __reduce55< 'input, >( input: &'input str, @@ -21684,7 +21709,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 27) } - pub(crate) fn __reduce56< + fn __reduce56< 'input, >( input: &'input str, @@ -21708,7 +21733,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce57< + fn __reduce57< 'input, >( input: &'input str, @@ -21732,7 +21757,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce58< + fn __reduce58< 'input, >( input: &'input str, @@ -21753,7 +21778,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (4, 28) } - pub(crate) fn __reduce59< + fn __reduce59< 'input, >( input: &'input str, @@ -21778,7 +21803,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (8, 28) } - pub(crate) fn __reduce60< + fn __reduce60< 'input, >( input: &'input str, @@ -21800,7 +21825,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (5, 28) } - pub(crate) fn __reduce61< + fn __reduce61< 'input, >( input: &'input str, @@ -21819,7 +21844,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce62< + fn __reduce62< 'input, >( input: &'input str, @@ -21839,7 +21864,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } - pub(crate) fn __reduce63< + fn __reduce63< 'input, >( input: &'input str, @@ -21858,7 +21883,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce64< + fn __reduce64< 'input, >( input: &'input str, @@ -21875,7 +21900,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 29) } - pub(crate) fn __reduce65< + fn __reduce65< 'input, >( input: &'input str, @@ -21892,7 +21917,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 30) } - pub(crate) fn __reduce66< + fn __reduce66< 'input, >( input: &'input str, @@ -21909,7 +21934,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce67< + fn __reduce67< 'input, >( input: &'input str, @@ -21926,7 +21951,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce68< + fn __reduce68< 'input, >( input: &'input str, @@ -21943,7 +21968,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (1, 32) } - pub(crate) fn __reduce69< + fn __reduce69< 'input, >( input: &'input str, @@ -21953,13 +21978,13 @@ mod __parse__Module { ) -> (usize, usize) { // Operand? = => ActionFn(50); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action50::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (0, 32) } - pub(crate) fn __reduce70< + fn __reduce70< 'input, >( input: &'input str, @@ -21976,7 +22001,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (1, 33) } - pub(crate) fn __reduce71< + fn __reduce71< 'input, >( input: &'input str, @@ -21995,7 +22020,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (2, 34) } - pub(crate) fn __reduce72< + fn __reduce72< 'input, >( input: &'input str, @@ -22012,7 +22037,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (1, 34) } - pub(crate) fn __reduce73< + fn __reduce73< 'input, >( input: &'input str, @@ -22031,7 +22056,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (2, 35) } - pub(crate) fn __reduce74< + fn __reduce74< 'input, >( input: &'input str, @@ -22048,7 +22073,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (1, 35) } - pub(crate) fn __reduce75< + fn __reduce75< 'input, >( input: &'input str, @@ -22068,7 +22093,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (3, 36) } - pub(crate) fn __reduce76< + fn __reduce76< 'input, >( input: &'input str, @@ -22085,7 +22110,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (1, 37) } - pub(crate) fn __reduce77< + fn __reduce77< 'input, >( input: &'input str, @@ -22095,13 +22120,13 @@ mod __parse__Module { ) -> (usize, usize) { // TargetArgList? = => ActionFn(48); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action48::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (0, 37) } - pub(crate) fn __reduce78< + fn __reduce78< 'input, >( input: &'input str, @@ -22118,7 +22143,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce79< + fn __reduce79< 'input, >( input: &'input str, @@ -22135,7 +22160,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce80< + fn __reduce80< 'input, >( input: &'input str, @@ -22152,7 +22177,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce81< + fn __reduce81< 'input, >( input: &'input str, @@ -22169,7 +22194,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce82< + fn __reduce82< 'input, >( input: &'input str, @@ -22186,7 +22211,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce83< + fn __reduce83< 'input, >( input: &'input str, @@ -22203,7 +22228,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce84< + fn __reduce84< 'input, >( input: &'input str, @@ -22220,7 +22245,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce85< + fn __reduce85< 'input, >( input: &'input str, @@ -22237,7 +22262,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce86< + fn __reduce86< 'input, >( input: &'input str, @@ -22254,7 +22279,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce87< + fn __reduce87< 'input, >( input: &'input str, @@ -22271,7 +22296,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce88< + fn __reduce88< 'input, >( input: &'input str, @@ -22288,7 +22313,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (1, 39) } - pub(crate) fn __reduce89< + fn __reduce89< 'input, >( input: &'input str, @@ -22298,13 +22323,13 @@ mod __parse__Module { ) -> (usize, usize) { // Type? = => ActionFn(62); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action62::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (0, 39) } - pub(crate) fn __reduce90< + fn __reduce90< 'input, >( input: &'input str, @@ -22321,7 +22346,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce91< + fn __reduce91< 'input, >( input: &'input str, @@ -22338,7 +22363,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce92< + fn __reduce92< 'input, >( input: &'input str, @@ -22355,7 +22380,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 41) } - pub(crate) fn __reduce93< + fn __reduce93< 'input, >( input: &'input str, @@ -22372,7 +22397,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 42) } - pub(crate) fn __reduce94< + fn __reduce94< 'input, >( input: &'input str, @@ -22389,7 +22414,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (1, 43) } - pub(crate) fn __reduce95< + fn __reduce95< 'input, >( input: &'input str, @@ -22406,7 +22431,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 44) } - pub(crate) fn __reduce96< + fn __reduce96< 'input, >( input: &'input str, @@ -22423,7 +22448,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 45) } - pub(crate) fn __reduce98< + fn __reduce98< 'input, >( input: &'input str, @@ -22440,7 +22465,7 @@ mod __parse__Module { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 47) } - pub(crate) fn __reduce99< + fn __reduce99< 'input, >( input: &'input str, @@ -22458,10 +22483,11 @@ mod __parse__Module { (1, 48) } } +#[allow(unused_imports)] pub use self::__parse__Module::ModuleParser; #[rustfmt::skip] -#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] +#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)] mod __parse__Operand { use std::str::FromStr; @@ -22632,7 +22658,7 @@ mod __parse__Operand { } }).collect() } - pub(crate) struct __StateMachine<'input> + struct __StateMachine<'input> where { input: &'input str, @@ -22785,7 +22811,7 @@ mod __parse__Operand { _: core::marker::PhantomData<(&'input ())>, ) -> __Symbol<'input> { - match __token_index { + #[allow(clippy::manual_range_patterns)]match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), @@ -23404,6 +23430,7 @@ mod __parse__Operand { _priv: (), } + impl Default for OperandParser { fn default() -> Self { Self::new() } } impl OperandParser { pub fn new() -> OperandParser { let __builder = super::__intern_token::new_builder(); @@ -23464,7 +23491,7 @@ mod __parse__Operand { __states.push(__next_state); } } - pub(crate) fn __reduce< + fn __reduce< 'input, >( input: &'input str, @@ -24135,7 +24162,7 @@ mod __parse__Operand { _ => __symbol_type_mismatch() } } - pub(crate) fn __reduce0< + fn __reduce0< 'input, >( input: &'input str, @@ -24152,7 +24179,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } - pub(crate) fn __reduce1< + fn __reduce1< 'input, >( input: &'input str, @@ -24162,13 +24189,13 @@ mod __parse__Operand { ) -> (usize, usize) { // "-"? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action45::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (0, 0) } - pub(crate) fn __reduce2< + fn __reduce2< 'input, >( input: &'input str, @@ -24187,7 +24214,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } - pub(crate) fn __reduce3< + fn __reduce3< 'input, >( input: &'input str, @@ -24197,13 +24224,13 @@ mod __parse__Operand { ) -> (usize, usize) { // ( ",")* = => ActionFn(72); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action72::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 2) } - pub(crate) fn __reduce4< + fn __reduce4< 'input, >( input: &'input str, @@ -24220,7 +24247,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } - pub(crate) fn __reduce5< + fn __reduce5< 'input, >( input: &'input str, @@ -24239,7 +24266,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } - pub(crate) fn __reduce6< + fn __reduce6< 'input, >( input: &'input str, @@ -24259,7 +24286,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (3, 3) } - pub(crate) fn __reduce7< + fn __reduce7< 'input, >( input: &'input str, @@ -24278,7 +24305,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } - pub(crate) fn __reduce8< + fn __reduce8< 'input, >( input: &'input str, @@ -24288,13 +24315,13 @@ mod __parse__Operand { ) -> (usize, usize) { // ( ",")* = => ActionFn(75); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action75::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } - pub(crate) fn __reduce9< + fn __reduce9< 'input, >( input: &'input str, @@ -24311,7 +24338,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } - pub(crate) fn __reduce10< + fn __reduce10< 'input, >( input: &'input str, @@ -24330,7 +24357,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (2, 6) } - pub(crate) fn __reduce11< + fn __reduce11< 'input, >( input: &'input str, @@ -24350,7 +24377,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (3, 6) } - pub(crate) fn __reduce12< + fn __reduce12< 'input, >( input: &'input str, @@ -24369,7 +24396,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } - pub(crate) fn __reduce13< + fn __reduce13< 'input, >( input: &'input str, @@ -24379,13 +24406,13 @@ mod __parse__Operand { ) -> (usize, usize) { // ( ",")* = => ActionFn(63); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action63::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 8) } - pub(crate) fn __reduce14< + fn __reduce14< 'input, >( input: &'input str, @@ -24402,7 +24429,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } - pub(crate) fn __reduce15< + fn __reduce15< 'input, >( input: &'input str, @@ -24421,7 +24448,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 9) } - pub(crate) fn __reduce16< + fn __reduce16< 'input, >( input: &'input str, @@ -24441,7 +24468,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (3, 9) } - pub(crate) fn __reduce17< + fn __reduce17< 'input, >( input: &'input str, @@ -24460,7 +24487,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 10) } - pub(crate) fn __reduce18< + fn __reduce18< 'input, >( input: &'input str, @@ -24477,7 +24504,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 11) } - pub(crate) fn __reduce19< + fn __reduce19< 'input, >( input: &'input str, @@ -24487,13 +24514,13 @@ mod __parse__Operand { ) -> (usize, usize) { // Arg? = => ActionFn(71); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action71::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce20< + fn __reduce20< 'input, >( input: &'input str, @@ -24513,7 +24540,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce21< + fn __reduce21< 'input, >( input: &'input str, @@ -24534,7 +24561,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } - pub(crate) fn __reduce22< + fn __reduce22< 'input, >( input: &'input str, @@ -24553,7 +24580,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 12) } - pub(crate) fn __reduce23< + fn __reduce23< 'input, >( input: &'input str, @@ -24573,7 +24600,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce24< + fn __reduce24< 'input, >( input: &'input str, @@ -24583,13 +24610,13 @@ mod __parse__Operand { ) -> (usize, usize) { // BasicBlock* = => ActionFn(56); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action56::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (0, 13) } - pub(crate) fn __reduce25< + fn __reduce25< 'input, >( input: &'input str, @@ -24606,7 +24633,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 13) } - pub(crate) fn __reduce26< + fn __reduce26< 'input, >( input: &'input str, @@ -24623,7 +24650,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 14) } - pub(crate) fn __reduce27< + fn __reduce27< 'input, >( input: &'input str, @@ -24642,7 +24669,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 14) } - pub(crate) fn __reduce28< + fn __reduce28< 'input, >( input: &'input str, @@ -24662,7 +24689,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (3, 15) } - pub(crate) fn __reduce29< + fn __reduce29< 'input, >( input: &'input str, @@ -24679,7 +24706,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 16) } - pub(crate) fn __reduce30< + fn __reduce30< 'input, >( input: &'input str, @@ -24689,13 +24716,13 @@ mod __parse__Operand { ) -> (usize, usize) { // BasicBlockArgList? = => ActionFn(55); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action55::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (0, 16) } - pub(crate) fn __reduce31< + fn __reduce31< 'input, >( input: &'input str, @@ -24712,7 +24739,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 17) } - pub(crate) fn __reduce32< + fn __reduce32< 'input, >( input: &'input str, @@ -24729,7 +24756,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce33< + fn __reduce33< 'input, >( input: &'input str, @@ -24746,7 +24773,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce34< + fn __reduce34< 'input, >( input: &'input str, @@ -24763,7 +24790,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce35< + fn __reduce35< 'input, >( input: &'input str, @@ -24773,13 +24800,13 @@ mod __parse__Operand { ) -> (usize, usize) { // Comma = => ActionFn(99); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action99::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (0, 19) } - pub(crate) fn __reduce36< + fn __reduce36< 'input, >( input: &'input str, @@ -24798,7 +24825,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 19) } - pub(crate) fn __reduce37< + fn __reduce37< 'input, >( input: &'input str, @@ -24815,7 +24842,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce38< + fn __reduce38< 'input, >( input: &'input str, @@ -24832,7 +24859,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce39< + fn __reduce39< 'input, >( input: &'input str, @@ -24842,13 +24869,13 @@ mod __parse__Operand { ) -> (usize, usize) { // Comma = => ActionFn(111); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action111::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (0, 20) } - pub(crate) fn __reduce40< + fn __reduce40< 'input, >( input: &'input str, @@ -24867,7 +24894,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 20) } - pub(crate) fn __reduce41< + fn __reduce41< 'input, >( input: &'input str, @@ -24884,7 +24911,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce42< + fn __reduce42< 'input, >( input: &'input str, @@ -24901,7 +24928,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce43< + fn __reduce43< 'input, >( input: &'input str, @@ -24911,13 +24938,13 @@ mod __parse__Operand { ) -> (usize, usize) { // Comma = => ActionFn(119); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action119::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 21) } - pub(crate) fn __reduce44< + fn __reduce44< 'input, >( input: &'input str, @@ -24936,7 +24963,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } - pub(crate) fn __reduce45< + fn __reduce45< 'input, >( input: &'input str, @@ -24953,7 +24980,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce46< + fn __reduce46< 'input, >( input: &'input str, @@ -24970,7 +24997,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 22) } - pub(crate) fn __reduce47< + fn __reduce47< 'input, >( input: &'input str, @@ -24995,7 +25022,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (8, 23) } - pub(crate) fn __reduce48< + fn __reduce48< 'input, >( input: &'input str, @@ -25021,7 +25048,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (9, 23) } - pub(crate) fn __reduce49< + fn __reduce49< 'input, >( input: &'input str, @@ -25038,7 +25065,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (1, 24) } - pub(crate) fn __reduce50< + fn __reduce50< 'input, >( input: &'input str, @@ -25057,7 +25084,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (2, 24) } - pub(crate) fn __reduce51< + fn __reduce51< 'input, >( input: &'input str, @@ -25076,7 +25103,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 25) } - pub(crate) fn __reduce52< + fn __reduce52< 'input, >( input: &'input str, @@ -25086,13 +25113,13 @@ mod __parse__Operand { ) -> (usize, usize) { // Instruction* = => ActionFn(52); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action52::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (0, 26) } - pub(crate) fn __reduce53< + fn __reduce53< 'input, >( input: &'input str, @@ -25109,7 +25136,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 26) } - pub(crate) fn __reduce54< + fn __reduce54< 'input, >( input: &'input str, @@ -25126,7 +25153,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 27) } - pub(crate) fn __reduce55< + fn __reduce55< 'input, >( input: &'input str, @@ -25145,7 +25172,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 27) } - pub(crate) fn __reduce56< + fn __reduce56< 'input, >( input: &'input str, @@ -25169,7 +25196,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce57< + fn __reduce57< 'input, >( input: &'input str, @@ -25193,7 +25220,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce58< + fn __reduce58< 'input, >( input: &'input str, @@ -25214,7 +25241,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (4, 28) } - pub(crate) fn __reduce59< + fn __reduce59< 'input, >( input: &'input str, @@ -25239,7 +25266,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (8, 28) } - pub(crate) fn __reduce60< + fn __reduce60< 'input, >( input: &'input str, @@ -25261,7 +25288,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (5, 28) } - pub(crate) fn __reduce61< + fn __reduce61< 'input, >( input: &'input str, @@ -25280,7 +25307,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce62< + fn __reduce62< 'input, >( input: &'input str, @@ -25300,7 +25327,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } - pub(crate) fn __reduce63< + fn __reduce63< 'input, >( input: &'input str, @@ -25319,7 +25346,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce64< + fn __reduce64< 'input, >( input: &'input str, @@ -25336,7 +25363,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 29) } - pub(crate) fn __reduce65< + fn __reduce65< 'input, >( input: &'input str, @@ -25353,7 +25380,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 30) } - pub(crate) fn __reduce66< + fn __reduce66< 'input, >( input: &'input str, @@ -25370,7 +25397,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce67< + fn __reduce67< 'input, >( input: &'input str, @@ -25387,7 +25414,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce68< + fn __reduce68< 'input, >( input: &'input str, @@ -25404,7 +25431,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (1, 32) } - pub(crate) fn __reduce69< + fn __reduce69< 'input, >( input: &'input str, @@ -25414,13 +25441,13 @@ mod __parse__Operand { ) -> (usize, usize) { // Operand? = => ActionFn(50); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action50::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (0, 32) } - pub(crate) fn __reduce70< + fn __reduce70< 'input, >( input: &'input str, @@ -25437,7 +25464,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (1, 33) } - pub(crate) fn __reduce71< + fn __reduce71< 'input, >( input: &'input str, @@ -25456,7 +25483,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (2, 34) } - pub(crate) fn __reduce72< + fn __reduce72< 'input, >( input: &'input str, @@ -25473,7 +25500,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (1, 34) } - pub(crate) fn __reduce73< + fn __reduce73< 'input, >( input: &'input str, @@ -25492,7 +25519,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (2, 35) } - pub(crate) fn __reduce74< + fn __reduce74< 'input, >( input: &'input str, @@ -25509,7 +25536,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (1, 35) } - pub(crate) fn __reduce75< + fn __reduce75< 'input, >( input: &'input str, @@ -25529,7 +25556,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (3, 36) } - pub(crate) fn __reduce76< + fn __reduce76< 'input, >( input: &'input str, @@ -25546,7 +25573,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (1, 37) } - pub(crate) fn __reduce77< + fn __reduce77< 'input, >( input: &'input str, @@ -25556,13 +25583,13 @@ mod __parse__Operand { ) -> (usize, usize) { // TargetArgList? = => ActionFn(48); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action48::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (0, 37) } - pub(crate) fn __reduce78< + fn __reduce78< 'input, >( input: &'input str, @@ -25579,7 +25606,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce79< + fn __reduce79< 'input, >( input: &'input str, @@ -25596,7 +25623,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce80< + fn __reduce80< 'input, >( input: &'input str, @@ -25613,7 +25640,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce81< + fn __reduce81< 'input, >( input: &'input str, @@ -25630,7 +25657,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce82< + fn __reduce82< 'input, >( input: &'input str, @@ -25647,7 +25674,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce83< + fn __reduce83< 'input, >( input: &'input str, @@ -25664,7 +25691,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce84< + fn __reduce84< 'input, >( input: &'input str, @@ -25681,7 +25708,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce85< + fn __reduce85< 'input, >( input: &'input str, @@ -25698,7 +25725,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce86< + fn __reduce86< 'input, >( input: &'input str, @@ -25715,7 +25742,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce87< + fn __reduce87< 'input, >( input: &'input str, @@ -25732,7 +25759,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce88< + fn __reduce88< 'input, >( input: &'input str, @@ -25749,7 +25776,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (1, 39) } - pub(crate) fn __reduce89< + fn __reduce89< 'input, >( input: &'input str, @@ -25759,13 +25786,13 @@ mod __parse__Operand { ) -> (usize, usize) { // Type? = => ActionFn(62); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action62::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (0, 39) } - pub(crate) fn __reduce90< + fn __reduce90< 'input, >( input: &'input str, @@ -25782,7 +25809,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce91< + fn __reduce91< 'input, >( input: &'input str, @@ -25799,7 +25826,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce92< + fn __reduce92< 'input, >( input: &'input str, @@ -25816,7 +25843,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 41) } - pub(crate) fn __reduce93< + fn __reduce93< 'input, >( input: &'input str, @@ -25833,7 +25860,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 42) } - pub(crate) fn __reduce94< + fn __reduce94< 'input, >( input: &'input str, @@ -25850,7 +25877,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (1, 43) } - pub(crate) fn __reduce95< + fn __reduce95< 'input, >( input: &'input str, @@ -25867,7 +25894,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 44) } - pub(crate) fn __reduce96< + fn __reduce96< 'input, >( input: &'input str, @@ -25884,7 +25911,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 45) } - pub(crate) fn __reduce97< + fn __reduce97< 'input, >( input: &'input str, @@ -25901,7 +25928,7 @@ mod __parse__Operand { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 46) } - pub(crate) fn __reduce99< + fn __reduce99< 'input, >( input: &'input str, @@ -25919,10 +25946,11 @@ mod __parse__Operand { (1, 48) } } +#[allow(unused_imports)] pub use self::__parse__Operand::OperandParser; #[rustfmt::skip] -#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] +#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)] mod __parse__Target { use std::str::FromStr; @@ -26145,7 +26173,7 @@ mod __parse__Target { } }).collect() } - pub(crate) struct __StateMachine<'input> + struct __StateMachine<'input> where { input: &'input str, @@ -26298,7 +26326,7 @@ mod __parse__Target { _: core::marker::PhantomData<(&'input ())>, ) -> __Symbol<'input> { - match __token_index { + #[allow(clippy::manual_range_patterns)]match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), @@ -26917,6 +26945,7 @@ mod __parse__Target { _priv: (), } + impl Default for TargetParser { fn default() -> Self { Self::new() } } impl TargetParser { pub fn new() -> TargetParser { let __builder = super::__intern_token::new_builder(); @@ -26977,7 +27006,7 @@ mod __parse__Target { __states.push(__next_state); } } - pub(crate) fn __reduce< + fn __reduce< 'input, >( input: &'input str, @@ -27648,7 +27677,7 @@ mod __parse__Target { _ => __symbol_type_mismatch() } } - pub(crate) fn __reduce0< + fn __reduce0< 'input, >( input: &'input str, @@ -27665,7 +27694,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } - pub(crate) fn __reduce1< + fn __reduce1< 'input, >( input: &'input str, @@ -27675,13 +27704,13 @@ mod __parse__Target { ) -> (usize, usize) { // "-"? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action45::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (0, 0) } - pub(crate) fn __reduce2< + fn __reduce2< 'input, >( input: &'input str, @@ -27700,7 +27729,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } - pub(crate) fn __reduce3< + fn __reduce3< 'input, >( input: &'input str, @@ -27710,13 +27739,13 @@ mod __parse__Target { ) -> (usize, usize) { // ( ",")* = => ActionFn(72); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action72::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (0, 2) } - pub(crate) fn __reduce4< + fn __reduce4< 'input, >( input: &'input str, @@ -27733,7 +27762,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 2) } - pub(crate) fn __reduce5< + fn __reduce5< 'input, >( input: &'input str, @@ -27752,7 +27781,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } - pub(crate) fn __reduce6< + fn __reduce6< 'input, >( input: &'input str, @@ -27772,7 +27801,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (3, 3) } - pub(crate) fn __reduce7< + fn __reduce7< 'input, >( input: &'input str, @@ -27791,7 +27820,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } - pub(crate) fn __reduce8< + fn __reduce8< 'input, >( input: &'input str, @@ -27801,13 +27830,13 @@ mod __parse__Target { ) -> (usize, usize) { // ( ",")* = => ActionFn(75); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action75::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } - pub(crate) fn __reduce9< + fn __reduce9< 'input, >( input: &'input str, @@ -27824,7 +27853,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } - pub(crate) fn __reduce10< + fn __reduce10< 'input, >( input: &'input str, @@ -27843,7 +27872,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (2, 6) } - pub(crate) fn __reduce11< + fn __reduce11< 'input, >( input: &'input str, @@ -27863,7 +27892,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (3, 6) } - pub(crate) fn __reduce12< + fn __reduce12< 'input, >( input: &'input str, @@ -27882,7 +27911,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } - pub(crate) fn __reduce13< + fn __reduce13< 'input, >( input: &'input str, @@ -27892,13 +27921,13 @@ mod __parse__Target { ) -> (usize, usize) { // ( ",")* = => ActionFn(63); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action63::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 8) } - pub(crate) fn __reduce14< + fn __reduce14< 'input, >( input: &'input str, @@ -27915,7 +27944,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } - pub(crate) fn __reduce15< + fn __reduce15< 'input, >( input: &'input str, @@ -27934,7 +27963,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 9) } - pub(crate) fn __reduce16< + fn __reduce16< 'input, >( input: &'input str, @@ -27954,7 +27983,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (3, 9) } - pub(crate) fn __reduce17< + fn __reduce17< 'input, >( input: &'input str, @@ -27973,7 +28002,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 10) } - pub(crate) fn __reduce18< + fn __reduce18< 'input, >( input: &'input str, @@ -27990,7 +28019,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 11) } - pub(crate) fn __reduce19< + fn __reduce19< 'input, >( input: &'input str, @@ -28000,13 +28029,13 @@ mod __parse__Target { ) -> (usize, usize) { // Arg? = => ActionFn(71); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action71::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 11) } - pub(crate) fn __reduce20< + fn __reduce20< 'input, >( input: &'input str, @@ -28026,7 +28055,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce21< + fn __reduce21< 'input, >( input: &'input str, @@ -28047,7 +28076,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } - pub(crate) fn __reduce22< + fn __reduce22< 'input, >( input: &'input str, @@ -28066,7 +28095,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 12) } - pub(crate) fn __reduce23< + fn __reduce23< 'input, >( input: &'input str, @@ -28086,7 +28115,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } - pub(crate) fn __reduce24< + fn __reduce24< 'input, >( input: &'input str, @@ -28096,13 +28125,13 @@ mod __parse__Target { ) -> (usize, usize) { // BasicBlock* = => ActionFn(56); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action56::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (0, 13) } - pub(crate) fn __reduce25< + fn __reduce25< 'input, >( input: &'input str, @@ -28119,7 +28148,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 13) } - pub(crate) fn __reduce26< + fn __reduce26< 'input, >( input: &'input str, @@ -28136,7 +28165,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 14) } - pub(crate) fn __reduce27< + fn __reduce27< 'input, >( input: &'input str, @@ -28155,7 +28184,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 14) } - pub(crate) fn __reduce28< + fn __reduce28< 'input, >( input: &'input str, @@ -28175,7 +28204,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (3, 15) } - pub(crate) fn __reduce29< + fn __reduce29< 'input, >( input: &'input str, @@ -28192,7 +28221,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 16) } - pub(crate) fn __reduce30< + fn __reduce30< 'input, >( input: &'input str, @@ -28202,13 +28231,13 @@ mod __parse__Target { ) -> (usize, usize) { // BasicBlockArgList? = => ActionFn(55); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action55::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (0, 16) } - pub(crate) fn __reduce31< + fn __reduce31< 'input, >( input: &'input str, @@ -28225,7 +28254,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 17) } - pub(crate) fn __reduce32< + fn __reduce32< 'input, >( input: &'input str, @@ -28242,7 +28271,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce33< + fn __reduce33< 'input, >( input: &'input str, @@ -28259,7 +28288,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 18) } - pub(crate) fn __reduce34< + fn __reduce34< 'input, >( input: &'input str, @@ -28276,7 +28305,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce35< + fn __reduce35< 'input, >( input: &'input str, @@ -28286,13 +28315,13 @@ mod __parse__Target { ) -> (usize, usize) { // Comma = => ActionFn(99); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action99::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (0, 19) } - pub(crate) fn __reduce36< + fn __reduce36< 'input, >( input: &'input str, @@ -28311,7 +28340,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 19) } - pub(crate) fn __reduce37< + fn __reduce37< 'input, >( input: &'input str, @@ -28328,7 +28357,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } - pub(crate) fn __reduce38< + fn __reduce38< 'input, >( input: &'input str, @@ -28345,7 +28374,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce39< + fn __reduce39< 'input, >( input: &'input str, @@ -28355,13 +28384,13 @@ mod __parse__Target { ) -> (usize, usize) { // Comma = => ActionFn(111); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action111::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (0, 20) } - pub(crate) fn __reduce40< + fn __reduce40< 'input, >( input: &'input str, @@ -28380,7 +28409,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 20) } - pub(crate) fn __reduce41< + fn __reduce41< 'input, >( input: &'input str, @@ -28397,7 +28426,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 20) } - pub(crate) fn __reduce42< + fn __reduce42< 'input, >( input: &'input str, @@ -28414,7 +28443,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce43< + fn __reduce43< 'input, >( input: &'input str, @@ -28424,13 +28453,13 @@ mod __parse__Target { ) -> (usize, usize) { // Comma = => ActionFn(119); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action119::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 21) } - pub(crate) fn __reduce44< + fn __reduce44< 'input, >( input: &'input str, @@ -28449,7 +28478,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } - pub(crate) fn __reduce45< + fn __reduce45< 'input, >( input: &'input str, @@ -28466,7 +28495,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 21) } - pub(crate) fn __reduce46< + fn __reduce46< 'input, >( input: &'input str, @@ -28483,7 +28512,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 22) } - pub(crate) fn __reduce47< + fn __reduce47< 'input, >( input: &'input str, @@ -28508,7 +28537,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (8, 23) } - pub(crate) fn __reduce48< + fn __reduce48< 'input, >( input: &'input str, @@ -28534,7 +28563,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (9, 23) } - pub(crate) fn __reduce49< + fn __reduce49< 'input, >( input: &'input str, @@ -28551,7 +28580,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (1, 24) } - pub(crate) fn __reduce50< + fn __reduce50< 'input, >( input: &'input str, @@ -28570,7 +28599,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant19(__nt), __end)); (2, 24) } - pub(crate) fn __reduce51< + fn __reduce51< 'input, >( input: &'input str, @@ -28589,7 +28618,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 25) } - pub(crate) fn __reduce52< + fn __reduce52< 'input, >( input: &'input str, @@ -28599,13 +28628,13 @@ mod __parse__Target { ) -> (usize, usize) { // Instruction* = => ActionFn(52); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action52::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (0, 26) } - pub(crate) fn __reduce53< + fn __reduce53< 'input, >( input: &'input str, @@ -28622,7 +28651,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 26) } - pub(crate) fn __reduce54< + fn __reduce54< 'input, >( input: &'input str, @@ -28639,7 +28668,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 27) } - pub(crate) fn __reduce55< + fn __reduce55< 'input, >( input: &'input str, @@ -28658,7 +28687,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 27) } - pub(crate) fn __reduce56< + fn __reduce56< 'input, >( input: &'input str, @@ -28682,7 +28711,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce57< + fn __reduce57< 'input, >( input: &'input str, @@ -28706,7 +28735,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (7, 28) } - pub(crate) fn __reduce58< + fn __reduce58< 'input, >( input: &'input str, @@ -28727,7 +28756,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (4, 28) } - pub(crate) fn __reduce59< + fn __reduce59< 'input, >( input: &'input str, @@ -28752,7 +28781,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (8, 28) } - pub(crate) fn __reduce60< + fn __reduce60< 'input, >( input: &'input str, @@ -28774,7 +28803,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (5, 28) } - pub(crate) fn __reduce61< + fn __reduce61< 'input, >( input: &'input str, @@ -28793,7 +28822,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce62< + fn __reduce62< 'input, >( input: &'input str, @@ -28813,7 +28842,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } - pub(crate) fn __reduce63< + fn __reduce63< 'input, >( input: &'input str, @@ -28832,7 +28861,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } - pub(crate) fn __reduce64< + fn __reduce64< 'input, >( input: &'input str, @@ -28849,7 +28878,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 29) } - pub(crate) fn __reduce65< + fn __reduce65< 'input, >( input: &'input str, @@ -28866,7 +28895,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 30) } - pub(crate) fn __reduce66< + fn __reduce66< 'input, >( input: &'input str, @@ -28883,7 +28912,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce67< + fn __reduce67< 'input, >( input: &'input str, @@ -28900,7 +28929,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 31) } - pub(crate) fn __reduce68< + fn __reduce68< 'input, >( input: &'input str, @@ -28917,7 +28946,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (1, 32) } - pub(crate) fn __reduce69< + fn __reduce69< 'input, >( input: &'input str, @@ -28927,13 +28956,13 @@ mod __parse__Target { ) -> (usize, usize) { // Operand? = => ActionFn(50); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action50::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (0, 32) } - pub(crate) fn __reduce70< + fn __reduce70< 'input, >( input: &'input str, @@ -28950,7 +28979,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (1, 33) } - pub(crate) fn __reduce71< + fn __reduce71< 'input, >( input: &'input str, @@ -28969,7 +28998,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (2, 34) } - pub(crate) fn __reduce72< + fn __reduce72< 'input, >( input: &'input str, @@ -28986,7 +29015,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant26(__nt), __end)); (1, 34) } - pub(crate) fn __reduce73< + fn __reduce73< 'input, >( input: &'input str, @@ -29005,7 +29034,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (2, 35) } - pub(crate) fn __reduce74< + fn __reduce74< 'input, >( input: &'input str, @@ -29022,7 +29051,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (1, 35) } - pub(crate) fn __reduce75< + fn __reduce75< 'input, >( input: &'input str, @@ -29042,7 +29071,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (3, 36) } - pub(crate) fn __reduce76< + fn __reduce76< 'input, >( input: &'input str, @@ -29059,7 +29088,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (1, 37) } - pub(crate) fn __reduce77< + fn __reduce77< 'input, >( input: &'input str, @@ -29069,13 +29098,13 @@ mod __parse__Target { ) -> (usize, usize) { // TargetArgList? = => ActionFn(48); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action48::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant28(__nt), __end)); (0, 37) } - pub(crate) fn __reduce78< + fn __reduce78< 'input, >( input: &'input str, @@ -29092,7 +29121,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce79< + fn __reduce79< 'input, >( input: &'input str, @@ -29109,7 +29138,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce80< + fn __reduce80< 'input, >( input: &'input str, @@ -29126,7 +29155,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce81< + fn __reduce81< 'input, >( input: &'input str, @@ -29143,7 +29172,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce82< + fn __reduce82< 'input, >( input: &'input str, @@ -29160,7 +29189,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce83< + fn __reduce83< 'input, >( input: &'input str, @@ -29177,7 +29206,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce84< + fn __reduce84< 'input, >( input: &'input str, @@ -29194,7 +29223,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce85< + fn __reduce85< 'input, >( input: &'input str, @@ -29211,7 +29240,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce86< + fn __reduce86< 'input, >( input: &'input str, @@ -29228,7 +29257,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce87< + fn __reduce87< 'input, >( input: &'input str, @@ -29245,7 +29274,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 38) } - pub(crate) fn __reduce88< + fn __reduce88< 'input, >( input: &'input str, @@ -29262,7 +29291,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (1, 39) } - pub(crate) fn __reduce89< + fn __reduce89< 'input, >( input: &'input str, @@ -29272,13 +29301,13 @@ mod __parse__Target { ) -> (usize, usize) { // Type? = => ActionFn(62); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); + let __end = __start; let __nt = super::__action62::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (0, 39) } - pub(crate) fn __reduce90< + fn __reduce90< 'input, >( input: &'input str, @@ -29295,7 +29324,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce91< + fn __reduce91< 'input, >( input: &'input str, @@ -29312,7 +29341,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 40) } - pub(crate) fn __reduce92< + fn __reduce92< 'input, >( input: &'input str, @@ -29329,7 +29358,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 41) } - pub(crate) fn __reduce93< + fn __reduce93< 'input, >( input: &'input str, @@ -29346,7 +29375,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 42) } - pub(crate) fn __reduce94< + fn __reduce94< 'input, >( input: &'input str, @@ -29363,7 +29392,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (1, 43) } - pub(crate) fn __reduce95< + fn __reduce95< 'input, >( input: &'input str, @@ -29380,7 +29409,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 44) } - pub(crate) fn __reduce96< + fn __reduce96< 'input, >( input: &'input str, @@ -29397,7 +29426,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (1, 45) } - pub(crate) fn __reduce97< + fn __reduce97< 'input, >( input: &'input str, @@ -29414,7 +29443,7 @@ mod __parse__Target { __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (1, 46) } - pub(crate) fn __reduce98< + fn __reduce98< 'input, >( input: &'input str, @@ -29432,8 +29461,9 @@ mod __parse__Target { (1, 47) } } +#[allow(unused_imports)] pub use self::__parse__Target::TargetParser; -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] mod __intern_token { #![allow(unused_imports)] use std::str::FromStr; @@ -29446,40 +29476,40 @@ mod __intern_token { extern crate alloc; pub fn new_builder() -> __lalrpop_util::lexer::MatcherBuilder { let __strs: &[(&str, bool)] = &[ - ("^((?:@[A-Z_a-z][0-9A-Z_a-z]*))", false), - ("^((?:[1-9][0-9]*))", false), - ("^((?:(?:bb)((?:0|((?:[1-9][0-9]*))))))", false), - ("^((?:v((?:0|((?:[1-9][0-9]*))))))", false), - ("^(\\()", false), - ("^(\\))", false), - ("^(,)", false), - ("^(\\-)", false), - ("^(0)", false), - ("^(:)", false), - ("^(;)", false), - ("^(=)", false), - ("^((?:add))", false), - ("^((?:bool))", false), - ("^((?:br))", false), - ("^((?:condbr))", false), - ("^((?:eq))", false), - ("^((?:fun))", false), - ("^((?:gt))", false), - ("^((?:i16))", false), - ("^((?:i32))", false), - ("^((?:i64))", false), - ("^((?:i8))", false), - ("^((?:icmp))", false), - ("^((?:ret))", false), - ("^((?:sub))", false), - ("^((?:u16))", false), - ("^((?:u32))", false), - ("^((?:u64))", false), - ("^((?:u8))", false), - ("^((?:void))", false), - ("^(\\{)", false), - ("^(\\})", false), - (r"^(\s*)", true), + ("(?:@[A-Z_a-z][0-9A-Z_a-z]*)", false), + ("(?:[1-9][0-9]*)", false), + ("(?:(?:bb)((?:0|((?:[1-9][0-9]*)))))", false), + ("(?:v((?:0|((?:[1-9][0-9]*)))))", false), + ("\\(", false), + ("\\)", false), + (",", false), + ("\\-", false), + ("0", false), + (":", false), + (";", false), + ("=", false), + ("(?:add)", false), + ("(?:bool)", false), + ("(?:br)", false), + ("(?:condbr)", false), + ("(?:eq)", false), + ("(?:fun)", false), + ("(?:gt)", false), + ("(?:i16)", false), + ("(?:i32)", false), + ("(?:i64)", false), + ("(?:i8)", false), + ("(?:icmp)", false), + ("(?:ret)", false), + ("(?:sub)", false), + ("(?:u16)", false), + ("(?:u32)", false), + ("(?:u64)", false), + ("(?:u8)", false), + ("(?:void)", false), + ("\\{", false), + ("\\}", false), + (r"\s+", true), ]; __lalrpop_util::lexer::MatcherBuilder::new(__strs.iter().copied()).unwrap() } @@ -29487,120 +29517,105 @@ mod __intern_token { pub(crate) use self::__lalrpop_util::lexer::Token; #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action0< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Module, usize), -) -> Module -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action0<'input>(input: &'input str, (_, __0, _): (usize, Module, usize)) -> Module { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Function, usize), -) -> Function -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action1<'input>(input: &'input str, (_, __0, _): (usize, Function, usize)) -> Function { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action2< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, BasicBlock, usize), -) -> BasicBlock -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action2<'input>(input: &'input str, (_, __0, _): (usize, BasicBlock, usize)) -> BasicBlock { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action3< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Instruction, usize), -) -> Instruction -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action3<'input>(input: &'input str, (_, __0, _): (usize, Instruction, usize)) -> Instruction { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action4< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Instruction, usize), -) -> Instruction -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action4<'input>(input: &'input str, (_, __0, _): (usize, Instruction, usize)) -> Instruction { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action5< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, CmpOp, usize), -) -> CmpOp -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action5<'input>(input: &'input str, (_, __0, _): (usize, CmpOp, usize)) -> CmpOp { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action6< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Target, usize), -) -> Target -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action6<'input>(input: &'input str, (_, __0, _): (usize, Target, usize)) -> Target { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action7< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Operand, usize), -) -> Operand -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action7<'input>(input: &'input str, (_, __0, _): (usize, Operand, usize)) -> Operand { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action8< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action8<'input>( input: &'input str, (_, functions, _): (usize, alloc::vec::Vec, usize), -) -> Module -{ - Module { - functions, - } +) -> Module { + Module { functions } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action9< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action9<'input>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, ret_ty, _): (usize, Type, usize), @@ -29611,8 +29626,7 @@ fn __action9< (_, _, _): (usize, &'input str, usize), (_, blocks, _): (usize, alloc::vec::Vec, usize), (_, _, _): (usize, &'input str, usize), -) -> Function -{ +) -> Function { Function { name, ret_ty, @@ -29622,17 +29636,18 @@ fn __action9< } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action10< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action10<'input>( input: &'input str, (_, id, _): (usize, BasicBlockId, usize), (_, args, _): (usize, core::option::Option>, usize), (_, _, _): (usize, &'input str, usize), (_, instructions, _): (usize, alloc::vec::Vec, usize), -) -> BasicBlock -{ +) -> BasicBlock { BasicBlock { args: args.unwrap_or_default(), id, @@ -29641,53 +29656,55 @@ fn __action10< } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action11< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action11<'input>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, args, _): (usize, Vec, usize), (_, _, _): (usize, &'input str, usize), -) -> Vec -{ +) -> Vec { args } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action12< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action12<'input>( input: &'input str, (_, ty, _): (usize, Type, usize), (_, id, _): (usize, RegId, usize), -) -> Arg -{ - Arg { - ty, - id, - } +) -> Arg { + Arg { ty, id } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action13< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action13<'input>( input: &'input str, (_, instr, _): (usize, Instruction, usize), (_, _, _): (usize, &'input str, usize), -) -> Instruction -{ +) -> Instruction { instr } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action14< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action14<'input>( input: &'input str, (_, decl, _): (usize, RegId, usize), (_, _, _): (usize, &'input str, usize), @@ -29696,16 +29713,17 @@ fn __action14< (_, op1, _): (usize, Operand, usize), (_, _, _): (usize, &'input str, usize), (_, op2, _): (usize, Operand, usize), -) -> Instruction -{ +) -> Instruction { Instruction::Add(decl, ty, op1, op2) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action15< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action15<'input>( input: &'input str, (_, decl, _): (usize, RegId, usize), (_, _, _): (usize, &'input str, usize), @@ -29714,31 +29732,33 @@ fn __action15< (_, op1, _): (usize, Operand, usize), (_, _, _): (usize, &'input str, usize), (_, op2, _): (usize, Operand, usize), -) -> Instruction -{ +) -> Instruction { Instruction::Sub(decl, ty, op1, op2) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action16< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action16<'input>( input: &'input str, (_, decl, _): (usize, RegId, usize), (_, _, _): (usize, &'input str, usize), (_, ty, _): (usize, Type, usize), (_, op, _): (usize, Operand, usize), -) -> Instruction -{ +) -> Instruction { Instruction::Op(decl, ty, op) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action17< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action17<'input>( input: &'input str, (_, decl, _): (usize, RegId, usize), (_, _, _): (usize, &'input str, usize), @@ -29748,372 +29768,340 @@ fn __action17< (_, op1, _): (usize, Operand, usize), (_, _, _): (usize, &'input str, usize), (_, op2, _): (usize, Operand, usize), -) -> Instruction -{ +) -> Instruction { Instruction::ICmp(decl, op, ty, op1, op2) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action18< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action18<'input>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, condition, _): (usize, Operand, usize), (_, true_target, _): (usize, Target, usize), (_, _, _): (usize, &'input str, usize), (_, false_target, _): (usize, Target, usize), -) -> Instruction -{ +) -> Instruction { Instruction::Condbr(condition, true_target, false_target) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action19< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action19<'input>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, target, _): (usize, Target, usize), -) -> Instruction -{ +) -> Instruction { Instruction::Br(target) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action20< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action20<'input>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, ty, _): (usize, Type, usize), (_, op, _): (usize, core::option::Option, usize), -) -> Instruction -{ +) -> Instruction { Instruction::Ret(ty, op) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action21< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> CmpOp -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action21<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> CmpOp { CmpOp::Eq } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action22< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> CmpOp -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action22<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> CmpOp { CmpOp::Gt } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action23< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action23<'input>( input: &'input str, (_, id, _): (usize, BasicBlockId, usize), (_, args, _): (usize, core::option::Option>, usize), -) -> Target -{ +) -> Target { Target(id, args) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action24< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action24<'input>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, args, _): (usize, Vec, usize), (_, _, _): (usize, &'input str, usize), -) -> Vec -{ +) -> Vec { args } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action25< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Literal, usize), -) -> Operand -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action25<'input>(input: &'input str, (_, __0, _): (usize, Literal, usize)) -> Operand { Operand::Literal(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action26< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, RegId, usize), -) -> Operand -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action26<'input>(input: &'input str, (_, __0, _): (usize, RegId, usize)) -> Operand { Operand::Register(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action27< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, i64, usize), -) -> Literal -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action27<'input>(input: &'input str, (_, __0, _): (usize, i64, usize)) -> Literal { Literal::Int(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action28< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action28<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::U8 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action29< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action29<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::U16 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action30< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action30<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::U32 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action31< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action31<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::U64 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action32< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action32<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::I8 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action33< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action33<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::I16 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action34< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action34<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::I32 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action35< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action35<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::I64 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action36< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action36<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::Void } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action37< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Type -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action37<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> Type { Type::Bool } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action38< - 'input, ->( - input: &'input str, - (_, id, _): (usize, &'input str, usize), -) -> String -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action38<'input>(input: &'input str, (_, id, _): (usize, &'input str, usize)) -> String { id[1..].to_string() } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action39< - 'input, ->( - input: &'input str, - (_, id, _): (usize, &'input str, usize), -) -> RegId -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action39<'input>(input: &'input str, (_, id, _): (usize, &'input str, usize)) -> RegId { RegId(u32::from_str(&id[1..]).unwrap()) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action40< - 'input, ->( - input: &'input str, - (_, id, _): (usize, &'input str, usize), -) -> BasicBlockId -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action40<'input>(input: &'input str, (_, id, _): (usize, &'input str, usize)) -> BasicBlockId { BasicBlockId(u32::from_str(&id[2..]).unwrap()) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action41< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action41<'input>( input: &'input str, (_, s, _): (usize, core::option::Option<&'input str>, usize), (_, num, _): (usize, u64, usize), -) -> i64 -{ +) -> i64 { match s { - Some(_) => -(num as i64), - None => num as i64 -} + Some(_) => -(num as i64), + None => num as i64, + } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action42< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> u64 -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action42<'input>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> u64 { 0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action43< - 'input, ->( - input: &'input str, - (_, s, _): (usize, &'input str, usize), -) -> u64 -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action43<'input>(input: &'input str, (_, s, _): (usize, &'input str, usize)) -> u64 { u64::from_str(s).unwrap() } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action44< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action44<'input>( input: &'input str, (_, __0, _): (usize, &'input str, usize), -) -> core::option::Option<&'input str> -{ +) -> core::option::Option<&'input str> { Some(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action45< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action45<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> core::option::Option<&'input str> -{ +) -> core::option::Option<&'input str> { None } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action46< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action46<'input>( input: &'input str, (_, mut v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { match e { None => v, Some(e) => { @@ -30124,65 +30112,70 @@ fn __action46< } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action47< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action47<'input>( input: &'input str, (_, __0, _): (usize, Vec, usize), -) -> core::option::Option> -{ +) -> core::option::Option> { Some(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action48< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action48<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> core::option::Option> -{ +) -> core::option::Option> { None } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action49< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action49<'input>( input: &'input str, (_, __0, _): (usize, Operand, usize), -) -> core::option::Option -{ +) -> core::option::Option { Some(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action50< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action50<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> core::option::Option -{ +) -> core::option::Option { None } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action51< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action51<'input>( input: &'input str, (_, mut v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { match e { None => v, Some(e) => { @@ -30193,90 +30186,97 @@ fn __action51< } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action52< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action52<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action53< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action53<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { v } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action54< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action54<'input>( input: &'input str, (_, __0, _): (usize, Vec, usize), -) -> core::option::Option> -{ +) -> core::option::Option> { Some(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action55< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action55<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> core::option::Option> -{ +) -> core::option::Option> { None } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action56< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action56<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action57< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action57<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { v } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action58< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action58<'input>( input: &'input str, (_, mut v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { match e { None => v, Some(e) => { @@ -30287,760 +30287,683 @@ fn __action58< } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action59< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action59<'input>( input: &'input str, (_, __0, _): (usize, Function, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![__0] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action60< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action60<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, Function, usize), -) -> alloc::vec::Vec -{ - { let mut v = v; v.push(e); v } +) -> alloc::vec::Vec { + { + let mut v = v; + v.push(e); + v + } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action61< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action61<'input>( input: &'input str, (_, __0, _): (usize, Type, usize), -) -> core::option::Option -{ +) -> core::option::Option { Some(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action62< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action62<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> core::option::Option -{ +) -> core::option::Option { None } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action63< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action63<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action64< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action64<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { v } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action65< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action65<'input>( input: &'input str, (_, __0, _): (usize, Type, usize), (_, _, _): (usize, &'input str, usize), -) -> Type -{ +) -> Type { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action66< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action66<'input>( input: &'input str, (_, __0, _): (usize, BasicBlock, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![__0] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action67< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action67<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, BasicBlock, usize), -) -> alloc::vec::Vec -{ - { let mut v = v; v.push(e); v } +) -> alloc::vec::Vec { + { + let mut v = v; + v.push(e); + v + } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action68< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action68<'input>( input: &'input str, (_, __0, _): (usize, Instruction, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![__0] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action69< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action69<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, Instruction, usize), -) -> alloc::vec::Vec -{ - { let mut v = v; v.push(e); v } +) -> alloc::vec::Vec { + { + let mut v = v; + v.push(e); + v + } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action70< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action70<'input>( input: &'input str, (_, __0, _): (usize, Arg, usize), -) -> core::option::Option -{ +) -> core::option::Option { Some(__0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action71< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action71<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> core::option::Option -{ +) -> core::option::Option { None } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action72< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action72<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action73< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action73<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { v } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action74< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action74<'input>( input: &'input str, (_, __0, _): (usize, Arg, usize), (_, _, _): (usize, &'input str, usize), -) -> Arg -{ +) -> Arg { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action75< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action75<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action76< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action76<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { v } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action77< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action77<'input>( input: &'input str, (_, __0, _): (usize, Operand, usize), (_, _, _): (usize, &'input str, usize), -) -> Operand -{ +) -> Operand { __0 } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action78< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action78<'input>( input: &'input str, (_, __0, _): (usize, Operand, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![__0] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action79< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action79<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, Operand, usize), -) -> alloc::vec::Vec -{ - { let mut v = v; v.push(e); v } +) -> alloc::vec::Vec { + { + let mut v = v; + v.push(e); + v + } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action80< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action80<'input>( input: &'input str, (_, __0, _): (usize, Arg, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![__0] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action81< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action81<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, Arg, usize), -) -> alloc::vec::Vec -{ - { let mut v = v; v.push(e); v } +) -> alloc::vec::Vec { + { + let mut v = v; + v.push(e); + v + } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action82< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action82<'input>( input: &'input str, (_, __0, _): (usize, Type, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { alloc::vec![__0] } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action83< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action83<'input>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, Type, usize), -) -> alloc::vec::Vec -{ - { let mut v = v; v.push(e); v } +) -> alloc::vec::Vec { + { + let mut v = v; + v.push(e); + v + } } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action84< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action84<'input>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, u64, usize), -) -> i64 -{ +) -> i64 { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action44( - input, - __0, - ); + let __temp0 = __action44(input, __0); let __temp0 = (__start0, __temp0, __end0); - __action41( - input, - __temp0, - __1, - ) + __action41(input, __temp0, __1) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action85< - 'input, ->( - input: &'input str, - __0: (usize, u64, usize), -) -> i64 -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action85<'input>(input: &'input str, __0: (usize, u64, usize)) -> i64 { let __start0 = __0.0; let __end0 = __0.0; - let __temp0 = __action45( - input, - &__start0, - &__end0, - ); + let __temp0 = __action45(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action41( - input, - __temp0, - __0, - ) + __action41(input, __temp0, __0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action86< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action86<'input>( input: &'input str, __0: (usize, Arg, usize), __1: (usize, &'input str, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action74( - input, - __0, - __1, - ); + let __temp0 = __action74(input, __0, __1); let __temp0 = (__start0, __temp0, __end0); - __action80( - input, - __temp0, - ) + __action80(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action87< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action87<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, Arg, usize), __2: (usize, &'input str, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action74( - input, - __1, - __2, - ); + let __temp0 = __action74(input, __1, __2); let __temp0 = (__start0, __temp0, __end0); - __action81( - input, - __0, - __temp0, - ) + __action81(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action88< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action88<'input>( input: &'input str, __0: (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { let __start0 = __0.0; let __end0 = __0.0; - let __temp0 = __action72( - input, - &__start0, - &__end0, - ); + let __temp0 = __action72(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action51( - input, - __temp0, - __0, - ) + __action51(input, __temp0, __0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action89< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action89<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action73( - input, - __0, - ); + let __temp0 = __action73(input, __0); let __temp0 = (__start0, __temp0, __end0); - __action51( - input, - __temp0, - __1, - ) + __action51(input, __temp0, __1) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action90< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action90<'input>( input: &'input str, __0: (usize, Operand, usize), __1: (usize, &'input str, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action77( - input, - __0, - __1, - ); + let __temp0 = __action77(input, __0, __1); let __temp0 = (__start0, __temp0, __end0); - __action78( - input, - __temp0, - ) + __action78(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action91< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action91<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, Operand, usize), __2: (usize, &'input str, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action77( - input, - __1, - __2, - ); + let __temp0 = __action77(input, __1, __2); let __temp0 = (__start0, __temp0, __end0); - __action79( - input, - __0, - __temp0, - ) + __action79(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action92< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action92<'input>( input: &'input str, __0: (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { let __start0 = __0.0; let __end0 = __0.0; - let __temp0 = __action75( - input, - &__start0, - &__end0, - ); + let __temp0 = __action75(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action46( - input, - __temp0, - __0, - ) + __action46(input, __temp0, __0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action93< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action93<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action76( - input, - __0, - ); + let __temp0 = __action76(input, __0); let __temp0 = (__start0, __temp0, __end0); - __action46( - input, - __temp0, - __1, - ) + __action46(input, __temp0, __1) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action94< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action94<'input>( input: &'input str, __0: (usize, Type, usize), __1: (usize, &'input str, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action65( - input, - __0, - __1, - ); + let __temp0 = __action65(input, __0, __1); let __temp0 = (__start0, __temp0, __end0); - __action82( - input, - __temp0, - ) + __action82(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action95< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action95<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, Type, usize), __2: (usize, &'input str, usize), -) -> alloc::vec::Vec -{ +) -> alloc::vec::Vec { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action65( - input, - __1, - __2, - ); + let __temp0 = __action65(input, __1, __2); let __temp0 = (__start0, __temp0, __end0); - __action83( - input, - __0, - __temp0, - ) + __action83(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action96< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action96<'input>( input: &'input str, __0: (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { let __start0 = __0.0; let __end0 = __0.0; - let __temp0 = __action63( - input, - &__start0, - &__end0, - ); + let __temp0 = __action63(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action58( - input, - __temp0, - __0, - ) + __action58(input, __temp0, __0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action97< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action97<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, core::option::Option, usize), -) -> Vec -{ +) -> Vec { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action64( - input, - __0, - ); + let __temp0 = __action64(input, __0); let __temp0 = (__start0, __temp0, __end0); - __action58( - input, - __temp0, - __1, - ) + __action58(input, __temp0, __1) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action98< - 'input, ->( - input: &'input str, - __0: (usize, Arg, usize), -) -> Vec -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action98<'input>(input: &'input str, __0: (usize, Arg, usize)) -> Vec { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action70( - input, - __0, - ); + let __temp0 = __action70(input, __0); let __temp0 = (__start0, __temp0, __end0); - __action88( - input, - __temp0, - ) + __action88(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action99< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> Vec -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action99<'input>(input: &'input str, __lookbehind: &usize, __lookahead: &usize) -> Vec { let __start0 = *__lookbehind; let __end0 = *__lookahead; - let __temp0 = __action71( - input, - &__start0, - &__end0, - ); + let __temp0 = __action71(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action88( - input, - __temp0, - ) + __action88(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action100< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action100<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, Arg, usize), -) -> Vec -{ +) -> Vec { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action70( - input, - __1, - ); + let __temp0 = __action70(input, __1); let __temp0 = (__start0, __temp0, __end0); - __action89( - input, - __0, - __temp0, - ) + __action89(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action101< - 'input, ->( - input: &'input str, - __0: (usize, alloc::vec::Vec, usize), -) -> Vec -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action101<'input>(input: &'input str, __0: (usize, alloc::vec::Vec, usize)) -> Vec { let __start0 = __0.2; let __end0 = __0.2; - let __temp0 = __action71( - input, - &__start0, - &__end0, - ); + let __temp0 = __action71(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action89( - input, - __0, - __temp0, - ) + __action89(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action102< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action102<'input>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, Type, usize), @@ -31050,35 +30973,21 @@ fn __action102< __5: (usize, &'input str, usize), __6: (usize, &'input str, usize), __7: (usize, &'input str, usize), -) -> Function -{ +) -> Function { let __start0 = __6.2; let __end0 = __7.0; - let __temp0 = __action56( - input, - &__start0, - &__end0, - ); + let __temp0 = __action56(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action9( - input, - __0, - __1, - __2, - __3, - __4, - __5, - __6, - __temp0, - __7, - ) + __action9(input, __0, __1, __2, __3, __4, __5, __6, __temp0, __7) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action103< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action103<'input>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, Type, usize), @@ -31089,496 +30998,355 @@ fn __action103< __6: (usize, &'input str, usize), __7: (usize, alloc::vec::Vec, usize), __8: (usize, &'input str, usize), -) -> Function -{ +) -> Function { let __start0 = __7.0; let __end0 = __7.2; - let __temp0 = __action57( - input, - __7, - ); + let __temp0 = __action57(input, __7); let __temp0 = (__start0, __temp0, __end0); - __action9( - input, - __0, - __1, - __2, - __3, - __4, - __5, - __6, - __temp0, - __8, - ) + __action9(input, __0, __1, __2, __3, __4, __5, __6, __temp0, __8) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action104< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action104<'input>( input: &'input str, __0: (usize, BasicBlockId, usize), __1: (usize, Vec, usize), __2: (usize, &'input str, usize), __3: (usize, alloc::vec::Vec, usize), -) -> BasicBlock -{ +) -> BasicBlock { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action54( - input, - __1, - ); + let __temp0 = __action54(input, __1); let __temp0 = (__start0, __temp0, __end0); - __action10( - input, - __0, - __temp0, - __2, - __3, - ) + __action10(input, __0, __temp0, __2, __3) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action105< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action105<'input>( input: &'input str, __0: (usize, BasicBlockId, usize), __1: (usize, &'input str, usize), __2: (usize, alloc::vec::Vec, usize), -) -> BasicBlock -{ +) -> BasicBlock { let __start0 = __0.2; let __end0 = __1.0; - let __temp0 = __action55( - input, - &__start0, - &__end0, - ); + let __temp0 = __action55(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action10( - input, - __0, - __temp0, - __1, - __2, - ) + __action10(input, __0, __temp0, __1, __2) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action106< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action106<'input>( input: &'input str, __0: (usize, BasicBlockId, usize), __1: (usize, Vec, usize), __2: (usize, &'input str, usize), -) -> BasicBlock -{ +) -> BasicBlock { let __start0 = __2.2; let __end0 = __2.2; - let __temp0 = __action52( - input, - &__start0, - &__end0, - ); + let __temp0 = __action52(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action104( - input, - __0, - __1, - __2, - __temp0, - ) + __action104(input, __0, __1, __2, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action107< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action107<'input>( input: &'input str, __0: (usize, BasicBlockId, usize), __1: (usize, Vec, usize), __2: (usize, &'input str, usize), __3: (usize, alloc::vec::Vec, usize), -) -> BasicBlock -{ +) -> BasicBlock { let __start0 = __3.0; let __end0 = __3.2; - let __temp0 = __action53( - input, - __3, - ); + let __temp0 = __action53(input, __3); let __temp0 = (__start0, __temp0, __end0); - __action104( - input, - __0, - __1, - __2, - __temp0, - ) + __action104(input, __0, __1, __2, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action108< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action108<'input>( input: &'input str, __0: (usize, BasicBlockId, usize), __1: (usize, &'input str, usize), -) -> BasicBlock -{ +) -> BasicBlock { let __start0 = __1.2; let __end0 = __1.2; - let __temp0 = __action52( - input, - &__start0, - &__end0, - ); + let __temp0 = __action52(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action105( - input, - __0, - __1, - __temp0, - ) + __action105(input, __0, __1, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action109< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action109<'input>( input: &'input str, __0: (usize, BasicBlockId, usize), __1: (usize, &'input str, usize), __2: (usize, alloc::vec::Vec, usize), -) -> BasicBlock -{ +) -> BasicBlock { let __start0 = __2.0; let __end0 = __2.2; - let __temp0 = __action53( - input, - __2, - ); + let __temp0 = __action53(input, __2); let __temp0 = (__start0, __temp0, __end0); - __action105( - input, - __0, - __1, - __temp0, - ) + __action105(input, __0, __1, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action110< - 'input, ->( - input: &'input str, - __0: (usize, Operand, usize), -) -> Vec -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action110<'input>(input: &'input str, __0: (usize, Operand, usize)) -> Vec { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action49( - input, - __0, - ); + let __temp0 = __action49(input, __0); let __temp0 = (__start0, __temp0, __end0); - __action92( - input, - __temp0, - ) + __action92(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action111< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action111<'input>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> Vec -{ +) -> Vec { let __start0 = *__lookbehind; let __end0 = *__lookahead; - let __temp0 = __action50( - input, - &__start0, - &__end0, - ); + let __temp0 = __action50(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action92( - input, - __temp0, - ) + __action92(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action112< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action112<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, Operand, usize), -) -> Vec -{ +) -> Vec { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action49( - input, - __1, - ); + let __temp0 = __action49(input, __1); let __temp0 = (__start0, __temp0, __end0); - __action93( - input, - __0, - __temp0, - ) + __action93(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action113< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action113<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), -) -> Vec -{ +) -> Vec { let __start0 = __0.2; let __end0 = __0.2; - let __temp0 = __action50( - input, - &__start0, - &__end0, - ); + let __temp0 = __action50(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action93( - input, - __0, - __temp0, - ) + __action93(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action114< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action114<'input>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, Type, usize), __2: (usize, Operand, usize), -) -> Instruction -{ +) -> Instruction { let __start0 = __2.0; let __end0 = __2.2; - let __temp0 = __action49( - input, - __2, - ); + let __temp0 = __action49(input, __2); let __temp0 = (__start0, __temp0, __end0); - __action20( - input, - __0, - __1, - __temp0, - ) + __action20(input, __0, __1, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action115< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action115<'input>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, Type, usize), -) -> Instruction -{ +) -> Instruction { let __start0 = __1.2; let __end0 = __1.2; - let __temp0 = __action50( - input, - &__start0, - &__end0, - ); + let __temp0 = __action50(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action20( - input, - __0, - __1, - __temp0, - ) + __action20(input, __0, __1, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action116< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action116<'input>( input: &'input str, __0: (usize, BasicBlockId, usize), __1: (usize, Vec, usize), -) -> Target -{ +) -> Target { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action47( - input, - __1, - ); + let __temp0 = __action47(input, __1); let __temp0 = (__start0, __temp0, __end0); - __action23( - input, - __0, - __temp0, - ) + __action23(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action117< - 'input, ->( - input: &'input str, - __0: (usize, BasicBlockId, usize), -) -> Target -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action117<'input>(input: &'input str, __0: (usize, BasicBlockId, usize)) -> Target { let __start0 = __0.2; let __end0 = __0.2; - let __temp0 = __action48( - input, - &__start0, - &__end0, - ); + let __temp0 = __action48(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action23( - input, - __0, - __temp0, - ) + __action23(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action118< - 'input, ->( - input: &'input str, - __0: (usize, Type, usize), -) -> Vec -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action118<'input>(input: &'input str, __0: (usize, Type, usize)) -> Vec { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action61( - input, - __0, - ); + let __temp0 = __action61(input, __0); let __temp0 = (__start0, __temp0, __end0); - __action96( - input, - __temp0, - ) + __action96(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action119< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> Vec -{ +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action119<'input>(input: &'input str, __lookbehind: &usize, __lookahead: &usize) -> Vec { let __start0 = *__lookbehind; let __end0 = *__lookahead; - let __temp0 = __action62( - input, - &__start0, - &__end0, - ); + let __temp0 = __action62(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action96( - input, - __temp0, - ) + __action96(input, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action120< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action120<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), __1: (usize, Type, usize), -) -> Vec -{ +) -> Vec { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action61( - input, - __1, - ); + let __temp0 = __action61(input, __1); let __temp0 = (__start0, __temp0, __end0); - __action97( - input, - __0, - __temp0, - ) + __action97(input, __0, __temp0) } #[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action121< - 'input, ->( +#[allow( + clippy::too_many_arguments, + clippy::needless_lifetimes, + clippy::just_underscores_and_digits +)] +fn __action121<'input>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), -) -> Vec -{ +) -> Vec { let __start0 = __0.2; let __end0 = __0.2; - let __temp0 = __action62( - input, - &__start0, - &__end0, - ); + let __temp0 = __action62(input, &__start0, &__end0); let __temp0 = (__start0, __temp0, __end0); - __action97( - input, - __0, - __temp0, - ) + __action97(input, __0, __temp0) } -#[allow(clippy::type_complexity)] - -pub trait __ToTriple<'input, > -{ - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>>; +#[allow(clippy::type_complexity, dead_code)] + +pub trait __ToTriple<'input> { + fn to_triple( + value: Self, + ) -> Result< + (usize, Token<'input>, usize), + __lalrpop_util::ParseError, &'static str>, + >; } -impl<'input, > __ToTriple<'input, > for (usize, Token<'input>, usize) -{ - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>> { +impl<'input> __ToTriple<'input> for (usize, Token<'input>, usize) { + fn to_triple( + value: Self, + ) -> Result< + (usize, Token<'input>, usize), + __lalrpop_util::ParseError, &'static str>, + > { Ok(value) } } -impl<'input, > __ToTriple<'input, > for Result<(usize, Token<'input>, usize), &'static str> -{ - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>> { +impl<'input> __ToTriple<'input> for Result<(usize, Token<'input>, usize), &'static str> { + fn to_triple( + value: Self, + ) -> Result< + (usize, Token<'input>, usize), + __lalrpop_util::ParseError, &'static str>, + > { match value { Ok(v) => Ok(v), Err(error) => Err(__lalrpop_util::ParseError::User { error }), diff --git a/ir/crates/front/src/lib.rs b/ir/crates/front/src/lib.rs index 13f73f8..779e166 100644 --- a/ir/crates/front/src/lib.rs +++ b/ir/crates/front/src/lib.rs @@ -2,4 +2,7 @@ #[allow(warnings)] pub(crate) mod grammar; pub mod module; -pub use module::{Module, parse}; +pub use module::{ + parse, + Module, +}; diff --git a/ir/crates/front/src/module.rs b/ir/crates/front/src/module.rs index 4392be4..ccb84fc 100644 --- a/ir/crates/front/src/module.rs +++ b/ir/crates/front/src/module.rs @@ -1,6 +1,8 @@ use crate::grammar; -pub fn parse(input: &str) -> Result> { +pub fn parse( + input: &str, +) -> Result> { grammar::ModuleParser::new().parse(input) } @@ -17,7 +19,6 @@ pub struct Function { pub basic_blocks: Vec, } - #[derive(Debug, PartialEq, Eq)] pub struct Arg { pub id: RegId, @@ -45,7 +46,7 @@ pub enum Instruction { #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum CmpOp { Eq, - Gt + Gt, } #[derive(Debug, PartialEq, Eq)] @@ -84,48 +85,68 @@ pub struct BasicBlockId(pub u32); #[cfg(test)] mod tests { - use crate::grammar; - use crate::module::{Arg, BasicBlock, BasicBlockId, Function, Instruction, Operand, RegId, Type}; + use crate::{ + grammar, + module::{ + Arg, + BasicBlock, + BasicBlockId, + Function, + Instruction, + Operand, + RegId, + Type, + }, + }; #[test] fn should_parse_function() { - let function = grammar::FunctionParser::new().parse(r" + let function = grammar::FunctionParser::new() + .parse( + r" fun i32 @add(i32, i32) { bb0(i32 v0, i32 v1): v2 = add i32 v0, v1; v3 = add i32 v2, v1; ret i32 v3; } - ").unwrap(); + ", + ) + .unwrap(); assert_eq!( function, Function { name: "add".to_string(), ret_ty: Type::I32, - args: vec![ - Type::I32, - Type::I32, - ], - basic_blocks: vec![ - BasicBlock { - id: BasicBlockId(0), - instructions: vec![ - Instruction::Add(RegId(2), Type::I32, Operand::Register(RegId(0)), Operand::Register(RegId(1))), - Instruction::Add(RegId(3), Type::I32, Operand::Register(RegId(2)), Operand::Register(RegId(1))), - Instruction::Ret(Type::I32, Some(Operand::Register(RegId(3)))), - ], - args: vec![ - Arg { - id: RegId(0), - ty: Type::I32, - }, - Arg { - id: RegId(1), - ty: Type::I32, - }, - ], - }, - ], + args: vec![Type::I32, Type::I32,], + basic_blocks: vec![BasicBlock { + id: BasicBlockId(0), + instructions: vec![ + Instruction::Add( + RegId(2), + Type::I32, + Operand::Register(RegId(0)), + Operand::Register(RegId(1)) + ), + Instruction::Add( + RegId(3), + Type::I32, + Operand::Register(RegId(2)), + Operand::Register(RegId(1)) + ), + Instruction::Ret(Type::I32, Some(Operand::Register(RegId(3)))), + ], + args: vec![ + Arg { + id: RegId(0), + ty: Type::I32, + }, + Arg { + id: RegId(1), + ty: Type::I32, + }, + ], + },], } ) } diff --git a/ir/crates/middle/src/analysis/dataflow/backward.rs b/ir/crates/middle/src/analysis/dataflow/backward.rs index 406f7b5..a199eb0 100644 --- a/ir/crates/middle/src/analysis/dataflow/backward.rs +++ b/ir/crates/middle/src/analysis/dataflow/backward.rs @@ -1,8 +1,17 @@ use std::collections::VecDeque; + use cranelift_entity::EntitySet; -use crate::analysis::dataflow::{Analysis, DFState, InstrWalker}; -use crate::cfg::BasicBlockId; -use crate::{Function, Instr}; + +use crate::{ + analysis::dataflow::{ + Analysis, + DFState, + InstrWalker, + }, + cfg::BasicBlockId, + Function, + Instr, +}; pub struct BackwardAnalysisRunner<'a, A: Analysis> { pub state: DFState, visited: EntitySet, @@ -24,24 +33,27 @@ impl<'a, A: Analysis> BackwardAnalysisRunner<'a, A> { pub fn next_bb(&mut self) -> Option<(BasicBlockId, BAInstrWalker)> { let bb_id = self.worklist.pop_front()?; - let bb_state = self.state.create(bb_id, self.function.cfg.successors(bb_id)); + let bb_state = self + .state + .create(bb_id, self.function.cfg.successors(bb_id)); assert!(self.visited.insert(bb_id), "Block has already been visited"); for pred in self.function.cfg.predecessors(bb_id) { let mut succs = self.function.cfg.successors(pred); - let all_succs_visited = succs.all(|succ| { - self.visited.contains(succ) - }); + let all_succs_visited = succs.all(|succ| self.visited.contains(succ)); assert!(all_succs_visited, "Not all successors have been visited"); // if !all_succs_visited { // continue; // } // self.worklist.push_back(pred); } - Some((bb_id, BAInstrWalker { - basic_block: bb_id, - function: self.function, - bb_state, - })) + Some(( + bb_id, + BAInstrWalker { + basic_block: bb_id, + function: self.function, + bb_state, + }, + )) } pub fn collect(mut self) -> A::V { @@ -50,7 +62,6 @@ impl<'a, A: Analysis> BackwardAnalysisRunner<'a, A> { } self.state.state[self.function.cfg.entry_block()].clone() } - } pub struct BAInstrWalker<'a, 'b, A: Analysis> { @@ -60,7 +71,10 @@ pub struct BAInstrWalker<'a, 'b, A: Analysis> { } impl<'a, 'b, A: Analysis> InstrWalker for BAInstrWalker<'a, 'b, A> { - fn walk(mut self, mut h: H) where H: FnMut(&mut Instr, &A::V) { + fn walk(mut self, mut h: H) + where + H: FnMut(&mut Instr, &A::V), + { let bb = self.function.cfg.basic_block_mut(self.basic_block); A::analyse_term(bb.terminator(), self.bb_state); for instr in bb.instructions_mut().rev() { diff --git a/ir/crates/middle/src/analysis/dataflow/concrete_value.rs b/ir/crates/middle/src/analysis/dataflow/concrete_value.rs index c100ec5..83d7258 100644 --- a/ir/crates/middle/src/analysis/dataflow/concrete_value.rs +++ b/ir/crates/middle/src/analysis/dataflow/concrete_value.rs @@ -1,10 +1,22 @@ -use rustc_hash::{FxHashMap, FxHashSet}; -use crate::analysis::dataflow::lattice; -use crate::{Instr, InstrKind, VReg}; -use crate::analysis::dataflow::forward::ForwardAnalysisRunner; -use crate::cfg::Terminator; +use rustc_hash::{ + FxHashMap, + FxHashSet, +}; -use crate::instruction::{Const, Op}; +use crate::{ + analysis::dataflow::{ + forward::ForwardAnalysisRunner, + lattice, + }, + cfg::Terminator, + instruction::{ + Const, + Op, + }, + Instr, + InstrKind, + VReg, +}; #[derive(Debug, Default, Clone)] pub struct ConcreteValues { @@ -13,17 +25,13 @@ pub struct ConcreteValues { impl ConcreteValues { pub const fn new(values: FxHashSet) -> Self { - Self { - values - } + Self { values } } pub fn from_single_value(value: Const) -> Self { let mut values = FxHashSet::default(); values.insert(value); - Self { - values - } + Self { values } } pub fn as_single_value(&self) -> Option<&Const> { @@ -43,7 +51,6 @@ impl lattice::Value for ConcreteValues { } } - pub struct Analysis; pub type AnalysisRunner<'a> = ForwardAnalysisRunner<'a, Analysis>; @@ -53,7 +60,10 @@ impl super::Analysis for Analysis { fn analyse_instr(instr: &Instr, values: &mut Self::V) { if let InstrKind::Op(instr) = &instr.kind { if let Op::Const(const_val) = &instr.op { - values.insert(instr.value, ConcreteValues::from_single_value(const_val.clone())); + values.insert( + instr.value, + ConcreteValues::from_single_value(const_val.clone()), + ); } }; } diff --git a/ir/crates/middle/src/analysis/dataflow/forward.rs b/ir/crates/middle/src/analysis/dataflow/forward.rs index a9704af..f4c3cce 100644 --- a/ir/crates/middle/src/analysis/dataflow/forward.rs +++ b/ir/crates/middle/src/analysis/dataflow/forward.rs @@ -1,7 +1,15 @@ use cranelift_entity::EntitySet; -use crate::analysis::dataflow::{Analysis, DFState, InstrWalker}; -use crate::cfg::BasicBlockId; -use crate::{Function, Instr}; + +use crate::{ + analysis::dataflow::{ + Analysis, + DFState, + InstrWalker, + }, + cfg::BasicBlockId, + Function, + Instr, +}; pub struct ForwardAnalysisRunner<'a, A: Analysis> { pub state: DFState, @@ -24,23 +32,27 @@ impl<'a, A: Analysis> ForwardAnalysisRunner<'a, A> { pub fn next_bb(&mut self) -> Option<(BasicBlockId, FAInstrWalker)> { let bb_id = self.worklist.pop()?; - let bb_state = self.state.create(bb_id, self.function.cfg.predecessors(bb_id)); + let bb_state = self + .state + .create(bb_id, self.function.cfg.predecessors(bb_id)); assert!(self.visited.insert(bb_id), "Block has already been visited"); for successor in self.function.cfg.successors(bb_id) { let mut predecessors = self.function.cfg.predecessors(successor); - let all_preds_visited = predecessors.all(|predecessor| { - self.visited.contains(predecessor) - }); + let all_preds_visited = + predecessors.all(|predecessor| self.visited.contains(predecessor)); if !all_preds_visited { continue; } self.worklist.push(successor); } - Some((bb_id, FAInstrWalker { - basic_block: bb_id, - function: self.function, - bb_state, - })) + Some(( + bb_id, + FAInstrWalker { + basic_block: bb_id, + function: self.function, + bb_state, + }, + )) } } @@ -51,7 +63,10 @@ pub struct FAInstrWalker<'a, 'b, A: Analysis> { } impl<'a, 'b, A: Analysis> InstrWalker for FAInstrWalker<'a, 'b, A> { - fn walk(mut self, mut h: H) where H: FnMut(&mut Instr, &A::V) { + fn walk(mut self, mut h: H) + where + H: FnMut(&mut Instr, &A::V), + { let bb = self.function.cfg.basic_block_mut(self.basic_block); for instr in bb.instructions_mut() { h(instr, &*self.bb_state); diff --git a/ir/crates/middle/src/analysis/dataflow/lattice.rs b/ir/crates/middle/src/analysis/dataflow/lattice.rs index a71e0a9..b36e239 100644 --- a/ir/crates/middle/src/analysis/dataflow/lattice.rs +++ b/ir/crates/middle/src/analysis/dataflow/lattice.rs @@ -7,7 +7,10 @@ pub enum Element { Value(V), } -impl From for Element where V: Value { +impl From for Element +where + V: Value, +{ fn from(value: V) -> Self { Self::Value(value) } @@ -25,8 +28,7 @@ impl Element { (_, Self::Bottom) | (Self::Top, _) => { return false; } - (Self::Bottom, other) => - *self = other, + (Self::Bottom, other) => *self = other, (_, Self::Top) => { *self = Self::Top; } diff --git a/ir/crates/middle/src/analysis/dataflow/mod.rs b/ir/crates/middle/src/analysis/dataflow/mod.rs index 9eb0655..8d63e6b 100644 --- a/ir/crates/middle/src/analysis/dataflow/mod.rs +++ b/ir/crates/middle/src/analysis/dataflow/mod.rs @@ -1,28 +1,43 @@ -use std::fmt::Debug; -use std::hash::Hash; +use std::{ + fmt::Debug, + hash::Hash, +}; use cranelift_entity::SecondaryMap; -use rustc_hash::{FxHashMap, FxHashSet}; - use lattice::Value; +use rustc_hash::{ + FxHashMap, + FxHashSet, +}; + +use crate::{ + cfg::{ + BasicBlockId, + Terminator, + }, + Instr, +}; -use crate::Instr; -use crate::cfg::{BasicBlockId, Terminator}; - -pub mod lattice; +mod backward; pub mod concrete_value; -pub mod use_def; mod forward; -mod backward; +pub mod lattice; +pub mod use_def; type InstrValue = crate::VReg; #[derive(Default)] -pub struct DFState where V: Clone { +pub struct DFState +where + V: Clone, +{ state: SecondaryMap, } -impl DFState where V: Value { +impl DFState +where + V: Value, +{ pub fn new() -> Self { Self::default() } @@ -35,7 +50,11 @@ impl DFState where V: Value { &self.state[bb] } - pub fn create(&mut self, bb: BasicBlockId, join_partners: impl IntoIterator) -> &mut V { + pub fn create( + &mut self, + bb: BasicBlockId, + join_partners: impl IntoIterator, + ) -> &mut V { for join_partner in join_partners { let pred_state = self.get(join_partner).clone(); let entry = self.get_mut(bb); @@ -45,9 +64,10 @@ impl DFState where V: Value { } } - pub trait InstrWalker: Sized { - fn walk(self, h: H) where H: FnMut(&mut Instr, &V); + fn walk(self, h: H) + where + H: FnMut(&mut Instr, &V); fn drain(self) { self.walk(|_, _| {}); @@ -64,7 +84,11 @@ pub trait Analysis { pub type DFValueState = FxHashMap; -impl Value for FxHashMap where K: Clone + Debug + Eq + Hash, V: Value { +impl Value for FxHashMap +where + K: Clone + Debug + Eq + Hash, + V: Value, +{ fn join(&mut self, other: Self) -> bool { let mut changed = false; for (key, val) in other { @@ -77,12 +101,13 @@ impl Value for FxHashMap where K: Clone + Debug + Eq + Hash, V: Valu } } -impl Value for FxHashSet where T: Clone + Debug + Eq + Hash { +impl Value for FxHashSet +where + T: Clone + Debug + Eq + Hash, +{ fn join(&mut self, other: Self) -> bool { let len_before = self.len(); self.extend(other); self.len() != len_before } } - - diff --git a/ir/crates/middle/src/analysis/dataflow/use_def.rs b/ir/crates/middle/src/analysis/dataflow/use_def.rs index 4073033..c4195b0 100644 --- a/ir/crates/middle/src/analysis/dataflow/use_def.rs +++ b/ir/crates/middle/src/analysis/dataflow/use_def.rs @@ -1,10 +1,19 @@ use cranelift_entity::SecondaryMap; -use crate::{Instr, VReg}; -use crate::analysis::dataflow::backward::BackwardAnalysisRunner; -use crate::analysis::dataflow::lattice; -use crate::cfg::{BasicBlockId, InstrId, Terminator}; -use crate::instruction::Op; +use crate::{ + analysis::dataflow::{ + backward::BackwardAnalysisRunner, + lattice, + }, + cfg::{ + BasicBlockId, + InstrId, + Terminator, + }, + instruction::Op, + Instr, + VReg, +}; #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct InstrUid(pub BasicBlockId, pub InstrId); @@ -28,9 +37,7 @@ impl From<&Terminator> for InstrUid { } #[derive(Debug, Default, Clone)] -pub struct UseDef( - SecondaryMap, Option>)> -); +pub struct UseDef(SecondaryMap, Option>)>); impl UseDef { pub fn register_def(&mut self, def: VReg, instr_uid: InstrUid) -> Option { @@ -38,34 +45,30 @@ impl UseDef { } pub fn register_use(&mut self, use_: VReg, instr_uid: InstrUid) { - let uses = self.0[use_].1.get_or_insert_with( - Vec::new - ); + let uses = self.0[use_].1.get_or_insert_with(Vec::new); uses.push(instr_uid); } - + pub fn is_defined(&self, def: VReg) -> bool { self.0[def].0.is_some() } - + pub fn get_def(&self, def: VReg) -> Option { self.0[def].0 } - + /// Returns all defined, but unused registers - pub fn unused_regs(&self) -> impl Iterator + '_ { - self.0.iter().filter_map( - |(vreg, (def, uses))| { - def.and_then(|_| { - let is_unused = uses.as_ref().map(|uses| uses.is_empty()).unwrap_or(true); - if is_unused { - Some(vreg) - } else { - None - } - }) - } - ) + pub fn unused_regs(&self) -> impl Iterator + '_ { + self.0.iter().filter_map(|(vreg, (def, uses))| { + def.and_then(|_| { + let is_unused = uses.as_ref().map(|uses| uses.is_empty()).unwrap_or(true); + if is_unused { + Some(vreg) + } else { + None + } + }) + }) } } @@ -82,13 +85,12 @@ impl lattice::Value for UseDef { for use_ in uses.iter().flatten().copied() { self.register_use(vreg, use_); changed = true; - } + } } changed } } - pub struct Analysis; pub type AnalysisRunner<'a> = BackwardAnalysisRunner<'a, Analysis>; @@ -108,10 +110,12 @@ impl super::Analysis for Analysis { } } - fn analyse_term(term: &Terminator, use_def: &mut Self::V){ - for used_vreg in term.used().into_iter().flat_map( - |op| op.try_as_vreg_ref().copied() - ) { + fn analyse_term(term: &Terminator, use_def: &mut Self::V) { + for used_vreg in term + .used() + .into_iter() + .flat_map(|op| op.try_as_vreg_ref().copied()) + { use_def.register_use(used_vreg, term.into()); } } diff --git a/ir/crates/middle/src/cfg/builder.rs b/ir/crates/middle/src/cfg/builder.rs index 1b4e682..797496d 100644 --- a/ir/crates/middle/src/cfg/builder.rs +++ b/ir/crates/middle/src/cfg/builder.rs @@ -1,10 +1,28 @@ use cranelift_entity::EntityRef; -use crate::cfg::{BasicBlockId, Terminator, TerminatorKind}; -use crate::function::Function; -use crate::instruction::{AllocaInstr, BinOpInstr, CmpInstr, CmpOp, Instr, InstrKind, LoadInstr, Op, OpInstr, StoreInstr, VRegData}; -use crate::ty::Type; -use crate::VReg; +use crate::{ + cfg::{ + BasicBlockId, + Terminator, + TerminatorKind, + }, + function::Function, + instruction::{ + AllocaInstr, + BinOpInstr, + CmpInstr, + CmpOp, + Instr, + InstrKind, + LoadInstr, + Op, + OpInstr, + StoreInstr, + VRegData, + }, + ty::Type, + VReg, +}; #[derive(Debug)] pub struct Builder<'func> { @@ -15,7 +33,11 @@ pub struct Builder<'func> { impl<'func> Builder<'func> { pub fn new(func: &'func mut Function) -> Self { - Self { func, current_bb: None, next_vreg: None } + Self { + func, + current_bb: None, + next_vreg: None, + } } pub fn start_bb(&mut self) -> BasicBlockId { @@ -24,7 +46,6 @@ impl<'func> Builder<'func> { bb } - pub fn create_bb(&mut self) -> BasicBlockId { self.func.cfg.new_basic_block() } @@ -41,32 +62,21 @@ impl<'func> Builder<'func> { pub fn alloca(&mut self, ty: Type, num_elements: Option) -> VReg { let value = self.next_vreg(Type::Ptr(Box::new(ty.clone()))); - let alloca = AllocaInstr::new( - value, - num_elements, - ); + let alloca = AllocaInstr::new(value, num_elements); self.add_instr(ty, InstrKind::Alloca(alloca)); value } pub fn add(&mut self, ty: Type, lhs: Op, rhs: Op) -> VReg { let value = self.next_vreg(ty.clone()); - let instr = BinOpInstr { - value, - lhs, - rhs, - }; + let instr = BinOpInstr { value, lhs, rhs }; self.add_instr(ty, InstrKind::Add(instr)); value } pub fn sub(&mut self, ty: Type, lhs: Op, rhs: Op) -> VReg { let value = self.next_vreg(ty.clone()); - let sub = BinOpInstr { - value, - lhs, - rhs, - }; + let sub = BinOpInstr { value, lhs, rhs }; self.add_instr(ty, InstrKind::Sub(sub)); value } @@ -88,10 +98,7 @@ impl<'func> Builder<'func> { pub fn op(&mut self, ty: Type, op: Op) -> VReg { let value = self.next_vreg(ty.clone()); - let op_instr = OpInstr { - value, - op, - }; + let op_instr = OpInstr { value, op }; self.add_instr(ty, InstrKind::Op(op_instr)); value } @@ -99,21 +106,25 @@ impl<'func> Builder<'func> { pub fn icmp(&mut self, condition: CmpOp, op1: Op, op2: Op) -> VReg { let ty = Type::Bool; let value = self.next_vreg(ty.clone()); - self.add_instr(ty, InstrKind::Cmp( - CmpInstr { + self.add_instr( + ty, + InstrKind::Cmp(CmpInstr { value, op: condition, lhs: op1, rhs: op2, - } - )); + }), + ); value } pub fn add_argument(&mut self, ty: Type) -> VReg { let value = self.next_vreg(ty); let current_bb = self.current_bb(); - self.func.cfg.basic_block_mut(current_bb).add_argument(value); + self.func + .cfg + .basic_block_mut(current_bb) + .add_argument(value); value } @@ -122,7 +133,9 @@ impl<'func> Builder<'func> { } pub fn add_instr(&mut self, ty: Type, instr_kind: InstrKind) { - self.func.cfg.add_instruction(self.current_bb(), ty, instr_kind); + self.func + .cfg + .add_instruction(self.current_bb(), ty, instr_kind); } /// Tells the builder to use this vreg for the next instruction @@ -161,12 +174,14 @@ impl<'func> Builder<'func> { None => self.func.cfg.new_vreg(VRegData { ty, defined_in: self.current_bb(), - }) + }), } } pub(crate) fn max_bb_id(&self) -> Option { - Some(BasicBlockId::new(self.func.cfg.basic_blocks.len().checked_sub(1)?)) + Some(BasicBlockId::new( + self.func.cfg.basic_blocks.len().checked_sub(1)?, + )) } pub fn current_bb(&self) -> BasicBlockId { @@ -176,11 +191,23 @@ impl<'func> Builder<'func> { #[cfg(test)] mod tests { - use crate::cfg; - use crate::cfg::{BranchTerm, CondBranchTerm, JumpTarget, RetTerm, TerminatorKind}; - use crate::instruction::{CmpOp, Const, Op}; - use crate::test::create_test_function; - use crate::ty::Type; + use crate::{ + cfg, + cfg::{ + BranchTerm, + CondBranchTerm, + JumpTarget, + RetTerm, + TerminatorKind, + }, + instruction::{ + CmpOp, + Const, + Op, + }, + test::create_test_function, + ty::Type, + }; #[test] fn should_add_allocas_to_entry_block() { @@ -190,10 +217,13 @@ mod tests { cfg_builder.alloca(Type::I32, None); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); - assert_eq!(function.cfg.to_string(), "bb0: + assert_eq!( + function.cfg.to_string(), + "bb0: v0 = alloca i32; ret void; -"); +" + ); } #[test] @@ -207,10 +237,13 @@ mod tests { Op::Const(Const::Int(Type::I32, 1)), ); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); - assert_eq!(function.cfg.to_string(), "bb0: + assert_eq!( + function.cfg.to_string(), + "bb0: v0 = sub i32 0, 1; ret void; -"); +" + ); } #[test] @@ -220,10 +253,13 @@ mod tests { cfg_builder.start_bb(); cfg_builder.op(Type::I32, Op::Const(Const::Int(Type::I32, 0))); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); - assert_eq!(function.cfg.to_string(), "bb0: + assert_eq!( + function.cfg.to_string(), + "bb0: v0 = i32 0; ret void; -"); +" + ); } #[test] @@ -234,11 +270,14 @@ mod tests { let alloca_value = cfg_builder.alloca(Type::I32, None); cfg_builder.store(Type::I32, alloca_value, Op::Const(Const::Int(Type::I32, 0))); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); - assert_eq!("bb0: + assert_eq!( + "bb0: v0 = alloca i32; store i32 0, ptr v0; ret void; -", function.cfg.to_string()); +", + function.cfg.to_string() + ); } #[test] @@ -249,11 +288,14 @@ mod tests { let alloca_value = cfg_builder.alloca(Type::I32, None); cfg_builder.load(Type::I32, Op::Vreg(alloca_value)); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); - assert_eq!("bb0: + assert_eq!( + "bb0: v0 = alloca i32; v1 = load i32 ptr v0; ret void; -", function.cfg.to_string()); +", + function.cfg.to_string() + ); } #[test] @@ -263,26 +305,31 @@ mod tests { let _bb0 = cfg_builder.start_bb(); let bb1 = cfg_builder.create_bb(); let bb2 = cfg_builder.create_bb(); - let cmp_value = cfg_builder.icmp(CmpOp::Eq, Op::Const(Const::Int(Type::I32, 0)), Op::Const(Const::Int(Type::I32, 1))); - cfg_builder.end_bb(TerminatorKind::CondBranch( - CondBranchTerm { - cond: Op::Vreg(cmp_value), - true_target: JumpTarget::no_args(bb1), - false_target: JumpTarget::no_args(bb2), - } - )); + let cmp_value = cfg_builder.icmp( + CmpOp::Eq, + Op::Const(Const::Int(Type::I32, 0)), + Op::Const(Const::Int(Type::I32, 1)), + ); + cfg_builder.end_bb(TerminatorKind::CondBranch(CondBranchTerm { + cond: Op::Vreg(cmp_value), + true_target: JumpTarget::no_args(bb1), + false_target: JumpTarget::no_args(bb2), + })); cfg_builder.set_bb(bb1); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); cfg_builder.set_bb(bb2); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); - assert_eq!("bb0: + assert_eq!( + "bb0: v0 = icmp bool eq 0, 1; condbr v0, bb1, bb2; bb1: ret void; bb2: ret void; -", function.cfg.to_string()); +", + function.cfg.to_string() + ); } #[test] @@ -294,20 +341,32 @@ bb2: let bb2 = cfg_builder.create_bb(); let bb3 = cfg_builder.create_bb(); let bb4 = cfg_builder.create_bb(); - cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new(JumpTarget::no_args(bb1)))); + cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new( + JumpTarget::no_args(bb1), + ))); cfg_builder.set_bb(bb1); let var_0 = cfg_builder.op(Type::I32, Op::Const(Const::Int(Type::I32, 0))); - cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new(JumpTarget::new(bb3, vec![var_0.into()])))); + cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new(JumpTarget::new( + bb3, + vec![var_0.into()], + )))); cfg_builder.set_bb(bb2); let var_1 = cfg_builder.op(Type::I32, Op::Const(Const::Int(Type::I32, 1))); - cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new(JumpTarget::new(bb3, vec![var_1.into()])))); + cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new(JumpTarget::new( + bb3, + vec![var_1.into()], + )))); cfg_builder.set_bb(bb3); let var_2 = cfg_builder.add_argument(Type::I32); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::new(Type::I32, var_2.into()))); cfg_builder.set_bb(bb4); let var_3 = cfg_builder.op(Type::I32, Op::Const(Const::Int(Type::I32, 2))); - cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new(JumpTarget::new(bb3, vec![var_3.into()])))); - assert_eq!("bb0: + cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new(JumpTarget::new( + bb3, + vec![var_3.into()], + )))); + assert_eq!( + "bb0: br bb1; bb1: v0 = i32 0; @@ -320,6 +379,8 @@ bb3(i32 v2): bb4: v3 = i32 2; br bb3(v3); -", function.cfg.to_string()); +", + function.cfg.to_string() + ); } } diff --git a/ir/crates/middle/src/cfg/domtree.rs b/ir/crates/middle/src/cfg/domtree.rs index f60ffe2..8e77ae9 100644 --- a/ir/crates/middle/src/cfg/domtree.rs +++ b/ir/crates/middle/src/cfg/domtree.rs @@ -1,31 +1,43 @@ -use petgraph::algo::dominators::Dominators; -use petgraph::prelude::NodeIndex; +use petgraph::{ + algo::dominators::Dominators, + prelude::NodeIndex, +}; -use super::{BasicBlockId, Cfg}; +use super::{ + BasicBlockId, + Cfg, +}; pub struct DomTree<'a> { dominators: Dominators, - cfg: &'a Cfg + cfg: &'a Cfg, } -impl <'a> DomTree<'a> { +impl<'a> DomTree<'a> { pub fn compute(cfg: &'a Cfg) -> Self { Self { - dominators: petgraph::algo::dominators::simple_fast(&cfg.graph, cfg.entry_block().into()), - cfg + dominators: petgraph::algo::dominators::simple_fast( + &cfg.graph, + cfg.entry_block().into(), + ), + cfg, } } pub fn idom(&self, basic_block: BasicBlockId) -> Option { - self.dominators.immediate_dominator(basic_block.into()).map(|node_idx| node_idx.into()) + self.dominators + .immediate_dominator(basic_block.into()) + .map(|node_idx| node_idx.into()) } - + /// Returns true if `a` dominates `b`. - /// + /// /// A basic block `a` dominates `b` if every path from the entry block to `b` must go through `a`. - /// + /// /// **Note** that false is returned if `a` is not reachable from the entry block. pub fn dominates(&self, a: BasicBlockId, b: BasicBlockId) -> bool { - let Some(dominators) = self.dominators.dominators(b.into()) else { return false; }; + let Some(dominators) = self.dominators.dominators(b.into()) else { + return false; + }; dominators.into_iter().any(|node_idx| node_idx == a.into()) } } diff --git a/ir/crates/middle/src/cfg/mod.rs b/ir/crates/middle/src/cfg/mod.rs index 177fe70..350ecd2 100644 --- a/ir/crates/middle/src/cfg/mod.rs +++ b/ir/crates/middle/src/cfg/mod.rs @@ -1,19 +1,37 @@ #![doc = include_str!("cfg.md")] -use std::fmt::{Debug, Display, Formatter}; - -use cranelift_entity::{entity_impl, EntityRef, PrimaryMap}; -use index_vec::IndexVec; -use petgraph::prelude::*; -use petgraph::visit::Walker; -use smallvec::SmallVec; +use std::fmt::{ + Debug, + Display, + Formatter, +}; #[allow(unused_imports)] pub use builder::Builder; +use cranelift_entity::{ + entity_impl, + EntityRef, + PrimaryMap, +}; pub use domtree::DomTree; +use index_vec::IndexVec; +use petgraph::{ + prelude::*, + visit::Walker, +}; +use smallvec::SmallVec; -use crate::{InstrKind, Type, VReg}; -use crate::instruction::{Instr, Op, OpInstr, VRegData}; +use crate::{ + instruction::{ + Instr, + Op, + OpInstr, + VRegData, + }, + InstrKind, + Type, + VReg, +}; mod builder; mod domtree; @@ -70,17 +88,20 @@ impl Cfg { } /// Returns an iterator visiting all basics blocks in arbitrary order. - pub fn basic_blocks(&self) -> impl Iterator { - self.basic_blocks.iter().filter(|(id, bb)| bb.has_terminator()) + pub fn basic_blocks(&self) -> impl Iterator { + self.basic_blocks + .iter() + .filter(|(id, bb)| bb.has_terminator()) } /// Returns an iterator visiting all basics block ids in arbitrary order. - pub fn basic_block_ids(&self) -> impl Iterator + '_ { + pub fn basic_block_ids(&self) -> impl Iterator + '_ { self.basic_blocks().map(|(id, _)| id) } - pub fn basic_block_ids_ordered(&self) -> impl Iterator + '_ { - Bfs::new(&self.graph, self.entry_block().into()).iter(&self.graph) + pub fn basic_block_ids_ordered(&self) -> impl Iterator + '_ { + Bfs::new(&self.graph, self.entry_block().into()) + .iter(&self.graph) .map(|node| node.into()) } @@ -93,7 +114,6 @@ impl Cfg { &mut self.basic_blocks[id] } - pub fn entry_block(&self) -> BasicBlockId { self.entry_block.expect("Entry block has not been created") } @@ -104,16 +124,18 @@ impl Cfg { pub fn add_instruction(&mut self, id: BasicBlockId, ty: Type, instr: InstrKind) { let bb = self.basic_block_mut(id); - bb.append_instruction(ty,instr); + bb.append_instruction(ty, instr); } pub fn copy_reg_instr(&self, dest: VReg, reg: VReg) -> InstrKind { - self.copy_op_instr( - dest, - Op::Vreg(reg), - ) + self.copy_op_instr(dest, Op::Vreg(reg)) } - pub fn copy_op_to_temp_instr(&mut self, id: BasicBlockId, src_op: Op, src_ty: Type) -> (InstrKind, VReg) { + pub fn copy_op_to_temp_instr( + &mut self, + id: BasicBlockId, + src_op: Op, + src_ty: Type, + ) -> (InstrKind, VReg) { let dest = self.new_vreg(VRegData { defined_in: id, ty: src_ty.clone(), @@ -122,14 +144,11 @@ impl Cfg { (instr, dest) } - pub fn copy_op_instr(&self, dest: VReg, src_op: Op) -> InstrKind { - InstrKind::Op( - OpInstr { - op: src_op, - value: dest, - } - ) + InstrKind::Op(OpInstr { + op: src_op, + value: dest, + }) } pub fn set_terminator(&mut self, id: BasicBlockId, terminator: TerminatorKind) { @@ -139,22 +158,17 @@ impl Cfg { } fn set_edges_from_terminator(&mut self, id: BasicBlockId, terminator: &TerminatorKind) { - self.graph.retain_edges( - |graph, edge| { - graph.edge_endpoints(edge).unwrap().0 != id.into() - } - ); + self.graph + .retain_edges(|graph, edge| graph.edge_endpoints(edge).unwrap().0 != id.into()); match &terminator { - TerminatorKind::Branch(BranchTerm { - target, - }) => { + TerminatorKind::Branch(BranchTerm { target }) => { self.add_edge(id, target.id); } TerminatorKind::CondBranch(CondBranchTerm { - true_target, - false_target, - .. - }) => { + true_target, + false_target, + .. + }) => { self.add_edge(id, true_target.id); self.add_edge(id, false_target.id); } @@ -168,11 +182,16 @@ impl Cfg { self.graph.add_edge(source.into(), target.into(), ()); } - pub fn predecessors(&self, basic_block: BasicBlockId) -> impl Iterator + '_ { - self.graph.neighbors_directed(basic_block.into(), Incoming).map(|n| n.into()) + pub fn predecessors( + &self, + basic_block: BasicBlockId, + ) -> impl Iterator + '_ { + self.graph + .neighbors_directed(basic_block.into(), Incoming) + .map(|n| n.into()) } - pub fn successors(&self, basic_block: BasicBlockId) -> impl Iterator + '_ { + pub fn successors(&self, basic_block: BasicBlockId) -> impl Iterator + '_ { self.graph.neighbors(basic_block.into()).map(|n| n.into()) } @@ -201,15 +220,14 @@ impl Cfg { pub fn vreg(&self, vreg: VReg) -> &VRegData { &self.vregs[vreg] } - - pub fn dfs_postorder(&self) -> impl Iterator + '_ { + + pub fn dfs_postorder(&self) -> impl Iterator + '_ { DfsPostOrder::new(&self.graph, self.entry_block().into()) .iter(&self.graph) .map(|node| node.into()) } } - impl Display for Cfg { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { let indent = " "; @@ -248,10 +266,7 @@ mod cfg_tests { let bb1 = cfg.new_basic_block(); cfg.set_terminator(bb1, TerminatorKind::Ret(RetTerm::empty())); cfg.remove_basic_block(bb0); - assert_eq!( - cfg.basic_block_ids().collect::>(), - vec![bb1], - ); + assert_eq!(cfg.basic_block_ids().collect::>(), vec![bb1],); assert_eq!( cfg.basic_blocks().map(|(id, _)| id).collect::>(), vec![bb1], @@ -272,9 +287,7 @@ pub struct BasicBlock { } impl BasicBlock { - pub fn new( - id: BasicBlockId, - ) -> Self { + pub fn new(id: BasicBlockId) -> Self { Self { id, arguments: vec![], @@ -287,7 +300,9 @@ impl BasicBlock { /// /// Panics if the terminators is not set. pub fn terminator(&self) -> &Terminator { - self.terminator.as_ref().expect("Basic blocks must have a terminator") + self.terminator + .as_ref() + .expect("Basic blocks must have a terminator") } pub fn set_terminator(&mut self, term: Terminator) { @@ -305,7 +320,10 @@ impl BasicBlock { /// mean a change of the [`BasicBlock`]'s successors. /// /// *Panics*, if the basic block does not have a terminator yet. - pub fn update_terminator<'a, F, R>(&'a mut self, f: F) -> R where F: FnOnce(&'a mut Terminator) -> R + 'a { + pub fn update_terminator<'a, F, R>(&'a mut self, f: F) -> R + where + F: FnOnce(&'a mut Terminator) -> R + 'a, + { // todo: additional safety checks f(self.terminator.as_mut().unwrap()) } @@ -315,11 +333,11 @@ impl BasicBlock { self.terminator.is_some() } - pub fn arguments(&self) -> impl Iterator + '_ { + pub fn arguments(&self) -> impl Iterator + '_ { self.arguments.iter().copied() } - pub fn clear_arguments(&mut self) -> impl Iterator + '_ { + pub fn clear_arguments(&mut self) -> impl Iterator + '_ { self.arguments.drain(..) } @@ -332,16 +350,19 @@ impl BasicBlock { } /// Returns an iterator over the [`BasicBlock`]'s [`Instructions`][`Instr`]. - pub fn instructions(&self) -> impl DoubleEndedIterator { + pub fn instructions(&self) -> impl DoubleEndedIterator { self.instructions.iter() } /// Returns a mutable iterator over the [`BasicBlock`]'s [`Instructions`][`Instr`]. - pub fn instructions_mut(&mut self) -> impl DoubleEndedIterator { + pub fn instructions_mut(&mut self) -> impl DoubleEndedIterator { self.instructions.iter_mut() } - pub fn remove_instructions_by_pred

(&mut self, p: P) where P: FnMut(&Instr) -> bool { + pub fn remove_instructions_by_pred

(&mut self, p: P) + where + P: FnMut(&Instr) -> bool, + { self.instructions.retain(p) } @@ -349,7 +370,7 @@ impl BasicBlock { self.instructions.remove(id) } - pub fn append_instructions(&mut self, e_instructions: impl Iterator) { + pub fn append_instructions(&mut self, e_instructions: impl Iterator) { self.instructions.extend(e_instructions); } @@ -359,7 +380,6 @@ impl BasicBlock { let instr = Instr::new(ty, instr, self.id, instr_id); self.instructions.push(instr); } - } #[cfg(test)] @@ -367,10 +387,27 @@ mod bb_tests { use cranelift_entity::EntityRef; use index_vec::index_vec; - use crate::{Instr, InstrKind, Type, VReg}; - use crate::instruction::{Const, Op, OpInstr}; - - use super::{BranchTerm, Cfg, CondBranchTerm, InstrId, JumpTarget, RetTerm, Terminator, TerminatorKind}; + use super::{ + BranchTerm, + Cfg, + CondBranchTerm, + InstrId, + JumpTarget, + RetTerm, + Terminator, + TerminatorKind, + }; + use crate::{ + instruction::{ + Const, + Op, + OpInstr, + }, + Instr, + InstrKind, + Type, + VReg, + }; #[test] fn should_set_entry_block() { @@ -388,22 +425,19 @@ mod bb_tests { let bb2 = cfg.new_basic_block(); cfg.set_terminator(bb0, TerminatorKind::Ret(RetTerm::empty())); assert!(cfg.successors(bb0).eq(vec![].into_iter())); - cfg.set_terminator(bb0, TerminatorKind::Branch(BranchTerm::new(JumpTarget::new( - bb1, - vec![], - )))); + cfg.set_terminator( + bb0, + TerminatorKind::Branch(BranchTerm::new(JumpTarget::new(bb1, vec![]))), + ); assert!(cfg.successors(bb0).eq(vec![bb1].into_iter())); - cfg.set_terminator(bb0, TerminatorKind::CondBranch(CondBranchTerm::new( - Op::Const(Const::Int(Type::I32, 1)), - JumpTarget::new( - bb1, - vec![], - ), - JumpTarget::new( - bb2, - vec![], - ), - ))); + cfg.set_terminator( + bb0, + TerminatorKind::CondBranch(CondBranchTerm::new( + Op::Const(Const::Int(Type::I32, 1)), + JumpTarget::new(bb1, vec![]), + JumpTarget::new(bb2, vec![]), + )), + ); assert!(cfg.successors(bb0).eq(vec![bb2, bb1].into_iter())); } @@ -411,14 +445,15 @@ mod bb_tests { fn should_add_instruction() { let mut cfg = Cfg::new(); let bb0 = cfg.new_basic_block(); - let instr = InstrKind::Op(OpInstr { op: Op::Const(Const::Int(Type::I32, 3)), value: VReg::new(2) }); + let instr = InstrKind::Op(OpInstr { + op: Op::Const(Const::Int(Type::I32, 3)), + value: VReg::new(2), + }); cfg.add_instruction(bb0, Type::I32, instr.clone()); - assert_eq!(cfg.basic_block(bb0).instructions, index_vec![Instr::new( - Type::I32, - instr, - bb0, - InstrId::from_raw(0), - )]); + assert_eq!( + cfg.basic_block(bb0).instructions, + index_vec![Instr::new(Type::I32, instr, bb0, InstrId::from_raw(0),)] + ); } } @@ -433,7 +468,10 @@ impl Terminator { Self { kind, bb } } - pub fn clear_args<'a>(&'a mut self, target: BasicBlockId) -> Option + 'a> { + pub fn clear_args<'a>( + &'a mut self, + target: BasicBlockId, + ) -> Option + 'a> { match &mut self.kind { TerminatorKind::Ret(_) => None, TerminatorKind::Branch(branch_term) => { @@ -454,7 +492,7 @@ impl Terminator { } } - pub fn branch_args(&self, target: BasicBlockId) -> Option> { + pub fn branch_args(&self, target: BasicBlockId) -> Option> { match &self.kind { TerminatorKind::Ret(_) => None, TerminatorKind::Branch(branch_term) => { @@ -495,19 +533,18 @@ impl Terminator { pub fn used(&self) -> SmallVec<[&Op; 2]> { match &self.kind { - TerminatorKind::Ret(ret_term) => { - ret_term.value.as_ref().into_iter().collect() - } - TerminatorKind::Branch(branch_term) => { - branch_term.target.arguments.iter().collect() - } - TerminatorKind::CondBranch(condbr_term) => { - [&condbr_term.cond].into_iter().chain( - condbr_term.true_target.arguments.iter().chain( - condbr_term.false_target.arguments.iter() - ) - ).collect() - } + TerminatorKind::Ret(ret_term) => ret_term.value.as_ref().into_iter().collect(), + TerminatorKind::Branch(branch_term) => branch_term.target.arguments.iter().collect(), + TerminatorKind::CondBranch(condbr_term) => [&condbr_term.cond] + .into_iter() + .chain( + condbr_term + .true_target + .arguments + .iter() + .chain(condbr_term.false_target.arguments.iter()), + ) + .collect(), } } } @@ -526,7 +563,11 @@ impl Display for Terminator { write!(f, "br {}", branch.target)?; } TerminatorKind::CondBranch(branch) => { - write!(f, "condbr {}, {}, {}", branch.cond, branch.true_target, branch.false_target)?; + write!( + f, + "condbr {}, {}, {}", + branch.cond, branch.true_target, branch.false_target + )?; } } Ok(()) @@ -548,10 +589,16 @@ pub struct RetTerm { impl RetTerm { pub const fn new(ty: Type, value: Op) -> Self { - Self { value: Some(value), ty } + Self { + value: Some(value), + ty, + } } pub const fn empty() -> Self { - Self { value: None, ty: Type::Void } + Self { + value: None, + ty: Type::Void, + } } } @@ -563,10 +610,7 @@ pub struct JumpTarget { impl JumpTarget { pub fn new(id: BasicBlockId, arguments: Vec) -> Self { - Self { - id, - arguments, - } + Self { id, arguments } } pub fn no_args(id: BasicBlockId) -> Self { diff --git a/ir/crates/middle/src/front_bridge.rs b/ir/crates/middle/src/front_bridge.rs index 428b0bf..0766546 100644 --- a/ir/crates/middle/src/front_bridge.rs +++ b/ir/crates/middle/src/front_bridge.rs @@ -1,8 +1,31 @@ -use natrix_front::module::{Instruction, Literal, Operand, RegId}; +use natrix_front::module::{ + Instruction, + Literal, + Operand, + RegId, +}; -use crate::{cfg, Function, Module, Type, VReg}; -use crate::cfg::{BasicBlockId, BranchTerm, Builder, CondBranchTerm, JumpTarget, RetTerm, TerminatorKind}; -use crate::instruction::{CmpOp, Const, Op}; +use crate::{ + cfg, + cfg::{ + BasicBlockId, + BranchTerm, + Builder, + CondBranchTerm, + JumpTarget, + RetTerm, + TerminatorKind, + }, + instruction::{ + CmpOp, + Const, + Op, + }, + Function, + Module, + Type, + VReg, +}; pub struct FrontBridge {} @@ -21,9 +44,15 @@ impl FrontBridge { } fn bridge_function(&mut self, front_f: natrix_front::module::Function) -> Function { - let mut function = Function::new(front_f.name, front_f.args.into_iter().map( - |arg| arg.into() - ).collect::>(), front_f.ret_ty.into()); + let mut function = Function::new( + front_f.name, + front_f + .args + .into_iter() + .map(|arg| arg.into()) + .collect::>(), + front_f.ret_ty.into(), + ); let mut cfg_builder = cfg::Builder::new(&mut function); for basic_block in &front_f.basic_blocks { let bb_id = basic_block.id.into(); @@ -66,25 +95,15 @@ impl FrontBridge { let cond = self.operand_to_op(condition, Type::Bool); let true_target = self.map_target(true_target, &mut cfg_builder); let false_target = self.map_target(false_target, &mut cfg_builder); - cfg_builder.end_bb( - TerminatorKind::CondBranch( - CondBranchTerm::new( - cond, - true_target, - false_target, - ) - ) - ); + cfg_builder.end_bb(TerminatorKind::CondBranch(CondBranchTerm::new( + cond, + true_target, + false_target, + ))); } Instruction::Br(target) => { let target = self.map_target(target, &mut cfg_builder); - cfg_builder.end_bb( - TerminatorKind::Branch( - BranchTerm::new( - target - ) - ) - ); + cfg_builder.end_bb(TerminatorKind::Branch(BranchTerm::new(target))); } Instruction::ICmp(dest, op, ty, lhs, rhs) => { let lhs = self.operand_to_op(lhs, ty.into()); @@ -98,39 +117,45 @@ impl FrontBridge { function } - fn map_target(&mut self, target: natrix_front::module::Target, builder: &mut cfg::Builder) -> JumpTarget { + fn map_target( + &mut self, + target: natrix_front::module::Target, + builder: &mut cfg::Builder, + ) -> JumpTarget { let target_bb_id = target.0.into(); JumpTarget::new( target_bb_id, - target.1.map( - |args| { + target + .1 + .map(|args| { let bb_args = builder.get_bb_arguments(target_bb_id); - args.into_iter().enumerate().map( - |(i, arg_op)| { + args.into_iter() + .enumerate() + .map(|(i, arg_op)| { self.operand_to_op(arg_op, builder.vreg(bb_args[i]).ty.clone()) - } - ).collect::>() - } - ).unwrap_or_default(), + }) + .collect::>() + }) + .unwrap_or_default(), ) } fn ensure_bb_exists(builder: &mut Builder, bb_id: BasicBlockId) { - while builder.max_bb_id().map(|max_bb_id| max_bb_id < bb_id).unwrap_or(true) { + while builder + .max_bb_id() + .map(|max_bb_id| max_bb_id < bb_id) + .unwrap_or(true) + { builder.create_bb(); } } fn operand_to_op(&self, operand: Operand, context_ty: Type) -> Op { match operand { - Operand::Literal(literal) => { - Op::Const(match literal { - Literal::Int(value) => Const::Int(context_ty, value) - }) - } - Operand::Register(reg) => { - Op::Vreg(reg.into()) - } + Operand::Literal(literal) => Op::Const(match literal { + Literal::Int(value) => Const::Int(context_ty, value), + }), + Operand::Register(reg) => Op::Vreg(reg.into()), } } } diff --git a/ir/crates/middle/src/function.rs b/ir/crates/middle/src/function.rs index 9dd3e27..9974f82 100644 --- a/ir/crates/middle/src/function.rs +++ b/ir/crates/middle/src/function.rs @@ -1,11 +1,19 @@ -use std::fmt::{Display, Formatter}; - -use cranelift_entity::{entity_impl, PrimaryMap}; - -use crate::cfg::Cfg; -use crate::instruction::VRegData; -use crate::ty::Type; -use crate::VReg; +use std::fmt::{ + Display, + Formatter, +}; + +use cranelift_entity::{ + entity_impl, + PrimaryMap, +}; + +use crate::{ + cfg::Cfg, + instruction::VRegData, + ty::Type, + VReg, +}; #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] pub struct FunctionId(u32); @@ -21,7 +29,6 @@ pub struct Function { pub cfg: Cfg, } - impl Function { pub fn new(name: String, params: Vec, ret_ty: Type) -> Self { Self { @@ -31,7 +38,6 @@ impl Function { cfg: Cfg::new(), } } - } impl Display for Function { diff --git a/ir/crates/middle/src/instruction.rs b/ir/crates/middle/src/instruction.rs index 0c27366..6ebf485 100644 --- a/ir/crates/middle/src/instruction.rs +++ b/ir/crates/middle/src/instruction.rs @@ -1,11 +1,29 @@ -use std::fmt::{Display, Formatter}; -use std::ops::Sub; -use smallvec::{SmallVec, smallvec}; - -use strum_macros::{Display, EnumTryAs}; - -use crate::{Type, VReg}; -use crate::cfg::{BasicBlockId, Cfg, InstrId}; +use std::{ + fmt::{ + Display, + Formatter, + }, + ops::Sub, +}; + +use smallvec::{ + smallvec, + SmallVec, +}; +use strum_macros::{ + Display, + EnumTryAs, +}; + +use crate::{ + cfg::{ + BasicBlockId, + Cfg, + InstrId, + }, + Type, + VReg, +}; /// An instruction in a basic block. /// @@ -26,17 +44,15 @@ pub enum InstrIdentifyingKey { impl Instr { pub const fn new(ty: Type, kind: InstrKind, bb: BasicBlockId, id: InstrId) -> Self { - Self { - id, - bb, - ty, - kind, - } + Self { id, bb, ty, kind } } pub fn identifying_key(&self) -> Option { match &self.kind { - InstrKind::Sub(instr) => Some(InstrIdentifyingKey::Sub(instr.lhs.clone(), instr.rhs.clone())), + InstrKind::Sub(instr) => Some(InstrIdentifyingKey::Sub( + instr.lhs.clone(), + instr.rhs.clone(), + )), _ => None, } } @@ -56,7 +72,7 @@ impl Instr { InstrKind::Add(instr) => Some(instr.value), } } - + pub fn used(&self) -> SmallVec<[&Op; 2]> { match &self.kind { InstrKind::Alloca(_) => smallvec![], @@ -81,10 +97,18 @@ impl Display for InstrDisplay<'_> { } } InstrKind::Sub(instr) => { - write!(f, "{} = sub {} {}, {}", instr.value, self.1.ty, instr.lhs, instr.rhs)?; + write!( + f, + "{} = sub {} {}, {}", + instr.value, self.1.ty, instr.lhs, instr.rhs + )?; } InstrKind::Add(instr) => { - write!(f, "{} = add {} {}, {}", instr.value, self.1.ty, instr.lhs, instr.rhs)?; + write!( + f, + "{} = add {} {}, {}", + instr.value, self.1.ty, instr.lhs, instr.rhs + )?; } InstrKind::Op(instr) => { write!(f, "{} = {} {}", instr.value, self.1.ty, instr.op)?; @@ -93,10 +117,18 @@ impl Display for InstrDisplay<'_> { write!(f, "store {} {}, ptr {}", self.1.ty, instr.value, instr.dest)?; } InstrKind::Load(instr) => { - write!(f, "{} = load {} ptr {}", instr.dest, self.1.ty, instr.source)?; + write!( + f, + "{} = load {} ptr {}", + instr.dest, self.1.ty, instr.source + )?; } InstrKind::Cmp(instr) => { - write!(f, "{} = icmp {} {} {}, {}", instr.value, self.1.ty, instr.op, instr.lhs, instr.rhs)?; + write!( + f, + "{} = icmp {} {} {}, {}", + instr.value, self.1.ty, instr.op, instr.lhs, instr.rhs + )?; } }; Ok(()) @@ -120,7 +152,6 @@ pub enum InstrKind { Cmp(CmpInstr), } - #[derive(Debug, Clone, Eq, PartialEq)] pub struct AllocaInstr { pub value: VReg, @@ -161,7 +192,6 @@ pub struct OpInstr { pub op: Op, } - #[derive(Debug, Clone, Eq, PartialEq, Hash, EnumTryAs)] pub enum Op { Const(Const), @@ -178,9 +208,7 @@ impl Op { pub fn referenced_value(&self) -> Option { match self { Op::Const(_) => None, - Op::Vreg(value) => { - Some(*value) - } + Op::Vreg(value) => Some(*value), } } } @@ -194,7 +222,6 @@ impl Display for Op { } } - #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum Const { Int(Type, i64), @@ -239,7 +266,7 @@ impl Const { impl Display for Const { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { - Self::Int(_,value) => write!(f, "{}", value), + Self::Int(_, value) => write!(f, "{}", value), } } } @@ -265,22 +292,33 @@ pub enum CmpOp { // Sge, } - #[cfg(test)] mod tests { mod instruction_type { - use crate::cfg; - use crate::cfg::{RetTerm, TerminatorKind}; - use crate::instruction::{Const, Op}; - use crate::test::create_test_function; - use crate::ty::Type; + use crate::{ + cfg, + cfg::{ + RetTerm, + TerminatorKind, + }, + instruction::{ + Const, + Op, + }, + test::create_test_function, + ty::Type, + }; #[test] fn test_sub_instruction_type() { let mut function = create_test_function(); let mut cfg_builder = cfg::Builder::new(&mut function); cfg_builder.start_bb(); - let vreg = cfg_builder.sub(Type::I8, Op::Const(Const::Int(Type::I8, 0)), Op::Const(Const::Int(Type::I8, 1))); + let vreg = cfg_builder.sub( + Type::I8, + Op::Const(Const::Int(Type::I8, 0)), + Op::Const(Const::Int(Type::I8, 1)), + ); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); assert_eq!(function.cfg.vreg_ty(vreg).clone(), Type::I8); } @@ -292,7 +330,10 @@ mod tests { cfg_builder.start_bb(); let alloca_value = cfg_builder.alloca(Type::I8, None); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); - assert_eq!(function.cfg.vreg_ty(alloca_value).clone(), Type::Ptr(Box::new(Type::I8))); + assert_eq!( + function.cfg.vreg_ty(alloca_value).clone(), + Type::Ptr(Box::new(Type::I8)) + ); } #[test] @@ -313,7 +354,10 @@ mod tests { let alloca_value = cfg_builder.alloca(Type::I8, None); cfg_builder.store(Type::I8, alloca_value, Op::Const(Const::Int(Type::I8, 0))); cfg_builder.end_bb(TerminatorKind::Ret(RetTerm::empty())); - assert_eq!(function.cfg.basic_block(bb).instructions[1].defined_vreg(), None); + assert_eq!( + function.cfg.basic_block(bb).instructions[1].defined_vreg(), + None + ); } #[test] diff --git a/ir/crates/middle/src/lib.rs b/ir/crates/middle/src/lib.rs index fcb1de7..6f767e8 100644 --- a/ir/crates/middle/src/lib.rs +++ b/ir/crates/middle/src/lib.rs @@ -3,8 +3,14 @@ use cranelift_entity::entity_impl; pub use front_bridge::FrontBridge; -pub use function::{Function, FunctionId}; -pub use instruction::{Instr, InstrKind}; +pub use function::{ + Function, + FunctionId, +}; +pub use instruction::{ + Instr, + InstrKind, +}; pub use module::Module; pub use ty::Type; @@ -16,12 +22,11 @@ pub struct VReg(u32); entity_impl!(VReg, "v"); pub mod instruction; -pub mod optimization; pub mod module; +pub mod optimization; mod analysis; +mod front_bridge; #[cfg(test)] pub mod test; pub mod ty; -mod front_bridge; - diff --git a/ir/crates/middle/src/module.rs b/ir/crates/middle/src/module.rs index 34d4ec4..810af27 100644 --- a/ir/crates/middle/src/module.rs +++ b/ir/crates/middle/src/module.rs @@ -1,11 +1,24 @@ -use std::fmt::{Display, Formatter}; -use std::time::Instant; -use cranelift_entity::PrimaryMap; +use std::{ + fmt::{ + Display, + Formatter, + }, + time::Instant, +}; -use tracing::{debug, info}; +use cranelift_entity::PrimaryMap; +use tracing::{ + debug, + info, +}; -use crate::{Function, FunctionId, Instr, optimization}; -use crate::optimization::PipelineConfig; +use crate::{ + optimization, + optimization::PipelineConfig, + Function, + FunctionId, + Instr, +}; #[derive(Debug, Clone, Default)] pub struct Module { @@ -14,9 +27,9 @@ pub struct Module { impl Module { pub fn find_function_by_name(&self, name: &str) -> Option<&Function> { - self.functions.values().find( - |function| function.name == name - ) + self.functions + .values() + .find(|function| function.name == name) } pub fn optimize(&mut self, config: PipelineConfig) { diff --git a/ir/crates/middle/src/optimization/basic_block_pass/constant_fold.rs b/ir/crates/middle/src/optimization/basic_block_pass/constant_fold.rs index ce17263..ac257e0 100644 --- a/ir/crates/middle/src/optimization/basic_block_pass/constant_fold.rs +++ b/ir/crates/middle/src/optimization/basic_block_pass/constant_fold.rs @@ -1,12 +1,26 @@ use rustc_hash::FxHashMap; use tracing::debug; -use crate::{FunctionId, VReg}; -use crate::cfg::{BasicBlockId, TerminatorKind}; -use crate::instruction::{Const, CmpOp, InstrKind, Op, OpInstr}; -use crate::module::Module; -use crate::optimization::basic_block_pass::BasicBlockPass; -use crate::optimization::Pass; +use crate::{ + cfg::{ + BasicBlockId, + TerminatorKind, + }, + instruction::{ + CmpOp, + Const, + InstrKind, + Op, + OpInstr, + }, + module::Module, + optimization::{ + basic_block_pass::BasicBlockPass, + Pass, + }, + FunctionId, + VReg, +}; pub struct ConstantFoldPass {} @@ -17,7 +31,12 @@ impl Pass for ConstantFoldPass { } impl BasicBlockPass for ConstantFoldPass { - fn run_on_basic_block(&mut self, module: &mut Module, function: FunctionId, basic_block_id: BasicBlockId) -> usize { + fn run_on_basic_block( + &mut self, + module: &mut Module, + function: FunctionId, + basic_block_id: BasicBlockId, + ) -> usize { let cfg = &mut module.functions[function].cfg; let bb = cfg.basic_block_mut(basic_block_id); let mut changes = 0; @@ -32,9 +51,12 @@ impl BasicBlockPass for ConstantFoldPass { if Self::try_replace_op(&constant_values, &mut sub_instr.rhs) { changes += 1; } - if let Some(const_val) = Self::eval_binary_instr(&constant_values, &sub_instr.lhs, &sub_instr.rhs, |lhs, rhs| { - lhs.sub(rhs).unwrap() - }) { + if let Some(const_val) = Self::eval_binary_instr( + &constant_values, + &sub_instr.lhs, + &sub_instr.rhs, + |lhs, rhs| lhs.sub(rhs).unwrap(), + ) { instr.kind = InstrKind::Op(OpInstr { value: sub_instr.value, op: Op::Const(const_val), @@ -49,9 +71,12 @@ impl BasicBlockPass for ConstantFoldPass { if Self::try_replace_op(&constant_values, &mut add_instr.rhs) { changes += 1; } - if let Some(const_val) = Self::eval_binary_instr(&constant_values, &add_instr.lhs, &add_instr.rhs, |lhs, rhs| { - lhs.add(rhs).unwrap() - }) { + if let Some(const_val) = Self::eval_binary_instr( + &constant_values, + &add_instr.lhs, + &add_instr.rhs, + |lhs, rhs| lhs.add(rhs).unwrap(), + ) { instr.kind = InstrKind::Op(OpInstr { value: add_instr.value, op: Op::Const(const_val), @@ -66,11 +91,14 @@ impl BasicBlockPass for ConstantFoldPass { None } Op::Vreg(place) => { - constant_values.get(place).cloned().and_then(|constant_value| { - constant_values.insert(*place, constant_value.clone()); - changes += 1; - Some(Op::Const(constant_value)) - }) + constant_values + .get(place) + .cloned() + .and_then(|constant_value| { + constant_values.insert(*place, constant_value.clone()); + changes += 1; + Some(Op::Const(constant_value)) + }) } }; if let Some(updated_op) = updated_op { @@ -94,9 +122,12 @@ impl BasicBlockPass for ConstantFoldPass { if Self::try_replace_op(&constant_values, &mut icmp_instr.rhs) { changes += 1; } - if let Some(const_val) = Self::eval_binary_instr(&constant_values, &icmp_instr.lhs, &icmp_instr.rhs, |lhs, rhs| { - lhs.cmp(rhs, CmpOp::from(icmp_instr.op)).unwrap() - }) { + if let Some(const_val) = Self::eval_binary_instr( + &constant_values, + &icmp_instr.lhs, + &icmp_instr.rhs, + |lhs, rhs| lhs.cmp(rhs, CmpOp::from(icmp_instr.op)).unwrap(), + ) { instr.kind = InstrKind::Op(OpInstr { value: icmp_instr.value, op: Op::Const(const_val), @@ -106,28 +137,26 @@ impl BasicBlockPass for ConstantFoldPass { } } } - bb.update_terminator(|terminator| { - match &mut terminator.kind { - TerminatorKind::Ret(ret_term) => { - if let Some(ret_value) = &mut ret_term.value { - match ret_value { - Op::Const(_) => {} - Op::Vreg(value) => { - if let Some(constant_value) = constant_values.get(value) { - changes += 1; - *ret_value = Op::Const(constant_value.clone()); - } + bb.update_terminator(|terminator| match &mut terminator.kind { + TerminatorKind::Ret(ret_term) => { + if let Some(ret_value) = &mut ret_term.value { + match ret_value { + Op::Const(_) => {} + Op::Vreg(value) => { + if let Some(constant_value) = constant_values.get(value) { + changes += 1; + *ret_value = Op::Const(constant_value.clone()); } } } } - TerminatorKind::CondBranch(cond_branch) => { - if Self::try_replace_op(&constant_values, &mut cond_branch.cond) { - changes += 1; - } + } + TerminatorKind::CondBranch(cond_branch) => { + if Self::try_replace_op(&constant_values, &mut cond_branch.cond) { + changes += 1; } - TerminatorKind::Branch(_) => {} } + TerminatorKind::Branch(_) => {} }); changes } @@ -152,7 +181,15 @@ impl ConstantFoldPass { false } - fn eval_binary_instr(constant_values: &FxHashMap, lhs: &Op, rhs: &Op, eval: E) -> Option where E: FnOnce(Const, Const) -> Const { + fn eval_binary_instr( + constant_values: &FxHashMap, + lhs: &Op, + rhs: &Op, + eval: E, + ) -> Option + where + E: FnOnce(Const, Const) -> Const, + { let left_const = Self::op_to_const(constant_values, lhs); let right_const = Self::op_to_const(constant_values, rhs); if let (Some(left_const), Some(right_const)) = (left_const, right_const) { @@ -164,9 +201,14 @@ impl ConstantFoldPass { #[cfg(test)] mod tests { - use crate::cfg; - use crate::optimization::PipelineConfig; - use crate::test::{assert_module_is_equal_to_src, create_test_module_from_source}; + use crate::{ + cfg, + optimization::PipelineConfig, + test::{ + assert_module_is_equal_to_src, + create_test_module_from_source, + }, + }; #[test] fn should_compute_subtraction() { @@ -178,7 +220,7 @@ mod tests { v1 = sub i32 v0, 7; ret i32 v1; } - " + ", ); module.optimize(PipelineConfig::all_disabled()); let function = module.find_function_by_name("test").unwrap(); @@ -204,7 +246,7 @@ bb0: v1 = add i32 v0, 7; ret i32 v1; } - " + ", ); module.optimize(PipelineConfig::all_disabled()); assert_module_is_equal_to_src( @@ -229,7 +271,7 @@ bb0: v2 = add i32 v0, v1; ret i32 v2; } - " + ", ); module.optimize(PipelineConfig::all_disabled()); let function = module.find_function_by_name("test").unwrap(); diff --git a/ir/crates/middle/src/optimization/basic_block_pass/copy_propagation.rs b/ir/crates/middle/src/optimization/basic_block_pass/copy_propagation.rs index 16a6b26..a94f6aa 100644 --- a/ir/crates/middle/src/optimization/basic_block_pass/copy_propagation.rs +++ b/ir/crates/middle/src/optimization/basic_block_pass/copy_propagation.rs @@ -1,15 +1,26 @@ use rustc_hash::FxHashMap; -use crate::{FunctionId, VReg}; -use crate::cfg::{BasicBlockId, TerminatorKind}; -use crate::instruction::{InstrKind, Op}; -use crate::module::Module; -use crate::optimization::basic_block_pass::BasicBlockPass; -use crate::optimization::Pass; +use crate::{ + cfg::{ + BasicBlockId, + TerminatorKind, + }, + instruction::{ + InstrKind, + Op, + }, + module::Module, + optimization::{ + basic_block_pass::BasicBlockPass, + Pass, + }, + FunctionId, + VReg, +}; #[derive(Debug, Clone, Eq, PartialEq, Default)] struct CopyGraph { - edges: FxHashMap + edges: FxHashMap, } impl CopyGraph { @@ -36,7 +47,12 @@ impl Pass for CopyPropagationPass { } impl BasicBlockPass for CopyPropagationPass { - fn run_on_basic_block(&mut self, module: &mut Module, function: FunctionId, basic_block: BasicBlockId) -> usize { + fn run_on_basic_block( + &mut self, + module: &mut Module, + function: FunctionId, + basic_block: BasicBlockId, + ) -> usize { let cfg = &mut module.functions[function].cfg; let bb = cfg.basic_block_mut(basic_block); let mut changes = 0; @@ -45,53 +61,67 @@ impl BasicBlockPass for CopyPropagationPass { match &mut instr.kind { InstrKind::Alloca(_) => {} InstrKind::Store(store_instr) => { - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, &mut store_instr.value)); + changes += usize::from(Self::apply_copy_graph_to_op( + ©_graph, + &mut store_instr.value, + )); } InstrKind::Load(_) => {} - InstrKind::Op(op_instr) => { - match &op_instr.op { - Op::Const(_) => {} - Op::Vreg(value) => { - copy_graph.insert_copy(*value, op_instr.value); - } - } - } + InstrKind::Op(op_instr) => match &op_instr.op { + Op::Const(_) => {} + Op::Vreg(value) => { + copy_graph.insert_copy(*value, op_instr.value); + } + }, InstrKind::Sub(sub_instr) => { - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, &mut sub_instr.lhs)); - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, &mut sub_instr.rhs)); + changes += usize::from(Self::apply_copy_graph_to_op( + ©_graph, + &mut sub_instr.lhs, + )); + changes += usize::from(Self::apply_copy_graph_to_op( + ©_graph, + &mut sub_instr.rhs, + )); } InstrKind::Add(add_instr) => { - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, &mut add_instr.lhs)); - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, &mut add_instr.rhs)); + changes += usize::from(Self::apply_copy_graph_to_op( + ©_graph, + &mut add_instr.lhs, + )); + changes += usize::from(Self::apply_copy_graph_to_op( + ©_graph, + &mut add_instr.rhs, + )); } InstrKind::Cmp(instr) => { - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, &mut instr.lhs)); - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, &mut instr.rhs)); + changes += + usize::from(Self::apply_copy_graph_to_op(©_graph, &mut instr.lhs)); + changes += + usize::from(Self::apply_copy_graph_to_op(©_graph, &mut instr.rhs)); } } } - bb.update_terminator(|terminator| { - match &mut terminator.kind { - TerminatorKind::Ret(ret_term) => { - if let Some(value) = &mut ret_term.value { - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, value)); - } - } - TerminatorKind::CondBranch(cond_branch) => { - changes += usize::from(Self::apply_copy_graph_to_op(©_graph, &mut cond_branch.cond)) - } - TerminatorKind::Branch(_) => { - - } - } + bb.update_terminator(|terminator| match &mut terminator.kind { + TerminatorKind::Ret(ret_term) => { + if let Some(value) = &mut ret_term.value { + changes += usize::from(Self::apply_copy_graph_to_op(©_graph, value)); + } + } + TerminatorKind::CondBranch(cond_branch) => { + changes += usize::from(Self::apply_copy_graph_to_op( + ©_graph, + &mut cond_branch.cond, + )) + } + TerminatorKind::Branch(_) => {} }); changes } } impl CopyPropagationPass { - fn apply_copy_graph_to_op(copy_graph: &CopyGraph, op: &mut Op) -> bool{ + fn apply_copy_graph_to_op(copy_graph: &CopyGraph, op: &mut Op) -> bool { match op { Op::Const(_) => false, Op::Vreg(value) => { @@ -109,8 +139,10 @@ impl CopyPropagationPass { #[cfg(test)] mod tests { - use crate::optimization::PipelineConfig; - use crate::test::create_test_module_from_source; + use crate::{ + optimization::PipelineConfig, + test::create_test_module_from_source, + }; #[test] fn should_propagate_copies() { @@ -124,7 +156,7 @@ mod tests { v4 = sub i32 v2, v3; ret i32 v4; } - " + ", ); module.optimize(PipelineConfig::copy_propagation_only()); let function = module.find_function_by_name("test").unwrap(); diff --git a/ir/crates/middle/src/optimization/basic_block_pass/cse.rs b/ir/crates/middle/src/optimization/basic_block_pass/cse.rs index ac53e75..83cd840 100644 --- a/ir/crates/middle/src/optimization/basic_block_pass/cse.rs +++ b/ir/crates/middle/src/optimization/basic_block_pass/cse.rs @@ -1,11 +1,21 @@ use rustc_hash::FxHashMap; -use crate::{FunctionId, VReg}; -use crate::cfg::BasicBlockId; -use crate::instruction::{InstrIdentifyingKey, InstrKind, Op, OpInstr}; -use crate::module::Module; -use crate::optimization::basic_block_pass::BasicBlockPass; -use crate::optimization::Pass; +use crate::{ + cfg::BasicBlockId, + instruction::{ + InstrIdentifyingKey, + InstrKind, + Op, + OpInstr, + }, + module::Module, + optimization::{ + basic_block_pass::BasicBlockPass, + Pass, + }, + FunctionId, + VReg, +}; /// # Common Subexpression Elimination /// @@ -20,7 +30,12 @@ impl Pass for CSEPass { } impl BasicBlockPass for CSEPass { - fn run_on_basic_block(&mut self, module: &mut Module, function: FunctionId, basic_block: BasicBlockId) -> usize { + fn run_on_basic_block( + &mut self, + module: &mut Module, + function: FunctionId, + basic_block: BasicBlockId, + ) -> usize { let cfg = &mut module.functions[function].cfg; let bb = cfg.basic_block_mut(basic_block); let mut changes = 0; @@ -49,11 +64,26 @@ impl BasicBlockPass for CSEPass { #[cfg(test)] mod tests { - use crate::{cfg, optimization}; - use crate::cfg::{RetTerm, TerminatorKind}; - use crate::instruction::{Const, Op}; - use crate::optimization::{Pipeline, PipelineConfig}; - use crate::test::{create_test_module, create_test_module_from_source}; + use crate::{ + cfg, + cfg::{ + RetTerm, + TerminatorKind, + }, + instruction::{ + Const, + Op, + }, + optimization, + optimization::{ + Pipeline, + PipelineConfig, + }, + test::{ + create_test_module, + create_test_module_from_source, + }, + }; #[test] fn should_replace_duplicate_subtraction() { @@ -66,17 +96,20 @@ mod tests { v3 = sub i32 v2, v1; ret i32 v3; } - " + ", ); module.optimize(PipelineConfig::cse_only()); let function = module.find_function_by_name("test").unwrap(); - assert_eq!("fun i32 @test(i32) { + assert_eq!( + "fun i32 @test(i32) { bb0(i32 v0): v1 = sub i32 v0, 3; v2 = i32 v1; v3 = sub i32 v2, v1; ret i32 v3; } -", function.to_string()); +", + function.to_string() + ); } } diff --git a/ir/crates/middle/src/optimization/basic_block_pass/mod.rs b/ir/crates/middle/src/optimization/basic_block_pass/mod.rs index ec9e0da..c87b371 100644 --- a/ir/crates/middle/src/optimization/basic_block_pass/mod.rs +++ b/ir/crates/middle/src/optimization/basic_block_pass/mod.rs @@ -1,22 +1,36 @@ -use crate::optimization::{FunctionPass, Pass}; -use crate::cfg::BasicBlockId; -use crate::FunctionId; -use crate::module::Module; +use crate::{ + cfg::BasicBlockId, + module::Module, + optimization::{ + FunctionPass, + Pass, + }, + FunctionId, +}; pub mod constant_fold; -pub mod cse; pub mod copy_propagation; +pub mod cse; pub trait BasicBlockPass: Pass { - fn run_on_basic_block(&mut self, module: &mut Module, function: FunctionId, basic_block: BasicBlockId) -> usize; + fn run_on_basic_block( + &mut self, + module: &mut Module, + function: FunctionId, + basic_block: BasicBlockId, + ) -> usize; } impl FunctionPass for T - where T: BasicBlockPass +where + T: BasicBlockPass, { fn run_on_function(&mut self, module: &mut Module, function: FunctionId) -> usize { let mut changes = 0; - let basic_blocks = module.functions[function].cfg.basic_block_ids().collect::>(); + let basic_blocks = module.functions[function] + .cfg + .basic_block_ids() + .collect::>(); for basic_block in basic_blocks { changes += self.run_on_basic_block(module, function, basic_block); } diff --git a/ir/crates/middle/src/optimization/function_pass/cfg_simplify/bb_merge.rs b/ir/crates/middle/src/optimization/function_pass/cfg_simplify/bb_merge.rs index db7c161..461e821 100644 --- a/ir/crates/middle/src/optimization/function_pass/cfg_simplify/bb_merge.rs +++ b/ir/crates/middle/src/optimization/function_pass/cfg_simplify/bb_merge.rs @@ -1,7 +1,10 @@ use tracing::debug; -use crate::FunctionId; -use crate::module::Module; -use crate::optimization::FunctionPass; + +use crate::{ + module::Module, + optimization::FunctionPass, + FunctionId, +}; /// # Basic block merge /// @@ -67,8 +70,6 @@ use crate::optimization::FunctionPass; /// This pass needs to recompute the dominator tree for every merge operation. /// /// Therefore, it is relatively expensive to run. -/// -/// #[derive(Default)] pub struct Pass {} @@ -89,14 +90,16 @@ impl FunctionPass for Pass { continue; } let domtree = cfg.dom_tree(); - let Some(a_id) = domtree.idom(b_id) else { continue; }; + let Some(a_id) = domtree.idom(b_id) else { + continue; + }; if cfg.successors(a_id).count() != 1 { continue; } debug!("Merging {b_id} into {a_id}"); let (instructions, b_term) = cfg.remove_basic_block(b_id); let a = cfg.basic_block_mut(a_id); - a.append_instructions(instructions.into_iter()); + a.append_instructions(instructions.into_iter()); a.update_terminator(|term| *term = b_term); cfg.recompute_successors(a_id); merged += 1; @@ -108,14 +111,22 @@ impl FunctionPass for Pass { #[cfg(test)] mod tests { - use crate::cfg; - use crate::optimization::CFGSimplifyPipelineConfig; - use crate::optimization::PipelineConfig; - use crate::test::{assert_module_is_equal_to_src, create_test_module_from_source}; + use crate::{ + cfg, + optimization::{ + CFGSimplifyPipelineConfig, + PipelineConfig, + }, + test::{ + assert_module_is_equal_to_src, + create_test_module_from_source, + }, + }; #[test] fn should_merge_in_more_complex_cfg() { - let mut module = create_test_module_from_source(" + let mut module = create_test_module_from_source( + " fun void @test() { bb0: v0 = bool 1; @@ -136,10 +147,15 @@ mod tests { v5 = add i32 9, 10; ret void; } -"); +", + ); dbg!(module.to_string()); - module.optimize(PipelineConfig::cfg_simplify_only(CFGSimplifyPipelineConfig::bb_merge_only())); - assert_module_is_equal_to_src(&module, " + module.optimize(PipelineConfig::cfg_simplify_only( + CFGSimplifyPipelineConfig::bb_merge_only(), + )); + assert_module_is_equal_to_src( + &module, + " fun void @test() { bb0: v0 = bool 1; @@ -156,7 +172,7 @@ mod tests { v5 = i32 19; ret void; } -", ); +", + ); } } - diff --git a/ir/crates/middle/src/optimization/function_pass/cfg_simplify/jump_threading.rs b/ir/crates/middle/src/optimization/function_pass/cfg_simplify/jump_threading.rs index d60dac8..8c0007a 100644 --- a/ir/crates/middle/src/optimization/function_pass/cfg_simplify/jump_threading.rs +++ b/ir/crates/middle/src/optimization/function_pass/cfg_simplify/jump_threading.rs @@ -1,9 +1,19 @@ use tracing::debug; -use crate::cfg::{BasicBlockId, BranchTerm, TerminatorKind}; -use crate::FunctionId; -use crate::instruction::{Const, Op}; -use crate::module::Module; -use crate::optimization::basic_block_pass; + +use crate::{ + cfg::{ + BasicBlockId, + BranchTerm, + TerminatorKind, + }, + instruction::{ + Const, + Op, + }, + module::Module, + optimization::basic_block_pass, + FunctionId, +}; /// # Jump threading optimization pass /// @@ -24,9 +34,9 @@ use crate::optimization::basic_block_pass; /// 5. Depending on the constant, we choose the new jump target and replace the conditional branch with an unconditional branch /// 6. Update the successors of the basic block - this is currently implemented by just recomputing the successors, /// but could be optimized as we know the exact successors after the optimization -/// +/// /// ## Example -/// +/// /// ```text /// fun @test() { /// bb0: @@ -37,7 +47,7 @@ use crate::optimization::basic_block_pass; /// ret /// } /// ``` -/// +/// /// After the optimization, the function will look like this: /// /// ```text @@ -50,11 +60,10 @@ use crate::optimization::basic_block_pass; /// ret /// } /// ``` -/// -/// ## Costs of this pass /// -/// This optimization only needs to check the terminator of the basic block and therefore is relatively cheap to run. +/// ## Costs of this pass /// +/// This optimization only needs to check the terminator of the basic block and therefore is relatively cheap to run. #[derive(Default)] pub struct Pass {} @@ -65,7 +74,12 @@ impl crate::optimization::Pass for Pass { } impl basic_block_pass::BasicBlockPass for Pass { - fn run_on_basic_block(&mut self, module: &mut Module, function: FunctionId, basic_block: BasicBlockId) -> usize { + fn run_on_basic_block( + &mut self, + module: &mut Module, + function: FunctionId, + basic_block: BasicBlockId, + ) -> usize { let cfg = &mut module.functions[function].cfg; let bb = cfg.basic_block_mut(basic_block); let changes = bb.update_terminator(|term| { @@ -93,7 +107,7 @@ impl basic_block_pass::BasicBlockPass for Pass { } }); // Only recompute successors if we have changed anything as - // recompute_successors does not check whether any updates have occurred + // recompute_successors does not check whether any updates have occurred if changes > 0 { cfg.recompute_successors(basic_block); } diff --git a/ir/crates/middle/src/optimization/function_pass/cfg_simplify/mod.rs b/ir/crates/middle/src/optimization/function_pass/cfg_simplify/mod.rs index 31f9b60..5eda9df 100644 --- a/ir/crates/middle/src/optimization/function_pass/cfg_simplify/mod.rs +++ b/ir/crates/middle/src/optimization/function_pass/cfg_simplify/mod.rs @@ -1,9 +1,14 @@ -use crate::FunctionId; -use crate::module::Module; -use crate::optimization::{CFGSimplifyPipelineConfig, FunctionPass}; +use crate::{ + module::Module, + optimization::{ + CFGSimplifyPipelineConfig, + FunctionPass, + }, + FunctionId, +}; -mod jump_threading; mod bb_merge; +mod jump_threading; mod unreachable_bb_elim; pub struct Pass { @@ -50,9 +55,18 @@ impl FunctionPass for Pass { #[cfg(test)] mod tests { use tracing_test::traced_test; - use crate::cfg; - use crate::optimization::{CFGSimplifyPipelineConfig, PipelineConfig}; - use crate::test::{assert_module_is_equal_to_src, create_test_module_from_source}; + + use crate::{ + cfg, + optimization::{ + CFGSimplifyPipelineConfig, + PipelineConfig, + }, + test::{ + assert_module_is_equal_to_src, + create_test_module_from_source, + }, + }; #[test] #[traced_test] @@ -67,16 +81,18 @@ mod tests { bb2: ret i32 v0; } - " + ", ); - module.optimize(PipelineConfig::cfg_simplify_only(CFGSimplifyPipelineConfig::o3())); + module.optimize(PipelineConfig::cfg_simplify_only( + CFGSimplifyPipelineConfig::o3(), + )); assert_module_is_equal_to_src( &module, "fun i32 @test(i32) { bb0(i32 v0): ret i32 v0; } - " + ", ) } } diff --git a/ir/crates/middle/src/optimization/function_pass/cfg_simplify/unreachable_bb_elim.rs b/ir/crates/middle/src/optimization/function_pass/cfg_simplify/unreachable_bb_elim.rs index 445cb03..3f6a621 100644 --- a/ir/crates/middle/src/optimization/function_pass/cfg_simplify/unreachable_bb_elim.rs +++ b/ir/crates/middle/src/optimization/function_pass/cfg_simplify/unreachable_bb_elim.rs @@ -1,8 +1,18 @@ -use tracing::{debug, trace}; -use crate::{FunctionId, Instr}; -use crate::instruction::{InstrKind, OpInstr}; -use crate::module::Module; -use crate::optimization::function_pass::FunctionPass; +use tracing::{ + debug, + trace, +}; + +use crate::{ + instruction::{ + InstrKind, + OpInstr, + }, + module::Module, + optimization::function_pass::FunctionPass, + FunctionId, + Instr, +}; /// # Unreachable Basic Block Elimination /// @@ -53,7 +63,6 @@ use crate::optimization::function_pass::FunctionPass; /// ## Costs of this pass /// /// This pass needs to compute the [DomTree][`crate::cfg::DomTree`] for the function, which has a time complexity of O(n^2). -/// #[derive(Default)] pub struct Pass {} @@ -78,7 +87,11 @@ impl FunctionPass for Pass { if unreachable_bbs.is_empty() { return 0; } - trace!("Removing {} unreachable basic blocks: {:?}", unreachable_bbs.len(), unreachable_bbs); + trace!( + "Removing {} unreachable basic blocks: {:?}", + unreachable_bbs.len(), + unreachable_bbs + ); let removed = unreachable_bbs.len(); for bb in unreachable_bbs { // Remove the unreachable block from the cfg @@ -90,7 +103,9 @@ impl FunctionPass for Pass { // This is the case if the successor now only has one predecessor let pred_id = { let mut preds = function.cfg.predecessors(successor_id); - let Some(pred_id) = preds.next() else { continue; }; + let Some(pred_id) = preds.next() else { + continue; + }; if preds.next().is_some() { continue; } @@ -99,24 +114,31 @@ impl FunctionPass for Pass { debug!("Removing jump target argument list from {pred_id}"); // Clear the jump target argument list of the predecessor let pred = function.cfg.basic_block_mut(pred_id); - let Some(branch_args) = pred.update_terminator(|terminator| { - terminator.clear_args(successor_id) - }) else { + let Some(branch_args) = + pred.update_terminator(|terminator| terminator.clear_args(successor_id)) + else { continue; }; debug!("Removing basic block arguments from {successor_id}"); let branch_args = branch_args.collect::>(); // Remove the basic block arguments from the successor - let successors_args = function.cfg.basic_block_mut(successor_id).clear_arguments().collect::>(); + let successors_args = function + .cfg + .basic_block_mut(successor_id) + .clear_arguments() + .collect::>(); for (argument, op) in successors_args.into_iter().zip(branch_args) { let ty = function.cfg.vreg_ty_cloned(argument); // To keep the program consistent, we need to insert move instruction for each argument // They look like this: // = - function.cfg.basic_block_mut(pred_id).append_instruction(ty, InstrKind::Op(OpInstr { - value: argument, - op, - })); + function.cfg.basic_block_mut(pred_id).append_instruction( + ty, + InstrKind::Op(OpInstr { + value: argument, + op, + }), + ); } } } @@ -127,15 +149,25 @@ impl FunctionPass for Pass { #[cfg(test)] mod tests { use tracing_test::traced_test; - use crate::cfg; - use crate::optimization::{CFGSimplifyPipelineConfig, Pipeline}; - use crate::optimization::PipelineConfig; - use crate::test::{assert_module_is_equal_to_src, create_test_module_from_source}; + + use crate::{ + cfg, + optimization::{ + CFGSimplifyPipelineConfig, + Pipeline, + PipelineConfig, + }, + test::{ + assert_module_is_equal_to_src, + create_test_module_from_source, + }, + }; #[test] #[traced_test] fn should_work_on_cfg_without_bb_args() { - let mut module = create_test_module_from_source(r#" + let mut module = create_test_module_from_source( + r#" fun void @test() { bb0: v0 = bool 1; @@ -147,9 +179,14 @@ mod tests { v3 = i32 8; ret void; } - "#); - module.optimize(PipelineConfig::cfg_simplify_only(CFGSimplifyPipelineConfig::unreachable_bb_elim_only())); - assert_module_is_equal_to_src(&module, " + "#, + ); + module.optimize(PipelineConfig::cfg_simplify_only( + CFGSimplifyPipelineConfig::unreachable_bb_elim_only(), + )); + assert_module_is_equal_to_src( + &module, + " fun void @test() { bb0: v0 = bool 1; @@ -158,12 +195,14 @@ mod tests { v3 = i32 8; ret void; } - ") + ", + ) } #[test] fn should_work_on_cfg_with_bb_args() { - let mut module = create_test_module_from_source(r#" + let mut module = create_test_module_from_source( + r#" fun i32 @test() { bb0: v0 = i32 8; @@ -175,9 +214,14 @@ mod tests { v3 = i32 v4; ret i32 v3; } - "#); - module.optimize(PipelineConfig::cfg_simplify_only(CFGSimplifyPipelineConfig::unreachable_bb_elim_only())); - assert_module_is_equal_to_src(&module, " + "#, + ); + module.optimize(PipelineConfig::cfg_simplify_only( + CFGSimplifyPipelineConfig::unreachable_bb_elim_only(), + )); + assert_module_is_equal_to_src( + &module, + " fun i32 @test() { bb0: v0 = i32 8; @@ -187,6 +231,7 @@ mod tests { v3 = i32 v4; ret i32 v3; } - ") + ", + ) } } diff --git a/ir/crates/middle/src/optimization/function_pass/constant_propagation.rs b/ir/crates/middle/src/optimization/function_pass/constant_propagation.rs index 37d3a50..48260d5 100644 --- a/ir/crates/middle/src/optimization/function_pass/constant_propagation.rs +++ b/ir/crates/middle/src/optimization/function_pass/constant_propagation.rs @@ -1,12 +1,28 @@ -use tracing::{debug, debug_span}; +use tracing::{ + debug, + debug_span, +}; -use crate::analysis::dataflow::{concrete_value, DFValueState, InstrWalker}; -use crate::analysis::dataflow::concrete_value::ConcreteValues; -use crate::cfg::TerminatorKind; -use crate::FunctionId; -use crate::instruction::{Const, InstrKind, Op}; -use crate::module::Module; -use crate::optimization::{FunctionPass, Pass}; +use crate::{ + analysis::dataflow::{ + concrete_value, + concrete_value::ConcreteValues, + DFValueState, + InstrWalker, + }, + cfg::TerminatorKind, + instruction::{ + Const, + InstrKind, + Op, + }, + module::Module, + optimization::{ + FunctionPass, + Pass, + }, + FunctionId, +}; #[derive(Default)] pub struct ConstantPropagation; @@ -20,7 +36,8 @@ impl Pass for ConstantPropagation { impl FunctionPass for ConstantPropagation { fn run_on_function(&mut self, module: &mut Module, function: FunctionId) -> usize { let mut changes = 0; - let mut analysis_runner = concrete_value::AnalysisRunner::new(&mut module.functions[function]); + let mut analysis_runner = + concrete_value::AnalysisRunner::new(&mut module.functions[function]); while let Some((bb_id, mut instr_walker)) = analysis_runner.next_bb() { // let bb = instr_walker.function.cfg.basic_block(bb_id); // let bb_args = bb.arguments(); @@ -88,45 +105,44 @@ impl FunctionPass for ConstantPropagation { // } // } - instr_walker.walk(|instr, state| { - match &mut instr.kind { - InstrKind::Op(op) => { - if Self::maybe_replace_op(&mut op.op, state) { - changes += 1; - } + instr_walker.walk(|instr, state| match &mut instr.kind { + InstrKind::Op(op) => { + if Self::maybe_replace_op(&mut op.op, state) { + changes += 1; } - InstrKind::Sub(instr) => { - if Self::maybe_replace_op(&mut instr.lhs, state) { - changes += 1; - } - if Self::maybe_replace_op(&mut instr.rhs, state) { - changes += 1; - } + } + InstrKind::Sub(instr) => { + if Self::maybe_replace_op(&mut instr.lhs, state) { + changes += 1; } - InstrKind::Add(instr) => { - if Self::maybe_replace_op(&mut instr.lhs, state) { - changes += 1; - } - if Self::maybe_replace_op(&mut instr.rhs, state) { - changes += 1; - } + if Self::maybe_replace_op(&mut instr.rhs, state) { + changes += 1; } - InstrKind::Cmp(icmp) => { - if Self::maybe_replace_op(&mut icmp.lhs, state) { - changes += 1; - } - if Self::maybe_replace_op(&mut icmp.rhs, state) { - changes += 1; - } + } + InstrKind::Add(instr) => { + if Self::maybe_replace_op(&mut instr.lhs, state) { + changes += 1; + } + if Self::maybe_replace_op(&mut instr.rhs, state) { + changes += 1; } - InstrKind::Alloca(_) | - InstrKind::Load(_) | - InstrKind::Store(_) => {} } + InstrKind::Cmp(icmp) => { + if Self::maybe_replace_op(&mut icmp.lhs, state) { + changes += 1; + } + if Self::maybe_replace_op(&mut icmp.rhs, state) { + changes += 1; + } + } + InstrKind::Alloca(_) | InstrKind::Load(_) | InstrKind::Store(_) => {} }); - analysis_runner.function.cfg.basic_block_mut(bb_id).update_terminator( - |terminator| { + analysis_runner + .function + .cfg + .basic_block_mut(bb_id) + .update_terminator(|terminator| { let state = analysis_runner.state.get(bb_id); match &mut terminator.kind { TerminatorKind::Ret(ret) => { @@ -156,9 +172,8 @@ impl FunctionPass for ConstantPropagation { } } } - } - ); - }; + }); + } changes } } @@ -166,20 +181,15 @@ impl FunctionPass for ConstantPropagation { impl ConstantPropagation { fn maybe_replace_op(op: &mut Op, state: &DFValueState) -> bool { match op { - Op::Const(_) => - false, - Op::Vreg(value) => { - match state.get(value).and_then(|s| s.as_single_value()) { - None => { - false - } - Some(const_value) => { - debug!("Replaced {value} with {const_value}"); - *op = Op::Const(const_value.clone()); - true - } + Op::Const(_) => false, + Op::Vreg(value) => match state.get(value).and_then(|s| s.as_single_value()) { + None => false, + Some(const_value) => { + debug!("Replaced {value} with {const_value}"); + *op = Op::Const(const_value.clone()); + true } - } + }, } } } @@ -188,8 +198,13 @@ impl ConstantPropagation { mod tests { use tracing_test::traced_test; - use crate::optimization::PipelineConfig; - use crate::test::{assert_module_is_equal_to_src, create_test_module_from_source}; + use crate::{ + optimization::PipelineConfig, + test::{ + assert_module_is_equal_to_src, + create_test_module_from_source, + }, + }; #[test] #[traced_test] @@ -208,7 +223,7 @@ bb2: v3 = add i32 v2, v0; ret i32 v3; } - " + ", ); module.optimize(PipelineConfig::global_constant_propagation_only()); assert_module_is_equal_to_src( @@ -226,7 +241,7 @@ bb2: v3 = i32 16; ret i32 16; } - "); + ", + ); } } - diff --git a/ir/crates/middle/src/optimization/function_pass/dead_code_elimination.rs b/ir/crates/middle/src/optimization/function_pass/dead_code_elimination.rs index 801d015..431135e 100644 --- a/ir/crates/middle/src/optimization/function_pass/dead_code_elimination.rs +++ b/ir/crates/middle/src/optimization/function_pass/dead_code_elimination.rs @@ -1,11 +1,18 @@ use cranelift_entity::SecondaryMap; use tracing::debug; -use crate::analysis::dataflow; -use crate::analysis::dataflow::use_def::InstrUid; -use crate::FunctionId; -use crate::module::Module; -use crate::optimization::{FunctionPass, Pass}; +use crate::{ + analysis::{ + dataflow, + dataflow::use_def::InstrUid, + }, + module::Module, + optimization::{ + FunctionPass, + Pass, + }, + FunctionId, +}; #[derive(Debug, Clone, Eq, PartialEq, Default)] pub struct DeadCodeEliminationPass {} @@ -18,9 +25,7 @@ impl Pass for DeadCodeEliminationPass { impl FunctionPass for DeadCodeEliminationPass { fn run_on_function(&mut self, module: &mut Module, function: FunctionId) -> usize { - let runner = dataflow::use_def::AnalysisRunner::new( - &mut module.functions[function] - ); + let runner = dataflow::use_def::AnalysisRunner::new(&mut module.functions[function]); let state = runner.collect(); let mut changes = 0; let mut removed_instr_count = SecondaryMap::new(); @@ -41,12 +46,18 @@ impl FunctionPass for DeadCodeEliminationPass { #[cfg(test)] mod tests { - use crate::optimization::PipelineConfig; - use crate::test::{assert_module_is_equal_to_src, create_test_module_from_source}; + use crate::{ + optimization::PipelineConfig, + test::{ + assert_module_is_equal_to_src, + create_test_module_from_source, + }, + }; #[test] fn should_eliminate_unused_values() { - let mut module = create_test_module_from_source(" + let mut module = create_test_module_from_source( + " fun i32 @test() { bb0: v0 = i32 20; @@ -56,7 +67,8 @@ mod tests { bb1: ret i32 v0; } - "); + ", + ); module.optimize(PipelineConfig::dead_code_elimination_only()); assert_module_is_equal_to_src( &module, @@ -68,7 +80,7 @@ mod tests { bb1: ret i32 v0; } - " + ", ); } } diff --git a/ir/crates/middle/src/optimization/function_pass/mod.rs b/ir/crates/middle/src/optimization/function_pass/mod.rs index 80b7e3e..b37590c 100644 --- a/ir/crates/middle/src/optimization/function_pass/mod.rs +++ b/ir/crates/middle/src/optimization/function_pass/mod.rs @@ -1,11 +1,13 @@ -pub mod dead_code_elimination; -pub mod constant_propagation; pub mod cfg_simplify; +pub mod constant_propagation; +pub mod dead_code_elimination; -use crate::FunctionId; -use crate::module::Module; -use crate::optimization::Pass; +use crate::{ + module::Module, + optimization::Pass, + FunctionId, +}; -pub trait FunctionPass: Pass{ +pub trait FunctionPass: Pass { fn run_on_function(&mut self, module: &mut Module, function: FunctionId) -> usize; } diff --git a/ir/crates/middle/src/optimization/mod.rs b/ir/crates/middle/src/optimization/mod.rs index ee5da13..fc54876 100644 --- a/ir/crates/middle/src/optimization/mod.rs +++ b/ir/crates/middle/src/optimization/mod.rs @@ -1,12 +1,24 @@ -use tracing::{debug, trace, trace_span}; - -use crate::FunctionId; -use crate::module::Module; -use crate::optimization::basic_block_pass::constant_fold::ConstantFoldPass; -use crate::optimization::basic_block_pass::copy_propagation::CopyPropagationPass; -use crate::optimization::basic_block_pass::cse::CSEPass; -use crate::optimization::function_pass::dead_code_elimination::DeadCodeEliminationPass; -use crate::optimization::function_pass::FunctionPass; +use tracing::{ + debug, + trace, + trace_span, +}; + +use crate::{ + module::Module, + optimization::{ + basic_block_pass::{ + constant_fold::ConstantFoldPass, + copy_propagation::CopyPropagationPass, + cse::CSEPass, + }, + function_pass::{ + dead_code_elimination::DeadCodeEliminationPass, + FunctionPass, + }, + }, + FunctionId, +}; pub mod basic_block_pass; pub mod function_pass; @@ -167,10 +179,7 @@ pub struct Pipeline<'m> { impl<'a> Pipeline<'a> { pub fn new(module: &'a mut Module, config: PipelineConfig) -> Self { - Self { - module, - config, - } + Self { module, config } } pub fn run(&mut self) { @@ -218,9 +227,13 @@ impl<'a> Pipeline<'a> { passes.push(Box::::default()); } if self.config.global_constant_propagation { - passes.push(Box::::default()); + passes.push(Box::< + function_pass::constant_propagation::ConstantPropagation, + >::default()); } - passes.push(Box::new(function_pass::cfg_simplify::Pass::new(self.config.cfg_simplify))); + passes.push(Box::new(function_pass::cfg_simplify::Pass::new( + self.config.cfg_simplify, + ))); passes } @@ -228,4 +241,3 @@ impl<'a> Pipeline<'a> { &self.config } } - diff --git a/ir/crates/middle/src/test.rs b/ir/crates/middle/src/test.rs index f623db4..f437446 100644 --- a/ir/crates/middle/src/test.rs +++ b/ir/crates/middle/src/test.rs @@ -1,4 +1,9 @@ -use crate::{Function, FunctionId, Module, Type}; +use crate::{ + Function, + FunctionId, + Module, + Type, +}; pub fn create_test_function() -> Function { Function::new("test".to_string(), vec![], Type::I32) diff --git a/ir/crates/middle/src/ty.rs b/ir/crates/middle/src/ty.rs index 5c78409..267069e 100644 --- a/ir/crates/middle/src/ty.rs +++ b/ir/crates/middle/src/ty.rs @@ -1,4 +1,7 @@ -use std::fmt::{Display, Formatter}; +use std::fmt::{ + Display, + Formatter, +}; #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum Type { @@ -16,7 +19,6 @@ pub enum Type { } impl Type { - pub const fn size(&self) -> u32 { match self { Self::U8 => 1, diff --git a/lang/Cargo.lock b/lang/Cargo.lock deleted file mode 100644 index 6aa3c6f..0000000 --- a/lang/Cargo.lock +++ /dev/null @@ -1,543 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "fusion-compiler" -version = "0.1.0" -dependencies = [ - "anyhow", - "iced-x86", - "itertools", - "serial_test", - "termion", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "futures" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" - -[[package]] -name = "futures-executor" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" - -[[package]] -name = "futures-sink" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" - -[[package]] -name = "futures-task" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" - -[[package]] -name = "futures-util" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "iced-x86" -version = "1.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdd366a53278429c028367e0ba22a46cab6d565a57afb959f06e92c7a69e7828" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "itertools" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" -dependencies = [ - "either", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.150" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" - -[[package]] -name = "libredox" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" -dependencies = [ - "bitflags 2.4.1", - "libc", - "redox_syscall", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "numtoa" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_termios" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20145670ba436b55d91fc92d25e71160fbfbdd57831631c8d7d36377a476f1cb" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "serial_test" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d" -dependencies = [ - "dashmap", - "futures", - "lazy_static", - "log", - "parking_lot", - "serial_test_derive", -] - -[[package]] -name = "serial_test_derive" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "termion" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4648c7def6f2043b2568617b9f9b75eae88ca185dbc1f1fda30e95a85d49d7d" -dependencies = [ - "libc", - "libredox", - "numtoa", - "redox_termios", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "nu-ansi-term", - "sharded-slab", - "smallvec", - "thread_local", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/lang/rust-toolchain.toml b/lang/rust-toolchain.toml deleted file mode 100644 index c046a09..0000000 --- a/lang/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel="nightly" diff --git a/lang/src/ast/evaluator.rs b/lang/src/ast/evaluator.rs index 82db120..52ada89 100644 --- a/lang/src/ast/evaluator.rs +++ b/lang/src/ast/evaluator.rs @@ -2,10 +2,37 @@ use std::collections::HashMap; use fusion_compiler::Idx; -use crate::ast::{AssignExpr, Ast, BinaryExpr, BinOpKind, BlockExpr, Body, BoolExpr, CallExpr, Expr, FunctionDeclaration, IfExpr, ItemId, LetStmt, NumberExpr, ParenthesizedExpr, Stmt, UnaryExpr, UnOpKind, VarExpr, WhileStmt}; -use crate::ast::visitor::ASTVisitor; -use crate::compilation_unit::{FunctionIdx, GlobalScope, VariableIdx}; -use crate::text::span::TextSpan; +use crate::{ + ast::{ + visitor::ASTVisitor, + AssignExpr, + Ast, + BinOpKind, + BinaryExpr, + BlockExpr, + Body, + BoolExpr, + CallExpr, + Expr, + FunctionDeclaration, + IfExpr, + ItemId, + LetStmt, + NumberExpr, + ParenthesizedExpr, + Stmt, + UnOpKind, + UnaryExpr, + VarExpr, + WhileStmt, + }, + compilation_unit::{ + FunctionIdx, + GlobalScope, + VariableIdx, + }, + text::span::TextSpan, +}; #[derive(Debug)] pub struct Frame { @@ -141,7 +168,13 @@ impl<'a> ASTVisitor for ASTEvaluator<'a> { self.pop_frame(); } - fn visit_func_decl(&mut self, _ast: &mut Ast, _func_decl: &FunctionDeclaration, _item_id: ItemId) {} + fn visit_func_decl( + &mut self, + _ast: &mut Ast, + _func_decl: &FunctionDeclaration, + _item_id: ItemId, + ) { + } fn visit_while_statement(&mut self, ast: &mut Ast, while_statement: &WhileStmt) { self.push_frame(); @@ -191,13 +224,7 @@ impl<'a> ASTVisitor for ASTEvaluator<'a> { .global_scope .lookup_function(function_name) .map(|f| self.global_scope.functions.get(f)) - .expect( - format!( - "Function '{}' not found", - function_name - ) - .as_str(), - ); + .expect(format!("Function '{}' not found", function_name).as_str()); let mut arguments = Vec::new(); for argument in &call_expression.arguments { self.visit_expression(ast, *argument); @@ -234,7 +261,7 @@ impl<'a> ASTVisitor for ASTEvaluator<'a> { var_expr.variable_idx.as_index(), identifier ) - .as_str(), + .as_str(), ), ); } @@ -251,7 +278,12 @@ impl<'a> ASTVisitor for ASTEvaluator<'a> { panic!("Cannot evaluate error expression") } - fn visit_unary_expression(&mut self, ast: &mut Ast, unary_expression: &UnaryExpr, _expr: &Expr) { + fn visit_unary_expression( + &mut self, + ast: &mut Ast, + unary_expression: &UnaryExpr, + _expr: &Expr, + ) { self.visit_expression(ast, unary_expression.operand); let operand = self.expect_last_value().expect_number(); self.last_value = Some(Value::Number(match unary_expression.operator.kind { diff --git a/lang/src/ast/lexer.rs b/lang/src/ast/lexer.rs index 79b4049..f6096c5 100644 --- a/lang/src/ast/lexer.rs +++ b/lang/src/ast/lexer.rs @@ -1,5 +1,9 @@ +use std::fmt::{ + Display, + Formatter, +}; + use crate::text::span::TextSpan; -use std::fmt::{Display, Formatter}; #[derive(Debug, Clone, PartialEq)] pub enum TokenKind { @@ -89,7 +93,6 @@ impl Display for TokenKind { TokenKind::Colon => write!(f, "Colon"), TokenKind::Arrow => write!(f, "Arrow"), TokenKind::SemiColon => write!(f, "SemiColon"), - } } } diff --git a/lang/src/ast/mod.rs b/lang/src/ast/mod.rs index 510c4e3..e4eac0b 100644 --- a/lang/src/ast/mod.rs +++ b/lang/src/ast/mod.rs @@ -1,17 +1,33 @@ -use std::fmt::{Display, Formatter}; -use std::hash::Hash; -use std::ops::Deref; - -use termion::color::{Fg, Reset}; - -use fusion_compiler::{idx, Idx, IdxVec}; +use std::{ + fmt::{ + Display, + Formatter, + }, + hash::Hash, + ops::Deref, +}; + +use fusion_compiler::{ + idx, + Idx, + IdxVec, +}; use printer::ASTPrinter; +use termion::color::{ + Fg, + Reset, +}; use visitor::ASTVisitor; -use crate::ast::lexer::Token; -use crate::compilation_unit::{FunctionIdx, VariableIdx}; -use crate::text::span::TextSpan; -use crate::typings::Type; +use crate::{ + ast::lexer::Token, + compilation_unit::{ + FunctionIdx, + VariableIdx, + }, + text::span::TextSpan, + typings::Type, +}; pub mod evaluator; pub mod lexer; @@ -515,7 +531,6 @@ pub enum UnOpKind { BitwiseNot, } - impl Display for UnOpKind { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { return match self { @@ -748,11 +763,7 @@ pub struct Body { } impl Body { - pub fn new( - opening_brace: Token, - stmts: Vec, - closing_brace: Token, - ) -> Self { + pub fn new(opening_brace: Token, stmts: Vec, closing_brace: Token) -> Self { Self { opening_brace, stmts, @@ -763,9 +774,9 @@ impl Body { pub fn span(&self, ast: &Ast) -> TextSpan { TextSpan::combine( self.stmts - .iter().map( - |stmt| ast.query_stmt(*stmt).span(ast) - ).collect::>() + .iter() + .map(|stmt| ast.query_stmt(*stmt).span(ast)) + .collect::>(), ) } @@ -798,11 +809,31 @@ impl Deref for Body { #[cfg(test)] mod test { - use crate::ast::{AssignExpr, Ast, BinaryExpr, BlockExpr, BoolExpr, CallExpr, Expr, FunctionDeclaration, IfExpr, ItemId, LetStmt, NumberExpr, ParenthesizedExpr, ReturnStmt, Stmt, UnaryExpr, VarExpr, WhileStmt}; - use crate::compilation_unit::CompilationUnit; - use crate::text::span::TextSpan; - use super::visitor::ASTVisitor; + use crate::{ + ast::{ + AssignExpr, + Ast, + BinaryExpr, + BlockExpr, + BoolExpr, + CallExpr, + Expr, + FunctionDeclaration, + IfExpr, + ItemId, + LetStmt, + NumberExpr, + ParenthesizedExpr, + ReturnStmt, + Stmt, + UnaryExpr, + VarExpr, + WhileStmt, + }, + compilation_unit::CompilationUnit, + text::span::TextSpan, + }; #[derive(Debug, PartialEq, Eq)] enum TestASTNode { @@ -858,7 +889,7 @@ mod test { ); for (index, (expected, actual)) in - self.expected.iter().zip(self.actual.iter()).enumerate() + self.expected.iter().zip(self.actual.iter()).enumerate() { assert_eq!( expected, actual, @@ -870,7 +901,12 @@ mod test { } impl ASTVisitor for ASTVerifier { - fn visit_func_decl(&mut self, ast: &mut Ast, func_decl: &FunctionDeclaration, item_id: ItemId) { + fn visit_func_decl( + &mut self, + ast: &mut Ast, + func_decl: &FunctionDeclaration, + item_id: ItemId, + ) { self.actual.push(TestASTNode::Func); for stmt in func_decl.body.iter() { self.visit_statement(ast, *stmt); diff --git a/lang/src/ast/parser.rs b/lang/src/ast/parser.rs index afbab38..9258382 100644 --- a/lang/src/ast/parser.rs +++ b/lang/src/ast/parser.rs @@ -1,10 +1,36 @@ use std::cell::Cell; -use crate::ast::{Ast, BinOpAssociativity, BinOperator, BinOpKind, Body, ElseBranch, Expr, ExprId, FuncDeclParameter, FunctionReturnTypeSyntax, Item, ItemKind, StaticTypeAnnotation, Stmt, StmtId, UnOperator, UnOpKind}; -use crate::ast::lexer::{Token, TokenKind}; -use crate::compilation_unit::{GlobalScope, resolve_type_from_string}; -use crate::diagnostics::DiagnosticsBagCell; -use crate::typings::Type; +use crate::{ + ast::{ + lexer::{ + Token, + TokenKind, + }, + Ast, + BinOpAssociativity, + BinOpKind, + BinOperator, + Body, + ElseBranch, + Expr, + ExprId, + FuncDeclParameter, + FunctionReturnTypeSyntax, + Item, + ItemKind, + StaticTypeAnnotation, + Stmt, + StmtId, + UnOpKind, + UnOperator, + }, + compilation_unit::{ + resolve_type_from_string, + GlobalScope, + }, + diagnostics::DiagnosticsBagCell, + typings::Type, +}; #[derive(Debug, Clone)] pub struct Counter { @@ -101,8 +127,12 @@ impl<'a> Parser<'a> { &self.diagnostics_bag, ¶meter.type_annotation.type_name, ); - self.global_scope - .declare_variable(¶meter.identifier.span.literal, ty, false, false) + self.global_scope.declare_variable( + ¶meter.identifier.span.literal, + ty, + false, + false, + ) }) .collect(); @@ -292,7 +322,7 @@ impl<'a> Parser<'a> { let equal_precedence = inner_operator.precedence() == operator.precedence(); if !greater_precedence && !(equal_precedence - && inner_operator.associativity() == BinOpAssociativity::Right) + && inner_operator.associativity() == BinOpAssociativity::Right) { break; } @@ -379,7 +409,7 @@ impl<'a> Parser<'a> { self.ast.error_expression(token.span) } } - .id; + .id; } fn parse_call_expression(&mut self, identifier: Token) -> ExprId { diff --git a/lang/src/ast/printer.rs b/lang/src/ast/printer.rs index 74a2fea..40a3edb 100644 --- a/lang/src/ast/printer.rs +++ b/lang/src/ast/printer.rs @@ -1,7 +1,9 @@ use termion::color; -use crate::ast::*; -use crate::text::span::TextSpan; +use crate::{ + ast::*, + text::span::TextSpan, +}; pub struct ASTPrinter { indent: usize, @@ -73,7 +75,12 @@ impl ASTPrinter { } impl ASTVisitor for ASTPrinter { - fn visit_func_decl(&mut self, ast: &mut Ast, func_decl: &FunctionDeclaration, _item_id: ItemId) { + fn visit_func_decl( + &mut self, + ast: &mut Ast, + func_decl: &FunctionDeclaration, + _item_id: ItemId, + ) { self.add_keyword("func"); self.add_whitespace(); self.add_text(&func_decl.identifier.span.literal); @@ -217,7 +224,12 @@ impl ASTVisitor for ASTPrinter { .push_str(&format!("{}{}", Self::TEXT_COLOR.fg_str(), span.literal,)); } - fn visit_unary_expression(&mut self, ast: &mut Ast, unary_expression: &UnaryExpr, _expr: &Expr) { + fn visit_unary_expression( + &mut self, + ast: &mut Ast, + unary_expression: &UnaryExpr, + _expr: &Expr, + ) { self.result.push_str(&format!( "{}{}", Self::TEXT_COLOR.fg_str(), diff --git a/lang/src/ast/visitor.rs b/lang/src/ast/visitor.rs index 5570c8a..5abb252 100644 --- a/lang/src/ast/visitor.rs +++ b/lang/src/ast/visitor.rs @@ -1,13 +1,35 @@ - - - -use crate::ast::{AssignExpr, Ast, BinaryExpr, BlockExpr, Body, BoolExpr, CallExpr, Expr, ExprId, ExprKind, FunctionDeclaration, IfExpr, ItemId, ItemKind, LetStmt, NumberExpr, ParenthesizedExpr, ReturnStmt, Stmt, StmtId, StmtKind, UnaryExpr, VarExpr, WhileStmt}; -use crate::text::span::TextSpan; +use crate::{ + ast::{ + AssignExpr, + Ast, + BinaryExpr, + BlockExpr, + Body, + BoolExpr, + CallExpr, + Expr, + ExprId, + ExprKind, + FunctionDeclaration, + IfExpr, + ItemId, + ItemKind, + LetStmt, + NumberExpr, + ParenthesizedExpr, + ReturnStmt, + Stmt, + StmtId, + StmtKind, + UnaryExpr, + VarExpr, + WhileStmt, + }, + text::span::TextSpan, +}; pub trait ASTVisitor { fn visit_item(&mut self, ast: &mut Ast, item: ItemId) { - - self.visit_item_default(ast, item); } diff --git a/lang/src/codegen/c/ast.rs b/lang/src/codegen/c/ast.rs index 16700ae..f30ee07 100644 --- a/lang/src/codegen/c/ast.rs +++ b/lang/src/codegen/c/ast.rs @@ -1,9 +1,22 @@ -use std::fmt::{Display, Formatter}; -use std::io::Write; +use std::{ + fmt::{ + Display, + Formatter, + }, + io::Write, +}; + use anyhow::Result; -use crate::ast::{BinOperator, BinOpKind, UnOperator, UnOpKind}; -use crate::typings::Type; +use crate::{ + ast::{ + BinOpKind, + BinOperator, + UnOpKind, + UnOperator, + }, + typings::Type, +}; pub struct CAst { pub items: Vec, @@ -11,9 +24,7 @@ pub struct CAst { impl CAst { pub fn new(items: Vec) -> Self { - Self { - items, - } + Self { items } } } diff --git a/lang/src/codegen/c/mod.rs b/lang/src/codegen/c/mod.rs index 186e9de..1da94f2 100644 --- a/lang/src/codegen/c/mod.rs +++ b/lang/src/codegen/c/mod.rs @@ -1,8 +1,8 @@ mod ast; -mod transpiler; mod program; +mod transpiler; -#[allow(unused_imports)] -pub use transpiler::CTranspiler; #[allow(unused_imports)] pub use program::CProgram; +#[allow(unused_imports)] +pub use transpiler::CTranspiler; diff --git a/lang/src/codegen/c/program.rs b/lang/src/codegen/c/program.rs index 0f283fb..853e580 100644 --- a/lang/src/codegen/c/program.rs +++ b/lang/src/codegen/c/program.rs @@ -1,16 +1,30 @@ -use std::fs::File; -use std::process::Command; -use std::io::Write; +use std::{ + fs::File, + io::Write, + process::Command, +}; + use anyhow::anyhow; -use crate::codegen::c::ast::{CAst, CBlock, CExpr, CFunctionDecl, CItem, CParameter, CStmt}; -use crate::codegen::c::CTranspiler; -use crate::compilation_unit::CompilationUnit; + +use crate::{ + codegen::c::{ + ast::{ + CAst, + CBlock, + CExpr, + CFunctionDecl, + CItem, + CParameter, + CStmt, + }, + CTranspiler, + }, + compilation_unit::CompilationUnit, +}; impl From for CProgram { fn from(value: CAst) -> Self { - Self { - ast: value, - } + Self { ast: value } } } @@ -44,16 +58,17 @@ impl CProgram { .arg(Self::C_INPUT_FILE) .arg("-o") .arg(Self::OUTPUT_FILE) - .status()?.exit_ok()?; + .status()? + .exit_ok()?; Ok(file) } pub fn run(&self) -> anyhow::Result { let _ = self.compile()?; let run_result = Command::new(format!("./{}", Self::OUTPUT_FILE)).status()?; - Ok(run_result.code().ok_or( - anyhow!("Program exited without returning a value") - )?) + Ok(run_result + .code() + .ok_or(anyhow!("Program exited without returning a value"))?) } } diff --git a/lang/src/codegen/c/transpiler.rs b/lang/src/codegen/c/transpiler.rs index 004b3ed..4b22c91 100644 --- a/lang/src/codegen/c/transpiler.rs +++ b/lang/src/codegen/c/transpiler.rs @@ -1,9 +1,52 @@ use std::collections::HashMap; -use crate::ast::{Ast, BinaryExpr, BlockExpr, CallExpr, Expr, ExprId, ExprKind, FunctionDeclaration, IfExpr, Item, ItemKind, StmtId, StmtKind, UnaryExpr}; -use crate::codegen::c::ast::{CAssignExpr, CAst, CBinaryExpr, CBinOperator, CBlock, CBool, CCallExpr, CExpr, CFunctionDecl, CFunctionImpl, CIfStmt, CItem, CNumber, CParameter, CReturn, CStmt, CType, CUnaryExpr, CUnOperator, CVarDecl, CVarExpr, CWhile}; -use crate::compilation_unit::{GlobalScope, VariableIdx}; -use crate::typings::Type; +use crate::{ + ast::{ + Ast, + BinaryExpr, + BlockExpr, + CallExpr, + Expr, + ExprId, + ExprKind, + FunctionDeclaration, + IfExpr, + Item, + ItemKind, + StmtId, + StmtKind, + UnaryExpr, + }, + codegen::c::ast::{ + CAssignExpr, + CAst, + CBinOperator, + CBinaryExpr, + CBlock, + CBool, + CCallExpr, + CExpr, + CFunctionDecl, + CFunctionImpl, + CIfStmt, + CItem, + CNumber, + CParameter, + CReturn, + CStmt, + CType, + CUnOperator, + CUnaryExpr, + CVarDecl, + CVarExpr, + CWhile, + }, + compilation_unit::{ + GlobalScope, + VariableIdx, + }, + typings::Type, +}; pub struct CTranspiler<'a> { global_scope: &'a GlobalScope, @@ -25,32 +68,31 @@ impl<'a> CTranspiler<'a> { CItem::Macro("true".to_string(), "1".to_string()), CItem::Macro("false".to_string(), "0".to_string()), ]; - items.extend(ast.items.iter().filter( - |item| matches!(item.kind, ItemKind::Function(_)) - ).map(|item| { - match &item.kind { - ItemKind::Stmt(_) => { - unreachable!() - } - ItemKind::Function(function) => { - self.transpile_function_decl(ast, function) - } - } - }).collect::>()); - items.extend(ast - .items - .iter() - .map(|item| self.transpile_item(ast, item)) - .collect::>()); + items.extend( + ast.items + .iter() + .filter(|item| matches!(item.kind, ItemKind::Function(_))) + .map(|item| match &item.kind { + ItemKind::Stmt(_) => { + unreachable!() + } + ItemKind::Function(function) => self.transpile_function_decl(ast, function), + }) + .collect::>(), + ); + items.extend( + ast.items + .iter() + .map(|item| self.transpile_item(ast, item)) + .collect::>(), + ); CAst::new(items) } fn transpile_item(&mut self, ast: &Ast, item: &Item) -> CItem { match &item.kind { ItemKind::Stmt(_) => panic!("Statement in global scope not supported"), - ItemKind::Function(function) => { - self.transpile_function(ast, function) - } + ItemKind::Function(function) => self.transpile_function(ast, function), } } @@ -59,8 +101,7 @@ impl<'a> CTranspiler<'a> { CItem::FunctionDecl(CFunctionDecl { name: function.name.clone(), - return_type: CType::try_from(&function.return_type) - .expect("Unsupported return type"), + return_type: CType::try_from(&function.return_type).expect("Unsupported return type"), parameters: function .parameters .iter() @@ -68,21 +109,24 @@ impl<'a> CTranspiler<'a> { let parameter = self.global_scope.variables.get(*parameter_idx); CParameter { name: self.get_variable_name(*parameter_idx), - ty: CType::try_from(¶meter.ty) - .expect("Unsupported parameter type"), + ty: CType::try_from(¶meter.ty).expect("Unsupported parameter type"), } }) .collect(), }) } - fn transpile_function(&mut self, ast: &Ast, function: &FunctionDeclaration) -> CItem { let function_decl = match self.transpile_function_decl(ast, function) { CItem::FunctionDecl(function_decl) => function_decl, - _ => unreachable!() + _ => unreachable!(), }; - let mut body_stmts = function.body.iter().map(|stmt| self.transpile_stmt(ast, *stmt)).flatten().collect::>(); + let mut body_stmts = function + .body + .iter() + .map(|stmt| self.transpile_stmt(ast, *stmt)) + .flatten() + .collect::>(); CItem::FunctionImpl(CFunctionImpl { name: function_decl.name, @@ -101,24 +145,18 @@ impl<'a> CTranspiler<'a> { value: number.number, }), ), - ExprKind::Binary(binary_expr) => { - self.transpile_binary_expr(ast, &binary_expr) - } - ExprKind::Unary(unary_expr) => { - self.transpile_unary_expr(ast, &unary_expr) - } + ExprKind::Binary(binary_expr) => self.transpile_binary_expr(ast, &binary_expr), + ExprKind::Unary(unary_expr) => self.transpile_unary_expr(ast, &unary_expr), ExprKind::Parenthesized(paren_expr) => { let (expr_stmts, expr) = self.transpile_expr(ast, paren_expr.inner); (expr_stmts, CExpr::Parenthesized(Box::new(expr))) } - ExprKind::Variable(var_expr) => { - ( - None, - CExpr::Var(CVarExpr { - name: self.get_variable_name(var_expr.variable_idx) - }), - ) - } + ExprKind::Variable(var_expr) => ( + None, + CExpr::Var(CVarExpr { + name: self.get_variable_name(var_expr.variable_idx), + }), + ), ExprKind::Assignment(assignment_expr) => { let (assign_expr_stmts, assign_expr) = self.transpile_expr(ast, assignment_expr.expression); @@ -136,20 +174,19 @@ impl<'a> CTranspiler<'a> { value: bool_expr.value, }), ), - ExprKind::Call(call_expr) => { - self.transpile_call_expr(ast, call_expr) - } - ExprKind::If(if_expr) => { - self.transpile_if_expr(ast, &expr, if_expr) - } - ExprKind::Block(block_expr) => { - self.transpile_block_expr(ast, &expr, block_expr) - } + ExprKind::Call(call_expr) => self.transpile_call_expr(ast, call_expr), + ExprKind::If(if_expr) => self.transpile_if_expr(ast, &expr, if_expr), + ExprKind::Block(block_expr) => self.transpile_block_expr(ast, &expr, block_expr), ExprKind::Error(_) => panic!("Error expression"), } } - fn transpile_if_expr(&mut self, ast: &Ast, expr: &&Expr, if_expr: &IfExpr) -> (Option>, CExpr) { + fn transpile_if_expr( + &mut self, + ast: &Ast, + expr: &&Expr, + if_expr: &IfExpr, + ) -> (Option>, CExpr) { let (cond_stmts, condition) = self.transpile_expr(ast, if_expr.condition); let (then_expr_stmts, then_expr) = // self.transpile_expr(ast, if_expr.then_branch); @@ -228,7 +265,12 @@ impl<'a> CTranspiler<'a> { } } - fn transpile_block_expr(&mut self, ast: &Ast, expr: &&Expr, block_expr: &BlockExpr) -> (Option>, CExpr) { + fn transpile_block_expr( + &mut self, + ast: &Ast, + expr: &&Expr, + block_expr: &BlockExpr, + ) -> (Option>, CExpr) { let mut stmts = Vec::new(); let assign_returning_expr_to_temp_var = !matches!(&expr.ty, Type::Void); let (temp_var, temp_var_name) = if assign_returning_expr_to_temp_var { @@ -270,7 +312,11 @@ impl<'a> CTranspiler<'a> { ) } - fn transpile_call_expr(&mut self, ast: &Ast, call_expr: &CallExpr) -> (Option>, CExpr) { + fn transpile_call_expr( + &mut self, + ast: &Ast, + call_expr: &CallExpr, + ) -> (Option>, CExpr) { let function = self.global_scope.functions.get(call_expr.function_idx); let mut stmts = Vec::new(); let arguments = call_expr @@ -293,10 +339,13 @@ impl<'a> CTranspiler<'a> { ) } - fn transpile_unary_expr(&mut self, ast: &Ast, unary_expr: &&UnaryExpr) -> (Option>, CExpr) { + fn transpile_unary_expr( + &mut self, + ast: &Ast, + unary_expr: &&UnaryExpr, + ) -> (Option>, CExpr) { let (expr_stmts, expr) = self.transpile_expr(ast, unary_expr.operand); - let op = CUnOperator::try_from(&unary_expr.operator) - .expect("Unsupported unary operator"); + let op = CUnOperator::try_from(&unary_expr.operator).expect("Unsupported unary operator"); ( expr_stmts, CExpr::Unary(CUnaryExpr { @@ -306,11 +355,15 @@ impl<'a> CTranspiler<'a> { ) } - fn transpile_binary_expr(&mut self, ast: &Ast, binary_expr: &&BinaryExpr) -> (Option>, CExpr) { + fn transpile_binary_expr( + &mut self, + ast: &Ast, + binary_expr: &&BinaryExpr, + ) -> (Option>, CExpr) { let (left_stmts, left) = self.transpile_expr(ast, binary_expr.left); let (right_stmts, right) = self.transpile_expr(ast, binary_expr.right); - let op = CBinOperator::try_from(&binary_expr.operator) - .expect("Unsupported binary operator"); + let op = + CBinOperator::try_from(&binary_expr.operator).expect("Unsupported binary operator"); let mut stmts = Vec::new(); if let Some(left_stmts) = left_stmts { stmts.extend(left_stmts); @@ -373,17 +426,12 @@ impl<'a> CTranspiler<'a> { statements: then_block_stmts, }, else_block: Some(CBlock { - statements: vec![ - CStmt::Break, - ] + statements: vec![CStmt::Break], }), })); - CStmt::While(CWhile { - condition: CExpr::Bool(CBool { - value: true, - }), + condition: CExpr::Bool(CBool { value: true }), body: CBlock { statements: while_body_stmts, }, @@ -430,7 +478,8 @@ impl CTranspiler<'_> { let shadowing_variables = self.shadowing_variables.get_mut(&variable.name); let shadowing_variables = match shadowing_variables { None => { - self.shadowing_variables.insert(variable.name.clone(), vec![variable_idx]); + self.shadowing_variables + .insert(variable.name.clone(), vec![variable_idx]); self.shadowing_variables.get_mut(&variable.name).unwrap() } Some(shadowing_variables) => shadowing_variables, @@ -450,8 +499,10 @@ impl CTranspiler<'_> { mod test { use serial_test::serial; - use crate::codegen::c::CProgram; - use crate::compilation_unit::CompilationUnit; + use crate::{ + codegen::c::CProgram, + compilation_unit::CompilationUnit, + }; fn expect_return_value(input: &str, expected_return_value: i32, include_main: bool) { let input = if include_main { @@ -464,7 +515,11 @@ mod test { let compilation_unit = CompilationUnit::compile(&input).expect("Compilation failed"); let program = CProgram::from_compilation_unit(&compilation_unit); let c_return_value = program.run().expect("C program failed"); - return assert_eq!(c_return_value, expected_return_value, "Expected return value {} but got {}", expected_return_value, c_return_value); + return assert_eq!( + c_return_value, expected_return_value, + "Expected return value {} but got {}", + expected_return_value, c_return_value + ); } #[test] @@ -611,7 +666,6 @@ mod test { expect_return_value(input, 1, true) } - #[test] #[serial] fn while_loop_condition_expression_evaluation() { @@ -645,5 +699,3 @@ mod test { expect_return_value(input, 1, true) } } - - diff --git a/lang/src/codegen/mod.rs b/lang/src/codegen/mod.rs index 5fb3b82..8a38764 100644 --- a/lang/src/codegen/mod.rs +++ b/lang/src/codegen/mod.rs @@ -1,5 +1,2 @@ pub mod c; pub mod x86_64; - - - diff --git a/lang/src/codegen/x86_64/mod.rs b/lang/src/codegen/x86_64/mod.rs index 02eeb9a..ef86549 100644 --- a/lang/src/codegen/x86_64/mod.rs +++ b/lang/src/codegen/x86_64/mod.rs @@ -1,13 +1,34 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::{ + HashMap, + HashSet, +}; use anyhow::Result; -use iced_x86::{Code, Decoder, DecoderOptions, Formatter, Instruction, IntelFormatter, MemoryOperand, NumberBase, Register}; -use iced_x86::code_asm::*; - use fusion_compiler::bug; - -use crate::lir; -use crate::lir::{ConstOp, InstructionKind, OperandKind, PlaceIdx, Terminator, Type}; +use iced_x86::{ + code_asm::*, + Code, + Decoder, + DecoderOptions, + Formatter, + Instruction, + IntelFormatter, + MemoryOperand, + NumberBase, + Register, +}; + +use crate::{ + lir, + lir::{ + ConstOp, + InstructionKind, + OperandKind, + PlaceIdx, + Terminator, + Type, + }, +}; pub struct CallingConvention<'a>(&'a lir::Function); @@ -37,18 +58,18 @@ impl X86_64Codegen { let mut function_label = self.asm.create_label(); self.asm.set_label(&mut function_label)?; for bb_idx in function.basic_blocks.iter().copied() { - let label = self.labels.entry(bb_idx).or_insert_with(|| self.asm.create_label()); + let label = self + .labels + .entry(bb_idx) + .or_insert_with(|| self.asm.create_label()); self.asm.set_label(label)?; let bb = &lir.basic_blocks[bb_idx]; for instr in &bb.instructions { match &instr.kind { - InstructionKind::Add { - target, - lhs, - rhs - } => { + InstructionKind::Add { target, lhs, rhs } => { assert_eq!(lhs.ty.layout(), rhs.ty.layout()); - let target_loc = self.allocator.get_location_or_alloc(&lir.places[*target]); + let target_loc = + self.allocator.get_location_or_alloc(&lir.places[*target]); match (&lhs.kind, &rhs.kind) { (OperandKind::Deref(l_place), OperandKind::Deref(r_place)) => { // Determine destination and source @@ -72,7 +93,8 @@ impl X86_64Codegen { } else { // todo: swap l & r if l is in a register, but r is not - let l_place_loc = *self.allocator.get_location_or_panic(l_place); + let l_place_loc = + *self.allocator.get_location_or_panic(l_place); self.mov(&target_loc, &l_place_loc)?; (*target, *r_place) }; @@ -104,99 +126,90 @@ impl X86_64Codegen { let loc = *self.allocator.get_location_or_panic(place); self.mov(&target_loc, &loc)?; } - OperandKind::Const(const_op) => { - match const_op { - ConstOp::Int32(value) => { - self.move_i32(target_loc, *value)?; - } + OperandKind::Const(const_op) => match const_op { + ConstOp::Int32(value) => { + self.move_i32(target_loc, *value)?; } - } + }, } } InstructionKind::Gt { target, lhs, rhs } => { - let target_loc = self.allocator.get_location_or_alloc(&lir.places[*target]); + let target_loc = + self.allocator.get_location_or_alloc(&lir.places[*target]); match (&lhs.kind, &rhs.kind) { (OperandKind::Deref(l_place), OperandKind::Deref(r_place)) => { let l_loc = *self.allocator.get_location_or_panic(l_place); let r_loc = *self.allocator.get_location_or_panic(r_place); match (l_loc, r_loc) { (Location::Register(l_reg), Location::Register(r_reg)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Cmp_r64_rm64, - l_reg, - r_reg, - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Cmp_r64_rm64, + l_reg, + r_reg, + )?)?; } - (Location::Register(l_reg), Location::Stack(r_entry_idx)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Cmp_r64_rm64, - l_reg, - self.mem_op_from_stack_entry(r_entry_idx), - )? - )?; + ( + Location::Register(l_reg), + Location::Stack(r_entry_idx), + ) => { + self.asm.add_instruction(Instruction::with2( + Code::Cmp_r64_rm64, + l_reg, + self.mem_op_from_stack_entry(r_entry_idx), + )?)?; } - (Location::Stack(l_entry_idx), Location::Register(r_reg)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Cmp_rm64_r64, - self.mem_op_from_stack_entry(l_entry_idx), - r_reg, - )? - )?; + ( + Location::Stack(l_entry_idx), + Location::Register(r_reg), + ) => { + self.asm.add_instruction(Instruction::with2( + Code::Cmp_rm64_r64, + self.mem_op_from_stack_entry(l_entry_idx), + r_reg, + )?)?; } - (Location::Stack(l_entry_idx), Location::Stack(r_entry_idx)) => { - let (l_reg, spilled) = self.allocator.move_stack_to_free_reg( - l_entry_idx - ); + ( + Location::Stack(l_entry_idx), + Location::Stack(r_entry_idx), + ) => { + let (l_reg, spilled) = + self.allocator.move_stack_to_free_reg(l_entry_idx); if let Some(spilled) = spilled { self.do_spilling(spilled)?; } - self.asm.add_instruction( - Instruction::with2( - Code::Cmp_rm64_r64, - l_reg, - self.mem_op_from_stack_entry(r_entry_idx), - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Cmp_rm64_r64, + l_reg, + self.mem_op_from_stack_entry(r_entry_idx), + )?)?; } } } (OperandKind::Const(_), OperandKind::Const(_)) => { bug!("This operation should have been evaluated during constant propagation"); } - (OperandKind::Deref(l_place), OperandKind::Const(const_op)) | - (OperandKind::Const(const_op), OperandKind::Deref(l_place)) => { + (OperandKind::Deref(l_place), OperandKind::Const(const_op)) + | (OperandKind::Const(const_op), OperandKind::Deref(l_place)) => { let l_loc = *self.allocator.get_location_or_panic(l_place); match l_loc { - Location::Register(reg) => { - match *const_op { - ConstOp::Int32(value) => { - self.asm.add_instruction( - Instruction::with2( - Code::Cmp_rm64_imm32, - reg, - value, - )? - )?; - } + Location::Register(reg) => match *const_op { + ConstOp::Int32(value) => { + self.asm.add_instruction(Instruction::with2( + Code::Cmp_rm64_imm32, + reg, + value, + )?)?; } - } - Location::Stack(entry_idx) => { - match *const_op { - ConstOp::Int32(value) => { - self.asm.add_instruction( - Instruction::with2( - Code::Cmp_rm64_imm32, - self.mem_op_from_stack_entry(entry_idx), - value, - )? - )?; - } + }, + Location::Stack(entry_idx) => match *const_op { + ConstOp::Int32(value) => { + self.asm.add_instruction(Instruction::with2( + Code::Cmp_rm64_imm32, + self.mem_op_from_stack_entry(entry_idx), + value, + )?)?; } - } + }, } } }; @@ -204,84 +217,72 @@ impl X86_64Codegen { if let Some(spilled) = spilled { self.do_spilling(spilled)?; } - self.asm.add_instruction( - Instruction::with1( - Code::Setg_rm8, - flag_reg, - )? - )?; + self.asm + .add_instruction(Instruction::with1(Code::Setg_rm8, flag_reg)?)?; // todo: revert spilling self.allocator.free_register(flag_reg); - let (target_reg, spilled) = self.allocator.ensure_in_register(*target)?; + let (target_reg, spilled) = + self.allocator.ensure_in_register(*target)?; if let Some(spilled) = spilled { self.do_spilling(spilled)?; } - self.asm.add_instruction( - Instruction::with2( - Code::Movzx_r64_rm8, - target_reg, - flag_reg, - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Movzx_r64_rm8, + target_reg, + flag_reg, + )?)?; } } } match bb.terminator.as_ref() { None => bug!("Basic block {:?} has no terminator", bb_idx), - Some(terminator) => { - match terminator { - Terminator::Return { value } => { - if let Some(value) = value { - match &value.kind { - OperandKind::Deref(place) => { - let loc = self.allocator.get_location_or_panic(place); - match loc { - Location::Register(reg) => { - self.asm.add_instruction( - Instruction::with2( - Code::Mov_r64_rm64, - Register::RAX, - *reg, - )? - )?; - } - Location::Stack(entry_idx) => { - self.asm.add_instruction( - Instruction::with2( - Code::Mov_r64_rm64, - Register::RAX, - self.mem_op_from_stack_entry(*entry_idx), - )? - )?; - } + Some(terminator) => match terminator { + Terminator::Return { value } => { + if let Some(value) = value { + match &value.kind { + OperandKind::Deref(place) => { + let loc = self.allocator.get_location_or_panic(place); + match loc { + Location::Register(reg) => { + self.asm.add_instruction(Instruction::with2( + Code::Mov_r64_rm64, + Register::RAX, + *reg, + )?)?; } - } - OperandKind::Const(const_op) => { - match const_op { - ConstOp::Int32(value) => { - self.asm.add_instruction( - Instruction::with2( - Code::Mov_rm64_imm32, - Register::RAX, - *value, - )? - )?; - } + Location::Stack(entry_idx) => { + self.asm.add_instruction(Instruction::with2( + Code::Mov_r64_rm64, + Register::RAX, + self.mem_op_from_stack_entry(*entry_idx), + )?)?; } } } + OperandKind::Const(const_op) => match const_op { + ConstOp::Int32(value) => { + self.asm.add_instruction(Instruction::with2( + Code::Mov_rm64_imm32, + Register::RAX, + *value, + )?)?; + } + }, } - self.asm.ret()?; - } - Terminator::Jump { target } => { - let target_label = self.labels.entry(*target).or_insert_with(|| self.asm.create_label()); - self.asm.jmp(*target_label)?; } + self.asm.ret()?; } - } + Terminator::Jump { target } => { + let target_label = self + .labels + .entry(*target) + .or_insert_with(|| self.asm.create_label()); + self.asm.jmp(*target_label)?; + } + }, } } } @@ -290,28 +291,22 @@ impl X86_64Codegen { fn add_const(&mut self, dest_loc: &Location, r_const: &ConstOp) -> Result<()> { match r_const { - ConstOp::Int32(value) => { - match dest_loc { - Location::Register(reg) => { - self.asm.add_instruction( - Instruction::with2( - Code::Add_rm64_imm32, - *reg, - *value, - )? - )?; - } - Location::Stack(entry_idx) => { - self.asm.add_instruction( - Instruction::with2( - Code::Add_rm64_imm32, - self.mem_op_from_stack_entry(*entry_idx), - *value, - )? - )?; - } + ConstOp::Int32(value) => match dest_loc { + Location::Register(reg) => { + self.asm.add_instruction(Instruction::with2( + Code::Add_rm64_imm32, + *reg, + *value, + )?)?; } - } + Location::Stack(entry_idx) => { + self.asm.add_instruction(Instruction::with2( + Code::Add_rm64_imm32, + self.mem_op_from_stack_entry(*entry_idx), + *value, + )?)?; + } + }, } Ok(()) } @@ -329,46 +324,36 @@ impl X86_64Codegen { // Move `dest` to reg, apply 2) match (dest_loc, src_loc) { (Location::Register(dest_reg), Location::Register(src_reg)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Add_r64_rm64, - *dest_reg, - *src_reg, - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Add_r64_rm64, + *dest_reg, + *src_reg, + )?)?; } (Location::Register(dest_reg), Location::Stack(src_entry_idx)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Add_r64_rm64, - *dest_reg, - self.mem_op_from_stack_entry(*src_entry_idx), - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Add_r64_rm64, + *dest_reg, + self.mem_op_from_stack_entry(*src_entry_idx), + )?)?; } (Location::Stack(dest_entry_idx), Location::Register(src_reg)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Add_rm64_r64, - self.mem_op_from_stack_entry(*dest_entry_idx), - *src_reg, - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Add_rm64_r64, + self.mem_op_from_stack_entry(*dest_entry_idx), + *src_reg, + )?)?; } (Location::Stack(dest_entry_idx), Location::Stack(src_entry_idx)) => { - let (dest_reg, spilled) = self.allocator.move_stack_to_free_reg( - *dest_entry_idx - ); + let (dest_reg, spilled) = self.allocator.move_stack_to_free_reg(*dest_entry_idx); if let Some(spilled) = spilled { self.do_spilling(spilled)?; } - self.asm.add_instruction( - Instruction::with2( - Code::Add_rm64_r64, - dest_reg, - self.mem_op_from_stack_entry(*src_entry_idx), - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Add_rm64_r64, + dest_reg, + self.mem_op_from_stack_entry(*src_entry_idx), + )?)?; } } Ok(()) @@ -377,46 +362,36 @@ impl X86_64Codegen { fn mov(&mut self, dest: &Location, src: &Location) -> Result<()> { match (dest, src) { (Location::Register(dest_reg), Location::Register(src_reg)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Mov_r64_rm64, - *dest_reg, - *src_reg, - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Mov_r64_rm64, + *dest_reg, + *src_reg, + )?)?; } (Location::Register(dest_reg), Location::Stack(src_entry_idx)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Mov_r64_rm64, - *dest_reg, - self.mem_op_from_stack_entry(*src_entry_idx), - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Mov_r64_rm64, + *dest_reg, + self.mem_op_from_stack_entry(*src_entry_idx), + )?)?; } (Location::Stack(dest_entry_idx), Location::Register(src_reg)) => { - self.asm.add_instruction( - Instruction::with2( - Code::Mov_rm64_r64, - self.mem_op_from_stack_entry(*dest_entry_idx), - *src_reg, - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Mov_rm64_r64, + self.mem_op_from_stack_entry(*dest_entry_idx), + *src_reg, + )?)?; } (Location::Stack(dest_entry_idx), Location::Stack(src_entry_idx)) => { - let (dest_reg, spilled) = self.allocator.move_stack_to_free_reg( - *dest_entry_idx - ); + let (dest_reg, spilled) = self.allocator.move_stack_to_free_reg(*dest_entry_idx); if let Some(spilled) = spilled { self.do_spilling(spilled)?; } - self.asm.add_instruction( - Instruction::with2( - Code::Mov_rm64_r64, - dest_reg, - self.mem_op_from_stack_entry(*src_entry_idx), - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Mov_rm64_r64, + dest_reg, + self.mem_op_from_stack_entry(*src_entry_idx), + )?)?; } } Ok(()) @@ -425,23 +400,16 @@ impl X86_64Codegen { fn move_i32(&mut self, loc: Location, value: i32) -> Result<()> { match loc { Location::Register(reg) => { - self.asm.add_instruction( - Instruction::with2( - Code::Mov_rm64_imm32, - reg, - value, - )? - )?; + self.asm + .add_instruction(Instruction::with2(Code::Mov_rm64_imm32, reg, value)?)?; } Location::Stack(entry_idx) => { assert_eq!(entry_idx, self.allocator.frame.entries.len() - 1); - self.asm.add_instruction( - Instruction::with2( - Code::Pushq_imm32, - self.mem_op_from_stack_entry(entry_idx), - value, - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Pushq_imm32, + self.mem_op_from_stack_entry(entry_idx), + value, + )?)?; } }; Ok(()) @@ -456,32 +424,23 @@ impl X86_64Codegen { fn move_i64(&mut self, loc: Location, value: i64) -> Result<()> { match loc { Location::Register(reg) => { - self.asm.add_instruction( - Instruction::with2( - Code::Mov_r64_imm64, - reg, - value, - )? - )?; + self.asm + .add_instruction(Instruction::with2(Code::Mov_r64_imm64, reg, value)?)?; } Location::Stack(entry_idx) => { assert_eq!(entry_idx, self.allocator.frame.entries.len() - 1); // Split the value into two 32 bit values let (low, high) = (value as u32, (value >> 32) as u32); - self.asm.add_instruction( - Instruction::with2( - Code::Pushq_imm32, - self.mem_op_from_stack_entry(entry_idx), - low, - )? - )?; - self.asm.add_instruction( - Instruction::with2( - Code::Pushq_imm32, - self.mem_op_from_stack_entry(entry_idx), - high, - )? - )?; + self.asm.add_instruction(Instruction::with2( + Code::Pushq_imm32, + self.mem_op_from_stack_entry(entry_idx), + low, + )?)?; + self.asm.add_instruction(Instruction::with2( + Code::Pushq_imm32, + self.mem_op_from_stack_entry(entry_idx), + high, + )?)?; } }; Ok(()) @@ -509,16 +468,12 @@ impl X86_64Codegen { fn mem_op_from_stack_entry(&self, stack_entry_idx: usize) -> MemoryOperand { let stack_offset = self.allocator.frame.get_entry(stack_entry_idx).offset; - MemoryOperand::with_base_displ( - Register::RBP, - stack_offset as i64, - ) + MemoryOperand::with_base_displ(Register::RBP, stack_offset as i64) } pub fn get_asm_output(&mut self) -> Result { let bytes = self.asm.assemble(0)?; - let mut decoder = - Decoder::with_ip(64, &bytes, 0, DecoderOptions::NONE); + let mut decoder = Decoder::with_ip(64, &bytes, 0, DecoderOptions::NONE); let mut formatter = IntelFormatter::new(); formatter.options_mut().set_number_base(NumberBase::Decimal); let mut temp_instr_output = String::new(); @@ -559,18 +514,15 @@ impl Allocator { pub fn ensure_in_register(&mut self, place: PlaceIdx) -> Result<(Register, Option)> { Ok(match self.get_location(&place).copied() { None => { - anyhow::bail!("Cannot ensure place {:?} is in register because it is not allocated", place); - } - Some(location) => { - match location { - Location::Register(reg) => { - (reg, None) - } - Location::Stack(entry_idx) => { - self.move_stack_to_free_reg(entry_idx) - } - } + anyhow::bail!( + "Cannot ensure place {:?} is in register because it is not allocated", + place + ); } + Some(location) => match location { + Location::Register(reg) => (reg, None), + Location::Stack(entry_idx) => self.move_stack_to_free_reg(entry_idx), + }, }) } @@ -580,45 +532,48 @@ impl Allocator { let (reg, spilled) = self.get_free_reg(entry_ty); self.free_stack(entry_idx); self.use_register(reg); - let place = self.places.iter().find( - |(_, loc)| match loc { + let place = self + .places + .iter() + .find(|(_, loc)| match loc { Location::Register(_) => false, - Location::Stack(idx) => *idx == entry_idx - } - ).map(|(place, _)| *place); + Location::Stack(idx) => *idx == entry_idx, + }) + .map(|(place, _)| *place); if let Some(place) = place { self.places.insert(place, Location::Register(reg)); } if let Some((spilled_place, _, spilled_to)) = spilled { - self.places.insert(spilled_place, Location::Stack(spilled_to)); + self.places + .insert(spilled_place, Location::Stack(spilled_to)); } (reg, spilled) } fn get_free_reg(&mut self, ty: Type) -> (Register, Option) { let mut spilled = None; - let reg = self.find_register_for_ty(ty).unwrap_or_else( - || { - let res = self.find_register_to_spill(ty); - spilled = Some(res); - res.1 - } - ); + let reg = self.find_register_for_ty(ty).unwrap_or_else(|| { + let res = self.find_register_to_spill(ty); + spilled = Some(res); + res.1 + }); (reg, spilled) } fn find_register_to_spill(&mut self, ty: Type) -> Spilled { - let (reg_to_spill, place_to_spill) = self.places.iter().find_map(|(place, loc)| { - match loc { + let (reg_to_spill, place_to_spill) = self + .places + .iter() + .find_map(|(place, loc)| match loc { Location::Register(reg) => { if reg.size() == ty.layout().size { return Some((*reg, *place)); } None } - Location::Stack(_) => None - } - }).unwrap(); + Location::Stack(_) => None, + }) + .unwrap(); let stack_idx = self.alloc_stack(ty); return (place_to_spill, reg_to_spill, stack_idx); } @@ -640,7 +595,9 @@ impl Allocator { fn find_register_for_ty(&mut self, ty: Type) -> Option { for reg in Register::values().filter( // todo: once we use lower than 64 bit integers, we need to check if the smaller registers are available - |reg| !self.used_registers.contains(reg) && reg.is_gpr() && reg.size() == ty.layout().size + |reg| { + !self.used_registers.contains(reg) && reg.is_gpr() && reg.size() == ty.layout().size + }, ) { self.used_registers.insert(reg); return Some(reg); @@ -664,14 +621,15 @@ impl Allocator { None => { bug!("{:?} has not yet been allocated.", place); } - Some(loc) => loc + Some(loc) => loc, } } pub fn get_location_or_alloc(&mut self, place: &lir::Place) -> Location { - self.places.get(&place.idx).copied().unwrap_or_else(|| { - self.alloc_place(place) - }) + self.places + .get(&place.idx) + .copied() + .unwrap_or_else(|| self.alloc_place(place)) } pub fn free_place(&mut self, place: &lir::Place) -> Result<()> { @@ -692,9 +650,7 @@ impl Allocator { Location::Register(reg) => { self.used_registers.remove(reg); } - Location::Stack(idx) => { - self.free_stack(*idx) - } + Location::Stack(idx) => self.free_stack(*idx), } } @@ -714,7 +670,6 @@ enum Location { Stack(usize), } - #[derive(Debug, Clone, Default)] struct StackFrame { entries: Vec, @@ -764,9 +719,7 @@ impl StackFrame { /// ----------------- /// | 0 | live /// ----------------- - /// /// ``` - /// fn cascading_free(&mut self, mut idx: usize) { while self.free(idx) { idx -= 1; @@ -803,4 +756,3 @@ struct StackFrameEntry { offset: usize, live: bool, } - diff --git a/lang/src/compilation_unit.rs b/lang/src/compilation_unit.rs index e75bd23..2ef5428 100644 --- a/lang/src/compilation_unit.rs +++ b/lang/src/compilation_unit.rs @@ -1,21 +1,59 @@ -use std::cell::RefCell; -use std::ops::Deref; +use std::{ + cell::RefCell, + ops::Deref, + rc::Rc, +}; + +use fusion_compiler::{ + idx, + Idx, + IdxVec, +}; -use std::rc::Rc; - -use fusion_compiler::{idx, Idx, IdxVec}; - -use crate::ast::evaluator::ASTEvaluator; -use crate::ast::lexer::{Lexer, Token}; -use crate::ast::parser::Parser; -use crate::ast::visitor::ASTVisitor; -use crate::ast::{AssignExpr, Ast, BinOpKind, BinaryExpr, BlockExpr, BoolExpr, CallExpr, Expr, ExprId, FunctionDeclaration, IfExpr, ItemId, LetStmt, NumberExpr, ParenthesizedExpr, ReturnStmt, Stmt, StmtKind, UnOpKind, UnaryExpr, VarExpr, WhileStmt, StmtId, Body}; -use crate::diagnostics::printer::DiagnosticsPrinter; -use crate::diagnostics::DiagnosticsBagCell; -use crate::text::span::TextSpan; #[allow(unused_imports)] pub use crate::typings::Type; -use crate::{diagnostics, text}; +use crate::{ + ast::{ + evaluator::ASTEvaluator, + lexer::{ + Lexer, + Token, + }, + parser::Parser, + visitor::ASTVisitor, + AssignExpr, + Ast, + BinOpKind, + BinaryExpr, + BlockExpr, + Body, + BoolExpr, + CallExpr, + Expr, + ExprId, + FunctionDeclaration, + IfExpr, + ItemId, + LetStmt, + NumberExpr, + ParenthesizedExpr, + ReturnStmt, + Stmt, + StmtId, + StmtKind, + UnOpKind, + UnaryExpr, + VarExpr, + WhileStmt, + }, + diagnostics, + diagnostics::{ + printer::DiagnosticsPrinter, + DiagnosticsBagCell, + }, + text, + text::span::TextSpan, +}; idx!(FunctionIdx); idx!(VariableIdx); @@ -28,7 +66,6 @@ pub struct Function { pub return_type: Type, } - #[derive(Debug, Clone)] pub struct Variable { pub name: String, @@ -51,7 +88,13 @@ impl GlobalScope { } } - pub fn declare_variable(&mut self, identifier: &str, ty: Type, is_global: bool, is_shadowing: bool) -> VariableIdx { + pub fn declare_variable( + &mut self, + identifier: &str, + ty: Type, + is_global: bool, + is_shadowing: bool, + ) -> VariableIdx { let variable = Variable { name: identifier.to_string(), ty, @@ -226,7 +269,6 @@ impl Scopes { fn current_local_scope(&self) -> Option<&LocalScope> { self.local_scopes.last() } - } struct Resolver { @@ -323,7 +365,12 @@ pub fn resolve_type_from_string(diagnostics: &DiagnosticsBagCell, type_name: &To } impl ASTVisitor for Resolver { - fn visit_func_decl(&mut self, ast: &mut Ast, func_decl: &FunctionDeclaration, _item_id: ItemId) { + fn visit_func_decl( + &mut self, + ast: &mut Ast, + func_decl: &FunctionDeclaration, + _item_id: ItemId, + ) { let function_idx = func_decl.idx; self.scopes.enter_function_scope(function_idx); let function = self.scopes.global_scope.functions.get(function_idx); @@ -410,11 +457,7 @@ impl ASTVisitor for Resolver { let then_ty = if_statement.then_branch.ty_or_void(&*ast); let else_ty = else_branch.body.ty_or_void(&*ast); let else_span = else_branch.body.span(&*ast); - ty = self.expect_type( - then_ty, - &else_ty, - &else_span, - ); + ty = self.expect_type(then_ty, &else_ty, &else_span); self.scopes.exit_scope(); } ast.set_type(expr.id, ty); diff --git a/lang/src/diagnostics/mod.rs b/lang/src/diagnostics/mod.rs index 4ec4111..753ad74 100644 --- a/lang/src/diagnostics/mod.rs +++ b/lang/src/diagnostics/mod.rs @@ -1,9 +1,16 @@ -use std::cell::RefCell; -use std::rc::Rc; - -use crate::ast::lexer::{Token, TokenKind}; -use crate::text::span::TextSpan; -use crate::typings::Type; +use std::{ + cell::RefCell, + rc::Rc, +}; + +use crate::{ + ast::lexer::{ + Token, + TokenKind, + }, + text::span::TextSpan, + typings::Type, +}; pub mod printer; @@ -155,9 +162,14 @@ impl DiagnosticsBag { #[cfg(test)] mod test { - use crate::compilation_unit::CompilationUnit; - use crate::diagnostics::{Diagnostic, DiagnosticKind}; - use crate::text::span::TextSpan; + use crate::{ + compilation_unit::CompilationUnit, + diagnostics::{ + Diagnostic, + DiagnosticKind, + }, + text::span::TextSpan, + }; struct DiagnosticsVerifier { actual: Vec, diff --git a/lang/src/diagnostics/printer.rs b/lang/src/diagnostics/printer.rs index 6ab2066..435f4c5 100644 --- a/lang/src/diagnostics/printer.rs +++ b/lang/src/diagnostics/printer.rs @@ -1,7 +1,15 @@ -use crate::diagnostics::Diagnostic; -use crate::text::SourceText; use std::cmp; -use termion::color::{Fg, Red, Reset}; + +use termion::color::{ + Fg, + Red, + Reset, +}; + +use crate::{ + diagnostics::Diagnostic, + text::SourceText, +}; pub struct DiagnosticsPrinter<'a> { text: &'a SourceText, @@ -23,7 +31,6 @@ impl<'a> DiagnosticsPrinter<'a> { /// ^ /// | /// +-- This is the error message (:) - /// pub fn stringify_diagnostic(&self, diagnostic: &Diagnostic) -> String { let line_index = self.text.line_index(diagnostic.span.start); let line = self.text.get_line(line_index); diff --git a/lang/src/hir/builder.rs b/lang/src/hir/builder.rs index 0c0670b..f701393 100644 --- a/lang/src/hir/builder.rs +++ b/lang/src/hir/builder.rs @@ -1,11 +1,32 @@ -use std::cell::Cell; -use std::collections::HashMap; +use std::{ + cell::Cell, + collections::HashMap, +}; use fusion_compiler::bug; -use crate::ast::{Ast, ExprId, ExprKind, ItemKind, StmtId, StmtKind}; -use crate::compilation_unit::{GlobalScope, VariableIdx}; -use crate::hir::{HIR, HIRExpr, HIRExprKind, HIRStmt, HIRStmtKind, Type}; +use crate::{ + ast::{ + Ast, + ExprId, + ExprKind, + ItemKind, + StmtId, + StmtKind, + }, + compilation_unit::{ + GlobalScope, + VariableIdx, + }, + hir::{ + HIRExpr, + HIRExprKind, + HIRStmt, + HIRStmtKind, + Type, + HIR, + }, +}; struct Ctx { stmts: Vec, @@ -13,9 +34,7 @@ struct Ctx { impl Ctx { fn new() -> Self { - Self { - stmts: vec![], - } + Self { stmts: vec![] } } fn with_capacity(capacity: usize) -> Self { @@ -35,7 +54,6 @@ impl HIRBuilder { Self { hir: HIR { functions: HashMap::new(), - }, temp_var_counter: Cell::new(0), } @@ -57,14 +75,18 @@ impl HIRBuilder { self.hir } - fn build_stmt(&self, stmt_id: StmtId, ast: &Ast, global_scope: &mut GlobalScope, ctx: &mut Ctx) { + fn build_stmt( + &self, + stmt_id: StmtId, + ast: &Ast, + global_scope: &mut GlobalScope, + ctx: &mut Ctx, + ) { let stmt = ast.query_stmt(stmt_id); let kind = match &stmt.kind { StmtKind::Expr(expr) => { let expr = self.build_expr(*expr, ast, global_scope, ctx); - HIRStmtKind::Expr { - expr, - } + HIRStmtKind::Expr { expr } } StmtKind::Let(let_stmt) => { let expr = self.build_expr(let_stmt.initializer, ast, global_scope, ctx); @@ -79,44 +101,43 @@ impl HIRBuilder { for stmt_id in while_stmt.body.iter() { self.build_stmt(*stmt_id, ast, global_scope, &mut while_body_ctx); } - let body = vec![ - HIRStmt { - kind: HIRStmtKind::If { - condition, - then_body: while_body_ctx.stmts, - else_body: vec![HIRStmt { - kind: HIRStmtKind::Break, - }], - } - } - ]; - HIRStmtKind::Loop { - body, - } + let body = vec![HIRStmt { + kind: HIRStmtKind::If { + condition, + then_body: while_body_ctx.stmts, + else_body: vec![HIRStmt { + kind: HIRStmtKind::Break, + }], + }, + }]; + HIRStmtKind::Loop { body } } StmtKind::Return(return_stmt) => { - let expr = return_stmt.return_value.as_ref().copied().map(|expr_id| { - self.build_expr(expr_id, ast, global_scope, ctx) - }).unwrap_or(HIRExpr { - kind: HIRExprKind::Unit, - ty: Type::Void, - }); - HIRStmtKind::Return { - expr, - } + let expr = return_stmt + .return_value + .as_ref() + .copied() + .map(|expr_id| self.build_expr(expr_id, ast, global_scope, ctx)) + .unwrap_or(HIRExpr { + kind: HIRExprKind::Unit, + ty: Type::Void, + }); + HIRStmtKind::Return { expr } } }; - ctx.stmts.push(HIRStmt { - kind, - }); + ctx.stmts.push(HIRStmt { kind }); } - fn build_expr(&self, expr_id: ExprId, ast: &Ast, global_scope: &mut GlobalScope, ctx: &mut Ctx) -> HIRExpr { + fn build_expr( + &self, + expr_id: ExprId, + ast: &Ast, + global_scope: &mut GlobalScope, + ctx: &mut Ctx, + ) -> HIRExpr { let expr = ast.query_expr(expr_id); let kind = match &expr.kind { - ExprKind::Number(number_expr) => { - HIRExprKind::Number(number_expr.number) - } + ExprKind::Number(number_expr) => HIRExprKind::Number(number_expr.number), ExprKind::Binary(binary_expr) => { let lhs = self.build_expr(binary_expr.left, ast, global_scope, ctx); let rhs = self.build_expr(binary_expr.right, ast, global_scope, ctx); @@ -134,18 +155,17 @@ impl HIRBuilder { } } ExprKind::Parenthesized(parenthesized_expr) => { - self.build_expr(parenthesized_expr.inner, ast, global_scope, ctx).kind - } - ExprKind::Variable(variable_expr) => { - HIRExprKind::Var(variable_expr.variable_idx) - } - ExprKind::Boolean(boolean_expr) => { - HIRExprKind::Bool(boolean_expr.value) + self.build_expr(parenthesized_expr.inner, ast, global_scope, ctx) + .kind } + ExprKind::Variable(variable_expr) => HIRExprKind::Var(variable_expr.variable_idx), + ExprKind::Boolean(boolean_expr) => HIRExprKind::Bool(boolean_expr.value), ExprKind::Call(call_expr) => { - let arguments = call_expr.arguments.iter().map(|expr_id| { - self.build_expr(*expr_id, ast, global_scope, ctx) - }).collect(); + let arguments = call_expr + .arguments + .iter() + .map(|expr_id| self.build_expr(*expr_id, ast, global_scope, ctx)) + .collect(); HIRExprKind::Call { function_idx: call_expr.function_idx, arguments, @@ -156,7 +176,7 @@ impl HIRBuilder { kind: HIRStmtKind::Assign { lhs: assignment_expr.variable_idx, rhs: self.build_expr(assignment_expr.expression, ast, global_scope, ctx), - } + }, }; ctx.stmts.push(stmt); HIRExprKind::Var(assignment_expr.variable_idx) @@ -174,25 +194,26 @@ impl HIRBuilder { HIRStmtKind::Expr { expr } => expr.clone(), _ => bug!("ICE: Last statement in block expression is not an expression"), }; - let temp_variable_idx = self.declare_next_temp_var(global_scope, expr.ty.clone()); + let temp_variable_idx = + self.declare_next_temp_var(global_scope, expr.ty.clone()); ctx.stmts.push(HIRStmt { kind: HIRStmtKind::Decl { variable_idx: temp_variable_idx, initializer: None, - } + }, }); *last_stmt = HIRStmt { kind: HIRStmtKind::Assign { lhs: temp_variable_idx, rhs: expr, - } + }, }; HIRExprKind::Var(temp_variable_idx) }; ctx.stmts.push(HIRStmt { kind: HIRStmtKind::Block { body: block_ctx.stmts, - } + }, }); expr_kind } @@ -211,12 +232,13 @@ impl HIRBuilder { let expr_kind = if matches!(expr.ty, Type::Void) { HIRExprKind::Unit } else { - let temp_variable_idx = self.declare_next_temp_var(global_scope, expr.ty.clone()); + let temp_variable_idx = + self.declare_next_temp_var(global_scope, expr.ty.clone()); ctx.stmts.push(HIRStmt { kind: HIRStmtKind::Decl { variable_idx: temp_variable_idx, initializer: None, - } + }, }); let then_expr = match then_ctx.stmts.last_mut().unwrap().kind { HIRStmtKind::Expr { ref mut expr } => expr.clone(), @@ -230,13 +252,13 @@ impl HIRBuilder { kind: HIRStmtKind::Assign { lhs: temp_variable_idx, rhs: then_expr, - } + }, }; *else_ctx.stmts.last_mut().unwrap() = HIRStmt { kind: HIRStmtKind::Assign { lhs: temp_variable_idx, rhs: else_expr, - } + }, }; HIRExprKind::Var(temp_variable_idx) }; @@ -245,7 +267,7 @@ impl HIRBuilder { condition, then_body: then_ctx.stmts, else_body: else_ctx.stmts, - } + }, }); expr_kind } @@ -258,12 +280,7 @@ impl HIRBuilder { } fn declare_next_temp_var(&self, global_scope: &mut GlobalScope, ty: Type) -> VariableIdx { - global_scope.declare_variable( - &self.next_temp_variable(), - ty, - false, - false, - ) + global_scope.declare_variable(&self.next_temp_variable(), ty, false, false) } fn next_temp_variable(&self) -> String { diff --git a/lang/src/hir/mod.rs b/lang/src/hir/mod.rs index 0609309..2101049 100644 --- a/lang/src/hir/mod.rs +++ b/lang/src/hir/mod.rs @@ -5,8 +5,17 @@ pub use builder::HIRBuilder; #[allow(unused)] pub use writer::HIRWriter; -use crate::ast::{BinOpKind, UnOpKind}; -use crate::compilation_unit::{FunctionIdx, Type, VariableIdx}; +use crate::{ + ast::{ + BinOpKind, + UnOpKind, + }, + compilation_unit::{ + FunctionIdx, + Type, + VariableIdx, + }, +}; mod builder; mod writer; diff --git a/lang/src/hir/writer.rs b/lang/src/hir/writer.rs index 08be1da..48336a0 100644 --- a/lang/src/hir/writer.rs +++ b/lang/src/hir/writer.rs @@ -1,17 +1,27 @@ use std::fmt::Write; use anyhow::Result; - use fusion_compiler::Idx; -use crate::compilation_unit::GlobalScope; -use crate::hir::{HIR, HIRExpr, HIRExprKind, HIRStmt, HIRStmtKind}; +use crate::{ + compilation_unit::GlobalScope, + hir::{ + HIRExpr, + HIRExprKind, + HIRStmt, + HIRStmtKind, + HIR, + }, +}; pub struct HIRWriter { _phantom: std::marker::PhantomData, } -impl HIRWriter where W: Write { +impl HIRWriter +where + W: Write, +{ pub fn write(writer: &mut W, hir: &HIR, global_scope: &GlobalScope) -> Result<()> { for (function_id, body) in &hir.functions { let function = global_scope.functions.get(*function_id); @@ -34,7 +44,11 @@ impl HIRWriter where W: Write { Ok(()) } - fn write_statement(writer: &mut W, statement: &HIRStmt, global_scope: &GlobalScope) -> Result<()> { + fn write_statement( + writer: &mut W, + statement: &HIRStmt, + global_scope: &GlobalScope, + ) -> Result<()> { match &statement.kind { HIRStmtKind::Loop { body } => { writeln!(writer, "loop {{")?; @@ -43,7 +57,11 @@ impl HIRWriter where W: Write { } writeln!(writer, "}}")?; } - HIRStmtKind::If { condition, then_body, else_body } => { + HIRStmtKind::If { + condition, + then_body, + else_body, + } => { write!(writer, "if ")?; Self::write_expression(writer, condition, global_scope)?; writeln!(writer, " {{")?; @@ -72,7 +90,10 @@ impl HIRWriter where W: Write { Self::write_expression(writer, expr, global_scope)?; writeln!(writer)?; } - HIRStmtKind::Decl { variable_idx, initializer } => { + HIRStmtKind::Decl { + variable_idx, + initializer, + } => { let variable = global_scope.variables.get(*variable_idx); write!(writer, "let {}: {}", variable.name, variable.ty)?; if let Some(initializer) = initializer { @@ -94,7 +115,11 @@ impl HIRWriter where W: Write { Ok(()) } - fn write_expression(writer: &mut W, expression: &HIRExpr, global_scope: &GlobalScope) -> Result<()> { + fn write_expression( + writer: &mut W, + expression: &HIRExpr, + global_scope: &GlobalScope, + ) -> Result<()> { match &expression.kind { HIRExprKind::Binary { operator, lhs, rhs } => { Self::write_expression(writer, lhs.as_ref(), global_scope)?; @@ -105,7 +130,10 @@ impl HIRWriter where W: Write { write!(writer, "{}", operator)?; Self::write_expression(writer, operand.as_ref(), global_scope)?; } - HIRExprKind::Call { function_idx, arguments } => { + HIRExprKind::Call { + function_idx, + arguments, + } => { let function = global_scope.functions.get(*function_idx); write!(writer, "{}(", function.name)?; for (arg_idx, arg) in arguments.iter().enumerate() { diff --git a/lang/src/lib.rs b/lang/src/lib.rs index 877f0b1..42fc373 100644 --- a/lang/src/lib.rs +++ b/lang/src/lib.rs @@ -12,12 +12,11 @@ macro_rules! idx { fn new(index: usize) -> Self { Self(index) } - } }; } -pub trait Idx: Copy + Clone + Sized{ +pub trait Idx: Copy + Clone + Sized { fn as_index(&self) -> usize; fn new(index: usize) -> Self; @@ -32,15 +31,14 @@ pub trait Idx: Copy + Clone + Sized{ #[derive(Debug, Clone, Eq, PartialEq, Default)] pub struct IdxVec - where - Index: Idx, +where + Index: Idx, { vec: Vec, _marker: std::marker::PhantomData, } -impl IdxVec -{ +impl IdxVec { pub fn new() -> Self { Self { vec: vec![], @@ -60,30 +58,28 @@ impl IdxVec next_index } - - pub fn iter(&self) -> impl Iterator { + pub fn iter(&self) -> impl Iterator { self.vec.iter() } - pub fn iter_mut(&mut self) -> impl Iterator { + pub fn iter_mut(&mut self) -> impl Iterator { self.vec.iter_mut() } - pub fn indexed_iter(&self) -> impl Iterator { + pub fn indexed_iter(&self) -> impl Iterator { self.vec .iter() .enumerate() .map(|(index, value)| (Index::new(index), value)) } - pub fn indexed_iter_mut(&mut self) -> impl Iterator { + pub fn indexed_iter_mut(&mut self) -> impl Iterator { self.vec .iter_mut() .enumerate() .map(|(index, value)| (Index::new(index), value)) } - pub fn cloned_indices(&self) -> Vec { self.vec .iter() @@ -92,7 +88,6 @@ impl IdxVec .collect() } - pub fn len(&self) -> usize { self.vec.len() } @@ -109,7 +104,7 @@ impl IdxVec &mut self[index] } - pub fn indices(&self) -> impl Iterator { + pub fn indices(&self) -> impl Iterator { (0..self.vec.len()).map(|index| Index::new(index)) } } @@ -121,7 +116,7 @@ impl IdxVec> { } #[inline] - pub fn indexed_iter_as_option(&self) -> impl Iterator> { + pub fn indexed_iter_as_option(&self) -> impl Iterator> { self.vec .iter() .enumerate() @@ -130,19 +125,22 @@ impl IdxVec> { #[inline] pub fn get_or_panic(&self, index: I) -> &T { - self.get(index).as_ref().unwrap_or_else(|| crate::bug!("Index {} does not exist", index.as_index())) + self.get(index) + .as_ref() + .unwrap_or_else(|| crate::bug!("Index {} does not exist", index.as_index())) } #[inline] pub fn get_mut_or_panic(&mut self, index: I) -> &mut T { - self.get_mut(index).as_mut().unwrap_or_else(|| crate::bug!("Index {} does not exist", index.as_index())) + self.get_mut(index) + .as_mut() + .unwrap_or_else(|| crate::bug!("Index {} does not exist", index.as_index())) } - } impl std::ops::Index for IdxVec - where - Index: Idx, +where + Index: Idx, { type Output = T; @@ -152,8 +150,8 @@ impl std::ops::Index for IdxVec } impl std::ops::IndexMut for IdxVec - where - Index: Idx, +where + Index: Idx, { fn index_mut(&mut self, index: Index) -> &mut T { return &mut self.vec[index.as_index()]; diff --git a/lang/src/lir/builder.rs b/lang/src/lir/builder.rs index c8918a0..2d370f9 100644 --- a/lang/src/lir/builder.rs +++ b/lang/src/lir/builder.rs @@ -1,10 +1,35 @@ use std::collections::HashMap; + use fusion_compiler::Idx; -use crate::compilation_unit::{GlobalScope, VariableIdx}; -use crate::lir::{BasicBlock, BasicBlockIdx, ConstOp, Function, Instruction, InstructionKind, LIR, Operand, OperandKind, Place, PlaceIdx, Terminator, Type}; -use crate::mir; -use crate::mir::{Binop, InstructionIdx, MIR, Value}; +use crate::{ + compilation_unit::{ + GlobalScope, + VariableIdx, + }, + lir::{ + BasicBlock, + BasicBlockIdx, + ConstOp, + Function, + Instruction, + InstructionKind, + Operand, + OperandKind, + Place, + PlaceIdx, + Terminator, + Type, + LIR, + }, + mir, + mir::{ + Binop, + InstructionIdx, + Value, + MIR, + }, +}; pub struct LIRBuilder<'mir> { mir: &'mir MIR, @@ -32,14 +57,12 @@ impl<'mir> LIRBuilder<'mir> { pub fn build(mut self) -> LIR { for (mir_function_idx, mir_function) in self.mir.functions.indexed_iter() { self.current_mir_function_idx = Some(mir_function_idx); - let function_idx = self.lir.functions.push( - Function { - name: mir_function.name.clone(), - return_type: mir_function.return_type.into(), - basic_blocks: Vec::new(), - parameters: Vec::new(), - } - ); + let function_idx = self.lir.functions.push(Function { + name: mir_function.name.clone(), + return_type: mir_function.return_type.into(), + basic_blocks: Vec::new(), + parameters: Vec::new(), + }); for bb_idx in mir_function.basic_blocks.iter().copied() { let mir_bb = self.mir.basic_blocks.get_or_panic(bb_idx); let _ = self.start_basic_block(); @@ -50,27 +73,35 @@ impl<'mir> LIRBuilder<'mir> { let lhs = self.build_operand(lhs); let rhs = self.build_operand(rhs); match operator { - Binop::Add => InstructionKind::Add { target: self.get_referencing_place(instruction_idx), lhs, rhs }, - Binop::Sub => InstructionKind::Sub { target: self.get_referencing_place(instruction_idx), lhs, rhs }, - Binop::Gt => InstructionKind::Gt { target: self.get_referencing_place(instruction_idx), lhs, rhs }, + Binop::Add => InstructionKind::Add { + target: self.get_referencing_place(instruction_idx), + lhs, + rhs, + }, + Binop::Sub => InstructionKind::Sub { + target: self.get_referencing_place(instruction_idx), + lhs, + rhs, + }, + Binop::Gt => InstructionKind::Gt { + target: self.get_referencing_place(instruction_idx), + lhs, + rhs, + }, _ => todo!("Unsupported binary operator {:?}", operator), } } mir::InstructionKind::Unary { .. } => todo!(), - mir::InstructionKind::Value(value) => { - InstructionKind::AllocInit { - target: self.get_referencing_place(instruction_idx), - value: self.build_operand(value), - } - } + mir::InstructionKind::Value(value) => InstructionKind::AllocInit { + target: self.get_referencing_place(instruction_idx), + value: self.build_operand(value), + }, mir::InstructionKind::Call { .. } => todo!(), mir::InstructionKind::Phi(_) => todo!(), }; - self.current_basic_block().instructions.push( - Instruction { - kind: instruction, - } - ); + self.current_basic_block() + .instructions + .push(Instruction { kind: instruction }); } let terminator = match &mir_bb.terminator().kind { mir::TerminatorKind::Return { value } => { @@ -78,9 +109,7 @@ impl<'mir> LIRBuilder<'mir> { Value::Void => None, _ => Some(self.build_operand(value)), }; - Terminator::Return { - value, - } + Terminator::Return { value } } mir::TerminatorKind::Jump(target) => Terminator::Jump { // todo: validate if that is correct @@ -91,7 +120,9 @@ impl<'mir> LIRBuilder<'mir> { }; self.current_basic_block().terminator = Some(terminator); let function = self.lir.functions.get_mut(function_idx); - function.basic_blocks.push(self.current_bb.expect("No current basic block")); + function + .basic_blocks + .push(self.current_bb.expect("No current basic block")); } } self.lir @@ -112,65 +143,60 @@ impl<'mir> LIRBuilder<'mir> { ty: Type::Int32, kind: OperandKind::Const(ConstOp::Int32(*value)), }, - Value::Void => todo!() + Value::Void => todo!(), } } fn start_basic_block(&mut self) -> BasicBlockIdx { - let bb_idx = self.lir.basic_blocks.push( - BasicBlock::default() - ); + let bb_idx = self.lir.basic_blocks.push(BasicBlock::default()); self.current_bb = Some(bb_idx); bb_idx } fn current_basic_block(&mut self) -> &mut BasicBlock { - self.lir.basic_blocks.get_mut(self.current_bb.expect("No current basic block")) + self.lir + .basic_blocks + .get_mut(self.current_bb.expect("No current basic block")) } fn get_current_function(&self) -> &mir::Function { - self.mir.functions.get(self.current_mir_function_idx.expect("No current function")) + self.mir + .functions + .get(self.current_mir_function_idx.expect("No current function")) } fn get_referencing_place(&mut self, instruction_idx: InstructionIdx) -> PlaceIdx { - let instruction = self.get_current_function().instructions.get(instruction_idx); + let instruction = self + .get_current_function() + .instructions + .get(instruction_idx); let ty = instruction.ty.into(); - let aliased_var = self.get_current_function().local_aliases.get(&instruction_idx).copied(); + let aliased_var = self + .get_current_function() + .local_aliases + .get(&instruction_idx) + .copied(); match aliased_var { - None => { - match self.instruction_to_place.get(&instruction_idx) { - None => { - let place = self.create_place(ty); - self.instruction_to_place.insert(instruction_idx, place); - place - } - Some(place) => { - *place - } + None => match self.instruction_to_place.get(&instruction_idx) { + None => { + let place = self.create_place(ty); + self.instruction_to_place.insert(instruction_idx, place); + place } - } - Some(aliased_var) => { - match self.var_to_place.get(&aliased_var) { - None => { - let place = self.create_place(ty); - self.var_to_place.insert(aliased_var, place); - place - } - Some(place) => { - *place - } + Some(place) => *place, + }, + Some(aliased_var) => match self.var_to_place.get(&aliased_var) { + None => { + let place = self.create_place(ty); + self.var_to_place.insert(aliased_var, place); + place } - } + Some(place) => *place, + }, } } fn create_place(&mut self, ty: Type) -> PlaceIdx { - self.lir.places.push_with_index( - |idx| - Place { - ty, - idx, - }) + self.lir.places.push_with_index(|idx| Place { ty, idx }) } } - diff --git a/lang/src/lir/mod.rs b/lang/src/lir/mod.rs index 4336667..0638afb 100644 --- a/lang/src/lir/mod.rs +++ b/lang/src/lir/mod.rs @@ -1,4 +1,9 @@ -use fusion_compiler::{idx, Idx, IdxVec}; +use fusion_compiler::{ + idx, + Idx, + IdxVec, +}; + use crate::mir; pub(crate) mod builder; @@ -23,7 +28,6 @@ impl LIR { } } - idx!(FunctionIdx); #[derive(Debug)] @@ -40,7 +44,6 @@ pub struct BasicBlock { pub terminator: Option, } - idx!(BasicBlockIdx); #[derive(Debug)] @@ -81,12 +84,8 @@ pub enum InstructionKind { #[derive(Debug)] pub enum Terminator { - Return { - value: Option, - }, - Jump { - target: BasicBlockIdx, - }, + Return { value: Option }, + Jump { target: BasicBlockIdx }, } #[derive(Debug)] @@ -95,7 +94,6 @@ pub struct Operand { pub kind: OperandKind, } - #[derive(Debug)] pub enum OperandKind { Deref(PlaceIdx), @@ -117,12 +115,11 @@ pub struct Place { pub ty: Type, } - idx!(PlaceIdx); #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum Type { Int32, - Int8 + Int8, } impl Type { @@ -154,4 +151,3 @@ pub struct Layout { pub size: usize, pub alignment: usize, } - diff --git a/lang/src/main.rs b/lang/src/main.rs index d328d3a..422578a 100644 --- a/lang/src/main.rs +++ b/lang/src/main.rs @@ -1,25 +1,37 @@ #![feature(exit_status_error)] -use std::fs::File; -use std::io::Write; +use std::{ + fs::File, + io::Write, +}; -use anyhow::{anyhow, Result}; +use anyhow::{ + anyhow, + Result, +}; -use crate::compilation_unit::CompilationUnit; -use crate::hir::{HIRBuilder, HIRWriter}; -use crate::mir::{MIRBuilder, MIRWriter}; -use crate::mir::optimizations::Optimizer; +use crate::{ + compilation_unit::CompilationUnit, + hir::{ + HIRBuilder, + HIRWriter, + }, + mir::{ + optimizations::Optimizer, + MIRBuilder, + MIRWriter, + }, +}; mod ast; mod codegen; mod compilation_unit; mod diagnostics; -mod text; -mod typings; -mod mir; mod hir; mod lir; - +mod mir; +mod text; +mod typings; fn main() -> Result<()> { std::env::set_var("RUST_BACKTRACE", "1"); @@ -46,9 +58,8 @@ fn main() -> Result<()> { } } "; - let mut compilation_unit = CompilationUnit::compile(input).map_err( - |err| anyhow!("Compilation failed") - )?; + let mut compilation_unit = + CompilationUnit::compile(input).map_err(|err| anyhow!("Compilation failed"))?; compilation_unit.run(); // let program = CProgram::from_compilation_unit(&compilation_unit); // let c_return_value = program.run()?; diff --git a/lang/src/mir/basic_block.rs b/lang/src/mir/basic_block.rs index 1ab13d8..28e05f9 100644 --- a/lang/src/mir/basic_block.rs +++ b/lang/src/mir/basic_block.rs @@ -1,6 +1,19 @@ -use std::fmt::{Display, Formatter}; -use fusion_compiler::{bug, Idx, idx}; -use crate::mir::{InstructionIdx, Terminator, TerminatorKind}; +use std::fmt::{ + Display, + Formatter, +}; + +use fusion_compiler::{ + bug, + idx, + Idx, +}; + +use crate::mir::{ + InstructionIdx, + Terminator, + TerminatorKind, +}; /// A node in the MIR. /// @@ -32,17 +45,14 @@ pub struct BasicBlock { } impl BasicBlock { - pub fn new( - idx: BasicBlockIdx, - ) -> Self { + pub fn new(idx: BasicBlockIdx) -> Self { Self { instructions: vec![], terminator: None, - idx + idx, } } - #[inline] pub fn is_terminated(&self) -> bool { self.terminator.is_some() @@ -50,12 +60,12 @@ impl BasicBlock { #[inline] pub fn set_terminator(&mut self, kind: TerminatorKind) { - tracing::debug!("Setting terminator of {:?} to {:?}",self.idx , kind); + tracing::debug!("Setting terminator of {:?} to {:?}", self.idx, kind); self.terminator = Some(Terminator::new(kind)); } /// Sets the [terminator][Terminator] of the basic block if the basic block is not already terminated. - pub fn maybe_set_terminator(&mut self, kind: TerminatorKind) { + pub fn maybe_set_terminator(&mut self, kind: TerminatorKind) { if !self.is_terminated() { self.set_terminator(kind); } @@ -63,15 +73,18 @@ impl BasicBlock { #[inline] pub fn terminator(&self) -> &Terminator { - self.terminator.as_ref().unwrap_or_else(|| bug!("Invalid terminator state in {:?}", self.idx)) + self.terminator + .as_ref() + .unwrap_or_else(|| bug!("Invalid terminator state in {:?}", self.idx)) } #[inline] pub fn terminator_mut(&mut self) -> &mut Terminator { - self.terminator.as_mut().unwrap_or_else(|| bug!("Invalid terminator state in {:?}", self.idx)) + self.terminator + .as_mut() + .unwrap_or_else(|| bug!("Invalid terminator state in {:?}", self.idx)) } - /// Appends `other` to `self`. /// /// 1. Appends the instructions of `other` to `self` @@ -99,7 +112,6 @@ impl BasicBlock { /// %5 = add %6, %7 /// %8 = add %5, %9 /// jump bb2 ; note that the terminator of bb0 is replaced with the terminator of bb1 - /// pub fn append(&mut self, other: Self) { self.instructions.extend(other.instructions); self.terminator = other.terminator; diff --git a/lang/src/mir/builder.rs b/lang/src/mir/builder.rs index 255a674..296aab8 100644 --- a/lang/src/mir/builder.rs +++ b/lang/src/mir/builder.rs @@ -1,23 +1,57 @@ -use std::collections::{HashMap, HashSet}; -use std::ops::{Deref, DerefMut}; +use std::{ + collections::{ + HashMap, + HashSet, + }, + ops::{ + Deref, + DerefMut, + }, +}; -use fusion_compiler::{bug, Idx, IdxVec}; +use fusion_compiler::{ + bug, + Idx, + IdxVec, +}; -use crate::compilation_unit::{GlobalScope, VariableIdx}; -use crate::hir::{HIR, HIRExpr, HIRExprKind, HIRStmt, HIRStmtKind}; -use crate::mir::{BasicBlocks, Function, FunctionIdx, Instruction, InstructionIdx, InstructionKind, MIR, PhiNode, TerminatorKind, Value}; -use crate::mir::basic_block::{BasicBlock, BasicBlockIdx}; +use crate::{ + compilation_unit::{ + GlobalScope, + VariableIdx, + }, + hir::{ + HIRExpr, + HIRExprKind, + HIRStmt, + HIRStmtKind, + HIR, + }, + mir::{ + basic_block::{ + BasicBlock, + BasicBlockIdx, + }, + BasicBlocks, + Function, + FunctionIdx, + Instruction, + InstructionIdx, + InstructionKind, + PhiNode, + TerminatorKind, + Value, + MIR, + }, +}; pub struct MIRBuilder { mir: MIR, } - impl MIRBuilder { pub fn new() -> Self { - Self { - mir: MIR::new(), - } + Self { mir: MIR::new() } } pub fn build(mut self, hir: &HIR, global_scope: &GlobalScope) -> MIR { @@ -25,33 +59,35 @@ impl MIRBuilder { let mut function_map = HashMap::new(); for (function_idx, function_body) in hir.functions.iter() { let function = global_scope.functions.get(*function_idx); - let function_builder = FunctionBuilder::new( - Function { - name: function.name.clone(), - return_type: function.return_type.clone().into(), - parameters: function.parameters.clone(), - basic_blocks: Vec::new(), - instructions: IdxVec::new(), - local_aliases: HashMap::new(), - } - ); - let (function, to_be_resolved) = function_builder.build( - &mut self.mir.basic_blocks, - global_scope, - function_body, - ); + let function_builder = FunctionBuilder::new(Function { + name: function.name.clone(), + return_type: function.return_type.clone().into(), + parameters: function.parameters.clone(), + basic_blocks: Vec::new(), + instructions: IdxVec::new(), + local_aliases: HashMap::new(), + }); + let (function, to_be_resolved) = + function_builder.build(&mut self.mir.basic_blocks, global_scope, function_body); let mir_function_idx = self.mir.functions.push(function); - calls_to_resolve.extend(to_be_resolved.into_iter().map(|(instruction_idx, function_idx)| (instruction_idx, function_idx, mir_function_idx))); + calls_to_resolve.extend(to_be_resolved.into_iter().map( + |(instruction_idx, function_idx)| (instruction_idx, function_idx, mir_function_idx), + )); function_map.insert(*function_idx, mir_function_idx); } for (instruction_idx, function_idx, function_that_called) in calls_to_resolve { let mir_function_idx = function_map[&function_idx]; - let instruction = self.mir.functions[function_that_called].instructions.get_mut(instruction_idx); + let instruction = self.mir.functions[function_that_called] + .instructions + .get_mut(instruction_idx); match &mut instruction.kind { - InstructionKind::Call { function_idx: call_function_idx, .. } => { + InstructionKind::Call { + function_idx: call_function_idx, + .. + } => { *call_function_idx = mir_function_idx; } - _ => bug!("Expected call instruction, found {:?}", instruction.kind) + _ => bug!("Expected call instruction, found {:?}", instruction.kind), } } self.mir @@ -72,9 +108,9 @@ struct FunctionBuilder { /// ```rust /// let a = 0; /// if true { - /// let a = 1; - /// a = 2; - /// println(a); + /// let a = 1; + /// a = 2; + /// println(a); /// } /// ``` /// would be translated to: @@ -113,14 +149,26 @@ impl FunctionBuilder { } } - pub fn build(mut self, basic_blocks: &mut BasicBlocks, global_scope: &GlobalScope, body: &[HIRStmt]) -> (Function, Vec<(InstructionIdx, crate::compilation_unit::FunctionIdx)>) { + pub fn build( + mut self, + basic_blocks: &mut BasicBlocks, + global_scope: &GlobalScope, + body: &[HIRStmt], + ) -> ( + Function, + Vec<(InstructionIdx, crate::compilation_unit::FunctionIdx)>, + ) { let mut bb_builder = BasicBlockBuilder::new(basic_blocks, &mut self.function); for (index, variable_idx) in self.function.parameters.clone().into_iter().enumerate() { let param_type = global_scope.variables.get(variable_idx).ty.clone().into(); - let instruction_idx = bb_builder.add_instruction(basic_blocks, &mut self.function, Instruction::new( - InstructionKind::Value(Value::ParameterRef(index)), - param_type, - )); + let instruction_idx = bb_builder.add_instruction( + basic_blocks, + &mut self.function, + Instruction::new( + InstructionKind::Value(Value::ParameterRef(index)), + param_type, + ), + ); self.write_variable(variable_idx, bb_builder.current_bb, instruction_idx); } for stmt in body.iter() { @@ -132,11 +180,25 @@ impl FunctionBuilder { self.seal_block(basic_blocks, block, global_scope); } let immediate_predecessors = predecessors.get_immediate(block); - for instr_idx in basic_blocks.get_or_panic(block).instructions.iter().copied() { + for instr_idx in basic_blocks + .get_or_panic(block) + .instructions + .iter() + .copied() + { let instruction = &self.function.instructions[instr_idx]; if let InstructionKind::Phi(phi) = &instruction.kind { - let predecessors_len = immediate_predecessors.map(|ip| ip.len()).unwrap_or_default(); - assert_eq!(phi.operands.len(), predecessors_len, "Phi node in {} has {} operand(s), but {} predecessor(s)", block, phi.operands.len(), predecessors_len); + let predecessors_len = immediate_predecessors + .map(|ip| ip.len()) + .unwrap_or_default(); + assert_eq!( + phi.operands.len(), + predecessors_len, + "Phi node in {} has {} operand(s), but {} predecessor(s)", + block, + phi.operands.len(), + predecessors_len + ); for (pred, _) in phi.operands.iter() { if let Some(immediate_predecessors) = immediate_predecessors { assert!(immediate_predecessors.contains(pred), "Phi node {:?} has operand for predecessor {:?}, but that is not an immediate predecessor of {:?}", phi, pred, block); @@ -150,20 +212,28 @@ impl FunctionBuilder { (self.function, self.call_references_to_resolve) } - fn build_stmt(&mut self, basic_blocks: &mut BasicBlocks, bb_builder: &mut BasicBlockBuilder, global_scope: &GlobalScope, stmt: &HIRStmt) { + fn build_stmt( + &mut self, + basic_blocks: &mut BasicBlocks, + bb_builder: &mut BasicBlockBuilder, + global_scope: &GlobalScope, + stmt: &HIRStmt, + ) { match &stmt.kind { - HIRStmtKind::Expr { - expr - } => { + HIRStmtKind::Expr { expr } => { // Transform the expression into a value and assign it to a new instruction // E.g. `1 + 2` becomes `%0 = 1 + 2` let value = self.build_expr(basic_blocks, bb_builder, global_scope, expr); let ty = expr.ty.clone().into(); - bb_builder.add_instruction(basic_blocks, &mut self.function, Instruction::new(InstructionKind::Value(value), ty)); + bb_builder.add_instruction( + basic_blocks, + &mut self.function, + Instruction::new(InstructionKind::Value(value), ty), + ); } HIRStmtKind::Decl { initializer, - variable_idx + variable_idx, } => { // Transform the initializer into a value and assign it to a new instruction // The instruction now represents the variable @@ -177,16 +247,19 @@ impl FunctionBuilder { // %0 = 1 + 2 // println(%0) // ``` - let value = initializer.as_ref().map(|initializer| self.build_expr(basic_blocks, bb_builder, global_scope, initializer)); + let value = initializer.as_ref().map(|initializer| { + self.build_expr(basic_blocks, bb_builder, global_scope, initializer) + }); let ty = global_scope.variables.get(*variable_idx).ty.clone().into(); // todo: we should figure out a way to omit the instruction if the variable is not initialized, e.g. by just setting the variable as live (using a StorageLive instruction?) - let instruction_idx = bb_builder.add_instruction(basic_blocks, &mut self.function, Instruction::new( - InstructionKind::Value(value.unwrap_or(Value::Void)), ty)); + let instruction_idx = bb_builder.add_instruction( + basic_blocks, + &mut self.function, + Instruction::new(InstructionKind::Value(value.unwrap_or(Value::Void)), ty), + ); self.write_variable(*variable_idx, bb_builder.current_bb, instruction_idx); } - HIRStmtKind::Loop { - body - } => { + HIRStmtKind::Loop { body } => { // High level steps: // 1. Create a loop entry block // 2. Build the loop body @@ -227,13 +300,20 @@ impl FunctionBuilder { // jump bb1 // bb5: <-- loop exit // return - let pred = bb_builder.terminate_and(basic_blocks, &mut self.function, TerminatorKind::Jump); + let pred = bb_builder.terminate_and( + basic_blocks, + &mut self.function, + TerminatorKind::Jump, + ); let loop_entry_bb = bb_builder.current_bb; self.push_loop(loop_entry_bb); for stmt in body.iter() { self.build_stmt(basic_blocks, bb_builder, global_scope, stmt); } - if !basic_blocks.get_or_panic(bb_builder.current_bb).is_terminated() { + if !basic_blocks + .get_or_panic(bb_builder.current_bb) + .is_terminated() + { bb_builder.terminate(basic_blocks, TerminatorKind::Jump(loop_entry_bb)); self.seal_block(basic_blocks, bb_builder.current_bb, global_scope); } @@ -243,21 +323,20 @@ impl FunctionBuilder { self.pop_loop_and_update(basic_blocks, exit_block); self.seal_block(basic_blocks, exit_block, global_scope); } - HIRStmtKind::Return { - expr - } => { + HIRStmtKind::Return { expr } => { let value = self.build_expr(basic_blocks, bb_builder, global_scope, expr); - if basic_blocks.get_or_panic(bb_builder.current_bb).is_terminated() { + if basic_blocks + .get_or_panic(bb_builder.current_bb) + .is_terminated() + { bb_builder.start_new_bb(basic_blocks, &mut self.function); } - let bb = bb_builder.terminate(basic_blocks, TerminatorKind::Return { - value, - }); + let bb = bb_builder.terminate(basic_blocks, TerminatorKind::Return { value }); } HIRStmtKind::If { condition, then_body, - else_body + else_body, } => { tracing::debug!("Building if statement"); tracing::debug!("Building condition"); @@ -266,13 +345,14 @@ impl FunctionBuilder { let then_start_bb = bb_builder.start_new_bb(basic_blocks, &mut self.function); let else_start_bb = bb_builder.start_new_bb(basic_blocks, &mut self.function); bb_builder.set_bb(pred); - bb_builder.terminate(basic_blocks, TerminatorKind::SwitchInt { - value: condition, - cases: vec![ - (0, else_start_bb), - ], - default: then_start_bb, - }); + bb_builder.terminate( + basic_blocks, + TerminatorKind::SwitchInt { + value: condition, + cases: vec![(0, else_start_bb)], + default: then_start_bb, + }, + ); tracing::debug!("Built condition"); // todo: is this correct? // self.seal_block(basic_blocks, pred, global_scope); @@ -294,12 +374,12 @@ impl FunctionBuilder { let else_exit_bb = bb_builder.current_bb; let if_end_bb = bb_builder.start_new_bb(basic_blocks, &mut self.function); tracing::debug!("Building if terminator"); - basic_blocks.get_mut_or_panic(then_exit_bb).maybe_set_terminator( - TerminatorKind::Jump(if_end_bb) - ); - basic_blocks.get_mut_or_panic(else_exit_bb).maybe_set_terminator( - TerminatorKind::Jump(if_end_bb) - ); + basic_blocks + .get_mut_or_panic(then_exit_bb) + .maybe_set_terminator(TerminatorKind::Jump(if_end_bb)); + basic_blocks + .get_mut_or_panic(else_exit_bb) + .maybe_set_terminator(TerminatorKind::Jump(if_end_bb)); tracing::debug!("Built if terminator"); // self.seal_block(basic_blocks, if_end_bb, global_scope); } @@ -308,13 +388,13 @@ impl FunctionBuilder { self.build_stmt(basic_blocks, bb_builder, global_scope, stmt); } } - HIRStmtKind::Assign { - rhs, - lhs - } => { + HIRStmtKind::Assign { rhs, lhs } => { let value = self.build_expr(basic_blocks, bb_builder, global_scope, rhs); - let instruction_idx = bb_builder.add_instruction(basic_blocks, &mut self.function, Instruction::new( - InstructionKind::Value(value), rhs.ty.clone().into())); + let instruction_idx = bb_builder.add_instruction( + basic_blocks, + &mut self.function, + Instruction::new(InstructionKind::Value(value), rhs.ty.clone().into()), + ); self.write_variable(*lhs, bb_builder.current_bb, instruction_idx); } HIRStmtKind::Break => { @@ -339,74 +419,85 @@ impl FunctionBuilder { } } - fn build_expr(&mut self, basics_blocks: &mut BasicBlocks, bb_builder: &mut BasicBlockBuilder, global_scope: &GlobalScope, expr: &HIRExpr) -> Value { + fn build_expr( + &mut self, + basics_blocks: &mut BasicBlocks, + bb_builder: &mut BasicBlockBuilder, + global_scope: &GlobalScope, + expr: &HIRExpr, + ) -> Value { match &expr.kind { // todo: support other numbers HIRExprKind::Number(value) => Value::ConstantInt(*value as i32), HIRExprKind::Bool(value) => Value::ConstantInt(if *value { 1 } else { 0 }), - HIRExprKind::Binary { - lhs, - operator, - rhs - } => { + HIRExprKind::Binary { lhs, operator, rhs } => { let lhs = self.build_expr(basics_blocks, bb_builder, global_scope, lhs); let rhs = self.build_expr(basics_blocks, bb_builder, global_scope, rhs); let ty = expr.ty.clone().into(); - let instruction_ref = bb_builder.add_instruction(basics_blocks, - &mut self.function, - Instruction::new( - InstructionKind::Binary { - operator: (*operator).into(), - lhs, - rhs, - }, - ty, - ), + let instruction_ref = bb_builder.add_instruction( + basics_blocks, + &mut self.function, + Instruction::new( + InstructionKind::Binary { + operator: (*operator).into(), + lhs, + rhs, + }, + ty, + ), ); Value::InstructionRef(instruction_ref) } - HIRExprKind::Unary { - operator, - operand - } => { + HIRExprKind::Unary { operator, operand } => { let operand = self.build_expr(basics_blocks, bb_builder, global_scope, operand); let ty = expr.ty.clone().into(); - let instruction_ref = bb_builder.add_instruction(basics_blocks, - &mut self.function, - Instruction::new( - InstructionKind::Unary { - operator: (*operator).into(), - operand, - }, - ty, - ), + let instruction_ref = bb_builder.add_instruction( + basics_blocks, + &mut self.function, + Instruction::new( + InstructionKind::Unary { + operator: (*operator).into(), + operand, + }, + ty, + ), ); Value::InstructionRef(instruction_ref) } HIRExprKind::Var(variable_idx) => { - let instruction_ref = self.read_variable(basics_blocks, *variable_idx, bb_builder.current_bb, global_scope).unwrap(); + let instruction_ref = self + .read_variable( + basics_blocks, + *variable_idx, + bb_builder.current_bb, + global_scope, + ) + .unwrap(); Value::InstructionRef(instruction_ref) } HIRExprKind::Call { function_idx, - arguments + arguments, } => { - let arguments = arguments.iter().map( - |arg| self.build_expr(basics_blocks, bb_builder, global_scope, arg) - ).collect(); + let arguments = arguments + .iter() + .map(|arg| self.build_expr(basics_blocks, bb_builder, global_scope, arg)) + .collect(); let ty = expr.ty.clone().into(); - let instruction_idx = bb_builder.add_instruction(basics_blocks, - &mut self.function, - Instruction::new( - InstructionKind::Call { - // todo: fix this - function_idx: FunctionIdx::first(), - arguments, - }, - ty, - ), + let instruction_idx = bb_builder.add_instruction( + basics_blocks, + &mut self.function, + Instruction::new( + InstructionKind::Call { + // todo: fix this + function_idx: FunctionIdx::first(), + arguments, + }, + ty, + ), ); - self.call_references_to_resolve.push((instruction_idx, *function_idx)); + self.call_references_to_resolve + .push((instruction_idx, *function_idx)); Value::InstructionRef(instruction_idx) } HIRExprKind::Unit => Value::Void, @@ -426,9 +517,22 @@ impl FunctionBuilder { /// Records the definition of a variable in the current basic block. #[inline] - pub fn write_variable(&mut self, variable: VariableIdx, bb_idx: BasicBlockIdx, instruction: InstructionIdx) { - tracing::debug!("Writing variable {:?} in {} as {:?}", variable, bb_idx, instruction); - self.definitions.entry(variable).or_default().insert(bb_idx, instruction); + pub fn write_variable( + &mut self, + variable: VariableIdx, + bb_idx: BasicBlockIdx, + instruction: InstructionIdx, + ) { + tracing::debug!( + "Writing variable {:?} in {} as {:?}", + variable, + bb_idx, + instruction + ); + self.definitions + .entry(variable) + .or_default() + .insert(bb_idx, instruction); self.function.local_aliases.insert(instruction, variable); } @@ -437,35 +541,68 @@ impl FunctionBuilder { /// /// It first checks if there is a definition in the given basic block (local definition). /// todo!() - pub fn read_variable(&mut self, basic_blocks: &mut BasicBlocks, variable: VariableIdx, bb_idx: BasicBlockIdx, scope: &GlobalScope) -> Option { + pub fn read_variable( + &mut self, + basic_blocks: &mut BasicBlocks, + variable: VariableIdx, + bb_idx: BasicBlockIdx, + scope: &GlobalScope, + ) -> Option { let definitions = self.definitions.get(&variable)?; match definitions.get(&bb_idx) { Some(instruction) => Some(*instruction), - None => { - self.read_variable_recursive(basic_blocks, variable, bb_idx, scope) - } + None => self.read_variable_recursive(basic_blocks, variable, bb_idx, scope), } } - pub fn read_variable_recursive(&mut self, basic_blocks: &mut BasicBlocks, variable: VariableIdx, bb_idx: BasicBlockIdx, scope: &GlobalScope) -> Option { + pub fn read_variable_recursive( + &mut self, + basic_blocks: &mut BasicBlocks, + variable: VariableIdx, + bb_idx: BasicBlockIdx, + scope: &GlobalScope, + ) -> Option { let predecessors = self.function.predecessors(basic_blocks); let preceding_bbs = predecessors.get_immediate(bb_idx)?; let instruction_ref = if !self.is_sealed(bb_idx) { - tracing::debug!("Found unsealed block {:?} for variable {:?}. Inserting operandless phi", bb_idx, variable); - let instruction_ref = self.add_operandless_phi_to_bb(basic_blocks, variable, bb_idx, scope); - self.incomplete_phis.entry(bb_idx).or_default().push((instruction_ref, variable)); + tracing::debug!( + "Found unsealed block {:?} for variable {:?}. Inserting operandless phi", + bb_idx, + variable + ); + let instruction_ref = + self.add_operandless_phi_to_bb(basic_blocks, variable, bb_idx, scope); + self.incomplete_phis + .entry(bb_idx) + .or_default() + .push((instruction_ref, variable)); instruction_ref } else if preceding_bbs.len() == 1 { // Optimize the common use case of a single predecessor self.read_variable(basic_blocks, variable, preceding_bbs[0], scope)? } else { // Break potential cycles with operandless phi - tracing::debug!("Inserting operandless phi for variable {:?} in block {:?}", variable, bb_idx); - let instruction_ref = self.add_operandless_phi_to_bb(basic_blocks, variable, bb_idx, scope); + tracing::debug!( + "Inserting operandless phi for variable {:?} in block {:?}", + variable, + bb_idx + ); + let instruction_ref = + self.add_operandless_phi_to_bb(basic_blocks, variable, bb_idx, scope); self.write_variable(variable, bb_idx, instruction_ref); - tracing::debug!("Adding phi operands for {:?} in block {:?}", variable, bb_idx); + tracing::debug!( + "Adding phi operands for {:?} in block {:?}", + variable, + bb_idx + ); - self.add_phi_operands(basic_blocks, instruction_ref, variable, preceding_bbs, scope); + self.add_phi_operands( + basic_blocks, + instruction_ref, + variable, + preceding_bbs, + scope, + ); // todo: remove trivial phi // self.try_remove_trivial_phi(phi); instruction_ref @@ -474,10 +611,17 @@ impl FunctionBuilder { Some(instruction_ref) } - fn add_operandless_phi_to_bb(&mut self, basic_blocks: &mut BasicBlocks, variable: VariableIdx, bb: BasicBlockIdx, scope: &GlobalScope) -> InstructionIdx { - let instruction_ref = self.function.instructions.push( - Instruction::new(InstructionKind::Phi(PhiNode::operandless()), scope.variables[variable].ty.clone().into(), - )); + fn add_operandless_phi_to_bb( + &mut self, + basic_blocks: &mut BasicBlocks, + variable: VariableIdx, + bb: BasicBlockIdx, + scope: &GlobalScope, + ) -> InstructionIdx { + let instruction_ref = self.function.instructions.push(Instruction::new( + InstructionKind::Phi(PhiNode::operandless()), + scope.variables[variable].ty.clone().into(), + )); let instructions = basic_blocks.get_or_panic(bb).instructions.clone(); let mut instructions_with_phi = vec![instruction_ref]; instructions_with_phi.extend(instructions); @@ -487,7 +631,12 @@ impl FunctionBuilder { fn try_remove_trivial_phi(&self, phi: &mut PhiNode) {} - fn seal_block(&mut self, basic_blocks: &mut BasicBlocks, bb_idx: BasicBlockIdx, global_scope: &GlobalScope) { + fn seal_block( + &mut self, + basic_blocks: &mut BasicBlocks, + bb_idx: BasicBlockIdx, + global_scope: &GlobalScope, + ) { if self.is_sealed(bb_idx) { bug!("Tried to seal block {} after it had been sealed", bb_idx); } @@ -497,19 +646,42 @@ impl FunctionBuilder { tracing::debug!("{:?} has incomplete phis {:?}", bb_idx, incomplete_phis); let predecessors = self.function.predecessors(basic_blocks); for (incomplete_phi, variable_idx) in incomplete_phis.iter().copied() { - self.add_phi_operands(basic_blocks, incomplete_phi, variable_idx, predecessors.get_immediate(bb_idx).unwrap(), global_scope); + self.add_phi_operands( + basic_blocks, + incomplete_phi, + variable_idx, + predecessors.get_immediate(bb_idx).unwrap(), + global_scope, + ); } } self.incomplete_phis.remove(&bb_idx); self.sealed_blocks.insert(bb_idx); } - fn add_phi_operands(&mut self, basic_blocks: &mut BasicBlocks, phi: InstructionIdx, variable: VariableIdx, preds: &Vec, scope: &GlobalScope) { - tracing::debug!("Adding phi operands for {:?} with predecessors {:?}", phi, preds); + fn add_phi_operands( + &mut self, + basic_blocks: &mut BasicBlocks, + phi: InstructionIdx, + variable: VariableIdx, + preds: &Vec, + scope: &GlobalScope, + ) { + tracing::debug!( + "Adding phi operands for {:?} with predecessors {:?}", + phi, + preds + ); for pred in preds.iter().copied() { - let variable_ref = self.read_variable(basic_blocks, variable, pred, scope).unwrap_or_else(|| { - bug!("No definition for variable {:?} in block {:?}", variable, pred) - }); + let variable_ref = self + .read_variable(basic_blocks, variable, pred, scope) + .unwrap_or_else(|| { + bug!( + "No definition for variable {:?} in block {:?}", + variable, + pred + ) + }); let phi = self.function.instructions[phi].kind.as_phi_mut().unwrap(); phi.push((pred, variable_ref)) } @@ -519,7 +691,6 @@ impl FunctionBuilder { } } - /// A helper to build basic blocks. /// /// Can be used to start new basic blocks, add instructions and terminate basic blocks. @@ -538,10 +709,19 @@ impl BasicBlockBuilder { builder } - pub fn add_instruction(&mut self, basic_blocks: &mut BasicBlocks, function: &mut Function, instruction: Instruction) -> InstructionIdx { + pub fn add_instruction( + &mut self, + basic_blocks: &mut BasicBlocks, + function: &mut Function, + instruction: Instruction, + ) -> InstructionIdx { let current_bb = self.get_current_bb_mut(basic_blocks); if let Some(terminator) = current_bb.terminator.as_ref() { - bug!("{} already has a terminator: {:?}", self.current_bb, terminator) + bug!( + "{} already has a terminator: {:?}", + self.current_bb, + terminator + ) } let instruction_idx = function.instructions.push(instruction); current_bb.instructions.push(instruction_idx); @@ -549,7 +729,11 @@ impl BasicBlockBuilder { } /// Starts a new basic block in `function` and returns it. - pub fn start_new_bb(&mut self, basic_blocks: &mut BasicBlocks, function: &mut Function) -> BasicBlockIdx { + pub fn start_new_bb( + &mut self, + basic_blocks: &mut BasicBlocks, + function: &mut Function, + ) -> BasicBlockIdx { let new_bb = basic_blocks.push_basic_block(); function.basic_blocks.push(new_bb); tracing::debug!("Starting new basic block {:?}", new_bb); @@ -562,24 +746,40 @@ impl BasicBlockBuilder { /// **Panics** if the current basic block is already terminated. /// /// Note: This does not start a new basic block. Use [`BasicBlockBuilder::terminate_and`] for that. - pub fn terminate(&mut self, basic_blocks: &mut BasicBlocks, terminator: TerminatorKind) -> BasicBlockIdx { + pub fn terminate( + &mut self, + basic_blocks: &mut BasicBlocks, + terminator: TerminatorKind, + ) -> BasicBlockIdx { let bb = self.get_current_bb_mut(basic_blocks); if let Some(terminator) = bb.terminator.as_ref() { - bug!("{:?} already has a terminator: {:?}", self.current_bb, terminator) + bug!( + "{:?} already has a terminator: {:?}", + self.current_bb, + terminator + ) } // Ensure that we do not jump to the same basic block, which at the moment would lead to an infinite loop, when reading variables. match &terminator { TerminatorKind::Jump(to) => { - assert_ne!(*to, self.current_bb, "Jumping to the same basic block is not yet supported"); + assert_ne!( + *to, self.current_bb, + "Jumping to the same basic block is not yet supported" + ); } TerminatorKind::SwitchInt { default, cases, .. } => { - assert_ne!(*default, self.current_bb, "Jumping to the same basic block is not yet supported"); + assert_ne!( + *default, self.current_bb, + "Jumping to the same basic block is not yet supported" + ); for (_, target) in cases { - assert_ne!(*target, self.current_bb, "Jumping to the same basic block is not yet supported"); + assert_ne!( + *target, self.current_bb, + "Jumping to the same basic block is not yet supported" + ); } } - TerminatorKind::Return { .. } | - TerminatorKind::Unresolved => {} + TerminatorKind::Return { .. } | TerminatorKind::Unresolved => {} }; bb.set_terminator(terminator); self.current_bb @@ -590,7 +790,12 @@ impl BasicBlockBuilder { /// `terminator_builder` is called with the index of the new basic block. /// /// See [`BasicBlockBuilder::terminate`] and [`BasicBlockBuilder::start_new_bb`]. - pub fn terminate_and(&mut self, basic_blocks: &mut BasicBlocks, function: &mut Function, terminator_builder: impl FnOnce(BasicBlockIdx) -> TerminatorKind) -> BasicBlockIdx { + pub fn terminate_and( + &mut self, + basic_blocks: &mut BasicBlocks, + function: &mut Function, + terminator_builder: impl FnOnce(BasicBlockIdx) -> TerminatorKind, + ) -> BasicBlockIdx { let old_bb = self.current_bb; let new_bb = self.start_new_bb(basic_blocks, function); self.set_bb(old_bb); @@ -609,7 +814,10 @@ impl BasicBlockBuilder { } #[inline] - fn get_current_bb_mut<'ctx>(&mut self, basic_blocks: &'ctx mut BasicBlocks) -> &'ctx mut BasicBlock { + fn get_current_bb_mut<'ctx>( + &mut self, + basic_blocks: &'ctx mut BasicBlocks, + ) -> &'ctx mut BasicBlock { basic_blocks.get_mut_or_panic(self.current_bb) } @@ -619,7 +827,6 @@ impl BasicBlockBuilder { } } - #[derive(Debug, Clone)] /// A map from basic blocks to their immediate dominator. struct Dominators(HashMap); @@ -629,7 +836,9 @@ impl Dominators { Self(HashMap::new()) } - pub fn from_immediate_dominators(immediate_dominators: HashMap) -> Self { + pub fn from_immediate_dominators( + immediate_dominators: HashMap, + ) -> Self { Self(immediate_dominators) } @@ -708,7 +917,10 @@ impl Predecessors { } pub fn insert_immediate(&mut self, bb: BasicBlockIdx, successor: BasicBlockIdx) { - self.0.entry(bb).or_insert_with(|| Vec::with_capacity(1)).push(successor); + self.0 + .entry(bb) + .or_insert_with(|| Vec::with_capacity(1)) + .push(successor); } } @@ -745,7 +957,10 @@ impl Successors { } pub fn insert_immediate(&mut self, bb: BasicBlockIdx, successor: BasicBlockIdx) { - self.0.entry(bb).or_insert_with(|| HashSet::with_capacity(1)).insert(successor); + self.0 + .entry(bb) + .or_insert_with(|| HashSet::with_capacity(1)) + .insert(successor); } } @@ -758,11 +973,7 @@ impl Function { TerminatorKind::Jump(target) => { successors.insert_immediate(idx, *target); } - TerminatorKind::SwitchInt { - default, - cases, - .. - } => { + TerminatorKind::SwitchInt { default, cases, .. } => { successors.insert_immediate(idx, *default); for (_, target) in cases { successors.insert_immediate(idx, *target); @@ -784,11 +995,7 @@ impl Function { TerminatorKind::Jump(target) => { predecessors.insert_immediate(*target, idx); } - TerminatorKind::SwitchInt { - default, - cases, - .. - } => { + TerminatorKind::SwitchInt { default, cases, .. } => { predecessors.insert_immediate(*default, idx); for (_, target) in cases { predecessors.insert_immediate(*target, idx); @@ -809,11 +1016,17 @@ mod test { use fusion_compiler::Idx; - use crate::mir::{BasicBlockIdx, MIR}; + use crate::mir::{ + BasicBlockIdx, + FunctionIdx, + MIR, + }; pub fn assert_mir(input: &str, expected_mir: &str) -> MIR { - let mut compilation_unit = crate::compilation_unit::CompilationUnit::compile(input).unwrap(); - let hir = crate::hir::HIRBuilder::new().build(&compilation_unit.ast, &mut compilation_unit.global_scope); + let mut compilation_unit = + crate::compilation_unit::CompilationUnit::compile(input).unwrap(); + let hir = crate::hir::HIRBuilder::new() + .build(&compilation_unit.ast, &mut compilation_unit.global_scope); let mir = crate::mir::MIRBuilder::new().build(&hir, &compilation_unit.global_scope); let mut actual_mir = String::new(); crate::mir::MIRWriter::write_text_representation(&mut actual_mir, &mir).unwrap(); @@ -856,12 +1069,27 @@ bb5(): return %0 "#; let mir = assert_mir(input, expected); - let predecessors = mir.functions[mir.functions.first_index()].predecessors(); + let predecessors = mir.functions[FunctionIdx(0)].predecessors(); assert_eq!(predecessors.get_all(BasicBlockIdx::new(0)), HashSet::new()); - assert_eq!(predecessors.get_all(BasicBlockIdx::new(1)), HashSet::from([BasicBlockIdx::new(0), BasicBlockIdx::new(4)])); - assert_eq!(predecessors.get_all(BasicBlockIdx::new(2)), HashSet::from([BasicBlockIdx::new(1)])); - assert_eq!(predecessors.get_all(BasicBlockIdx::new(3)), HashSet::from([BasicBlockIdx::new(1)])); - assert_eq!(predecessors.get_all(BasicBlockIdx::new(4)), HashSet::from([BasicBlockIdx::new(2)])); - assert_eq!(predecessors.get_all(BasicBlockIdx::new(5)), HashSet::from([BasicBlockIdx::new(3)])); + assert_eq!( + predecessors.get_all(BasicBlockIdx::new(1)), + HashSet::from([BasicBlockIdx::new(0), BasicBlockIdx::new(4)]) + ); + assert_eq!( + predecessors.get_all(BasicBlockIdx::new(2)), + HashSet::from([BasicBlockIdx::new(1)]) + ); + assert_eq!( + predecessors.get_all(BasicBlockIdx::new(3)), + HashSet::from([BasicBlockIdx::new(1)]) + ); + assert_eq!( + predecessors.get_all(BasicBlockIdx::new(4)), + HashSet::from([BasicBlockIdx::new(2)]) + ); + assert_eq!( + predecessors.get_all(BasicBlockIdx::new(5)), + HashSet::from([BasicBlockIdx::new(3)]) + ); } } diff --git a/lang/src/mir/mod.rs b/lang/src/mir/mod.rs index d8ecb97..27315b6 100644 --- a/lang/src/mir/mod.rs +++ b/lang/src/mir/mod.rs @@ -1,23 +1,40 @@ -use std::collections::HashMap; -use std::fmt::{Display, Formatter}; -use std::ops::{Deref, DerefMut}; -use basic_block::BasicBlock; -use fusion_compiler::{bug, idx, Idx, IdxVec}; -use crate::compilation_unit::VariableIdx; -use crate::{ast, compilation_unit}; +use std::{ + collections::HashMap, + fmt::{ + Display, + Formatter, + }, + ops::{ + Deref, + DerefMut, + }, +}; +use basic_block::{ + BasicBlock, + BasicBlockIdx, +}; #[allow(unused)] pub use builder::MIRBuilder; - +use fusion_compiler::{ + bug, + idx, + Idx, + IdxVec, +}; #[allow(unused)] pub use writer::MIRWriter; -use basic_block::BasicBlockIdx; +use crate::{ + ast, + compilation_unit, + compilation_unit::VariableIdx, +}; + +mod basic_block; mod builder; -mod writer; pub mod optimizations; -mod basic_block; - +mod writer; #[derive(Debug, Copy, Clone)] pub enum Type { @@ -32,7 +49,9 @@ impl From for Type { compilation_unit::Type::Bool => Self::Bool, compilation_unit::Type::Int => Self::Int, compilation_unit::Type::Void => Self::Void, - compilation_unit::Type::Unresolved | compilation_unit::Type::Error => bug!("Unresolved type") + compilation_unit::Type::Unresolved | compilation_unit::Type::Error => { + bug!("Unresolved type") + } } } } @@ -45,8 +64,7 @@ pub struct MIR { } impl MIR { - pub fn new( - ) -> Self { + pub fn new() -> Self { Self { functions: Functions::new(), basic_blocks: BasicBlocks::new(), @@ -54,7 +72,8 @@ impl MIR { } pub fn new_basic_block(&mut self) -> BasicBlockIdx { - self.basic_blocks.push_with_index(|idx| Some(BasicBlock::new(idx))) + self.basic_blocks + .push_with_index(|idx| Some(BasicBlock::new(idx))) } } @@ -79,7 +98,6 @@ impl Deref for BasicBlocks { } } - impl DerefMut for BasicBlocks { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 @@ -100,7 +118,6 @@ pub struct Function { idx!(FunctionIdx); - #[derive(Debug, Clone, Eq, PartialEq)] pub enum Value { InstructionRef(InstructionIdx), @@ -140,7 +157,10 @@ impl Value { } } - pub fn replace_copy_with_copied_ref(&mut self, copies: &HashMap) -> bool { + pub fn replace_copy_with_copied_ref( + &mut self, + copies: &HashMap, + ) -> bool { match self { Self::InstructionRef(idx) => { if let Some(new_reference) = copies.get(idx) { @@ -169,9 +189,6 @@ impl Value { } } - - - #[derive(Debug)] pub struct Instruction { pub kind: InstructionKind, @@ -180,10 +197,7 @@ pub struct Instruction { impl Instruction { pub fn new(kind: InstructionKind, ty: Type) -> Self { - Self { - kind, - ty, - } + Self { kind, ty } } pub fn is_pure(&self) -> bool { @@ -386,9 +400,7 @@ pub struct Terminator { impl Terminator { pub fn new(kind: TerminatorKind) -> Self { - Self { - kind, - } + Self { kind } } } @@ -408,6 +420,4 @@ pub enum TerminatorKind { /// /// This is for example used for an unresolved break statement, because the target of a break is not known until the loop has been built. Unresolved, - } - diff --git a/lang/src/mir/optimizations/global/branch_elimination.rs b/lang/src/mir/optimizations/global/branch_elimination.rs index 3f6e755..5d1cb69 100644 --- a/lang/src/mir/optimizations/global/branch_elimination.rs +++ b/lang/src/mir/optimizations/global/branch_elimination.rs @@ -1,10 +1,17 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::{ + HashMap, + HashSet, +}; use itertools::Itertools; -use crate::mir::{InstructionKind, MIR, TerminatorKind}; -use crate::mir::basic_block::BasicBlockIdx; -use crate::mir::optimizations::MIRPass; +use crate::mir::{ + basic_block::BasicBlockIdx, + optimizations::MIRPass, + InstructionKind, + TerminatorKind, + MIR, +}; /// Branch elimination is a global optimization that removes branches that are not needed. /// @@ -48,7 +55,9 @@ impl AppendixGraph { let mut paths = all_paths.clone(); // Step 2: Filter out subset paths paths.retain(|path| { - !all_paths.iter().any(|other_path| Self::is_subset_path(path, other_path)) + !all_paths + .iter() + .any(|other_path| Self::is_subset_path(path, other_path)) }); paths @@ -71,7 +80,6 @@ impl AppendixGraph { false } - } impl MIRPass for BranchElimination { @@ -90,14 +98,25 @@ impl MIRPass for BranchElimination { TerminatorKind::Return { .. } => {} TerminatorKind::Jump(target_idx) => { let target_idx = *target_idx; - if predecessors.get_immediate(target_idx).map(|i| i.len()).unwrap_or_default() == 1 { + if predecessors + .get_immediate(target_idx) + .map(|i| i.len()) + .unwrap_or_default() + == 1 + { appendix_graph.add_edge(bb_idx, target_idx); } } - TerminatorKind::SwitchInt { value, cases, default } => { + TerminatorKind::SwitchInt { + value, + cases, + default, + } => { if let Some(value) = value.as_i32() { tracing::info!("Found a switch on a constant value, replacing with a jump to the target"); - let case = cases.iter().find(|(case_value, _)| *case_value as i32 == value); + let case = cases + .iter() + .find(|(case_value, _)| *case_value as i32 == value); let target = case.map(|c| c.1).unwrap_or(*default); terminator.kind = TerminatorKind::Jump(target); changes += 1; @@ -127,20 +146,26 @@ impl MIRPass for BranchElimination { for successor in successors { let successor = mir.basic_blocks.get_mut_or_panic(*successor); for instruction_idx in successor.instructions.iter_mut() { - let instruction = function.instructions.get_mut(*instruction_idx); + let instruction = + function.instructions.get_mut(*instruction_idx); match &mut instruction.kind { InstructionKind::Binary { .. } => {} InstructionKind::Unary { .. } => {} InstructionKind::Value(_) => {} InstructionKind::Call { .. } => {} InstructionKind::Phi(phi) => { - phi.operands = phi.operands.iter().copied().map(|(from, instruction_idx)| { - if from == bb_to_append_idx { - (bb_idx, instruction_idx) - } else { - (from, instruction_idx) - } - }).collect(); + phi.operands = phi + .operands + .iter() + .copied() + .map(|(from, instruction_idx)| { + if from == bb_to_append_idx { + (bb_idx, instruction_idx) + } else { + (from, instruction_idx) + } + }) + .collect(); } } } diff --git a/lang/src/mir/optimizations/global/dead_code_elimination.rs b/lang/src/mir/optimizations/global/dead_code_elimination.rs index f7bc886..6a28c60 100644 --- a/lang/src/mir/optimizations/global/dead_code_elimination.rs +++ b/lang/src/mir/optimizations/global/dead_code_elimination.rs @@ -1,7 +1,13 @@ use std::collections::HashSet; -use crate::mir::{InstructionIdx, InstructionKind, MIR, TerminatorKind, Value}; -use crate::mir::optimizations::MIRPass; +use crate::mir::{ + optimizations::MIRPass, + InstructionIdx, + InstructionKind, + TerminatorKind, + Value, + MIR, +}; struct ReferencedInstructions(HashSet); @@ -30,27 +36,17 @@ impl MIRPass for DeadCodeElimination { for instruction_idx in bb.instructions.iter().copied() { let instruction = &mut function.instructions[instruction_idx]; match &mut instruction.kind { - InstructionKind::Binary { - lhs, - rhs, - .. - } => { + InstructionKind::Binary { lhs, rhs, .. } => { referenced_instructions.insert_if_is_instruction_ref(lhs); referenced_instructions.insert_if_is_instruction_ref(rhs); } - InstructionKind::Unary { - operand, - .. - } => { + InstructionKind::Unary { operand, .. } => { referenced_instructions.insert_if_is_instruction_ref(operand); } InstructionKind::Value(value) => { referenced_instructions.insert_if_is_instruction_ref(value); } - InstructionKind::Call { - arguments, - .. - } => { + InstructionKind::Call { arguments, .. } => { for argument in arguments.iter_mut() { referenced_instructions.insert_if_is_instruction_ref(argument); } @@ -79,7 +75,9 @@ impl MIRPass for DeadCodeElimination { for bb in function.basic_blocks.iter().copied() { let bb = mir.basic_blocks.get_mut_or_panic(bb); bb.instructions.retain(|instruction_idx| { - if referenced_instructions.0.contains(instruction_idx) || !function.instructions[*instruction_idx].is_pure() { + if referenced_instructions.0.contains(instruction_idx) + || !function.instructions[*instruction_idx].is_pure() + { true } else { changes += 1; diff --git a/lang/src/mir/optimizations/global/mod.rs b/lang/src/mir/optimizations/global/mod.rs index 53ddfeb..d17142b 100644 --- a/lang/src/mir/optimizations/global/mod.rs +++ b/lang/src/mir/optimizations/global/mod.rs @@ -1,3 +1,3 @@ -pub mod dead_code_elimination; pub mod branch_elimination; +pub mod dead_code_elimination; pub mod unreachable_code_elimination; diff --git a/lang/src/mir/optimizations/global/unreachable_code_elimination.rs b/lang/src/mir/optimizations/global/unreachable_code_elimination.rs index b6a0600..5d34ff7 100644 --- a/lang/src/mir/optimizations/global/unreachable_code_elimination.rs +++ b/lang/src/mir/optimizations/global/unreachable_code_elimination.rs @@ -1,7 +1,11 @@ use fusion_compiler::Idx; -use crate::mir::{InstructionKind, MIR}; -use crate::mir::basic_block::BasicBlockIdx; -use crate::mir::optimizations::MIRPass; + +use crate::mir::{ + basic_block::BasicBlockIdx, + optimizations::MIRPass, + InstructionKind, + MIR, +}; pub struct UnreachableCodeElimination; @@ -17,7 +21,12 @@ impl MIRPass for UnreachableCodeElimination { if bb == BasicBlockIdx::first() { continue; } - if predecessors.get_immediate(bb).map(|i| i.len()).unwrap_or_default() == 0 { + if predecessors + .get_immediate(bb) + .map(|i| i.len()) + .unwrap_or_default() + == 0 + { tracing::debug!("Found unreachable basic block {}, removing it", bb); basic_blocks_to_remove.push(bb); changes += 1; diff --git a/lang/src/mir/optimizations/local/algebraic_simplification.rs b/lang/src/mir/optimizations/local/algebraic_simplification.rs index f6157f8..b90896a 100644 --- a/lang/src/mir/optimizations/local/algebraic_simplification.rs +++ b/lang/src/mir/optimizations/local/algebraic_simplification.rs @@ -1,5 +1,13 @@ -use crate::mir::{BasicBlockIdx, Binop, FunctionIdx, InstructionKind, MIR, Type, Value}; -use crate::mir::optimizations::local::LocalMIRPass; +use crate::mir::{ + optimizations::local::LocalMIRPass, + BasicBlockIdx, + Binop, + FunctionIdx, + InstructionKind, + Type, + Value, + MIR, +}; pub struct AlgebraicSimplification; @@ -15,7 +23,13 @@ impl AlgebraicSimplification { Binop::Add | Binop::Sub | Binop::Or | Binop::Shl | Binop::Shr => Some(known_side), Binop::Mul | Binop::And => Some(0), Binop::Div | Binop::Mod => todo!("report division by zero"), - Binop::Xor | Binop::Eq | Binop::Neq | Binop::Lt | Binop::Leq | Binop::Gt | Binop::Geq => None, + Binop::Xor + | Binop::Eq + | Binop::Neq + | Binop::Lt + | Binop::Leq + | Binop::Gt + | Binop::Geq => None, } } else if known_side == 1 { match operator { @@ -24,8 +38,20 @@ impl AlgebraicSimplification { Binop::Mul => Some(known_side), Binop::Div => Some(known_side), Binop::Mod => Some(0), - Binop::And => if matches!(op_ty,Type::Bool) { Some(known_side) } else { None }, - Binop::Or => if matches!(op_ty,Type::Bool) { Some(1) } else { None }, + Binop::And => { + if matches!(op_ty, Type::Bool) { + Some(known_side) + } else { + None + } + } + Binop::Or => { + if matches!(op_ty, Type::Bool) { + Some(1) + } else { + None + } + } Binop::Xor => None, Binop::Shl => None, Binop::Shr => None, @@ -44,30 +70,41 @@ impl AlgebraicSimplification { } impl LocalMIRPass for AlgebraicSimplification { - fn run_on_basic_block(&mut self, mir: &mut MIR, function_idx: FunctionIdx, bb_idx: BasicBlockIdx) -> u32 { + fn run_on_basic_block( + &mut self, + mir: &mut MIR, + function_idx: FunctionIdx, + bb_idx: BasicBlockIdx, + ) -> u32 { let mut changes = 0; let function = mir.functions.get_mut(function_idx); let bb = mir.basic_blocks.get_mut_or_panic(bb_idx); for instruction_idx in bb.instructions.iter().copied() { let instruction = function.instructions.get_mut(instruction_idx); match &mut instruction.kind { - InstructionKind::Binary { - lhs, - rhs, - operator - } => { + InstructionKind::Binary { lhs, rhs, operator } => { let lhs_int = lhs.as_i32(); let rhs_int = rhs.as_i32(); match (lhs_int, rhs_int) { (None, Some(rhs_int)) => { - if let Some(result) = self.simplify_binary_instruction_one_side_known(*operator, &instruction.ty, rhs_int) { - instruction.kind = InstructionKind::Value(Value::ConstantInt(result)); + if let Some(result) = self.simplify_binary_instruction_one_side_known( + *operator, + &instruction.ty, + rhs_int, + ) { + instruction.kind = + InstructionKind::Value(Value::ConstantInt(result)); changes += 1; } } (Some(lhs_int), None) => { - if let Some(result) = self.simplify_binary_instruction_one_side_known(*operator, &instruction.ty, lhs_int) { - instruction.kind = InstructionKind::Value(Value::ConstantInt(result)); + if let Some(result) = self.simplify_binary_instruction_one_side_known( + *operator, + &instruction.ty, + lhs_int, + ) { + instruction.kind = + InstructionKind::Value(Value::ConstantInt(result)); changes += 1; } } diff --git a/lang/src/mir/optimizations/local/constants_folding.rs b/lang/src/mir/optimizations/local/constants_folding.rs index 3e07051..7c81095 100644 --- a/lang/src/mir/optimizations/local/constants_folding.rs +++ b/lang/src/mir/optimizations/local/constants_folding.rs @@ -1,8 +1,24 @@ -use std::collections::HashMap; -use std::ops::{Deref, DerefMut}; +use std::{ + collections::HashMap, + ops::{ + Deref, + DerefMut, + }, +}; -use crate::mir::{BasicBlockIdx, Binop, FunctionIdx, Instruction, InstructionIdx, InstructionKind, MIR, TerminatorKind, Unop, Value}; -use crate::mir::optimizations::local::LocalMIRPass; +use crate::mir::{ + optimizations::local::LocalMIRPass, + BasicBlockIdx, + Binop, + FunctionIdx, + Instruction, + InstructionIdx, + InstructionKind, + TerminatorKind, + Unop, + Value, + MIR, +}; struct ComputedConstantValues(HashMap); @@ -17,7 +33,7 @@ impl ComputedConstantValues { let instruction_idx = value.as_instruction_ref(); match instruction_idx.as_ref() { None => false, - Some(idx) => self.get(idx).is_some() + Some(idx) => self.get(idx).is_some(), } } } @@ -30,12 +46,10 @@ impl ComputedConstantValues { fn get_as_constant_value(&self, value: &Value) -> Option { match value { Value::ConstantInt(value) => Some(Value::ConstantInt(*value)), - Value::InstructionRef(idx) => { - match self.get(idx) { - None => None, - Some(value) => self.get_as_constant_value(value) - } - } + Value::InstructionRef(idx) => match self.get(idx) { + None => None, + Some(value) => self.get_as_constant_value(value), + }, Value::Void => Some(Value::Void), Value::ParameterRef(_) => None, } @@ -58,9 +72,13 @@ impl DerefMut for ComputedConstantValues { pub struct ConstantFolding; - impl LocalMIRPass for ConstantFolding { - fn run_on_basic_block(&mut self, mir: &mut MIR, function_idx: FunctionIdx, bb_idx: BasicBlockIdx) -> u32 { + fn run_on_basic_block( + &mut self, + mir: &mut MIR, + function_idx: FunctionIdx, + bb_idx: BasicBlockIdx, + ) -> u32 { let mut changes = 0; let function = mir.functions.get_mut(function_idx); let bb = mir.basic_blocks.get_mut_or_panic(bb_idx); @@ -68,15 +86,10 @@ impl LocalMIRPass for ConstantFolding { for instruction_idx in bb.instructions.iter().copied() { let instruction = function.instructions.get_mut(instruction_idx); match &mut instruction.kind { - InstructionKind::Binary { - lhs, - rhs, - operator - } => { + InstructionKind::Binary { lhs, rhs, operator } => { let lhs_int = constant_values.get_as_constant_integer(lhs); let rhs_int = constant_values.get_as_constant_integer(rhs); - if let - (Some(lhs_int), Some(rhs_int)) = (lhs_int, rhs_int) { + if let (Some(lhs_int), Some(rhs_int)) = (lhs_int, rhs_int) { let result = match operator { // todo: replace with safe arithmetic Binop::Add => lhs_int + rhs_int, @@ -99,7 +112,8 @@ impl LocalMIRPass for ConstantFolding { let value = Value::ConstantInt(result); constant_values.insert(instruction_idx, value.clone()); changes += 1; - *instruction = Instruction::new(InstructionKind::Value(value), instruction.ty); + *instruction = + Instruction::new(InstructionKind::Value(value), instruction.ty); } } InstructionKind::Unary { operator, operand } => { @@ -112,7 +126,8 @@ impl LocalMIRPass for ConstantFolding { let value = Value::ConstantInt(result); constant_values.insert(instruction_idx, value.clone()); changes += 1; - *instruction = Instruction::new(InstructionKind::Value(value), instruction.ty); + *instruction = + Instruction::new(InstructionKind::Value(value), instruction.ty); } } InstructionKind::Value(value) => { @@ -150,17 +165,14 @@ impl LocalMIRPass for ConstantFolding { } } TerminatorKind::Jump(_) => {} - TerminatorKind::SwitchInt { - value, - .. - } => { + TerminatorKind::SwitchInt { value, .. } => { if let Some(constant_value) = constant_values.get_as_constant_value(value) { if value.replace_if_not_equal(constant_value.clone()) { changes += 1; } } } - TerminatorKind::Unresolved => {} + TerminatorKind::Unresolved => {} } } changes diff --git a/lang/src/mir/optimizations/local/copy_propagation.rs b/lang/src/mir/optimizations/local/copy_propagation.rs index 9f8fc62..51070ca 100644 --- a/lang/src/mir/optimizations/local/copy_propagation.rs +++ b/lang/src/mir/optimizations/local/copy_propagation.rs @@ -1,12 +1,24 @@ use std::collections::HashMap; -use crate::mir::{BasicBlockIdx, FunctionIdx, InstructionIdx, InstructionKind, MIR, TerminatorKind}; -use crate::mir::optimizations::local::LocalMIRPass; +use crate::mir::{ + optimizations::local::LocalMIRPass, + BasicBlockIdx, + FunctionIdx, + InstructionIdx, + InstructionKind, + TerminatorKind, + MIR, +}; pub struct CopyPropagation; impl LocalMIRPass for CopyPropagation { - fn run_on_basic_block(&mut self, mir: &mut MIR, function_idx: FunctionIdx, bb_idx: BasicBlockIdx) -> u32 { + fn run_on_basic_block( + &mut self, + mir: &mut MIR, + function_idx: FunctionIdx, + bb_idx: BasicBlockIdx, + ) -> u32 { let mut changes = 0; // Marks an instruction as a copy of another instruction let mut copies: HashMap = HashMap::new(); @@ -15,11 +27,7 @@ impl LocalMIRPass for CopyPropagation { for instruction_idx in bb.instructions.iter().copied() { let instruction = &mut function.instructions[instruction_idx]; match &mut instruction.kind { - InstructionKind::Binary { - lhs, - rhs, - .. - } => { + InstructionKind::Binary { lhs, rhs, .. } => { if lhs.replace_copy_with_copied_ref(&copies) { changes += 1; } @@ -27,10 +35,7 @@ impl LocalMIRPass for CopyPropagation { changes += 1; } } - InstructionKind::Unary { - operand, - .. - } => { + InstructionKind::Unary { operand, .. } => { if operand.replace_copy_with_copied_ref(&copies) { changes += 1; } @@ -43,10 +48,7 @@ impl LocalMIRPass for CopyPropagation { // changes += 1; // } } - InstructionKind::Call { - arguments, - .. - } => { + InstructionKind::Call { arguments, .. } => { for argument in arguments.iter_mut() { if argument.replace_copy_with_copied_ref(&copies) { changes += 1; diff --git a/lang/src/mir/optimizations/local/mod.rs b/lang/src/mir/optimizations/local/mod.rs index 7c11a1b..cf94459 100644 --- a/lang/src/mir/optimizations/local/mod.rs +++ b/lang/src/mir/optimizations/local/mod.rs @@ -1,14 +1,23 @@ -use crate::mir::{BasicBlockIdx, FunctionIdx, MIR}; -use crate::mir::optimizations::MIRPass; +use crate::mir::{ + optimizations::MIRPass, + BasicBlockIdx, + FunctionIdx, + MIR, +}; -mod constants_folding; mod algebraic_simplification; +mod constants_folding; mod copy_propagation; mod trivial_phi_node_elimination; pub trait LocalMIRPass { /// Returns the number of changes made to the BasicBlock - fn run_on_basic_block(&mut self, mir: &mut MIR, function_idx: FunctionIdx, bb_idx: BasicBlockIdx) -> u32; + fn run_on_basic_block( + &mut self, + mir: &mut MIR, + function_idx: FunctionIdx, + bb_idx: BasicBlockIdx, + ) -> u32; } pub struct LocalOptimizer { @@ -23,7 +32,7 @@ impl LocalOptimizer { Box::new(constants_folding::ConstantFolding), Box::new(copy_propagation::CopyPropagation), Box::new(algebraic_simplification::AlgebraicSimplification), - ] + ], } } } diff --git a/lang/src/mir/optimizations/local/trivial_phi_node_elimination.rs b/lang/src/mir/optimizations/local/trivial_phi_node_elimination.rs index a6785a0..15778fd 100644 --- a/lang/src/mir/optimizations/local/trivial_phi_node_elimination.rs +++ b/lang/src/mir/optimizations/local/trivial_phi_node_elimination.rs @@ -1,16 +1,28 @@ -use crate::mir::{FunctionIdx, InstructionKind, MIR, Value}; -use crate::mir::basic_block::BasicBlockIdx; -use crate::mir::optimizations::local::LocalMIRPass; +use crate::mir::{ + basic_block::BasicBlockIdx, + optimizations::local::LocalMIRPass, + FunctionIdx, + InstructionKind, + Value, + MIR, +}; // todo: we should move this to the mir construction and just remove all unneeded phi nodes at the end of construction pub struct TrivialPhiNodeElimination; impl LocalMIRPass for TrivialPhiNodeElimination { - fn run_on_basic_block(&mut self, mir: &mut MIR, function_idx: FunctionIdx, bb_idx: BasicBlockIdx) -> u32 { + fn run_on_basic_block( + &mut self, + mir: &mut MIR, + function_idx: FunctionIdx, + bb_idx: BasicBlockIdx, + ) -> u32 { let mut changes = 0; let bb = mir.basic_blocks.get_mut(bb_idx).as_mut().unwrap(); for instruction_idx in bb.instructions.iter().copied() { - let instruction = mir.functions[function_idx].instructions.get_mut(instruction_idx); + let instruction = mir.functions[function_idx] + .instructions + .get_mut(instruction_idx); if let InstructionKind::Phi(phi) = &instruction.kind { assert!(!phi.operands.is_empty()); let mut referenced_instruction = Some(&phi.operands[0].1); @@ -21,9 +33,13 @@ impl LocalMIRPass for TrivialPhiNodeElimination { } } if let Some(referenced_instruction) = referenced_instruction { - tracing::info!("Found a trivial phi node in {} with same operands, removing it", bb_idx); + tracing::info!( + "Found a trivial phi node in {} with same operands, removing it", + bb_idx + ); changes += 1; - instruction.kind = InstructionKind::Value(Value::InstructionRef(*referenced_instruction)); + instruction.kind = + InstructionKind::Value(Value::InstructionRef(*referenced_instruction)); } } } diff --git a/lang/src/mir/optimizations/mod.rs b/lang/src/mir/optimizations/mod.rs index 0c2fab9..8a5b861 100644 --- a/lang/src/mir/optimizations/mod.rs +++ b/lang/src/mir/optimizations/mod.rs @@ -1,7 +1,7 @@ use crate::mir::MIR; -mod local; mod global; +mod local; pub trait MIRPass { /// Returns the number of changes made to the MIR @@ -20,7 +20,7 @@ impl Optimizer { Box::new(global::branch_elimination::BranchElimination), Box::new(global::dead_code_elimination::DeadCodeElimination), Box::new(local::LocalOptimizer::new()), - ] + ], } } @@ -40,4 +40,3 @@ impl Optimizer { } } } - diff --git a/lang/src/mir/writer.rs b/lang/src/mir/writer.rs index 6ac1379..832ff03 100644 --- a/lang/src/mir/writer.rs +++ b/lang/src/mir/writer.rs @@ -1,17 +1,34 @@ use std::fmt::Write; use anyhow::Result; +use fusion_compiler::{ + Idx, + IdxVec, +}; -use fusion_compiler::{Idx, IdxVec}; - -use crate::mir::{BasicBlockIdx, Function, FunctionIdx, Instruction, InstructionIdx, InstructionKind, MIR, Terminator, TerminatorKind, Type, Value}; -use crate::mir::basic_block::BasicBlock; +use crate::mir::{ + basic_block::BasicBlock, + BasicBlockIdx, + Function, + FunctionIdx, + Instruction, + InstructionIdx, + InstructionKind, + Terminator, + TerminatorKind, + Type, + Value, + MIR, +}; pub struct MIRWriter { _phantom: std::marker::PhantomData, } -impl MIRWriter where W: Write { +impl MIRWriter +where + W: Write, +{ pub fn write_graphviz_representation(writer: &mut W, ir: &MIR) -> Result<()> { writeln!(writer, "digraph {{")?; for function in ir.functions.iter() { @@ -21,15 +38,39 @@ impl MIRWriter where W: Write { let bb = ir.basic_blocks.get_or_panic(bb_idx); let mut bb_content = String::new(); MIRWriter::write_basic_block(&mut bb_content, &ir, function, bb_idx, &bb)?; - writeln!(writer, " {} [label=\"{}\"];", Self::format_bb_idx(bb_idx), bb_content)?; + writeln!( + writer, + " {} [label=\"{}\"];", + Self::format_bb_idx(bb_idx), + bb_content + )?; match &bb.terminator.as_ref().unwrap().kind { TerminatorKind::Jump(target) => { - writeln!(writer, " {} -> {};", Self::format_bb_idx(bb_idx), Self::format_bb_idx(*target))?; + writeln!( + writer, + " {} -> {};", + Self::format_bb_idx(bb_idx), + Self::format_bb_idx(*target) + )?; } - TerminatorKind::SwitchInt { value, cases, default } => { - writeln!(writer, " {} -> {};", Self::format_bb_idx(bb_idx), Self::format_bb_idx(*default))?; + TerminatorKind::SwitchInt { + value, + cases, + default, + } => { + writeln!( + writer, + " {} -> {};", + Self::format_bb_idx(bb_idx), + Self::format_bb_idx(*default) + )?; for (case_value, case_target) in cases.iter() { - writeln!(writer, " {} -> {};", Self::format_bb_idx(bb_idx), Self::format_bb_idx(*case_target))?; + writeln!( + writer, + " {} -> {};", + Self::format_bb_idx(bb_idx), + Self::format_bb_idx(*case_target) + )?; } } TerminatorKind::Return { .. } => {} @@ -52,14 +93,24 @@ impl MIRWriter where W: Write { Ok(()) } - fn write_basic_block(writer: &mut W, ir: &MIR, function: &Function, bb_idx: BasicBlockIdx, bb: &&BasicBlock) -> Result<()> { + fn write_basic_block( + writer: &mut W, + ir: &MIR, + function: &Function, + bb_idx: BasicBlockIdx, + bb: &&BasicBlock, + ) -> Result<()> { writeln!(writer, "{}:", Self::format_bb_idx(bb_idx))?; let indentation = " "; for instruction_idx in &bb.instructions { let instruction = function.instructions.get(*instruction_idx); write!(writer, "{}", indentation)?; if !matches!(instruction.ty, Type::Void) { - write!(writer, "{} = ", Self::format_instruction_idx(*instruction_idx))?; + write!( + writer, + "{} = ", + Self::format_instruction_idx(*instruction_idx) + )?; } Self::write_instruction(writer, &ir.functions, instruction)?; writeln!(writer)?; @@ -91,7 +142,10 @@ impl MIRWriter where W: Write { InstructionKind::Value(value) => { Self::write_value(writer, value)?; } - InstructionKind::Call { function_idx, arguments } => { + InstructionKind::Call { + function_idx, + arguments, + } => { let function = functions.get(*function_idx); write!(writer, "{}(", function.name)?; for (arg_idx, arg) in arguments.iter().enumerate() { @@ -105,7 +159,12 @@ impl MIRWriter where W: Write { InstructionKind::Phi(phi) => { write!(writer, "phi {{ ")?; for (idx, (from, instruction_ref)) in phi.iter().enumerate() { - write!(writer, "{} -> {}", from, Self::format_instruction_idx(*instruction_ref))?; + write!( + writer, + "{} -> {}", + from, + Self::format_instruction_idx(*instruction_ref) + )?; if idx != phi.len() - 1 { write!(writer, ", ")?; } @@ -129,7 +188,11 @@ impl MIRWriter where W: Write { TerminatorKind::Jump(target) => { write!(writer, "jump {}", target)?; } - TerminatorKind::SwitchInt { value, cases, default } => { + TerminatorKind::SwitchInt { + value, + cases, + default, + } => { write!(writer, "switchInt (")?; Self::write_value(writer, value)?; writeln!(writer, ") {{")?; @@ -148,7 +211,6 @@ impl MIRWriter where W: Write { Ok(()) } - fn write_value(writer: &mut W, value: &Value) -> Result<()> { match value { Value::InstructionRef(instruction_idx) => { @@ -167,12 +229,10 @@ impl MIRWriter where W: Write { Ok(()) } - fn format_instruction_idx(instruction_idx: InstructionIdx) -> String { format!("%{}", instruction_idx.as_index()) } - fn format_bb_idx(bb_idx: BasicBlockIdx) -> String { format!("bb{}", bb_idx.as_index()) } diff --git a/lang/src/text/span.rs b/lang/src/text/span.rs index b2c0fac..3198d96 100644 --- a/lang/src/text/span.rs +++ b/lang/src/text/span.rs @@ -25,7 +25,11 @@ impl TextSpan { let start = spans.first().unwrap().start; let end = spans.last().unwrap().end; - TextSpan::new(start, end, spans.into_iter().map(|span| span.literal).collect()) + TextSpan::new( + start, + end, + spans.into_iter().map(|span| span.literal).collect(), + ) } pub fn length(&self) -> usize { diff --git a/lang/src/typings/mod.rs b/lang/src/typings/mod.rs index 3dc2960..638230b 100644 --- a/lang/src/typings/mod.rs +++ b/lang/src/typings/mod.rs @@ -1,5 +1,7 @@ - -use std::fmt::{Display, Formatter}; +use std::fmt::{ + Display, + Formatter, +}; #[derive(Debug, Clone)] pub enum Type { diff --git a/ir/rust-toolchain.toml b/rust-toolchain.toml similarity index 100% rename from ir/rust-toolchain.toml rename to rust-toolchain.toml diff --git a/ir/rustfmt.toml b/rustfmt.toml similarity index 100% rename from ir/rustfmt.toml rename to rustfmt.toml