aboutsummaryrefslogtreecommitdiff
path: root/libunwind
diff options
context:
space:
mode:
authorYunQiang Su <wzssyqa@gmail.com>2023-08-19 00:35:25 -0400
committerBrad Smith <brad@comstyle.com>2023-08-19 00:35:25 -0400
commit22a84020d2324ac1f753705497a40c43d8284d94 (patch)
tree3b006c5742dcff34b62e43ae360828052d4d9c8e /libunwind
parent974c6393297c18c968ffafc43ba37f0827d536ea (diff)
downloadllvm-22a84020d2324ac1f753705497a40c43d8284d94.zip
llvm-22a84020d2324ac1f753705497a40c43d8284d94.tar.gz
llvm-22a84020d2324ac1f753705497a40c43d8284d94.tar.bz2
MIPS: unwind, don't save/restore hi/lo for R6
HI/LO registers have been removed in MIPSr6. Save and restore them only for pre-R6. We keep the memory space for the registers so that we can use the same register indexes for r6 and pre-r6. Fixes: #60682 Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D156283
Diffstat (limited to 'libunwind')
-rw-r--r--libunwind/include/libunwind.h3
-rw-r--r--libunwind/src/Registers.hpp16
-rw-r--r--libunwind/src/UnwindRegistersRestore.S4
-rw-r--r--libunwind/src/UnwindRegistersSave.S4
4 files changed, 25 insertions, 2 deletions
diff --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h
index d2ad5ab..b2dae8f 100644
--- a/libunwind/include/libunwind.h
+++ b/libunwind/include/libunwind.h
@@ -876,6 +876,9 @@ enum {
UNW_MIPS_F29 = 61,
UNW_MIPS_F30 = 62,
UNW_MIPS_F31 = 63,
+ // HI,LO have been dropped since r6, we keep them here.
+ // So, when we add DSP/MSA etc, we can use the same register indexes
+ // for r6 and pre-r6.
UNW_MIPS_HI = 64,
UNW_MIPS_LO = 65,
};
diff --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index c7b875d..fb6e04e 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -2869,7 +2869,7 @@ inline bool Registers_mips_o32::validRegister(int regNum) const {
return false;
if (regNum <= UNW_MIPS_R31)
return true;
-#if __mips_isa_rev != 6
+#if __mips_isa_rev < 6
if (regNum == UNW_MIPS_HI)
return true;
if (regNum == UNW_MIPS_LO)
@@ -2903,10 +2903,12 @@ inline uint32_t Registers_mips_o32::getRegister(int regNum) const {
return _registers.__pc;
case UNW_REG_SP:
return _registers.__r[29];
+#if __mips_isa_rev < 6
case UNW_MIPS_HI:
return _registers.__hi;
case UNW_MIPS_LO:
return _registers.__lo;
+#endif
}
_LIBUNWIND_ABORT("unsupported mips_o32 register");
}
@@ -2936,11 +2938,13 @@ inline void Registers_mips_o32::setRegister(int regNum, uint32_t value) {
case UNW_REG_SP:
_registers.__r[29] = value;
return;
+#if __mips_isa_rev < 6
case UNW_MIPS_HI:
_registers.__hi = value;
return;
case UNW_MIPS_LO:
_registers.__lo = value;
+#endif
return;
}
_LIBUNWIND_ABORT("unsupported mips_o32 register");
@@ -3120,10 +3124,12 @@ inline const char *Registers_mips_o32::getRegisterName(int regNum) {
return "$f30";
case UNW_MIPS_F31:
return "$f31";
+#if __mips_isa_rev < 6
case UNW_MIPS_HI:
return "$hi";
case UNW_MIPS_LO:
return "$lo";
+#endif
default:
return "unknown register";
}
@@ -3193,7 +3199,7 @@ inline bool Registers_mips_newabi::validRegister(int regNum) const {
return false;
if (regNum <= UNW_MIPS_R31)
return true;
-#if __mips_isa_rev != 6
+#if __mips_isa_rev < 6
if (regNum == UNW_MIPS_HI)
return true;
if (regNum == UNW_MIPS_LO)
@@ -3212,10 +3218,12 @@ inline uint64_t Registers_mips_newabi::getRegister(int regNum) const {
return _registers.__pc;
case UNW_REG_SP:
return _registers.__r[29];
+#if __mips_isa_rev < 6
case UNW_MIPS_HI:
return _registers.__hi;
case UNW_MIPS_LO:
return _registers.__lo;
+#endif
}
_LIBUNWIND_ABORT("unsupported mips_newabi register");
}
@@ -3233,12 +3241,14 @@ inline void Registers_mips_newabi::setRegister(int regNum, uint64_t value) {
case UNW_REG_SP:
_registers.__r[29] = value;
return;
+#if __mips_isa_rev < 6
case UNW_MIPS_HI:
_registers.__hi = value;
return;
case UNW_MIPS_LO:
_registers.__lo = value;
return;
+#endif
}
_LIBUNWIND_ABORT("unsupported mips_newabi register");
}
@@ -3417,10 +3427,12 @@ inline const char *Registers_mips_newabi::getRegisterName(int regNum) {
return "$f30";
case UNW_MIPS_F31:
return "$f31";
+#if __mips_isa_rev < 6
case UNW_MIPS_HI:
return "$hi";
case UNW_MIPS_LO:
return "$lo";
+#endif
default:
return "unknown register";
}
diff --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S
index 951189e..c4471ea 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -993,11 +993,13 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)
ldc1 $f31, (4 * 36 + 8 * 31)($4)
#endif
#endif
+#if __mips_isa_rev < 6
// restore hi and lo
lw $8, (4 * 33)($4)
mthi $8
lw $8, (4 * 34)($4)
mtlo $8
+#endif
// r0 is zero
lw $1, (4 * 1)($4)
lw $2, (4 * 2)($4)
@@ -1054,11 +1056,13 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv)
ldc1 $f\i, (280+8*\i)($4)
.endr
#endif
+#if __mips_isa_rev < 6
// restore hi and lo
ld $8, (8 * 33)($4)
mthi $8
ld $8, (8 * 34)($4)
mtlo $8
+#endif
// r0 is zero
ld $1, (8 * 1)($4)
ld $2, (8 * 2)($4)
diff --git a/libunwind/src/UnwindRegistersSave.S b/libunwind/src/UnwindRegistersSave.S
index 79f5696..58ffd1b 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -174,11 +174,13 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
sw $31, (4 * 31)($4)
# Store return address to pc
sw $31, (4 * 32)($4)
+#if __mips_isa_rev < 6
# hi and lo
mfhi $8
sw $8, (4 * 33)($4)
mflo $8
sw $8, (4 * 34)($4)
+#endif
#ifdef __mips_hard_float
#if __mips_fpr != 64
sdc1 $f0, (4 * 36 + 8 * 0)($4)
@@ -255,11 +257,13 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
.endr
# Store return address to pc
sd $31, (8 * 32)($4)
+#if __mips_isa_rev < 6
# hi and lo
mfhi $8
sd $8, (8 * 33)($4)
mflo $8
sd $8, (8 * 34)($4)
+#endif
#ifdef __mips_hard_float
.irp i,FROM_0_TO_31
sdc1 $f\i, (280+8*\i)($4)