diff --git a/extensions/native/compiler/src/conversion/mod.rs b/extensions/native/compiler/src/conversion/mod.rs index eb2a25c7a..3adcdb811 100644 --- a/extensions/native/compiler/src/conversion/mod.rs +++ b/extensions/native/compiler/src/conversion/mod.rs @@ -503,22 +503,38 @@ fn convert_instruction>( vec![] } } - AsmInstruction::ImmF(dst, val) => vec![inst( - options.opcode_with_offset(NativeLoadStoreOpcode::STOREW), - val, - F::ZERO, - i32_f(dst), - AS::Immediate, - AS::Native, - )], - AsmInstruction::CopyF(dst, src) => vec![inst( - options.opcode_with_offset(NativeLoadStoreOpcode::LOADW), - i32_f(dst), - F::ZERO, - i32_f(src), - AS::Native, - AS::Immediate, - )], + AsmInstruction::ImmF(dst, val) => if options.field_arithmetic_enabled { + vec![inst_med( + options.opcode_with_offset(FieldArithmeticOpcode::ADD), + i32_f(dst), + val, + F::ZERO, + AS::Native, + AS::Immediate, + AS::Native, + )] + } else { + panic!( + "Unsupported instruction {:?}, field arithmetic is disabled", + instruction + ) + }, + AsmInstruction::CopyF(dst, src) => if options.field_arithmetic_enabled { + vec![inst_med( + options.opcode_with_offset(FieldArithmeticOpcode::ADD), + i32_f(dst), + i32_f(src), + F::ZERO, + AS::Native, + AS::Native, + AS::Immediate + )] + } else { + panic!( + "Unsupported instruction {:?}, field arithmetic is disabled", + instruction + ) + }, AsmInstruction::AddF(..) | AsmInstruction::SubF(..) | AsmInstruction::MulF(..) @@ -612,13 +628,14 @@ pub fn convert_program>( options: CompilerOptions, ) -> Program { // mem[0] <- 0 - let init_register_0 = inst( - options.opcode_with_offset(NativeLoadStoreOpcode::STOREW), + let init_register_0 = inst_med( + options.opcode_with_offset(FieldArithmeticOpcode::ADD), + F::ZERO, F::ZERO, F::ZERO, - i32_f(0), - AS::Immediate, AS::Native, + AS::Immediate, + AS::Immediate, ); let init_debug_info = None;