mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
target/arm: Restrict TCG specific helpers
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20231130142519.28417-2-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
c36a0d577b
commit
d1d119bbd7
2 changed files with 55 additions and 55 deletions
|
@ -10142,61 +10142,6 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sign/zero extend */
|
|
||||||
uint32_t HELPER(sxtb16)(uint32_t x)
|
|
||||||
{
|
|
||||||
uint32_t res;
|
|
||||||
res = (uint16_t)(int8_t)x;
|
|
||||||
res |= (uint32_t)(int8_t)(x >> 16) << 16;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_possible_div0_trap(CPUARMState *env, uintptr_t ra)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Take a division-by-zero exception if necessary; otherwise return
|
|
||||||
* to get the usual non-trapping division behaviour (result of 0)
|
|
||||||
*/
|
|
||||||
if (arm_feature(env, ARM_FEATURE_M)
|
|
||||||
&& (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_DIV_0_TRP_MASK)) {
|
|
||||||
raise_exception_ra(env, EXCP_DIVBYZERO, 0, 1, ra);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t HELPER(uxtb16)(uint32_t x)
|
|
||||||
{
|
|
||||||
uint32_t res;
|
|
||||||
res = (uint16_t)(uint8_t)x;
|
|
||||||
res |= (uint32_t)(uint8_t)(x >> 16) << 16;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t HELPER(sdiv)(CPUARMState *env, int32_t num, int32_t den)
|
|
||||||
{
|
|
||||||
if (den == 0) {
|
|
||||||
handle_possible_div0_trap(env, GETPC());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (num == INT_MIN && den == -1) {
|
|
||||||
return INT_MIN;
|
|
||||||
}
|
|
||||||
return num / den;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t HELPER(udiv)(CPUARMState *env, uint32_t num, uint32_t den)
|
|
||||||
{
|
|
||||||
if (den == 0) {
|
|
||||||
handle_possible_div0_trap(env, GETPC());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return num / den;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t HELPER(rbit)(uint32_t x)
|
|
||||||
{
|
|
||||||
return revbit32(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
#ifdef CONFIG_USER_ONLY
|
||||||
|
|
||||||
static void switch_mode(CPUARMState *env, int mode)
|
static void switch_mode(CPUARMState *env, int mode)
|
||||||
|
|
|
@ -121,6 +121,61 @@ void HELPER(v8m_stackcheck)(CPUARMState *env, uint32_t newvalue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sign/zero extend */
|
||||||
|
uint32_t HELPER(sxtb16)(uint32_t x)
|
||||||
|
{
|
||||||
|
uint32_t res;
|
||||||
|
res = (uint16_t)(int8_t)x;
|
||||||
|
res |= (uint32_t)(int8_t)(x >> 16) << 16;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_possible_div0_trap(CPUARMState *env, uintptr_t ra)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Take a division-by-zero exception if necessary; otherwise return
|
||||||
|
* to get the usual non-trapping division behaviour (result of 0)
|
||||||
|
*/
|
||||||
|
if (arm_feature(env, ARM_FEATURE_M)
|
||||||
|
&& (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_DIV_0_TRP_MASK)) {
|
||||||
|
raise_exception_ra(env, EXCP_DIVBYZERO, 0, 1, ra);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t HELPER(uxtb16)(uint32_t x)
|
||||||
|
{
|
||||||
|
uint32_t res;
|
||||||
|
res = (uint16_t)(uint8_t)x;
|
||||||
|
res |= (uint32_t)(uint8_t)(x >> 16) << 16;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t HELPER(sdiv)(CPUARMState *env, int32_t num, int32_t den)
|
||||||
|
{
|
||||||
|
if (den == 0) {
|
||||||
|
handle_possible_div0_trap(env, GETPC());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (num == INT_MIN && den == -1) {
|
||||||
|
return INT_MIN;
|
||||||
|
}
|
||||||
|
return num / den;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t HELPER(udiv)(CPUARMState *env, uint32_t num, uint32_t den)
|
||||||
|
{
|
||||||
|
if (den == 0) {
|
||||||
|
handle_possible_div0_trap(env, GETPC());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return num / den;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t HELPER(rbit)(uint32_t x)
|
||||||
|
{
|
||||||
|
return revbit32(x);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t HELPER(add_setq)(CPUARMState *env, uint32_t a, uint32_t b)
|
uint32_t HELPER(add_setq)(CPUARMState *env, uint32_t a, uint32_t b)
|
||||||
{
|
{
|
||||||
uint32_t res = a + b;
|
uint32_t res = a + b;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue