From 5c3a227cc60da35a8ec61fee349a08883e345f8a Mon Sep 17 00:00:00 2001 From: William Wang Date: Tue, 7 Jul 2020 15:37:10 +0800 Subject: [PATCH] engine,rv64: add amomax, amominu, amomin --- src/isa/riscv64/exec/amo.h | 27 +++++++++++++++++++++++++++ src/isa/riscv64/exec/exec.c | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/isa/riscv64/exec/amo.h b/src/isa/riscv64/exec/amo.h index 2aa827db..f63ce1e0 100644 --- a/src/isa/riscv64/exec/amo.h +++ b/src/isa/riscv64/exec/amo.h @@ -79,6 +79,33 @@ static inline make_EHelper(amomaxu) { print_asm_template3(amomaxu); } +static inline make_EHelper(amomax) { + amo_load(s); + return_on_mem_ex(); + *s1 = (((sword_t)*s0) > ((sword_t)*dsrc2) ? *s0 : *dsrc2); + amo_update(s); + return_on_mem_ex(); + print_asm_template3(amomax); +} + +static inline make_EHelper(amominu) { + amo_load(s); + return_on_mem_ex(); + *s1 = (*s0 < *dsrc2 ? *s0 : *dsrc2); + amo_update(s); + return_on_mem_ex(); + print_asm_template3(amominu); +} + +static inline make_EHelper(amomin) { + amo_load(s); + return_on_mem_ex(); + *s1 = (((sword_t)*s0) < ((sword_t)*dsrc2) ? *s0 : *dsrc2); + amo_update(s); + return_on_mem_ex(); + print_asm_template3(amomin); +} + static inline make_EHelper(amoxor) { amo_load(s); return_on_mem_ex(); diff --git a/src/isa/riscv64/exec/exec.c b/src/isa/riscv64/exec/exec.c index c679f43f..9f091d88 100644 --- a/src/isa/riscv64/exec/exec.c +++ b/src/isa/riscv64/exec/exec.c @@ -102,6 +102,9 @@ static inline make_EHelper(atomic) { EX(0x04, amoxor) EX(0x0c, amoand) EX(0x08, amoor) + EX(0x10, amomin) + EX(0x14, amomax) + EX(0x18, amominu) EX(0x1c, amomaxu) } cpu.amo = false; -- GitLab