diff options
Diffstat (limited to 'gcc/config/riscv/riscv.cc')
-rw-r--r-- | gcc/config/riscv/riscv.cc | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index de5b87b1a87..0d1b83f4315 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -7513,6 +7513,95 @@ riscv_vectorize_preferred_vector_alignment (const_tree type) return TYPE_ALIGN (type); } +/* Implement Mode switching. */ + +static void +riscv_emit_mode_set (int entity, int mode, int prev_mode, + HARD_REG_SET regs_live ATTRIBUTE_UNUSED) +{ + switch (entity) + { + case RISCV_VXRM: + if (mode != VXRM_MODE_NONE && mode != prev_mode) + emit_insn (gen_vxrmsi (gen_int_mode (mode, SImode))); + break; + default: + gcc_unreachable (); + } +} + +/* Return mode that entity must be switched into + prior to the execution of insn. */ + +static int +riscv_mode_needed (int entity, rtx_insn *insn) +{ + switch (entity) + { + case RISCV_VXRM: + return recog_memoized (insn) >= 0 ? get_attr_vxrm_mode (insn) + : VXRM_MODE_NONE; + default: + gcc_unreachable (); + } +} + +/* Return the mode that an insn results in. */ + +static int +riscv_mode_after (int entity, int mode, rtx_insn *insn) +{ + switch (entity) + { + case RISCV_VXRM: + if (recog_memoized (insn) >= 0) + return reg_mentioned_p (gen_rtx_REG (SImode, VXRM_REGNUM), + PATTERN (insn)) + ? get_attr_vxrm_mode (insn) + : mode; + else + return mode; + default: + gcc_unreachable (); + } +} + +/* Return a mode that ENTITY is assumed to be + switched to at function entry. */ + +static int +riscv_mode_entry (int entity) +{ + switch (entity) + { + case RISCV_VXRM: + return VXRM_MODE_NONE; + default: + gcc_unreachable (); + } +} + +/* Return a mode that ENTITY is assumed to be + switched to at function exit. */ + +static int +riscv_mode_exit (int entity) +{ + switch (entity) + { + case RISCV_VXRM: + return VXRM_MODE_NONE; + default: + gcc_unreachable (); + } +} + +static int +riscv_mode_priority (int, int n) +{ + return n; +} + /* Initialize the GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" @@ -7789,6 +7878,21 @@ riscv_vectorize_preferred_vector_alignment (const_tree type) #define TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT \ riscv_vectorize_preferred_vector_alignment +/* Mode switching hooks. */ + +#undef TARGET_MODE_EMIT +#define TARGET_MODE_EMIT riscv_emit_mode_set +#undef TARGET_MODE_NEEDED +#define TARGET_MODE_NEEDED riscv_mode_needed +#undef TARGET_MODE_AFTER +#define TARGET_MODE_AFTER riscv_mode_after +#undef TARGET_MODE_ENTRY +#define TARGET_MODE_ENTRY riscv_mode_entry +#undef TARGET_MODE_EXIT +#define TARGET_MODE_EXIT riscv_mode_exit +#undef TARGET_MODE_PRIORITY +#define TARGET_MODE_PRIORITY riscv_mode_priority + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-riscv.h" |