Skip to content

Commit

Permalink
m68k: TARGET_CAN_CHANGE_MODE_CLASS is false for FP regs
Browse files Browse the repository at this point in the history
Just like i386, you cannot extract float or double values by using
the low bits of m68k float registers. Override this hook and check
that case.

Signed-off-by: Keith Packard <[email protected]>
  • Loading branch information
keith-packard committed Dec 29, 2024
1 parent 65c8fd7 commit 862467c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions gcc/config/m68k/m68k.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ static void m68k_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx [], int);
static HARD_REG_SET m68k_zero_call_used_regs (HARD_REG_SET);
static machine_mode m68k_c_mode_for_floating_type (enum tree_index);
static bool m68k_use_lra_p (void);
static bool m68k_can_change_mode_class (machine_mode from, machine_mode to, reg_class_t rclass);

/* Initialize the GCC target structure. */

Expand Down Expand Up @@ -370,6 +371,9 @@ static bool m68k_use_lra_p (void);
#undef TARGET_C_MODE_FOR_FLOATING_TYPE
#define TARGET_C_MODE_FOR_FLOATING_TYPE m68k_c_mode_for_floating_type

#undef TARGET_CAN_CHANGE_MODE_CLASS
#define TARGET_CAN_CHANGE_MODE_CLASS m68k_can_change_mode_class

TARGET_GNU_ATTRIBUTES (m68k_attribute_table,
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req,
Expand Down Expand Up @@ -7269,4 +7273,22 @@ m68k_use_lra_p ()
return m68k_lra_p;
}

/* Implement TARGET_CAN_CHANGE_MODE_CLASS. */

static bool
m68k_can_change_mode_class (machine_mode from,
machine_mode to,
reg_class_t rclass)
{
if (from == to)
return true;

/* 68881 registers can't do subreg at all, as all values are reformatted
to extended precision. */
if (reg_classes_intersect_p(rclass, FP_REGS))
return false;

return true;
}

#include "gt-m68k.h"

0 comments on commit 862467c

Please sign in to comment.