From 5c104cf9813516b18d421e8a420dad767384e4bf Mon Sep 17 00:00:00 2001 From: Spydr <58859306+Spydr06@users.noreply.github.com> Date: Sun, 12 Jun 2022 08:42:39 +0200 Subject: [PATCH] native: implement `neg()` for arm64 (#14745) --- vlib/v/gen/native/arm64.v | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vlib/v/gen/native/arm64.v b/vlib/v/gen/native/arm64.v index 0a1e11bb5f..d90814db48 100644 --- a/vlib/v/gen/native/arm64.v +++ b/vlib/v/gen/native/arm64.v @@ -77,6 +77,19 @@ fn (mut g Gen) mov_arm(reg Arm64Register, val u64) { */ } +fn (mut g Gen) neg_arm(r Arm64Register) { + g.neg_regs_arm(r, r) +} + +fn (mut g Gen) neg_regs_arm(a Arm64Register, b Arm64Register) { + if int(a) < 0x0f && int(b) < 0x0f { + g.write32(0xe2600000 | int(a) << 16 | int(b) << 12) + g.println('neg $a, $b') + } else { + g.n_error('unhandled neg $a, $b') + } +} + pub fn (mut g Gen) fn_decl_arm64(node ast.FnDecl) { g.gen_arm64_helloworld() // TODO