aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-02-09 00:16:26 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-02-19 13:01:11 -0800
commitd00cb5a5414198379575bc1fc5d5afb79d19ed00 (patch)
tree28a93cb0db04c0a81f0a05a07ecb6fc18c20d5d9 /pk
parentb0d83d2a8468553000bda6099fc5f907ec767b79 (diff)
downloadpk-d00cb5a5414198379575bc1fc5d5afb79d19ed00.zip
pk-d00cb5a5414198379575bc1fc5d5afb79d19ed00.tar.gz
pk-d00cb5a5414198379575bc1fc5d5afb79d19ed00.tar.bz2
Rely on __riscv_muldiv and __riscv_hard_float macros
Diffstat (limited to 'pk')
-rw-r--r--pk/emulation.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/pk/emulation.c b/pk/emulation.c
index 36c90a6..edc14bd 100644
--- a/pk/emulation.c
+++ b/pk/emulation.c
@@ -192,6 +192,7 @@ DECLARE_EMULATION_FUNC(emulate_mul_div)
{
uintptr_t rs1 = GET_RS1(insn, regs), rs2 = GET_RS2(insn, regs), val;
+#ifndef __riscv_muldiv
// If compiled with -mno-multiply, GCC will expand these out
if ((insn & MASK_MUL) == MATCH_MUL)
val = rs1 * rs2;
@@ -210,6 +211,7 @@ DECLARE_EMULATION_FUNC(emulate_mul_div)
else if ((insn & MASK_MULHSU) == MATCH_MULHSU)
val = ((double_int)(intptr_t)rs1 * (double_int)rs2) >> (8 * sizeof(rs1));
else
+#endif
return truly_illegal_insn(regs, mcause, mepc, mstatus, insn);
SET_RD(insn, regs, val);
@@ -217,13 +219,10 @@ DECLARE_EMULATION_FUNC(emulate_mul_div)
DECLARE_EMULATION_FUNC(emulate_mul_div32)
{
-#ifndef __riscv64
- return truly_illegal_insn(regs, mcause, mepc, mstatus, insn);
-#endif
-
uint32_t rs1 = GET_RS1(insn, regs), rs2 = GET_RS2(insn, regs);
int32_t val;
+#if defined(__riscv64) && !defined(__riscv_muldiv)
// If compiled with -mno-multiply, GCC will expand these out
if ((insn & MASK_MULW) == MATCH_MULW)
val = rs1 * rs2;
@@ -236,6 +235,7 @@ DECLARE_EMULATION_FUNC(emulate_mul_div32)
else if ((insn & MASK_REMUW) == MATCH_REMUW)
val = rs1 % rs2;
else
+#endif
return truly_illegal_insn(regs, mcause, mepc, mstatus, insn);
SET_RD(insn, regs, val);
@@ -245,6 +245,7 @@ static inline int emulate_read_csr(int num, uintptr_t mstatus, uintptr_t* result
{
switch (num)
{
+#ifndef __riscv_hard_float
case CSR_FRM:
if ((mstatus & MSTATUS_FS) == 0) break;
*result = GET_FRM();
@@ -257,6 +258,7 @@ static inline int emulate_read_csr(int num, uintptr_t mstatus, uintptr_t* result
if ((mstatus & MSTATUS_FS) == 0) break;
*result = GET_FCSR();
return 0;
+#endif
}
return -1;
}
@@ -265,9 +267,11 @@ static inline void emulate_write_csr(int num, uintptr_t value, uintptr_t mstatus
{
switch (num)
{
+#ifndef __riscv_hard_float
case CSR_FRM: SET_FRM(value); return;
case CSR_FFLAGS: SET_FFLAGS(value); return;
case CSR_FCSR: SET_FCSR(value); return;
+#endif
}
}