From 171b1e3ff7ed7e06f0ccaf2a3b364adfafaee614 Mon Sep 17 00:00:00 2001 From: Alexander Evgin Date: Fri, 1 Mar 2024 08:40:31 +0000 Subject: [PATCH] Move all components left to new memory model This commit contains a bunch of similar changes in different files, required to move to new memory. --- include/nil/blueprint/curves/init.hpp | 2 +- include/nil/blueprint/extract_constructor_parameters.hpp | 5 +++-- include/nil/blueprint/integers/bit_de_composition.hpp | 5 +++-- include/nil/blueprint/recursive_prover/fri_array_swap.hpp | 5 +++-- include/nil/blueprint/recursive_prover/fri_cosets.hpp | 5 +++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/nil/blueprint/curves/init.hpp b/include/nil/blueprint/curves/init.hpp index f5e501db..15bf5616 100644 --- a/include/nil/blueprint/curves/init.hpp +++ b/include/nil/blueprint/curves/init.hpp @@ -36,7 +36,7 @@ namespace nil { ASSERT(inst->getOperand(0)->getType() == inst->getOperand(1)->getType()); ASSERT(inst->getOperand(0)->getType()->isFieldTy()); - std::size_t arg_num = field_arg_num(inst->getOperand(0)->getType()); + std::size_t arg_num = field_chunks_num(llvm::cast(inst->getOperand(0)->getType())); if (arg_num == 1) { VarType x = frame.scalars[inst->getOperand(0)]; VarType y = frame.scalars[inst->getOperand(1)]; diff --git a/include/nil/blueprint/extract_constructor_parameters.hpp b/include/nil/blueprint/extract_constructor_parameters.hpp index ba3941ae..c8f4aa6d 100644 --- a/include/nil/blueprint/extract_constructor_parameters.hpp +++ b/include/nil/blueprint/extract_constructor_parameters.hpp @@ -83,9 +83,10 @@ namespace nil { if (gen_mode.has_assignments()) { ptr_type input_ptr = static_cast( typename BlueprintFieldType::integral_type(var_value(assignment, variables[input_value]).data)); + size_type elem_size = (BlueprintFieldType::number_bits + 7) / 8; for (std::size_t i = 0; i < input_length; i++) { - ASSERT(memory[input_ptr].size == (BlueprintFieldType::number_bits + 7) / 8); - const auto origin_var = memory.load(input_ptr++); + const auto origin_var = memory.load(input_ptr, elem_size); + input_ptr += elem_size; const auto wrapper = detail::put_constant (var_value(assignment, origin_var), assignment); diff --git a/include/nil/blueprint/integers/bit_de_composition.hpp b/include/nil/blueprint/integers/bit_de_composition.hpp index 50af7dd6..575b98d9 100644 --- a/include/nil/blueprint/integers/bit_de_composition.hpp +++ b/include/nil/blueprint/integers/bit_de_composition.hpp @@ -69,9 +69,10 @@ namespace nil { if (param.gen_mode.has_assignments()) { ptr_type result_ptr = static_cast( typename BlueprintFieldType::integral_type(var_value(assignment, variables[result_value]).data)); + size_type elem_size = (BlueprintFieldType::number_bits + 7) / 8; for (var v : result) { - ASSERT(memory[result_ptr].size == (BlueprintFieldType::number_bits + 7) / 8); - memory.store(result_ptr++, v); + memory.store(result_ptr, (BlueprintFieldType::number_bits + 7) / 8, v); + result_ptr += elem_size; } } } diff --git a/include/nil/blueprint/recursive_prover/fri_array_swap.hpp b/include/nil/blueprint/recursive_prover/fri_array_swap.hpp index 97f688d6..f19ec19d 100644 --- a/include/nil/blueprint/recursive_prover/fri_array_swap.hpp +++ b/include/nil/blueprint/recursive_prover/fri_array_swap.hpp @@ -78,8 +78,9 @@ namespace nil { ptr_type result_ptr = static_cast(typename BlueprintFieldType::integral_type( var_value(assignment, frame.scalars[result_value]).data)); for (std::size_t i = 0; i < array_size; i++) { - ASSERT(memory[result_ptr].size == (BlueprintFieldType::number_bits + 7) / 8); - memory.store(result_ptr++, res[i]); + size_type elem_size = (BlueprintFieldType::number_bits + 7) / 8; + memory.store(result_ptr, elem_size, res[i]); + result_ptr += elem_size; } } } diff --git a/include/nil/blueprint/recursive_prover/fri_cosets.hpp b/include/nil/blueprint/recursive_prover/fri_cosets.hpp index a96ce732..9543b469 100644 --- a/include/nil/blueprint/recursive_prover/fri_cosets.hpp +++ b/include/nil/blueprint/recursive_prover/fri_cosets.hpp @@ -72,8 +72,9 @@ namespace nil { typename BlueprintFieldType::integral_type(var_value(assignment, variables[result_value]).data)); for (std::size_t i = 0; i < result.size(); i++) { for (std::size_t j = 0; j < 3; j++) { - ASSERT(memory[result_ptr].size == (BlueprintFieldType::number_bits + 7) / 8); - memory.store(result_ptr++, result[i][j]); + size_type elem_size = (BlueprintFieldType::number_bits + 7) / 8; + memory.store(result_ptr, elem_size, result[i][j]); + result_ptr += elem_size; } } }