Skip to content

Commit 862467c

Browse files
committed
m68k: TARGET_CAN_CHANGE_MODE_CLASS is false for FP regs
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 <keithp@keithp.com>
1 parent 65c8fd7 commit 862467c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

gcc/config/m68k/m68k.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ static void m68k_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx [], int);
200200
static HARD_REG_SET m68k_zero_call_used_regs (HARD_REG_SET);
201201
static machine_mode m68k_c_mode_for_floating_type (enum tree_index);
202202
static bool m68k_use_lra_p (void);
203+
static bool m68k_can_change_mode_class (machine_mode from, machine_mode to, reg_class_t rclass);
203204

204205
/* Initialize the GCC target structure. */
205206

@@ -370,6 +371,9 @@ static bool m68k_use_lra_p (void);
370371
#undef TARGET_C_MODE_FOR_FLOATING_TYPE
371372
#define TARGET_C_MODE_FOR_FLOATING_TYPE m68k_c_mode_for_floating_type
372373

374+
#undef TARGET_CAN_CHANGE_MODE_CLASS
375+
#define TARGET_CAN_CHANGE_MODE_CLASS m68k_can_change_mode_class
376+
373377
TARGET_GNU_ATTRIBUTES (m68k_attribute_table,
374378
{
375379
/* { name, min_len, max_len, decl_req, type_req, fn_type_req,
@@ -7269,4 +7273,22 @@ m68k_use_lra_p ()
72697273
return m68k_lra_p;
72707274
}
72717275

7276+
/* Implement TARGET_CAN_CHANGE_MODE_CLASS. */
7277+
7278+
static bool
7279+
m68k_can_change_mode_class (machine_mode from,
7280+
machine_mode to,
7281+
reg_class_t rclass)
7282+
{
7283+
if (from == to)
7284+
return true;
7285+
7286+
/* 68881 registers can't do subreg at all, as all values are reformatted
7287+
to extended precision. */
7288+
if (reg_classes_intersect_p(rclass, FP_REGS))
7289+
return false;
7290+
7291+
return true;
7292+
}
7293+
72727294
#include "gt-m68k.h"

0 commit comments

Comments
 (0)