From 08b1e8d71ba7511945f19f20f82716bafedb44b4 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 14 Sep 2018 13:48:43 +0200 Subject: [PATCH] Make inn work; fix broken 64-bit loads and stores. --- mach/mips/libem/inn.s | 17 ++++++++--------- mach/mips/mcg/table | 8 ++++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mach/mips/libem/inn.s b/mach/mips/libem/inn.s index 07a4991b6..a0fcb0931 100644 --- a/mach/mips/libem/inn.s +++ b/mach/mips/libem/inn.s @@ -13,21 +13,20 @@ .define .inn .inn: lw r4, 0(sp) ! r4 = size of set (bytes) - lw r5, 0(sp) ! r5 = bit number - addiu sp, sp, 8 ! sp now points at bitset + lw r5, 4(sp) ! r5 = bit number + addiu sp, sp, 4 ! sp now points to word below bitset - srl r6, r5, 3 ! r6 = offset of word in set + andi r6, r5, ~31 ! r6 = bit offset of base of word in set + srl r6, r6, 3 ! r6 = byte offset of base of word in set addu r6, sp, r6 ! r6 = address of word in set - lw r6, 0(r6) ! r6 = word + lw r6, 4(r6) ! r6 = word (remember stack offset) - ext r7, r5, 0, 3 ! r7 = bit number within word + andi r7, r5, 31 ! r7 = bit number within word srlv r6, r6, r7 ! r7 = candidate bit now at bit 0 andi r6, r6, 1 ! r7 = bool - addu sp, sp, r4 ! retract over bitfield - - addiu sp, sp, -4 - sw r6, 0(sp) ! push result + addu sp, sp, r4 ! retract over bitfield (remember stack offset) + sw r6, 0(sp) ! store result jr ra nop diff --git a/mach/mips/mcg/table b/mach/mips/mcg/table index dbda9c84a..321eaea5d 100644 --- a/mach/mips/mcg/table +++ b/mach/mips/mcg/table @@ -233,8 +233,8 @@ PATTERNS /* Stores */ STORE.L(addr:address, value:(long)reg) - emit "sw %value.0, 4+%addr" - emit "sw %value.1, 0+%addr" + emit "sw %value.0, 0+%addr" + emit "sw %value.1, 4+%addr" cost 8; STORE.I(addr:address, value:(int)reg) @@ -267,8 +267,8 @@ PATTERNS * a register, resulting in %addr being corrupted before %out.1 is * loaded. */ out:(long)reg = LOAD.L(addr:address) - emit "lw at, 4+%addr" - emit "lw %out.1, 0+%addr" + emit "lw at, 0+%addr" + emit "lw %out.1, 4+%addr" emit "mov %out.0, at" cost 12; -- 2.34.1