Skip to content

Commit

Permalink
Merge 6bc886f into fd03ea0
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Sep 27, 2024
2 parents fd03ea0 + 6bc886f commit 8f62d49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,7 @@ impl<'block> BrilligBlock<'block> {
let results = dfg.instruction_results(instruction_id);

let source = self.convert_ssa_single_addr_value(arguments[0], dfg);

let radix: u32 = dfg
.get_numeric_constant(arguments[1])
.expect("Radix should be known")
.try_to_u64()
.expect("Radix should fit in u64")
.try_into()
.expect("Radix should be u32");
let radix = self.convert_ssa_single_addr_value(arguments[1], dfg);

let target_array = self
.variables
Expand Down Expand Up @@ -595,13 +588,17 @@ impl<'block> BrilligBlock<'block> {
)
.extract_array();

let two = self.brillig_context.make_usize_constant_instruction(2_usize.into());

self.brillig_context.codegen_to_radix(
source,
target_array,
2,
two,
matches!(endianness, Endian::Big),
true,
);

self.brillig_context.deallocate_single_addr(two);
}

// `Intrinsic::AsWitness` is used to provide hints to acir-gen on optimal expression splitting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,20 @@ impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<
&mut self,
source_field: SingleAddrVariable,
target_array: BrilligArray,
radix: u32,
radix: SingleAddrVariable,
big_endian: bool,
output_bits: bool, // If true will generate bit limbs, if false will generate byte limbs
) {
assert!(source_field.bit_size == F::max_num_bits());
assert!(radix.bit_size == 32);

self.codegen_initialize_array(target_array);

let heap_array = self.codegen_brillig_array_to_heap_array(target_array);

let radix_var = self.make_constant_instruction(F::from(radix as u128), 32);

self.black_box_op_instruction(BlackBoxOp::ToRadix {
input: source_field.address,
radix: radix_var.address,
radix: radix.address,
output: heap_array,
output_bits,
});
Expand All @@ -93,6 +92,5 @@ impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<
self.deallocate_single_addr(items_len);
}
self.deallocate_register(heap_array.pointer);
self.deallocate_register(radix_var.address);
}
}

0 comments on commit 8f62d49

Please sign in to comment.