diff --git a/hercules_ir/src/def_use.rs b/hercules_ir/src/def_use.rs index a99c8a23f0922106abd46ceeaa5e45303a9e20e3..9953134577ffbc3867c6f60224d7b20b62aa1e9e 100644 --- a/hercules_ir/src/def_use.rs +++ b/hercules_ir/src/def_use.rs @@ -157,8 +157,8 @@ pub fn get_uses(node: &Node) -> NodeUses { reduct, } => NodeUses::Three([*control, *init, *reduct]), Node::Return { control, data } => { - let mut uses: Vec<NodeID> = Vec::from(&data[..]); - uses.push(*control); + let mut uses: Vec<NodeID> = vec![*control]; + uses.extend(data); NodeUses::Variable(uses.into_boxed_slice()) } Node::Parameter { index: _ } => NodeUses::One([NodeID::new(0)]), diff --git a/hercules_ir/src/dot.rs b/hercules_ir/src/dot.rs index 921a813d7c9d680defe2e9dd8fa750ddf960d0cb..a7f890f87bb04b526f2c023b110c2d815d2d747f 100644 --- a/hercules_ir/src/dot.rs +++ b/hercules_ir/src/dot.rs @@ -349,6 +349,14 @@ fn write_node<W: Write>( } } } + Node::ControlProjection { + control: _, + selection, + } + | Node::DataProjection { + data: _, + selection, + } => write!(&mut suffix, "{}", selection)?, _ => {} }; diff --git a/hercules_ir/src/typecheck.rs b/hercules_ir/src/typecheck.rs index dca11fe7d73c8a4d196e843f224f7f8a784fbde2..919da6408f8ac72741353e7a36a57319ccc1866e 100644 --- a/hercules_ir/src/typecheck.rs +++ b/hercules_ir/src/typecheck.rs @@ -423,8 +423,8 @@ fn typeflow( control: _, data: _, } => { - if inputs.len() != 2 { - return Error(String::from("Return node must have exactly two inputs.")); + if inputs.len() < 1 { + return Error(String::from("Return node must have at least one input.")); } // Check type of control input first, since this may produce an @@ -1080,7 +1080,7 @@ fn typeflow( if *selection >= types.len() { return Error(String::from("Data projection's selection must be in range of the multi-return being indexed")); } - return Concrete(*type_id); + return Concrete(types[*selection]); } _ => { return Error(String::from( diff --git a/juno_frontend/src/codegen.rs b/juno_frontend/src/codegen.rs index 4e6f89e86c3bbc79500f931119392d707566e6d6..533fd268399722b50216c6a3c21c6ecf0603d528 100644 --- a/juno_frontend/src/codegen.rs +++ b/juno_frontend/src/codegen.rs @@ -276,7 +276,7 @@ impl CodeGenerator<'_> { block = block_ret; } let mut return_node = self.builder.allocate_node(); - return_node.build_return(block, vals); + return_node.build_return(block, vals.into()); self.builder.add_node(return_node); None } @@ -552,10 +552,9 @@ impl CodeGenerator<'_> { // Read each of the "inout values" and perform the SSA update let has_inouts = !inouts.is_empty(); for (idx, var) in inouts.into_iter().enumerate() { - let index = self.builder.builder.create_field_index(num_returns + idx); let mut proj = self.builder.allocate_node(); let proj_id = proj.id(); - proj.build_data_projection(call_id, index); + proj.build_data_projection(call_id, num_returns + idx); self.builder.add_node(proj); ssa.write_variable(var, block, proj_id); @@ -568,7 +567,7 @@ impl CodeGenerator<'_> { let mut proj = self.builder.allocate_node(); let proj_id = proj.id(); - proj.build_data_projection(call, index); + proj.build_data_projection(call, *index); self.builder.add_node(proj); (proj_id, block)