OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [mmix/] [mmix.c] - Diff between revs 38 and 154

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 38 Rev 154
/* Definitions of target machine for GNU compiler, for MMIX.
/* Definitions of target machine for GNU compiler, for MMIX.
   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007
   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
   Contributed by Hans-Peter Nilsson (hp@bitrange.com)
   Contributed by Hans-Peter Nilsson (hp@bitrange.com)
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
the Free Software Foundation; either version 3, or (at your option)
any later version.
any later version.
 
 
GCC is distributed in the hope that it will be useful,
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
#include "coretypes.h"
#include "coretypes.h"
#include "tm.h"
#include "tm.h"
#include "rtl.h"
#include "rtl.h"
#include "regs.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "hard-reg-set.h"
#include "hashtab.h"
#include "hashtab.h"
#include "insn-config.h"
#include "insn-config.h"
#include "output.h"
#include "output.h"
#include "flags.h"
#include "flags.h"
#include "tree.h"
#include "tree.h"
#include "function.h"
#include "function.h"
#include "expr.h"
#include "expr.h"
#include "toplev.h"
#include "toplev.h"
#include "recog.h"
#include "recog.h"
#include "ggc.h"
#include "ggc.h"
#include "dwarf2.h"
#include "dwarf2.h"
#include "debug.h"
#include "debug.h"
#include "tm_p.h"
#include "tm_p.h"
#include "integrate.h"
#include "integrate.h"
#include "target.h"
#include "target.h"
#include "target-def.h"
#include "target-def.h"
#include "real.h"
#include "real.h"
 
 
/* First some local helper definitions.  */
/* First some local helper definitions.  */
#define MMIX_FIRST_GLOBAL_REGNUM 32
#define MMIX_FIRST_GLOBAL_REGNUM 32
 
 
/* We'd need a current_function_has_landing_pad.  It's marked as such when
/* We'd need a current_function_has_landing_pad.  It's marked as such when
   a nonlocal_goto_receiver is expanded.  Not just a C++ thing, but
   a nonlocal_goto_receiver is expanded.  Not just a C++ thing, but
   mostly.  */
   mostly.  */
#define MMIX_CFUN_HAS_LANDING_PAD (cfun->machine->has_landing_pad != 0)
#define MMIX_CFUN_HAS_LANDING_PAD (cfun->machine->has_landing_pad != 0)
 
 
/* We have no means to tell DWARF 2 about the register stack, so we need
/* We have no means to tell DWARF 2 about the register stack, so we need
   to store the return address on the stack if an exception can get into
   to store the return address on the stack if an exception can get into
   this function.  FIXME: Narrow condition.  Before any whole-function
   this function.  FIXME: Narrow condition.  Before any whole-function
   analysis, regs_ever_live[] isn't initialized.  We know it's up-to-date
   analysis, regs_ever_live[] isn't initialized.  We know it's up-to-date
   after reload_completed; it may contain incorrect information some time
   after reload_completed; it may contain incorrect information some time
   before that.  Within a RTL sequence (after a call to start_sequence,
   before that.  Within a RTL sequence (after a call to start_sequence,
   such as in RTL expanders), leaf_function_p doesn't see all insns
   such as in RTL expanders), leaf_function_p doesn't see all insns
   (perhaps any insn).  But regs_ever_live is up-to-date when
   (perhaps any insn).  But regs_ever_live is up-to-date when
   leaf_function_p () isn't, so we "or" them together to get accurate
   leaf_function_p () isn't, so we "or" them together to get accurate
   information.  FIXME: Some tweak to leaf_function_p might be
   information.  FIXME: Some tweak to leaf_function_p might be
   preferable.  */
   preferable.  */
#define MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS                 \
#define MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS                 \
 (flag_exceptions                                               \
 (flag_exceptions                                               \
  && ((reload_completed && regs_ever_live[MMIX_rJ_REGNUM])      \
  && ((reload_completed && regs_ever_live[MMIX_rJ_REGNUM])      \
      || !leaf_function_p ()))
      || !leaf_function_p ()))
 
 
#define IS_MMIX_EH_RETURN_DATA_REG(REGNO)       \
#define IS_MMIX_EH_RETURN_DATA_REG(REGNO)       \
 (current_function_calls_eh_return              \
 (current_function_calls_eh_return              \
  && (EH_RETURN_DATA_REGNO (0) == REGNO          \
  && (EH_RETURN_DATA_REGNO (0) == REGNO          \
      || EH_RETURN_DATA_REGNO (1) == REGNO      \
      || EH_RETURN_DATA_REGNO (1) == REGNO      \
      || EH_RETURN_DATA_REGNO (2) == REGNO      \
      || EH_RETURN_DATA_REGNO (2) == REGNO      \
      || EH_RETURN_DATA_REGNO (3) == REGNO))
      || EH_RETURN_DATA_REGNO (3) == REGNO))
 
 
/* For the default ABI, we rename registers at output-time to fill the gap
/* For the default ABI, we rename registers at output-time to fill the gap
   between the (statically partitioned) saved registers and call-clobbered
   between the (statically partitioned) saved registers and call-clobbered
   registers.  In effect this makes unused call-saved registers to be used
   registers.  In effect this makes unused call-saved registers to be used
   as call-clobbered registers.  The benefit comes from keeping the number
   as call-clobbered registers.  The benefit comes from keeping the number
   of local registers (value of rL) low, since there's a cost of
   of local registers (value of rL) low, since there's a cost of
   increasing rL and clearing unused (unset) registers with lower numbers.
   increasing rL and clearing unused (unset) registers with lower numbers.
   Don't translate while outputting the prologue.  */
   Don't translate while outputting the prologue.  */
#define MMIX_OUTPUT_REGNO(N)                                    \
#define MMIX_OUTPUT_REGNO(N)                                    \
 (TARGET_ABI_GNU                                                \
 (TARGET_ABI_GNU                                                \
  || (int) (N) < MMIX_RETURN_VALUE_REGNUM                       \
  || (int) (N) < MMIX_RETURN_VALUE_REGNUM                       \
  || (int) (N) > MMIX_LAST_STACK_REGISTER_REGNUM                \
  || (int) (N) > MMIX_LAST_STACK_REGISTER_REGNUM                \
  || cfun == NULL                                               \
  || cfun == NULL                                               \
  || cfun->machine == NULL                                      \
  || cfun->machine == NULL                                      \
  || cfun->machine->in_prologue                                 \
  || cfun->machine->in_prologue                                 \
  ? (N) : ((N) - MMIX_RETURN_VALUE_REGNUM                       \
  ? (N) : ((N) - MMIX_RETURN_VALUE_REGNUM                       \
           + cfun->machine->highest_saved_stack_register + 1))
           + cfun->machine->highest_saved_stack_register + 1))
 
 
/* The %d in "POP %d,0".  */
/* The %d in "POP %d,0".  */
#define MMIX_POP_ARGUMENT()                                             \
#define MMIX_POP_ARGUMENT()                                             \
 ((! TARGET_ABI_GNU                                                     \
 ((! TARGET_ABI_GNU                                                     \
   && current_function_return_rtx != NULL                               \
   && current_function_return_rtx != NULL                               \
   && ! current_function_returns_struct)                                \
   && ! current_function_returns_struct)                                \
  ? (GET_CODE (current_function_return_rtx) == PARALLEL                 \
  ? (GET_CODE (current_function_return_rtx) == PARALLEL                 \
     ? GET_NUM_ELEM (XVEC (current_function_return_rtx, 0)) : 1) \
     ? GET_NUM_ELEM (XVEC (current_function_return_rtx, 0)) : 1) \
  : 0)
  : 0)
 
 
/* The canonical saved comparison operands for non-cc0 machines, set in
/* The canonical saved comparison operands for non-cc0 machines, set in
   the compare expander.  */
   the compare expander.  */
rtx mmix_compare_op0;
rtx mmix_compare_op0;
rtx mmix_compare_op1;
rtx mmix_compare_op1;
 
 
/* Declarations of locals.  */
/* Declarations of locals.  */
 
 
/* Intermediate for insn output.  */
/* Intermediate for insn output.  */
static int mmix_output_destination_register;
static int mmix_output_destination_register;
 
 
static void mmix_output_shiftvalue_op_from_str
static void mmix_output_shiftvalue_op_from_str
  (FILE *, const char *, HOST_WIDEST_INT);
  (FILE *, const char *, HOST_WIDEST_INT);
static void mmix_output_shifted_value (FILE *, HOST_WIDEST_INT);
static void mmix_output_shifted_value (FILE *, HOST_WIDEST_INT);
static void mmix_output_condition (FILE *, rtx, int);
static void mmix_output_condition (FILE *, rtx, int);
static HOST_WIDEST_INT mmix_intval (rtx);
static HOST_WIDEST_INT mmix_intval (rtx);
static void mmix_output_octa (FILE *, HOST_WIDEST_INT, int);
static void mmix_output_octa (FILE *, HOST_WIDEST_INT, int);
static bool mmix_assemble_integer (rtx, unsigned int, int);
static bool mmix_assemble_integer (rtx, unsigned int, int);
static struct machine_function *mmix_init_machine_status (void);
static struct machine_function *mmix_init_machine_status (void);
static void mmix_encode_section_info (tree, rtx, int);
static void mmix_encode_section_info (tree, rtx, int);
static const char *mmix_strip_name_encoding (const char *);
static const char *mmix_strip_name_encoding (const char *);
static void mmix_emit_sp_add (HOST_WIDE_INT offset);
static void mmix_emit_sp_add (HOST_WIDE_INT offset);
static void mmix_target_asm_function_prologue (FILE *, HOST_WIDE_INT);
static void mmix_target_asm_function_prologue (FILE *, HOST_WIDE_INT);
static void mmix_target_asm_function_end_prologue (FILE *);
static void mmix_target_asm_function_end_prologue (FILE *);
static void mmix_target_asm_function_epilogue (FILE *, HOST_WIDE_INT);
static void mmix_target_asm_function_epilogue (FILE *, HOST_WIDE_INT);
static void mmix_reorg (void);
static void mmix_reorg (void);
static void mmix_asm_output_mi_thunk
static void mmix_asm_output_mi_thunk
  (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree);
  (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree);
static void mmix_setup_incoming_varargs
static void mmix_setup_incoming_varargs
  (CUMULATIVE_ARGS *, enum machine_mode, tree, int *, int);
  (CUMULATIVE_ARGS *, enum machine_mode, tree, int *, int);
static void mmix_file_start (void);
static void mmix_file_start (void);
static void mmix_file_end (void);
static void mmix_file_end (void);
static bool mmix_rtx_costs (rtx, int, int, int *);
static bool mmix_rtx_costs (rtx, int, int, int *);
static rtx mmix_struct_value_rtx (tree, int);
static rtx mmix_struct_value_rtx (tree, int);
static bool mmix_pass_by_reference (const CUMULATIVE_ARGS *,
static bool mmix_pass_by_reference (const CUMULATIVE_ARGS *,
                                    enum machine_mode, tree, bool);
                                    enum machine_mode, tree, bool);
 
 
/* Target structure macros.  Listed by node.  See `Using and Porting GCC'
/* Target structure macros.  Listed by node.  See `Using and Porting GCC'
   for a general description.  */
   for a general description.  */
 
 
/* Node: Function Entry */
/* Node: Function Entry */
 
 
#undef TARGET_ASM_BYTE_OP
#undef TARGET_ASM_BYTE_OP
#define TARGET_ASM_BYTE_OP NULL
#define TARGET_ASM_BYTE_OP NULL
#undef TARGET_ASM_ALIGNED_HI_OP
#undef TARGET_ASM_ALIGNED_HI_OP
#define TARGET_ASM_ALIGNED_HI_OP NULL
#define TARGET_ASM_ALIGNED_HI_OP NULL
#undef TARGET_ASM_ALIGNED_SI_OP
#undef TARGET_ASM_ALIGNED_SI_OP
#define TARGET_ASM_ALIGNED_SI_OP NULL
#define TARGET_ASM_ALIGNED_SI_OP NULL
#undef TARGET_ASM_ALIGNED_DI_OP
#undef TARGET_ASM_ALIGNED_DI_OP
#define TARGET_ASM_ALIGNED_DI_OP NULL
#define TARGET_ASM_ALIGNED_DI_OP NULL
#undef TARGET_ASM_INTEGER
#undef TARGET_ASM_INTEGER
#define TARGET_ASM_INTEGER mmix_assemble_integer
#define TARGET_ASM_INTEGER mmix_assemble_integer
 
 
#undef TARGET_ASM_FUNCTION_PROLOGUE
#undef TARGET_ASM_FUNCTION_PROLOGUE
#define TARGET_ASM_FUNCTION_PROLOGUE mmix_target_asm_function_prologue
#define TARGET_ASM_FUNCTION_PROLOGUE mmix_target_asm_function_prologue
 
 
#undef TARGET_ASM_FUNCTION_END_PROLOGUE
#undef TARGET_ASM_FUNCTION_END_PROLOGUE
#define TARGET_ASM_FUNCTION_END_PROLOGUE mmix_target_asm_function_end_prologue
#define TARGET_ASM_FUNCTION_END_PROLOGUE mmix_target_asm_function_end_prologue
 
 
#undef TARGET_ASM_FUNCTION_EPILOGUE
#undef TARGET_ASM_FUNCTION_EPILOGUE
#define TARGET_ASM_FUNCTION_EPILOGUE mmix_target_asm_function_epilogue
#define TARGET_ASM_FUNCTION_EPILOGUE mmix_target_asm_function_epilogue
 
 
#undef TARGET_ENCODE_SECTION_INFO
#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO  mmix_encode_section_info
#define TARGET_ENCODE_SECTION_INFO  mmix_encode_section_info
#undef TARGET_STRIP_NAME_ENCODING
#undef TARGET_STRIP_NAME_ENCODING
#define TARGET_STRIP_NAME_ENCODING  mmix_strip_name_encoding
#define TARGET_STRIP_NAME_ENCODING  mmix_strip_name_encoding
 
 
#undef TARGET_ASM_OUTPUT_MI_THUNK
#undef TARGET_ASM_OUTPUT_MI_THUNK
#define TARGET_ASM_OUTPUT_MI_THUNK mmix_asm_output_mi_thunk
#define TARGET_ASM_OUTPUT_MI_THUNK mmix_asm_output_mi_thunk
#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
#define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall
#define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall
#undef TARGET_ASM_FILE_START
#undef TARGET_ASM_FILE_START
#define TARGET_ASM_FILE_START mmix_file_start
#define TARGET_ASM_FILE_START mmix_file_start
#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
#undef TARGET_ASM_FILE_END
#undef TARGET_ASM_FILE_END
#define TARGET_ASM_FILE_END mmix_file_end
#define TARGET_ASM_FILE_END mmix_file_end
 
 
#undef TARGET_RTX_COSTS
#undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS mmix_rtx_costs
#define TARGET_RTX_COSTS mmix_rtx_costs
#undef TARGET_ADDRESS_COST
#undef TARGET_ADDRESS_COST
#define TARGET_ADDRESS_COST hook_int_rtx_0
#define TARGET_ADDRESS_COST hook_int_rtx_0
 
 
#undef TARGET_MACHINE_DEPENDENT_REORG
#undef TARGET_MACHINE_DEPENDENT_REORG
#define TARGET_MACHINE_DEPENDENT_REORG mmix_reorg
#define TARGET_MACHINE_DEPENDENT_REORG mmix_reorg
 
 
#undef TARGET_PROMOTE_FUNCTION_ARGS
#undef TARGET_PROMOTE_FUNCTION_ARGS
#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
#if 0
#if 0
/* Apparently not doing TRT if int < register-size.  FIXME: Perhaps
/* Apparently not doing TRT if int < register-size.  FIXME: Perhaps
   FUNCTION_VALUE and LIBCALL_VALUE needs tweaking as some ports say.  */
   FUNCTION_VALUE and LIBCALL_VALUE needs tweaking as some ports say.  */
#undef TARGET_PROMOTE_FUNCTION_RETURN
#undef TARGET_PROMOTE_FUNCTION_RETURN
#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
#endif
#endif
 
 
#undef TARGET_STRUCT_VALUE_RTX
#undef TARGET_STRUCT_VALUE_RTX
#define TARGET_STRUCT_VALUE_RTX mmix_struct_value_rtx
#define TARGET_STRUCT_VALUE_RTX mmix_struct_value_rtx
#undef TARGET_SETUP_INCOMING_VARARGS
#undef TARGET_SETUP_INCOMING_VARARGS
#define TARGET_SETUP_INCOMING_VARARGS mmix_setup_incoming_varargs
#define TARGET_SETUP_INCOMING_VARARGS mmix_setup_incoming_varargs
#undef TARGET_PASS_BY_REFERENCE
#undef TARGET_PASS_BY_REFERENCE
#define TARGET_PASS_BY_REFERENCE mmix_pass_by_reference
#define TARGET_PASS_BY_REFERENCE mmix_pass_by_reference
#undef TARGET_CALLEE_COPIES
#undef TARGET_CALLEE_COPIES
#define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true
#define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true
#undef TARGET_DEFAULT_TARGET_FLAGS
#undef TARGET_DEFAULT_TARGET_FLAGS
#define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
#define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
 
 
struct gcc_target targetm = TARGET_INITIALIZER;
struct gcc_target targetm = TARGET_INITIALIZER;
 
 
/* Functions that are expansions for target macros.
/* Functions that are expansions for target macros.
   See Target Macros in `Using and Porting GCC'.  */
   See Target Macros in `Using and Porting GCC'.  */
 
 
/* OVERRIDE_OPTIONS.  */
/* OVERRIDE_OPTIONS.  */
 
 
void
void
mmix_override_options (void)
mmix_override_options (void)
{
{
  /* Should we err or should we warn?  Hmm.  At least we must neutralize
  /* Should we err or should we warn?  Hmm.  At least we must neutralize
     it.  For example the wrong kind of case-tables will be generated with
     it.  For example the wrong kind of case-tables will be generated with
     PIC; we use absolute address items for mmixal compatibility.  FIXME:
     PIC; we use absolute address items for mmixal compatibility.  FIXME:
     They could be relative if we just elide them to after all pertinent
     They could be relative if we just elide them to after all pertinent
     labels.  */
     labels.  */
  if (flag_pic)
  if (flag_pic)
    {
    {
      warning (0, "-f%s not supported: ignored", (flag_pic > 1) ? "PIC" : "pic");
      warning (0, "-f%s not supported: ignored", (flag_pic > 1) ? "PIC" : "pic");
      flag_pic = 0;
      flag_pic = 0;
    }
    }
}
}
 
 
/* INIT_EXPANDERS.  */
/* INIT_EXPANDERS.  */
 
 
void
void
mmix_init_expanders (void)
mmix_init_expanders (void)
{
{
  init_machine_status = mmix_init_machine_status;
  init_machine_status = mmix_init_machine_status;
}
}
 
 
/* Set the per-function data.  */
/* Set the per-function data.  */
 
 
static struct machine_function *
static struct machine_function *
mmix_init_machine_status (void)
mmix_init_machine_status (void)
{
{
  return ggc_alloc_cleared (sizeof (struct machine_function));
  return ggc_alloc_cleared (sizeof (struct machine_function));
}
}
 
 
/* DATA_ALIGNMENT.
/* DATA_ALIGNMENT.
   We have trouble getting the address of stuff that is located at other
   We have trouble getting the address of stuff that is located at other
   than 32-bit alignments (GETA requirements), so try to give everything
   than 32-bit alignments (GETA requirements), so try to give everything
   at least 32-bit alignment.  */
   at least 32-bit alignment.  */
 
 
int
int
mmix_data_alignment (tree type ATTRIBUTE_UNUSED, int basic_align)
mmix_data_alignment (tree type ATTRIBUTE_UNUSED, int basic_align)
{
{
  if (basic_align < 32)
  if (basic_align < 32)
    return 32;
    return 32;
 
 
  return basic_align;
  return basic_align;
}
}
 
 
/* CONSTANT_ALIGNMENT.  */
/* CONSTANT_ALIGNMENT.  */
 
 
int
int
mmix_constant_alignment (tree constant ATTRIBUTE_UNUSED, int basic_align)
mmix_constant_alignment (tree constant ATTRIBUTE_UNUSED, int basic_align)
{
{
  if (basic_align < 32)
  if (basic_align < 32)
    return 32;
    return 32;
 
 
  return basic_align;
  return basic_align;
}
}
 
 
/* LOCAL_ALIGNMENT.  */
/* LOCAL_ALIGNMENT.  */
 
 
int
int
mmix_local_alignment (tree type ATTRIBUTE_UNUSED, int basic_align)
mmix_local_alignment (tree type ATTRIBUTE_UNUSED, int basic_align)
{
{
  if (basic_align < 32)
  if (basic_align < 32)
    return 32;
    return 32;
 
 
  return basic_align;
  return basic_align;
}
}
 
 
/* CONDITIONAL_REGISTER_USAGE.  */
/* CONDITIONAL_REGISTER_USAGE.  */
 
 
void
void
mmix_conditional_register_usage (void)
mmix_conditional_register_usage (void)
{
{
  int i;
  int i;
 
 
  if (TARGET_ABI_GNU)
  if (TARGET_ABI_GNU)
    {
    {
      static const int gnu_abi_reg_alloc_order[]
      static const int gnu_abi_reg_alloc_order[]
        = MMIX_GNU_ABI_REG_ALLOC_ORDER;
        = MMIX_GNU_ABI_REG_ALLOC_ORDER;
 
 
      for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
      for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
        reg_alloc_order[i] = gnu_abi_reg_alloc_order[i];
        reg_alloc_order[i] = gnu_abi_reg_alloc_order[i];
 
 
      /* Change the default from the mmixware ABI.  For the GNU ABI,
      /* Change the default from the mmixware ABI.  For the GNU ABI,
         $15..$30 are call-saved just as $0..$14.  There must be one
         $15..$30 are call-saved just as $0..$14.  There must be one
         call-clobbered local register for the "hole" that holds the
         call-clobbered local register for the "hole" that holds the
         number of saved local registers saved by PUSHJ/PUSHGO during the
         number of saved local registers saved by PUSHJ/PUSHGO during the
         function call, receiving the return value at return.  So best is
         function call, receiving the return value at return.  So best is
         to use the highest, $31.  It's already marked call-clobbered for
         to use the highest, $31.  It's already marked call-clobbered for
         the mmixware ABI.  */
         the mmixware ABI.  */
      for (i = 15; i <= 30; i++)
      for (i = 15; i <= 30; i++)
        call_used_regs[i] = 0;
        call_used_regs[i] = 0;
 
 
      /* "Unfix" the parameter registers.  */
      /* "Unfix" the parameter registers.  */
      for (i = MMIX_RESERVED_GNU_ARG_0_REGNUM;
      for (i = MMIX_RESERVED_GNU_ARG_0_REGNUM;
           i < MMIX_RESERVED_GNU_ARG_0_REGNUM + MMIX_MAX_ARGS_IN_REGS;
           i < MMIX_RESERVED_GNU_ARG_0_REGNUM + MMIX_MAX_ARGS_IN_REGS;
           i++)
           i++)
        fixed_regs[i] = 0;
        fixed_regs[i] = 0;
    }
    }
 
 
  /* Step over the ":" in special register names.  */
  /* Step over the ":" in special register names.  */
  if (! TARGET_TOPLEVEL_SYMBOLS)
  if (! TARGET_TOPLEVEL_SYMBOLS)
    for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
      if (reg_names[i][0] == ':')
      if (reg_names[i][0] == ':')
        reg_names[i]++;
        reg_names[i]++;
}
}
 
 
/* LOCAL_REGNO.
/* LOCAL_REGNO.
   All registers that are part of the register stack and that will be
   All registers that are part of the register stack and that will be
   saved are local.  */
   saved are local.  */
 
 
int
int
mmix_local_regno (int regno)
mmix_local_regno (int regno)
{
{
  return regno <= MMIX_LAST_STACK_REGISTER_REGNUM && !call_used_regs[regno];
  return regno <= MMIX_LAST_STACK_REGISTER_REGNUM && !call_used_regs[regno];
}
}
 
 
/* PREFERRED_RELOAD_CLASS.
/* PREFERRED_RELOAD_CLASS.
   We need to extend the reload class of REMAINDER_REG and HIMULT_REG.  */
   We need to extend the reload class of REMAINDER_REG and HIMULT_REG.  */
 
 
enum reg_class
enum reg_class
mmix_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, enum reg_class class)
mmix_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, enum reg_class class)
{
{
  /* FIXME: Revisit.  */
  /* FIXME: Revisit.  */
  return GET_CODE (x) == MOD && GET_MODE (x) == DImode
  return GET_CODE (x) == MOD && GET_MODE (x) == DImode
    ? REMAINDER_REG : class;
    ? REMAINDER_REG : class;
}
}
 
 
/* PREFERRED_OUTPUT_RELOAD_CLASS.
/* PREFERRED_OUTPUT_RELOAD_CLASS.
   We need to extend the reload class of REMAINDER_REG and HIMULT_REG.  */
   We need to extend the reload class of REMAINDER_REG and HIMULT_REG.  */
 
 
enum reg_class
enum reg_class
mmix_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED,
mmix_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED,
                                    enum reg_class class)
                                    enum reg_class class)
{
{
  /* FIXME: Revisit.  */
  /* FIXME: Revisit.  */
  return GET_CODE (x) == MOD && GET_MODE (x) == DImode
  return GET_CODE (x) == MOD && GET_MODE (x) == DImode
    ? REMAINDER_REG : class;
    ? REMAINDER_REG : class;
}
}
 
 
/* SECONDARY_RELOAD_CLASS.
/* SECONDARY_RELOAD_CLASS.
   We need to reload regs of REMAINDER_REG and HIMULT_REG elsewhere.  */
   We need to reload regs of REMAINDER_REG and HIMULT_REG elsewhere.  */
 
 
enum reg_class
enum reg_class
mmix_secondary_reload_class (enum reg_class class,
mmix_secondary_reload_class (enum reg_class class,
                             enum machine_mode mode ATTRIBUTE_UNUSED,
                             enum machine_mode mode ATTRIBUTE_UNUSED,
                             rtx x ATTRIBUTE_UNUSED,
                             rtx x ATTRIBUTE_UNUSED,
                             int in_p ATTRIBUTE_UNUSED)
                             int in_p ATTRIBUTE_UNUSED)
{
{
  if (class == REMAINDER_REG
  if (class == REMAINDER_REG
      || class == HIMULT_REG
      || class == HIMULT_REG
      || class == SYSTEM_REGS)
      || class == SYSTEM_REGS)
    return GENERAL_REGS;
    return GENERAL_REGS;
 
 
  return NO_REGS;
  return NO_REGS;
}
}
 
 
/* CONST_OK_FOR_LETTER_P.  */
/* CONST_OK_FOR_LETTER_P.  */
 
 
int
int
mmix_const_ok_for_letter_p (HOST_WIDE_INT value, int c)
mmix_const_ok_for_letter_p (HOST_WIDE_INT value, int c)
{
{
  return
  return
    (c == 'I' ? value >= 0 && value <= 255
    (c == 'I' ? value >= 0 && value <= 255
     : c == 'J' ? value >= 0 && value <= 65535
     : c == 'J' ? value >= 0 && value <= 65535
     : c == 'K' ? value <= 0 && value >= -255
     : c == 'K' ? value <= 0 && value >= -255
     : c == 'L' ? mmix_shiftable_wyde_value (value)
     : c == 'L' ? mmix_shiftable_wyde_value (value)
     : c == 'M' ? value == 0
     : c == 'M' ? value == 0
     : c == 'N' ? mmix_shiftable_wyde_value (~value)
     : c == 'N' ? mmix_shiftable_wyde_value (~value)
     : c == 'O' ? (value == 3 || value == 5 || value == 9
     : c == 'O' ? (value == 3 || value == 5 || value == 9
                   || value == 17)
                   || value == 17)
     : 0);
     : 0);
}
}
 
 
/* CONST_DOUBLE_OK_FOR_LETTER_P.  */
/* CONST_DOUBLE_OK_FOR_LETTER_P.  */
 
 
int
int
mmix_const_double_ok_for_letter_p (rtx value, int c)
mmix_const_double_ok_for_letter_p (rtx value, int c)
{
{
  return
  return
    (c == 'G' ? value == CONST0_RTX (GET_MODE (value))
    (c == 'G' ? value == CONST0_RTX (GET_MODE (value))
     : 0);
     : 0);
}
}
 
 
/* EXTRA_CONSTRAINT.
/* EXTRA_CONSTRAINT.
   We need this since our constants are not always expressible as
   We need this since our constants are not always expressible as
   CONST_INT:s, but rather often as CONST_DOUBLE:s.  */
   CONST_INT:s, but rather often as CONST_DOUBLE:s.  */
 
 
int
int
mmix_extra_constraint (rtx x, int c, int strict)
mmix_extra_constraint (rtx x, int c, int strict)
{
{
  HOST_WIDEST_INT value;
  HOST_WIDEST_INT value;
 
 
  /* When checking for an address, we need to handle strict vs. non-strict
  /* When checking for an address, we need to handle strict vs. non-strict
     register checks.  Don't use address_operand, but instead its
     register checks.  Don't use address_operand, but instead its
     equivalent (its callee, which it is just a wrapper for),
     equivalent (its callee, which it is just a wrapper for),
     memory_operand_p and the strict-equivalent strict_memory_address_p.  */
     memory_operand_p and the strict-equivalent strict_memory_address_p.  */
  if (c == 'U')
  if (c == 'U')
    return
    return
      strict
      strict
      ? strict_memory_address_p (Pmode, x)
      ? strict_memory_address_p (Pmode, x)
      : memory_address_p (Pmode, x);
      : memory_address_p (Pmode, x);
 
 
  /* R asks whether x is to be loaded with GETA or something else.  Right
  /* R asks whether x is to be loaded with GETA or something else.  Right
     now, only a SYMBOL_REF and LABEL_REF can fit for
     now, only a SYMBOL_REF and LABEL_REF can fit for
     TARGET_BASE_ADDRESSES.
     TARGET_BASE_ADDRESSES.
 
 
     Only constant symbolic addresses apply.  With TARGET_BASE_ADDRESSES,
     Only constant symbolic addresses apply.  With TARGET_BASE_ADDRESSES,
     we just allow straight LABEL_REF or SYMBOL_REFs with SYMBOL_REF_FLAG
     we just allow straight LABEL_REF or SYMBOL_REFs with SYMBOL_REF_FLAG
     set right now; only function addresses and code labels.  If we change
     set right now; only function addresses and code labels.  If we change
     to let SYMBOL_REF_FLAG be set on other symbols, we have to check
     to let SYMBOL_REF_FLAG be set on other symbols, we have to check
     inside CONST expressions.  When TARGET_BASE_ADDRESSES is not in
     inside CONST expressions.  When TARGET_BASE_ADDRESSES is not in
     effect, a "raw" constant check together with mmix_constant_address_p
     effect, a "raw" constant check together with mmix_constant_address_p
     is all that's needed; we want all constant addresses to be loaded
     is all that's needed; we want all constant addresses to be loaded
     with GETA then.  */
     with GETA then.  */
  if (c == 'R')
  if (c == 'R')
    return
    return
      GET_CODE (x) != CONST_INT && GET_CODE (x) != CONST_DOUBLE
      GET_CODE (x) != CONST_INT && GET_CODE (x) != CONST_DOUBLE
      && mmix_constant_address_p (x)
      && mmix_constant_address_p (x)
      && (! TARGET_BASE_ADDRESSES
      && (! TARGET_BASE_ADDRESSES
          || (GET_CODE (x) == LABEL_REF
          || (GET_CODE (x) == LABEL_REF
              || (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FLAG (x))));
              || (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FLAG (x))));
 
 
  if (GET_CODE (x) != CONST_DOUBLE || GET_MODE (x) != VOIDmode)
  if (GET_CODE (x) != CONST_DOUBLE || GET_MODE (x) != VOIDmode)
    return 0;
    return 0;
 
 
  value = mmix_intval (x);
  value = mmix_intval (x);
 
 
  /* We used to map Q->J, R->K, S->L, T->N, U->O, but we don't have to any
  /* We used to map Q->J, R->K, S->L, T->N, U->O, but we don't have to any
     more ('U' taken for address_operand, 'R' similarly).  Some letters map
     more ('U' taken for address_operand, 'R' similarly).  Some letters map
     outside of CONST_INT, though; we still use 'S' and 'T'.  */
     outside of CONST_INT, though; we still use 'S' and 'T'.  */
  if (c == 'S')
  if (c == 'S')
    return mmix_shiftable_wyde_value (value);
    return mmix_shiftable_wyde_value (value);
  else if (c == 'T')
  else if (c == 'T')
    return mmix_shiftable_wyde_value (~value);
    return mmix_shiftable_wyde_value (~value);
  return 0;
  return 0;
}
}
 
 
/* DYNAMIC_CHAIN_ADDRESS.  */
/* DYNAMIC_CHAIN_ADDRESS.  */
 
 
rtx
rtx
mmix_dynamic_chain_address (rtx frame)
mmix_dynamic_chain_address (rtx frame)
{
{
  /* FIXME: the frame-pointer is stored at offset -8 from the current
  /* FIXME: the frame-pointer is stored at offset -8 from the current
     frame-pointer.  Unfortunately, the caller assumes that a
     frame-pointer.  Unfortunately, the caller assumes that a
     frame-pointer is present for *all* previous frames.  There should be
     frame-pointer is present for *all* previous frames.  There should be
     a way to say that that cannot be done, like for RETURN_ADDR_RTX.  */
     a way to say that that cannot be done, like for RETURN_ADDR_RTX.  */
  return plus_constant (frame, -8);
  return plus_constant (frame, -8);
}
}
 
 
/* STARTING_FRAME_OFFSET.  */
/* STARTING_FRAME_OFFSET.  */
 
 
int
int
mmix_starting_frame_offset (void)
mmix_starting_frame_offset (void)
{
{
  /* The old frame pointer is in the slot below the new one, so
  /* The old frame pointer is in the slot below the new one, so
     FIRST_PARM_OFFSET does not need to depend on whether the
     FIRST_PARM_OFFSET does not need to depend on whether the
     frame-pointer is needed or not.  We have to adjust for the register
     frame-pointer is needed or not.  We have to adjust for the register
     stack pointer being located below the saved frame pointer.
     stack pointer being located below the saved frame pointer.
     Similarly, we store the return address on the stack too, for
     Similarly, we store the return address on the stack too, for
     exception handling, and always if we save the register stack pointer.  */
     exception handling, and always if we save the register stack pointer.  */
  return
  return
    (-8
    (-8
     + (MMIX_CFUN_HAS_LANDING_PAD
     + (MMIX_CFUN_HAS_LANDING_PAD
        ? -16 : (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS ? -8 : 0)));
        ? -16 : (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS ? -8 : 0)));
}
}
 
 
/* RETURN_ADDR_RTX.  */
/* RETURN_ADDR_RTX.  */
 
 
rtx
rtx
mmix_return_addr_rtx (int count, rtx frame ATTRIBUTE_UNUSED)
mmix_return_addr_rtx (int count, rtx frame ATTRIBUTE_UNUSED)
{
{
  return count == 0
  return count == 0
    ? (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS
    ? (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS
       /* FIXME: Set frame_alias_set on the following.  (Why?)
       /* FIXME: Set frame_alias_set on the following.  (Why?)
          See mmix_initial_elimination_offset for the reason we can't use
          See mmix_initial_elimination_offset for the reason we can't use
          get_hard_reg_initial_val for both.  Always using a stack slot
          get_hard_reg_initial_val for both.  Always using a stack slot
          and not a register would be suboptimal.  */
          and not a register would be suboptimal.  */
       ? validize_mem (gen_rtx_MEM (Pmode, plus_constant (frame_pointer_rtx, -16)))
       ? validize_mem (gen_rtx_MEM (Pmode, plus_constant (frame_pointer_rtx, -16)))
       : get_hard_reg_initial_val (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM))
       : get_hard_reg_initial_val (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM))
    : NULL_RTX;
    : NULL_RTX;
}
}
 
 
/* SETUP_FRAME_ADDRESSES.  */
/* SETUP_FRAME_ADDRESSES.  */
 
 
void
void
mmix_setup_frame_addresses (void)
mmix_setup_frame_addresses (void)
{
{
  /* Nothing needed at the moment.  */
  /* Nothing needed at the moment.  */
}
}
 
 
/* The difference between the (imaginary) frame pointer and the stack
/* The difference between the (imaginary) frame pointer and the stack
   pointer.  Used to eliminate the frame pointer.  */
   pointer.  Used to eliminate the frame pointer.  */
 
 
int
int
mmix_initial_elimination_offset (int fromreg, int toreg)
mmix_initial_elimination_offset (int fromreg, int toreg)
{
{
  int regno;
  int regno;
  int fp_sp_offset
  int fp_sp_offset
    = (get_frame_size () + current_function_outgoing_args_size + 7) & ~7;
    = (get_frame_size () + current_function_outgoing_args_size + 7) & ~7;
 
 
  /* There is no actual offset between these two virtual values, but for
  /* There is no actual offset between these two virtual values, but for
     the frame-pointer, we have the old one in the stack position below
     the frame-pointer, we have the old one in the stack position below
     it, so the offset for the frame-pointer to the stack-pointer is one
     it, so the offset for the frame-pointer to the stack-pointer is one
     octabyte larger.  */
     octabyte larger.  */
  if (fromreg == MMIX_ARG_POINTER_REGNUM
  if (fromreg == MMIX_ARG_POINTER_REGNUM
      && toreg == MMIX_FRAME_POINTER_REGNUM)
      && toreg == MMIX_FRAME_POINTER_REGNUM)
    return 0;
    return 0;
 
 
  /* The difference is the size of local variables plus the size of
  /* The difference is the size of local variables plus the size of
     outgoing function arguments that would normally be passed as
     outgoing function arguments that would normally be passed as
     registers but must be passed on stack because we're out of
     registers but must be passed on stack because we're out of
     function-argument registers.  Only global saved registers are
     function-argument registers.  Only global saved registers are
     counted; the others go on the register stack.
     counted; the others go on the register stack.
 
 
     The frame-pointer is counted too if it is what is eliminated, as we
     The frame-pointer is counted too if it is what is eliminated, as we
     need to balance the offset for it from STARTING_FRAME_OFFSET.
     need to balance the offset for it from STARTING_FRAME_OFFSET.
 
 
     Also add in the slot for the register stack pointer we save if we
     Also add in the slot for the register stack pointer we save if we
     have a landing pad.
     have a landing pad.
 
 
     Unfortunately, we can't access $0..$14, from unwinder code easily, so
     Unfortunately, we can't access $0..$14, from unwinder code easily, so
     store the return address in a frame slot too.  FIXME: Only for
     store the return address in a frame slot too.  FIXME: Only for
     non-leaf functions.  FIXME: Always with a landing pad, because it's
     non-leaf functions.  FIXME: Always with a landing pad, because it's
     hard to know whether we need the other at the time we know we need
     hard to know whether we need the other at the time we know we need
     the offset for one (and have to state it).  It's a kludge until we
     the offset for one (and have to state it).  It's a kludge until we
     can express the register stack in the EH frame info.
     can express the register stack in the EH frame info.
 
 
     We have to do alignment here; get_frame_size will not return a
     We have to do alignment here; get_frame_size will not return a
     multiple of STACK_BOUNDARY.  FIXME: Add note in manual.  */
     multiple of STACK_BOUNDARY.  FIXME: Add note in manual.  */
 
 
  for (regno = MMIX_FIRST_GLOBAL_REGNUM;
  for (regno = MMIX_FIRST_GLOBAL_REGNUM;
       regno <= 255;
       regno <= 255;
       regno++)
       regno++)
    if ((regs_ever_live[regno] && ! call_used_regs[regno])
    if ((regs_ever_live[regno] && ! call_used_regs[regno])
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
      fp_sp_offset += 8;
      fp_sp_offset += 8;
 
 
  return fp_sp_offset
  return fp_sp_offset
    + (MMIX_CFUN_HAS_LANDING_PAD
    + (MMIX_CFUN_HAS_LANDING_PAD
       ? 16 : (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS ? 8 : 0))
       ? 16 : (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS ? 8 : 0))
    + (fromreg == MMIX_ARG_POINTER_REGNUM ? 0 : 8);
    + (fromreg == MMIX_ARG_POINTER_REGNUM ? 0 : 8);
}
}
 
 
/* Return an rtx for a function argument to go in a register, and 0 for
/* Return an rtx for a function argument to go in a register, and 0 for
   one that must go on stack.  */
   one that must go on stack.  */
 
 
rtx
rtx
mmix_function_arg (const CUMULATIVE_ARGS *argsp,
mmix_function_arg (const CUMULATIVE_ARGS *argsp,
                   enum machine_mode mode,
                   enum machine_mode mode,
                   tree type,
                   tree type,
                   int named ATTRIBUTE_UNUSED,
                   int named ATTRIBUTE_UNUSED,
                   int incoming)
                   int incoming)
{
{
  /* Last-argument marker.  */
  /* Last-argument marker.  */
  if (type == void_type_node)
  if (type == void_type_node)
    return (argsp->regs < MMIX_MAX_ARGS_IN_REGS)
    return (argsp->regs < MMIX_MAX_ARGS_IN_REGS)
      ? gen_rtx_REG (mode,
      ? gen_rtx_REG (mode,
                     (incoming
                     (incoming
                      ? MMIX_FIRST_INCOMING_ARG_REGNUM
                      ? MMIX_FIRST_INCOMING_ARG_REGNUM
                      : MMIX_FIRST_ARG_REGNUM) + argsp->regs)
                      : MMIX_FIRST_ARG_REGNUM) + argsp->regs)
      : NULL_RTX;
      : NULL_RTX;
 
 
  return (argsp->regs < MMIX_MAX_ARGS_IN_REGS
  return (argsp->regs < MMIX_MAX_ARGS_IN_REGS
          && !targetm.calls.must_pass_in_stack (mode, type)
          && !targetm.calls.must_pass_in_stack (mode, type)
          && (GET_MODE_BITSIZE (mode) <= 64
          && (GET_MODE_BITSIZE (mode) <= 64
              || argsp->lib
              || argsp->lib
              || TARGET_LIBFUNC))
              || TARGET_LIBFUNC))
    ? gen_rtx_REG (mode,
    ? gen_rtx_REG (mode,
                   (incoming
                   (incoming
                    ? MMIX_FIRST_INCOMING_ARG_REGNUM
                    ? MMIX_FIRST_INCOMING_ARG_REGNUM
                    : MMIX_FIRST_ARG_REGNUM)
                    : MMIX_FIRST_ARG_REGNUM)
                   + argsp->regs)
                   + argsp->regs)
    : NULL_RTX;
    : NULL_RTX;
}
}
 
 
/* Returns nonzero for everything that goes by reference, 0 for
/* Returns nonzero for everything that goes by reference, 0 for
   everything that goes by value.  */
   everything that goes by value.  */
 
 
static bool
static bool
mmix_pass_by_reference (const CUMULATIVE_ARGS *argsp, enum machine_mode mode,
mmix_pass_by_reference (const CUMULATIVE_ARGS *argsp, enum machine_mode mode,
                        tree type, bool named ATTRIBUTE_UNUSED)
                        tree type, bool named ATTRIBUTE_UNUSED)
{
{
  /* FIXME: Check: I'm not sure the must_pass_in_stack check is
  /* FIXME: Check: I'm not sure the must_pass_in_stack check is
     necessary.  */
     necessary.  */
  if (targetm.calls.must_pass_in_stack (mode, type))
  if (targetm.calls.must_pass_in_stack (mode, type))
    return true;
    return true;
 
 
  if (MMIX_FUNCTION_ARG_SIZE (mode, type) > 8
  if (MMIX_FUNCTION_ARG_SIZE (mode, type) > 8
      && !TARGET_LIBFUNC
      && !TARGET_LIBFUNC
      && (!argsp || !argsp->lib))
      && (!argsp || !argsp->lib))
    return true;
    return true;
 
 
  return false;
  return false;
}
}
 
 
/* Return nonzero if regno is a register number where a parameter is
/* Return nonzero if regno is a register number where a parameter is
   passed, and 0 otherwise.  */
   passed, and 0 otherwise.  */
 
 
int
int
mmix_function_arg_regno_p (int regno, int incoming)
mmix_function_arg_regno_p (int regno, int incoming)
{
{
  int first_arg_regnum
  int first_arg_regnum
    = incoming ? MMIX_FIRST_INCOMING_ARG_REGNUM : MMIX_FIRST_ARG_REGNUM;
    = incoming ? MMIX_FIRST_INCOMING_ARG_REGNUM : MMIX_FIRST_ARG_REGNUM;
 
 
  return regno >= first_arg_regnum
  return regno >= first_arg_regnum
    && regno < first_arg_regnum + MMIX_MAX_ARGS_IN_REGS;
    && regno < first_arg_regnum + MMIX_MAX_ARGS_IN_REGS;
}
}
 
 
/* FUNCTION_OUTGOING_VALUE.  */
/* FUNCTION_OUTGOING_VALUE.  */
 
 
rtx
rtx
mmix_function_outgoing_value (tree valtype, tree func ATTRIBUTE_UNUSED)
mmix_function_outgoing_value (tree valtype, tree func ATTRIBUTE_UNUSED)
{
{
  enum machine_mode mode = TYPE_MODE (valtype);
  enum machine_mode mode = TYPE_MODE (valtype);
  enum machine_mode cmode;
  enum machine_mode cmode;
  int first_val_regnum = MMIX_OUTGOING_RETURN_VALUE_REGNUM;
  int first_val_regnum = MMIX_OUTGOING_RETURN_VALUE_REGNUM;
  rtx vec[MMIX_MAX_REGS_FOR_VALUE];
  rtx vec[MMIX_MAX_REGS_FOR_VALUE];
  int i;
  int i;
  int nregs;
  int nregs;
 
 
  /* Return values that fit in a register need no special handling.
  /* Return values that fit in a register need no special handling.
     There's no register hole when parameters are passed in global
     There's no register hole when parameters are passed in global
     registers.  */
     registers.  */
  if (TARGET_ABI_GNU
  if (TARGET_ABI_GNU
      || GET_MODE_BITSIZE (mode) <= BITS_PER_WORD)
      || GET_MODE_BITSIZE (mode) <= BITS_PER_WORD)
    return
    return
      gen_rtx_REG (mode, MMIX_OUTGOING_RETURN_VALUE_REGNUM);
      gen_rtx_REG (mode, MMIX_OUTGOING_RETURN_VALUE_REGNUM);
 
 
  if (COMPLEX_MODE_P (mode))
  if (COMPLEX_MODE_P (mode))
    /* A complex type, made up of components.  */
    /* A complex type, made up of components.  */
    cmode = TYPE_MODE (TREE_TYPE (valtype));
    cmode = TYPE_MODE (TREE_TYPE (valtype));
  else
  else
    {
    {
      /* Of the other larger-than-register modes, we only support
      /* Of the other larger-than-register modes, we only support
         scalar mode TImode.  (At least, that's the only one that's
         scalar mode TImode.  (At least, that's the only one that's
         been rudimentally tested.)  Make sure we're alerted for
         been rudimentally tested.)  Make sure we're alerted for
         unexpected cases.  */
         unexpected cases.  */
      if (mode != TImode)
      if (mode != TImode)
        sorry ("support for mode %qs", GET_MODE_NAME (mode));
        sorry ("support for mode %qs", GET_MODE_NAME (mode));
 
 
      /* In any case, we will fill registers to the natural size.  */
      /* In any case, we will fill registers to the natural size.  */
      cmode = DImode;
      cmode = DImode;
    }
    }
 
 
  nregs = ((GET_MODE_BITSIZE (mode) + BITS_PER_WORD - 1) / BITS_PER_WORD);
  nregs = ((GET_MODE_BITSIZE (mode) + BITS_PER_WORD - 1) / BITS_PER_WORD);
 
 
  /* We need to take care of the effect of the register hole on return
  /* We need to take care of the effect of the register hole on return
     values of large sizes; the last register will appear as the first
     values of large sizes; the last register will appear as the first
     register, with the rest shifted.  (For complex modes, this is just
     register, with the rest shifted.  (For complex modes, this is just
     swapped registers.)  */
     swapped registers.)  */
 
 
  if (nregs > MMIX_MAX_REGS_FOR_VALUE)
  if (nregs > MMIX_MAX_REGS_FOR_VALUE)
    internal_error ("too large function value type, needs %d registers,\
    internal_error ("too large function value type, needs %d registers,\
 have only %d registers for this", nregs, MMIX_MAX_REGS_FOR_VALUE);
 have only %d registers for this", nregs, MMIX_MAX_REGS_FOR_VALUE);
 
 
  /* FIXME: Maybe we should handle structure values like this too
  /* FIXME: Maybe we should handle structure values like this too
     (adjusted for BLKmode), perhaps for both ABI:s.  */
     (adjusted for BLKmode), perhaps for both ABI:s.  */
  for (i = 0; i < nregs - 1; i++)
  for (i = 0; i < nregs - 1; i++)
    vec[i]
    vec[i]
      = gen_rtx_EXPR_LIST (VOIDmode,
      = gen_rtx_EXPR_LIST (VOIDmode,
                           gen_rtx_REG (cmode, first_val_regnum + i),
                           gen_rtx_REG (cmode, first_val_regnum + i),
                           GEN_INT ((i + 1) * BITS_PER_UNIT));
                           GEN_INT ((i + 1) * BITS_PER_UNIT));
 
 
  vec[nregs - 1]
  vec[nregs - 1]
    = gen_rtx_EXPR_LIST (VOIDmode,
    = gen_rtx_EXPR_LIST (VOIDmode,
                         gen_rtx_REG (cmode, first_val_regnum + nregs - 1),
                         gen_rtx_REG (cmode, first_val_regnum + nregs - 1),
                         const0_rtx);
                         const0_rtx);
 
 
  return gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nregs, vec));
  return gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nregs, vec));
}
}
 
 
/* FUNCTION_VALUE_REGNO_P.  */
/* FUNCTION_VALUE_REGNO_P.  */
 
 
int
int
mmix_function_value_regno_p (int regno)
mmix_function_value_regno_p (int regno)
{
{
  return regno == MMIX_RETURN_VALUE_REGNUM;
  return regno == MMIX_RETURN_VALUE_REGNUM;
}
}
 
 
/* EH_RETURN_DATA_REGNO. */
/* EH_RETURN_DATA_REGNO. */
 
 
int
int
mmix_eh_return_data_regno (int n)
mmix_eh_return_data_regno (int n)
{
{
  if (n >= 0 && n < 4)
  if (n >= 0 && n < 4)
    return MMIX_EH_RETURN_DATA_REGNO_START + n;
    return MMIX_EH_RETURN_DATA_REGNO_START + n;
 
 
  return INVALID_REGNUM;
  return INVALID_REGNUM;
}
}
 
 
/* EH_RETURN_STACKADJ_RTX. */
/* EH_RETURN_STACKADJ_RTX. */
 
 
rtx
rtx
mmix_eh_return_stackadj_rtx (void)
mmix_eh_return_stackadj_rtx (void)
{
{
  return gen_rtx_REG (Pmode, MMIX_EH_RETURN_STACKADJ_REGNUM);
  return gen_rtx_REG (Pmode, MMIX_EH_RETURN_STACKADJ_REGNUM);
}
}
 
 
/* EH_RETURN_HANDLER_RTX.  */
/* EH_RETURN_HANDLER_RTX.  */
 
 
rtx
rtx
mmix_eh_return_handler_rtx (void)
mmix_eh_return_handler_rtx (void)
{
{
  return gen_rtx_REG (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM);
  return gen_rtx_REG (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM);
}
}
 
 
/* ASM_PREFERRED_EH_DATA_FORMAT. */
/* ASM_PREFERRED_EH_DATA_FORMAT. */
 
 
int
int
mmix_asm_preferred_eh_data_format (int code ATTRIBUTE_UNUSED,
mmix_asm_preferred_eh_data_format (int code ATTRIBUTE_UNUSED,
                                   int global ATTRIBUTE_UNUSED)
                                   int global ATTRIBUTE_UNUSED)
{
{
  /* This is the default (was at 2001-07-20).  Revisit when needed.  */
  /* This is the default (was at 2001-07-20).  Revisit when needed.  */
  return DW_EH_PE_absptr;
  return DW_EH_PE_absptr;
}
}
 
 
/* Make a note that we've seen the beginning of the prologue.  This
/* Make a note that we've seen the beginning of the prologue.  This
   matters to whether we'll translate register numbers as calculated by
   matters to whether we'll translate register numbers as calculated by
   mmix_reorg.  */
   mmix_reorg.  */
 
 
static void
static void
mmix_target_asm_function_prologue (FILE *stream ATTRIBUTE_UNUSED,
mmix_target_asm_function_prologue (FILE *stream ATTRIBUTE_UNUSED,
                                   HOST_WIDE_INT framesize ATTRIBUTE_UNUSED)
                                   HOST_WIDE_INT framesize ATTRIBUTE_UNUSED)
{
{
  cfun->machine->in_prologue = 1;
  cfun->machine->in_prologue = 1;
}
}
 
 
/* Make a note that we've seen the end of the prologue.  */
/* Make a note that we've seen the end of the prologue.  */
 
 
static void
static void
mmix_target_asm_function_end_prologue (FILE *stream ATTRIBUTE_UNUSED)
mmix_target_asm_function_end_prologue (FILE *stream ATTRIBUTE_UNUSED)
{
{
  cfun->machine->in_prologue = 0;
  cfun->machine->in_prologue = 0;
}
}
 
 
/* Implement TARGET_MACHINE_DEPENDENT_REORG.  No actual rearrangements
/* Implement TARGET_MACHINE_DEPENDENT_REORG.  No actual rearrangements
   done here; just virtually by calculating the highest saved stack
   done here; just virtually by calculating the highest saved stack
   register number used to modify the register numbers at output time.  */
   register number used to modify the register numbers at output time.  */
 
 
static void
static void
mmix_reorg (void)
mmix_reorg (void)
{
{
  int regno;
  int regno;
 
 
  /* We put the number of the highest saved register-file register in a
  /* We put the number of the highest saved register-file register in a
     location convenient for the call-patterns to output.  Note that we
     location convenient for the call-patterns to output.  Note that we
     don't tell dwarf2 about these registers, since it can't restore them
     don't tell dwarf2 about these registers, since it can't restore them
     anyway.  */
     anyway.  */
  for (regno = MMIX_LAST_STACK_REGISTER_REGNUM;
  for (regno = MMIX_LAST_STACK_REGISTER_REGNUM;
       regno >= 0;
       regno >= 0;
       regno--)
       regno--)
    if ((regs_ever_live[regno] && !call_used_regs[regno])
    if ((regs_ever_live[regno] && !call_used_regs[regno])
        || (regno == MMIX_FRAME_POINTER_REGNUM && frame_pointer_needed))
        || (regno == MMIX_FRAME_POINTER_REGNUM && frame_pointer_needed))
      break;
      break;
 
 
  /* Regardless of whether they're saved (they might be just read), we
  /* Regardless of whether they're saved (they might be just read), we
     mustn't include registers that carry parameters.  We could scan the
     mustn't include registers that carry parameters.  We could scan the
     insns to see whether they're actually used (and indeed do other less
     insns to see whether they're actually used (and indeed do other less
     trivial register usage analysis and transformations), but it seems
     trivial register usage analysis and transformations), but it seems
     wasteful to optimize for unused parameter registers.  As of
     wasteful to optimize for unused parameter registers.  As of
     2002-04-30, regs_ever_live[n] seems to be set for only-reads too, but
     2002-04-30, regs_ever_live[n] seems to be set for only-reads too, but
     that might change.  */
     that might change.  */
  if (!TARGET_ABI_GNU && regno < current_function_args_info.regs - 1)
  if (!TARGET_ABI_GNU && regno < current_function_args_info.regs - 1)
    {
    {
      regno = current_function_args_info.regs - 1;
      regno = current_function_args_info.regs - 1;
 
 
      /* We don't want to let this cause us to go over the limit and make
      /* We don't want to let this cause us to go over the limit and make
         incoming parameter registers be misnumbered and treating the last
         incoming parameter registers be misnumbered and treating the last
         parameter register and incoming return value register call-saved.
         parameter register and incoming return value register call-saved.
         Stop things at the unmodified scheme.  */
         Stop things at the unmodified scheme.  */
      if (regno > MMIX_RETURN_VALUE_REGNUM - 1)
      if (regno > MMIX_RETURN_VALUE_REGNUM - 1)
        regno = MMIX_RETURN_VALUE_REGNUM - 1;
        regno = MMIX_RETURN_VALUE_REGNUM - 1;
    }
    }
 
 
  cfun->machine->highest_saved_stack_register = regno;
  cfun->machine->highest_saved_stack_register = regno;
}
}
 
 
/* TARGET_ASM_FUNCTION_EPILOGUE.  */
/* TARGET_ASM_FUNCTION_EPILOGUE.  */
 
 
static void
static void
mmix_target_asm_function_epilogue (FILE *stream,
mmix_target_asm_function_epilogue (FILE *stream,
                                   HOST_WIDE_INT locals_size ATTRIBUTE_UNUSED)
                                   HOST_WIDE_INT locals_size ATTRIBUTE_UNUSED)
{
{
  /* Emit an \n for readability of the generated assembly.  */
  /* Emit an \n for readability of the generated assembly.  */
  fputc ('\n', stream);
  fputc ('\n', stream);
}
}
 
 
/* TARGET_ASM_OUTPUT_MI_THUNK.  */
/* TARGET_ASM_OUTPUT_MI_THUNK.  */
 
 
static void
static void
mmix_asm_output_mi_thunk (FILE *stream,
mmix_asm_output_mi_thunk (FILE *stream,
                          tree fndecl ATTRIBUTE_UNUSED,
                          tree fndecl ATTRIBUTE_UNUSED,
                          HOST_WIDE_INT delta,
                          HOST_WIDE_INT delta,
                          HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
                          HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
                          tree func)
                          tree func)
{
{
  /* If you define TARGET_STRUCT_VALUE_RTX that returns 0 (i.e. pass
  /* If you define TARGET_STRUCT_VALUE_RTX that returns 0 (i.e. pass
     location of structure to return as invisible first argument), you
     location of structure to return as invisible first argument), you
     need to tweak this code too.  */
     need to tweak this code too.  */
  const char *regname = reg_names[MMIX_FIRST_INCOMING_ARG_REGNUM];
  const char *regname = reg_names[MMIX_FIRST_INCOMING_ARG_REGNUM];
 
 
  if (delta >= 0 && delta < 65536)
  if (delta >= 0 && delta < 65536)
    fprintf (stream, "\tINCL %s,%d\n", regname, (int)delta);
    fprintf (stream, "\tINCL %s,%d\n", regname, (int)delta);
  else if (delta < 0 && delta >= -255)
  else if (delta < 0 && delta >= -255)
    fprintf (stream, "\tSUBU %s,%s,%d\n", regname, regname, (int)-delta);
    fprintf (stream, "\tSUBU %s,%s,%d\n", regname, regname, (int)-delta);
  else
  else
    {
    {
      mmix_output_register_setting (stream, 255, delta, 1);
      mmix_output_register_setting (stream, 255, delta, 1);
      fprintf (stream, "\tADDU %s,%s,$255\n", regname, regname);
      fprintf (stream, "\tADDU %s,%s,$255\n", regname, regname);
    }
    }
 
 
  fprintf (stream, "\tJMP ");
  fprintf (stream, "\tJMP ");
  assemble_name (stream, XSTR (XEXP (DECL_RTL (func), 0), 0));
  assemble_name (stream, XSTR (XEXP (DECL_RTL (func), 0), 0));
  fprintf (stream, "\n");
  fprintf (stream, "\n");
}
}
 
 
/* FUNCTION_PROFILER.  */
/* FUNCTION_PROFILER.  */
 
 
void
void
mmix_function_profiler (FILE *stream ATTRIBUTE_UNUSED,
mmix_function_profiler (FILE *stream ATTRIBUTE_UNUSED,
                        int labelno ATTRIBUTE_UNUSED)
                        int labelno ATTRIBUTE_UNUSED)
{
{
  sorry ("function_profiler support for MMIX");
  sorry ("function_profiler support for MMIX");
}
}
 
 
/* Worker function for TARGET_SETUP_INCOMING_VARARGS.  For the moment,
/* Worker function for TARGET_SETUP_INCOMING_VARARGS.  For the moment,
   let's stick to pushing argument registers on the stack.  Later, we
   let's stick to pushing argument registers on the stack.  Later, we
   can parse all arguments in registers, to improve performance.  */
   can parse all arguments in registers, to improve performance.  */
 
 
static void
static void
mmix_setup_incoming_varargs (CUMULATIVE_ARGS *args_so_farp,
mmix_setup_incoming_varargs (CUMULATIVE_ARGS *args_so_farp,
                             enum machine_mode mode,
                             enum machine_mode mode,
                             tree vartype,
                             tree vartype,
                             int *pretend_sizep,
                             int *pretend_sizep,
                             int second_time ATTRIBUTE_UNUSED)
                             int second_time ATTRIBUTE_UNUSED)
{
{
  /* The last named variable has been handled, but
  /* The last named variable has been handled, but
     args_so_farp has not been advanced for it.  */
     args_so_farp has not been advanced for it.  */
  if (args_so_farp->regs + 1 < MMIX_MAX_ARGS_IN_REGS)
  if (args_so_farp->regs + 1 < MMIX_MAX_ARGS_IN_REGS)
    *pretend_sizep = (MMIX_MAX_ARGS_IN_REGS - (args_so_farp->regs + 1)) * 8;
    *pretend_sizep = (MMIX_MAX_ARGS_IN_REGS - (args_so_farp->regs + 1)) * 8;
 
 
  /* We assume that one argument takes up one register here.  That should
  /* We assume that one argument takes up one register here.  That should
     be true until we start messing with multi-reg parameters.  */
     be true until we start messing with multi-reg parameters.  */
  if ((7 + (MMIX_FUNCTION_ARG_SIZE (mode, vartype))) / 8 != 1)
  if ((7 + (MMIX_FUNCTION_ARG_SIZE (mode, vartype))) / 8 != 1)
    internal_error ("MMIX Internal: Last named vararg would not fit in a register");
    internal_error ("MMIX Internal: Last named vararg would not fit in a register");
}
}
 
 
/* TRAMPOLINE_SIZE.  */
/* TRAMPOLINE_SIZE.  */
/* Four 4-byte insns plus two 8-byte values.  */
/* Four 4-byte insns plus two 8-byte values.  */
int mmix_trampoline_size = 32;
int mmix_trampoline_size = 32;
 
 
 
 
/* TRAMPOLINE_TEMPLATE.  */
/* TRAMPOLINE_TEMPLATE.  */
 
 
void
void
mmix_trampoline_template (FILE *stream)
mmix_trampoline_template (FILE *stream)
{
{
  /* Read a value into the static-chain register and jump somewhere.  The
  /* Read a value into the static-chain register and jump somewhere.  The
     static chain is stored at offset 16, and the function address is
     static chain is stored at offset 16, and the function address is
     stored at offset 24.  */
     stored at offset 24.  */
  /* FIXME: GCC copies this using *intsize* (tetra), when it should use
  /* FIXME: GCC copies this using *intsize* (tetra), when it should use
     register size (octa).  */
     register size (octa).  */
  fprintf (stream, "\tGETA $255,1F\n\t");
  fprintf (stream, "\tGETA $255,1F\n\t");
  fprintf (stream, "LDOU %s,$255,0\n\t",
  fprintf (stream, "LDOU %s,$255,0\n\t",
           reg_names[MMIX_STATIC_CHAIN_REGNUM]);
           reg_names[MMIX_STATIC_CHAIN_REGNUM]);
  fprintf (stream, "LDOU $255,$255,8\n\t");
  fprintf (stream, "LDOU $255,$255,8\n\t");
  fprintf (stream, "GO $255,$255,0\n");
  fprintf (stream, "GO $255,$255,0\n");
  fprintf (stream, "1H\tOCTA 0\n\t");
  fprintf (stream, "1H\tOCTA 0\n\t");
  fprintf (stream, "OCTA 0\n");
  fprintf (stream, "OCTA 0\n");
}
}
 
 
/* INITIALIZE_TRAMPOLINE.  */
/* INITIALIZE_TRAMPOLINE.  */
/* Set the static chain and function pointer field in the trampoline.
/* Set the static chain and function pointer field in the trampoline.
   We also SYNCID here to be sure (doesn't matter in the simulator, but
   We also SYNCID here to be sure (doesn't matter in the simulator, but
   some day it will).  */
   some day it will).  */
 
 
void
void
mmix_initialize_trampoline (rtx trampaddr, rtx fnaddr, rtx static_chain)
mmix_initialize_trampoline (rtx trampaddr, rtx fnaddr, rtx static_chain)
{
{
  emit_move_insn (gen_rtx_MEM (DImode, plus_constant (trampaddr, 16)),
  emit_move_insn (gen_rtx_MEM (DImode, plus_constant (trampaddr, 16)),
                  static_chain);
                  static_chain);
  emit_move_insn (gen_rtx_MEM (DImode,
  emit_move_insn (gen_rtx_MEM (DImode,
                               plus_constant (trampaddr, 24)),
                               plus_constant (trampaddr, 24)),
                  fnaddr);
                  fnaddr);
  emit_insn (gen_sync_icache (validize_mem (gen_rtx_MEM (DImode,
  emit_insn (gen_sync_icache (validize_mem (gen_rtx_MEM (DImode,
                                                         trampaddr)),
                                                         trampaddr)),
                              GEN_INT (mmix_trampoline_size - 1)));
                              GEN_INT (mmix_trampoline_size - 1)));
}
}
 
 
/* We must exclude constant addresses that have an increment that is not a
/* We must exclude constant addresses that have an increment that is not a
   multiple of four bytes because of restrictions of the GETA
   multiple of four bytes because of restrictions of the GETA
   instruction, unless TARGET_BASE_ADDRESSES.  */
   instruction, unless TARGET_BASE_ADDRESSES.  */
 
 
int
int
mmix_constant_address_p (rtx x)
mmix_constant_address_p (rtx x)
{
{
  RTX_CODE code = GET_CODE (x);
  RTX_CODE code = GET_CODE (x);
  int addend = 0;
  int addend = 0;
  /* When using "base addresses", anything constant goes.  */
  /* When using "base addresses", anything constant goes.  */
  int constant_ok = TARGET_BASE_ADDRESSES != 0;
  int constant_ok = TARGET_BASE_ADDRESSES != 0;
 
 
  switch (code)
  switch (code)
    {
    {
    case LABEL_REF:
    case LABEL_REF:
    case SYMBOL_REF:
    case SYMBOL_REF:
      return 1;
      return 1;
 
 
    case HIGH:
    case HIGH:
      /* FIXME: Don't know how to dissect these.  Avoid them for now,
      /* FIXME: Don't know how to dissect these.  Avoid them for now,
         except we know they're constants.  */
         except we know they're constants.  */
      return constant_ok;
      return constant_ok;
 
 
    case CONST_INT:
    case CONST_INT:
      addend = INTVAL (x);
      addend = INTVAL (x);
      break;
      break;
 
 
    case CONST_DOUBLE:
    case CONST_DOUBLE:
      if (GET_MODE (x) != VOIDmode)
      if (GET_MODE (x) != VOIDmode)
        /* Strange that we got here.  FIXME: Check if we do.  */
        /* Strange that we got here.  FIXME: Check if we do.  */
        return constant_ok;
        return constant_ok;
      addend = CONST_DOUBLE_LOW (x);
      addend = CONST_DOUBLE_LOW (x);
      break;
      break;
 
 
    case CONST:
    case CONST:
      /* Note that expressions with arithmetic on forward references don't
      /* Note that expressions with arithmetic on forward references don't
         work in mmixal.  People using gcc assembly code with mmixal might
         work in mmixal.  People using gcc assembly code with mmixal might
         need to move arrays and such to before the point of use.  */
         need to move arrays and such to before the point of use.  */
      if (GET_CODE (XEXP (x, 0)) == PLUS)
      if (GET_CODE (XEXP (x, 0)) == PLUS)
        {
        {
          rtx x0 = XEXP (XEXP (x, 0), 0);
          rtx x0 = XEXP (XEXP (x, 0), 0);
          rtx x1 = XEXP (XEXP (x, 0), 1);
          rtx x1 = XEXP (XEXP (x, 0), 1);
 
 
          if ((GET_CODE (x0) == SYMBOL_REF
          if ((GET_CODE (x0) == SYMBOL_REF
               || GET_CODE (x0) == LABEL_REF)
               || GET_CODE (x0) == LABEL_REF)
              && (GET_CODE (x1) == CONST_INT
              && (GET_CODE (x1) == CONST_INT
                  || (GET_CODE (x1) == CONST_DOUBLE
                  || (GET_CODE (x1) == CONST_DOUBLE
                      && GET_MODE (x1) == VOIDmode)))
                      && GET_MODE (x1) == VOIDmode)))
            addend = mmix_intval (x1);
            addend = mmix_intval (x1);
          else
          else
            return constant_ok;
            return constant_ok;
        }
        }
      else
      else
        return constant_ok;
        return constant_ok;
      break;
      break;
 
 
    default:
    default:
      return 0;
      return 0;
    }
    }
 
 
  return constant_ok || (addend & 3) == 0;
  return constant_ok || (addend & 3) == 0;
}
}
 
 
/* Return 1 if the address is OK, otherwise 0.
/* Return 1 if the address is OK, otherwise 0.
   Used by GO_IF_LEGITIMATE_ADDRESS.  */
   Used by GO_IF_LEGITIMATE_ADDRESS.  */
 
 
int
int
mmix_legitimate_address (enum machine_mode mode ATTRIBUTE_UNUSED,
mmix_legitimate_address (enum machine_mode mode ATTRIBUTE_UNUSED,
                         rtx x,
                         rtx x,
                         int strict_checking)
                         int strict_checking)
{
{
#define MMIX_REG_OK(X)                                                  \
#define MMIX_REG_OK(X)                                                  \
  ((strict_checking                                                     \
  ((strict_checking                                                     \
    && (REGNO (X) <= MMIX_LAST_GENERAL_REGISTER                         \
    && (REGNO (X) <= MMIX_LAST_GENERAL_REGISTER                         \
        || (reg_renumber[REGNO (X)] > 0                                  \
        || (reg_renumber[REGNO (X)] > 0                                  \
            && reg_renumber[REGNO (X)] <= MMIX_LAST_GENERAL_REGISTER))) \
            && reg_renumber[REGNO (X)] <= MMIX_LAST_GENERAL_REGISTER))) \
   || (!strict_checking                                                 \
   || (!strict_checking                                                 \
       && (REGNO (X) <= MMIX_LAST_GENERAL_REGISTER                      \
       && (REGNO (X) <= MMIX_LAST_GENERAL_REGISTER                      \
           || REGNO (X) >= FIRST_PSEUDO_REGISTER                        \
           || REGNO (X) >= FIRST_PSEUDO_REGISTER                        \
           || REGNO (X) == ARG_POINTER_REGNUM)))
           || REGNO (X) == ARG_POINTER_REGNUM)))
 
 
  /* We only accept:
  /* We only accept:
     (mem reg)
     (mem reg)
     (mem (plus reg reg))
     (mem (plus reg reg))
     (mem (plus reg 0..255)).
     (mem (plus reg 0..255)).
     unless TARGET_BASE_ADDRESSES, in which case we accept all
     unless TARGET_BASE_ADDRESSES, in which case we accept all
     (mem constant_address) too.  */
     (mem constant_address) too.  */
 
 
 
 
    /* (mem reg) */
    /* (mem reg) */
  if (REG_P (x) && MMIX_REG_OK (x))
  if (REG_P (x) && MMIX_REG_OK (x))
    return 1;
    return 1;
 
 
  if (GET_CODE(x) == PLUS)
  if (GET_CODE(x) == PLUS)
    {
    {
      rtx x1 = XEXP (x, 0);
      rtx x1 = XEXP (x, 0);
      rtx x2 = XEXP (x, 1);
      rtx x2 = XEXP (x, 1);
 
 
      /* Try swapping the order.  FIXME: Do we need this?  */
      /* Try swapping the order.  FIXME: Do we need this?  */
      if (! REG_P (x1))
      if (! REG_P (x1))
        {
        {
          rtx tem = x1;
          rtx tem = x1;
          x1 = x2;
          x1 = x2;
          x2 = tem;
          x2 = tem;
        }
        }
 
 
      /* (mem (plus (reg?) (?))) */
      /* (mem (plus (reg?) (?))) */
      if (!REG_P (x1) || !MMIX_REG_OK (x1))
      if (!REG_P (x1) || !MMIX_REG_OK (x1))
        return TARGET_BASE_ADDRESSES && mmix_constant_address_p (x);
        return TARGET_BASE_ADDRESSES && mmix_constant_address_p (x);
 
 
      /* (mem (plus (reg) (reg?))) */
      /* (mem (plus (reg) (reg?))) */
      if (REG_P (x2) && MMIX_REG_OK (x2))
      if (REG_P (x2) && MMIX_REG_OK (x2))
        return 1;
        return 1;
 
 
      /* (mem (plus (reg) (0..255?))) */
      /* (mem (plus (reg) (0..255?))) */
      if (GET_CODE (x2) == CONST_INT
      if (GET_CODE (x2) == CONST_INT
          && CONST_OK_FOR_LETTER_P (INTVAL (x2), 'I'))
          && CONST_OK_FOR_LETTER_P (INTVAL (x2), 'I'))
        return 1;
        return 1;
 
 
      return 0;
      return 0;
    }
    }
 
 
  return TARGET_BASE_ADDRESSES && mmix_constant_address_p (x);
  return TARGET_BASE_ADDRESSES && mmix_constant_address_p (x);
}
}
 
 
/* LEGITIMATE_CONSTANT_P.  */
/* LEGITIMATE_CONSTANT_P.  */
 
 
int
int
mmix_legitimate_constant_p (rtx x)
mmix_legitimate_constant_p (rtx x)
{
{
  RTX_CODE code = GET_CODE (x);
  RTX_CODE code = GET_CODE (x);
 
 
  /* We must allow any number due to the way the cse passes works; if we
  /* We must allow any number due to the way the cse passes works; if we
     do not allow any number here, general_operand will fail, and insns
     do not allow any number here, general_operand will fail, and insns
     will fatally fail recognition instead of "softly".  */
     will fatally fail recognition instead of "softly".  */
  if (code == CONST_INT || code == CONST_DOUBLE)
  if (code == CONST_INT || code == CONST_DOUBLE)
    return 1;
    return 1;
 
 
  return CONSTANT_ADDRESS_P (x);
  return CONSTANT_ADDRESS_P (x);
}
}
 
 
/* SELECT_CC_MODE.  */
/* SELECT_CC_MODE.  */
 
 
enum machine_mode
enum machine_mode
mmix_select_cc_mode (RTX_CODE op, rtx x, rtx y ATTRIBUTE_UNUSED)
mmix_select_cc_mode (RTX_CODE op, rtx x, rtx y ATTRIBUTE_UNUSED)
{
{
  /* We use CCmode, CC_UNSmode, CC_FPmode, CC_FPEQmode and CC_FUNmode to
  /* We use CCmode, CC_UNSmode, CC_FPmode, CC_FPEQmode and CC_FUNmode to
     output different compare insns.  Note that we do not check the
     output different compare insns.  Note that we do not check the
     validity of the comparison here.  */
     validity of the comparison here.  */
 
 
  if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
  if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
    {
    {
      if (op == ORDERED || op == UNORDERED || op == UNGE
      if (op == ORDERED || op == UNORDERED || op == UNGE
          || op == UNGT || op == UNLE || op == UNLT)
          || op == UNGT || op == UNLE || op == UNLT)
        return CC_FUNmode;
        return CC_FUNmode;
 
 
      if (op == EQ || op == NE)
      if (op == EQ || op == NE)
        return CC_FPEQmode;
        return CC_FPEQmode;
 
 
      return CC_FPmode;
      return CC_FPmode;
    }
    }
 
 
  if (op == GTU || op == LTU || op == GEU || op == LEU)
  if (op == GTU || op == LTU || op == GEU || op == LEU)
    return CC_UNSmode;
    return CC_UNSmode;
 
 
  return CCmode;
  return CCmode;
}
}
 
 
/* REVERSIBLE_CC_MODE.  */
/* REVERSIBLE_CC_MODE.  */
 
 
int
int
mmix_reversible_cc_mode (enum machine_mode mode)
mmix_reversible_cc_mode (enum machine_mode mode)
{
{
  /* That is, all integer and the EQ, NE, ORDERED and UNORDERED float
  /* That is, all integer and the EQ, NE, ORDERED and UNORDERED float
     compares.  */
     compares.  */
  return mode != CC_FPmode;
  return mode != CC_FPmode;
}
}
 
 
/* TARGET_RTX_COSTS.  */
/* TARGET_RTX_COSTS.  */
 
 
static bool
static bool
mmix_rtx_costs (rtx x ATTRIBUTE_UNUSED,
mmix_rtx_costs (rtx x ATTRIBUTE_UNUSED,
                int code ATTRIBUTE_UNUSED,
                int code ATTRIBUTE_UNUSED,
                int outer_code ATTRIBUTE_UNUSED,
                int outer_code ATTRIBUTE_UNUSED,
                int *total ATTRIBUTE_UNUSED)
                int *total ATTRIBUTE_UNUSED)
{
{
  /* For the time being, this is just a stub and we'll accept the
  /* For the time being, this is just a stub and we'll accept the
     generic calculations, until we can do measurements, at least.
     generic calculations, until we can do measurements, at least.
     Say we did not modify any calculated costs.  */
     Say we did not modify any calculated costs.  */
  return false;
  return false;
}
}
 
 
/* REGISTER_MOVE_COST.  */
/* REGISTER_MOVE_COST.  */
 
 
int
int
mmix_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
mmix_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
                         enum reg_class from,
                         enum reg_class from,
                         enum reg_class to)
                         enum reg_class to)
{
{
  return (from == GENERAL_REGS && from == to) ? 2 : 3;
  return (from == GENERAL_REGS && from == to) ? 2 : 3;
}
}
 
 
/* Note that we don't have a TEXT_SECTION_ASM_OP, because it has to be a
/* Note that we don't have a TEXT_SECTION_ASM_OP, because it has to be a
   compile-time constant; it's used in an asm in crtstuff.c, compiled for
   compile-time constant; it's used in an asm in crtstuff.c, compiled for
   the target.  */
   the target.  */
 
 
/* DATA_SECTION_ASM_OP.  */
/* DATA_SECTION_ASM_OP.  */
 
 
const char *
const char *
mmix_data_section_asm_op (void)
mmix_data_section_asm_op (void)
{
{
  return "\t.data ! mmixal:= 8H LOC 9B";
  return "\t.data ! mmixal:= 8H LOC 9B";
}
}
 
 
static void
static void
mmix_encode_section_info (tree decl, rtx rtl, int first)
mmix_encode_section_info (tree decl, rtx rtl, int first)
{
{
  /* Test for an external declaration, and do nothing if it is one.  */
  /* Test for an external declaration, and do nothing if it is one.  */
  if ((TREE_CODE (decl) == VAR_DECL
  if ((TREE_CODE (decl) == VAR_DECL
       && (DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)))
       && (DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)))
      || (TREE_CODE (decl) == FUNCTION_DECL && TREE_PUBLIC (decl)))
      || (TREE_CODE (decl) == FUNCTION_DECL && TREE_PUBLIC (decl)))
    ;
    ;
  else if (first && DECL_P (decl))
  else if (first && DECL_P (decl))
    {
    {
      /* For non-visible declarations, add a "@" prefix, which we skip
      /* For non-visible declarations, add a "@" prefix, which we skip
         when the label is output.  If the label does not have this
         when the label is output.  If the label does not have this
         prefix, a ":" is output if -mtoplevel-symbols.
         prefix, a ":" is output if -mtoplevel-symbols.
 
 
         Note that this does not work for data that is declared extern and
         Note that this does not work for data that is declared extern and
         later defined as static.  If there's code in between, that code
         later defined as static.  If there's code in between, that code
         will refer to the extern declaration, and vice versa.  This just
         will refer to the extern declaration, and vice versa.  This just
         means that when -mtoplevel-symbols is in use, we can just handle
         means that when -mtoplevel-symbols is in use, we can just handle
         well-behaved ISO-compliant code.  */
         well-behaved ISO-compliant code.  */
 
 
      const char *str = XSTR (XEXP (rtl, 0), 0);
      const char *str = XSTR (XEXP (rtl, 0), 0);
      int len = strlen (str);
      int len = strlen (str);
      char *newstr;
      char *newstr;
 
 
      /* Why is the return type of ggc_alloc_string const?  */
      /* Why is the return type of ggc_alloc_string const?  */
      newstr = (char *) ggc_alloc_string ("", len + 1);
      newstr = (char *) ggc_alloc_string ("", len + 1);
 
 
      strcpy (newstr + 1, str);
      strcpy (newstr + 1, str);
      *newstr = '@';
      *newstr = '@';
      XSTR (XEXP (rtl, 0), 0) = newstr;
      XSTR (XEXP (rtl, 0), 0) = newstr;
    }
    }
 
 
  /* Set SYMBOL_REF_FLAG for things that we want to access with GETA.  We
  /* Set SYMBOL_REF_FLAG for things that we want to access with GETA.  We
     may need different options to reach for different things with GETA.
     may need different options to reach for different things with GETA.
     For now, functions and things we know or have been told are constant.  */
     For now, functions and things we know or have been told are constant.  */
  if (TREE_CODE (decl) == FUNCTION_DECL
  if (TREE_CODE (decl) == FUNCTION_DECL
      || TREE_CONSTANT (decl)
      || TREE_CONSTANT (decl)
      || (TREE_CODE (decl) == VAR_DECL
      || (TREE_CODE (decl) == VAR_DECL
          && TREE_READONLY (decl)
          && TREE_READONLY (decl)
          && !TREE_SIDE_EFFECTS (decl)
          && !TREE_SIDE_EFFECTS (decl)
          && (!DECL_INITIAL (decl)
          && (!DECL_INITIAL (decl)
              || TREE_CONSTANT (DECL_INITIAL (decl)))))
              || TREE_CONSTANT (DECL_INITIAL (decl)))))
    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
}
}
 
 
static const char *
static const char *
mmix_strip_name_encoding (const char *name)
mmix_strip_name_encoding (const char *name)
{
{
  for (; (*name == '@' || *name == '*'); name++)
  for (; (*name == '@' || *name == '*'); name++)
    ;
    ;
 
 
  return name;
  return name;
}
}
 
 
/* TARGET_ASM_FILE_START.
/* TARGET_ASM_FILE_START.
   We just emit a little comment for the time being.  */
   We just emit a little comment for the time being.  */
 
 
static void
static void
mmix_file_start (void)
mmix_file_start (void)
{
{
  default_file_start ();
  default_file_start ();
 
 
  fputs ("! mmixal:= 8H LOC Data_Section\n", asm_out_file);
  fputs ("! mmixal:= 8H LOC Data_Section\n", asm_out_file);
 
 
  /* Make sure each file starts with the text section.  */
  /* Make sure each file starts with the text section.  */
  switch_to_section (text_section);
  switch_to_section (text_section);
}
}
 
 
/* TARGET_ASM_FILE_END.  */
/* TARGET_ASM_FILE_END.  */
 
 
static void
static void
mmix_file_end (void)
mmix_file_end (void)
{
{
  /* Make sure each file ends with the data section.  */
  /* Make sure each file ends with the data section.  */
  switch_to_section (data_section);
  switch_to_section (data_section);
}
}
 
 
/* ASM_OUTPUT_SOURCE_FILENAME.  */
/* ASM_OUTPUT_SOURCE_FILENAME.  */
 
 
void
void
mmix_asm_output_source_filename (FILE *stream, const char *name)
mmix_asm_output_source_filename (FILE *stream, const char *name)
{
{
  fprintf (stream, "# 1 ");
  fprintf (stream, "# 1 ");
  OUTPUT_QUOTED_STRING (stream, name);
  OUTPUT_QUOTED_STRING (stream, name);
  fprintf (stream, "\n");
  fprintf (stream, "\n");
}
}
 
 
/* OUTPUT_QUOTED_STRING.  */
/* OUTPUT_QUOTED_STRING.  */
 
 
void
void
mmix_output_quoted_string (FILE *stream, const char *string, int length)
mmix_output_quoted_string (FILE *stream, const char *string, int length)
{
{
  const char * string_end = string + length;
  const char * string_end = string + length;
  static const char *const unwanted_chars = "\"[]\\";
  static const char *const unwanted_chars = "\"[]\\";
 
 
  /* Output "any character except newline and double quote character".  We
  /* Output "any character except newline and double quote character".  We
     play it safe and avoid all control characters too.  We also do not
     play it safe and avoid all control characters too.  We also do not
     want [] as characters, should input be passed through m4 with [] as
     want [] as characters, should input be passed through m4 with [] as
     quotes.  Further, we avoid "\", because the GAS port handles it as a
     quotes.  Further, we avoid "\", because the GAS port handles it as a
     quoting character.  */
     quoting character.  */
  while (string < string_end)
  while (string < string_end)
    {
    {
      if (*string
      if (*string
          && (unsigned char) *string < 128
          && (unsigned char) *string < 128
          && !ISCNTRL (*string)
          && !ISCNTRL (*string)
          && strchr (unwanted_chars, *string) == NULL)
          && strchr (unwanted_chars, *string) == NULL)
        {
        {
          fputc ('"', stream);
          fputc ('"', stream);
          while (*string
          while (*string
                 && (unsigned char) *string < 128
                 && (unsigned char) *string < 128
                 && !ISCNTRL (*string)
                 && !ISCNTRL (*string)
                 && strchr (unwanted_chars, *string) == NULL
                 && strchr (unwanted_chars, *string) == NULL
                 && string < string_end)
                 && string < string_end)
            {
            {
              fputc (*string, stream);
              fputc (*string, stream);
              string++;
              string++;
            }
            }
          fputc ('"', stream);
          fputc ('"', stream);
          if (string < string_end)
          if (string < string_end)
            fprintf (stream, ",");
            fprintf (stream, ",");
        }
        }
      if (string < string_end)
      if (string < string_end)
        {
        {
          fprintf (stream, "#%x", *string & 255);
          fprintf (stream, "#%x", *string & 255);
          string++;
          string++;
          if (string < string_end)
          if (string < string_end)
            fprintf (stream, ",");
            fprintf (stream, ",");
        }
        }
    }
    }
}
}
 
 
/* Target hook for assembling integer objects.  Use mmix_print_operand
/* Target hook for assembling integer objects.  Use mmix_print_operand
   for WYDE and TETRA.  Use mmix_output_octa to output 8-byte
   for WYDE and TETRA.  Use mmix_output_octa to output 8-byte
   CONST_DOUBLEs.  */
   CONST_DOUBLEs.  */
 
 
static bool
static bool
mmix_assemble_integer (rtx x, unsigned int size, int aligned_p)
mmix_assemble_integer (rtx x, unsigned int size, int aligned_p)
{
{
  if (aligned_p)
  if (aligned_p)
    switch (size)
    switch (size)
      {
      {
        /* We handle a limited number of types of operands in here.  But
        /* We handle a limited number of types of operands in here.  But
           that's ok, because we can punt to generic functions.  We then
           that's ok, because we can punt to generic functions.  We then
           pretend that aligned data isn't needed, so the usual .<pseudo>
           pretend that aligned data isn't needed, so the usual .<pseudo>
           syntax is used (which works for aligned data too).  We actually
           syntax is used (which works for aligned data too).  We actually
           *must* do that, since we say we don't have simple aligned
           *must* do that, since we say we don't have simple aligned
           pseudos, causing this function to be called.  We just try and
           pseudos, causing this function to be called.  We just try and
           keep as much compatibility as possible with mmixal syntax for
           keep as much compatibility as possible with mmixal syntax for
           normal cases (i.e. without GNU extensions and C only).  */
           normal cases (i.e. without GNU extensions and C only).  */
      case 1:
      case 1:
        if (GET_CODE (x) != CONST_INT)
        if (GET_CODE (x) != CONST_INT)
          {
          {
            aligned_p = 0;
            aligned_p = 0;
            break;
            break;
          }
          }
        fputs ("\tBYTE\t", asm_out_file);
        fputs ("\tBYTE\t", asm_out_file);
        mmix_print_operand (asm_out_file, x, 'B');
        mmix_print_operand (asm_out_file, x, 'B');
        fputc ('\n', asm_out_file);
        fputc ('\n', asm_out_file);
        return true;
        return true;
 
 
      case 2:
      case 2:
        if (GET_CODE (x) != CONST_INT)
        if (GET_CODE (x) != CONST_INT)
          {
          {
            aligned_p = 0;
            aligned_p = 0;
            break;
            break;
          }
          }
        fputs ("\tWYDE\t", asm_out_file);
        fputs ("\tWYDE\t", asm_out_file);
        mmix_print_operand (asm_out_file, x, 'W');
        mmix_print_operand (asm_out_file, x, 'W');
        fputc ('\n', asm_out_file);
        fputc ('\n', asm_out_file);
        return true;
        return true;
 
 
      case 4:
      case 4:
        if (GET_CODE (x) != CONST_INT)
        if (GET_CODE (x) != CONST_INT)
          {
          {
            aligned_p = 0;
            aligned_p = 0;
            break;
            break;
          }
          }
        fputs ("\tTETRA\t", asm_out_file);
        fputs ("\tTETRA\t", asm_out_file);
        mmix_print_operand (asm_out_file, x, 'L');
        mmix_print_operand (asm_out_file, x, 'L');
        fputc ('\n', asm_out_file);
        fputc ('\n', asm_out_file);
        return true;
        return true;
 
 
      case 8:
      case 8:
        /* We don't get here anymore for CONST_DOUBLE, because DImode
        /* We don't get here anymore for CONST_DOUBLE, because DImode
           isn't expressed as CONST_DOUBLE, and DFmode is handled
           isn't expressed as CONST_DOUBLE, and DFmode is handled
           elsewhere.  */
           elsewhere.  */
        gcc_assert (GET_CODE (x) != CONST_DOUBLE);
        gcc_assert (GET_CODE (x) != CONST_DOUBLE);
        assemble_integer_with_op ("\tOCTA\t", x);
        assemble_integer_with_op ("\tOCTA\t", x);
        return true;
        return true;
      }
      }
  return default_assemble_integer (x, size, aligned_p);
  return default_assemble_integer (x, size, aligned_p);
}
}
 
 
/* ASM_OUTPUT_ASCII.  */
/* ASM_OUTPUT_ASCII.  */
 
 
void
void
mmix_asm_output_ascii (FILE *stream, const char *string, int length)
mmix_asm_output_ascii (FILE *stream, const char *string, int length)
{
{
  while (length > 0)
  while (length > 0)
    {
    {
      int chunk_size = length > 60 ? 60 : length;
      int chunk_size = length > 60 ? 60 : length;
      fprintf (stream, "\tBYTE ");
      fprintf (stream, "\tBYTE ");
      mmix_output_quoted_string (stream, string, chunk_size);
      mmix_output_quoted_string (stream, string, chunk_size);
      string += chunk_size;
      string += chunk_size;
      length -= chunk_size;
      length -= chunk_size;
      fprintf (stream, "\n");
      fprintf (stream, "\n");
    }
    }
}
}
 
 
/* ASM_OUTPUT_ALIGNED_COMMON.  */
/* ASM_OUTPUT_ALIGNED_COMMON.  */
 
 
void
void
mmix_asm_output_aligned_common (FILE *stream,
mmix_asm_output_aligned_common (FILE *stream,
                                const char *name,
                                const char *name,
                                int size,
                                int size,
                                int align)
                                int align)
{
{
  /* This is mostly the elfos.h one.  There doesn't seem to be a way to
  /* This is mostly the elfos.h one.  There doesn't seem to be a way to
     express this in a mmixal-compatible way.  */
     express this in a mmixal-compatible way.  */
  fprintf (stream, "\t.comm\t");
  fprintf (stream, "\t.comm\t");
  assemble_name (stream, name);
  assemble_name (stream, name);
  fprintf (stream, ",%u,%u ! mmixal-incompatible COMMON\n",
  fprintf (stream, ",%u,%u ! mmixal-incompatible COMMON\n",
           size, align / BITS_PER_UNIT);
           size, align / BITS_PER_UNIT);
}
}
 
 
/* ASM_OUTPUT_ALIGNED_LOCAL.  */
/* ASM_OUTPUT_ALIGNED_LOCAL.  */
 
 
void
void
mmix_asm_output_aligned_local (FILE *stream,
mmix_asm_output_aligned_local (FILE *stream,
                               const char *name,
                               const char *name,
                               int size,
                               int size,
                               int align)
                               int align)
{
{
  switch_to_section (data_section);
  switch_to_section (data_section);
 
 
  ASM_OUTPUT_ALIGN (stream, exact_log2 (align/BITS_PER_UNIT));
  ASM_OUTPUT_ALIGN (stream, exact_log2 (align/BITS_PER_UNIT));
  assemble_name (stream, name);
  assemble_name (stream, name);
  fprintf (stream, "\tLOC @+%d\n", size);
  fprintf (stream, "\tLOC @+%d\n", size);
}
}
 
 
/* ASM_OUTPUT_LABEL.  */
/* ASM_OUTPUT_LABEL.  */
 
 
void
void
mmix_asm_output_label (FILE *stream, const char *name)
mmix_asm_output_label (FILE *stream, const char *name)
{
{
  assemble_name (stream, name);
  assemble_name (stream, name);
  fprintf (stream, "\tIS @\n");
  fprintf (stream, "\tIS @\n");
}
}
 
 
/* ASM_OUTPUT_INTERNAL_LABEL.  */
/* ASM_OUTPUT_INTERNAL_LABEL.  */
 
 
void
void
mmix_asm_output_internal_label (FILE *stream, const char *name)
mmix_asm_output_internal_label (FILE *stream, const char *name)
{
{
  assemble_name_raw (stream, name);
  assemble_name_raw (stream, name);
  fprintf (stream, "\tIS @\n");
  fprintf (stream, "\tIS @\n");
}
}
 
 
/* ASM_DECLARE_REGISTER_GLOBAL.  */
/* ASM_DECLARE_REGISTER_GLOBAL.  */
 
 
void
void
mmix_asm_declare_register_global (FILE *stream ATTRIBUTE_UNUSED,
mmix_asm_declare_register_global (FILE *stream ATTRIBUTE_UNUSED,
                                  tree decl ATTRIBUTE_UNUSED,
                                  tree decl ATTRIBUTE_UNUSED,
                                  int regno ATTRIBUTE_UNUSED,
                                  int regno ATTRIBUTE_UNUSED,
                                  const char *name ATTRIBUTE_UNUSED)
                                  const char *name ATTRIBUTE_UNUSED)
{
{
  /* Nothing to do here, but there *will* be, therefore the framework is
  /* Nothing to do here, but there *will* be, therefore the framework is
     here.  */
     here.  */
}
}
 
 
/* ASM_WEAKEN_LABEL.  */
/* ASM_WEAKEN_LABEL.  */
 
 
void
void
mmix_asm_weaken_label (FILE *stream ATTRIBUTE_UNUSED,
mmix_asm_weaken_label (FILE *stream ATTRIBUTE_UNUSED,
                       const char *name ATTRIBUTE_UNUSED)
                       const char *name ATTRIBUTE_UNUSED)
{
{
  fprintf (stream, "\t.weak ");
  fprintf (stream, "\t.weak ");
  assemble_name (stream, name);
  assemble_name (stream, name);
  fprintf (stream, " ! mmixal-incompatible\n");
  fprintf (stream, " ! mmixal-incompatible\n");
}
}
 
 
/* MAKE_DECL_ONE_ONLY.  */
/* MAKE_DECL_ONE_ONLY.  */
 
 
void
void
mmix_make_decl_one_only (tree decl)
mmix_make_decl_one_only (tree decl)
{
{
  DECL_WEAK (decl) = 1;
  DECL_WEAK (decl) = 1;
}
}
 
 
/* ASM_OUTPUT_LABELREF.
/* ASM_OUTPUT_LABELREF.
   Strip GCC's '*' and our own '@'.  No order is assumed.  */
   Strip GCC's '*' and our own '@'.  No order is assumed.  */
 
 
void
void
mmix_asm_output_labelref (FILE *stream, const char *name)
mmix_asm_output_labelref (FILE *stream, const char *name)
{
{
  int is_extern = 1;
  int is_extern = 1;
 
 
  for (; (*name == '@' || *name == '*'); name++)
  for (; (*name == '@' || *name == '*'); name++)
    if (*name == '@')
    if (*name == '@')
      is_extern = 0;
      is_extern = 0;
 
 
  asm_fprintf (stream, "%s%U%s",
  asm_fprintf (stream, "%s%U%s",
               is_extern && TARGET_TOPLEVEL_SYMBOLS ? ":" : "",
               is_extern && TARGET_TOPLEVEL_SYMBOLS ? ":" : "",
               name);
               name);
}
}
 
 
/* ASM_OUTPUT_DEF.  */
/* ASM_OUTPUT_DEF.  */
 
 
void
void
mmix_asm_output_def (FILE *stream, const char *name, const char *value)
mmix_asm_output_def (FILE *stream, const char *name, const char *value)
{
{
  assemble_name (stream, name);
  assemble_name (stream, name);
  fprintf (stream, "\tIS ");
  fprintf (stream, "\tIS ");
  assemble_name (stream, value);
  assemble_name (stream, value);
  fputc ('\n', stream);
  fputc ('\n', stream);
}
}
 
 
/* PRINT_OPERAND.  */
/* PRINT_OPERAND.  */
 
 
void
void
mmix_print_operand (FILE *stream, rtx x, int code)
mmix_print_operand (FILE *stream, rtx x, int code)
{
{
  /* When we add support for different codes later, we can, when needed,
  /* When we add support for different codes later, we can, when needed,
     drop through to the main handler with a modified operand.  */
     drop through to the main handler with a modified operand.  */
  rtx modified_x = x;
  rtx modified_x = x;
  int regno = x != NULL_RTX && REG_P (x) ? REGNO (x) : 0;
  int regno = x != NULL_RTX && REG_P (x) ? REGNO (x) : 0;
 
 
  switch (code)
  switch (code)
    {
    {
      /* Unrelated codes are in alphabetic order.  */
      /* Unrelated codes are in alphabetic order.  */
 
 
    case '+':
    case '+':
      /* For conditional branches, output "P" for a probable branch.  */
      /* For conditional branches, output "P" for a probable branch.  */
      if (TARGET_BRANCH_PREDICT)
      if (TARGET_BRANCH_PREDICT)
        {
        {
          x = find_reg_note (current_output_insn, REG_BR_PROB, 0);
          x = find_reg_note (current_output_insn, REG_BR_PROB, 0);
          if (x && INTVAL (XEXP (x, 0)) > REG_BR_PROB_BASE / 2)
          if (x && INTVAL (XEXP (x, 0)) > REG_BR_PROB_BASE / 2)
            putc ('P', stream);
            putc ('P', stream);
        }
        }
      return;
      return;
 
 
    case '.':
    case '.':
      /* For the %d in POP %d,0.  */
      /* For the %d in POP %d,0.  */
      fprintf (stream, "%d", MMIX_POP_ARGUMENT ());
      fprintf (stream, "%d", MMIX_POP_ARGUMENT ());
      return;
      return;
 
 
    case 'B':
    case 'B':
      if (GET_CODE (x) != CONST_INT)
      if (GET_CODE (x) != CONST_INT)
        fatal_insn ("MMIX Internal: Expected a CONST_INT, not this", x);
        fatal_insn ("MMIX Internal: Expected a CONST_INT, not this", x);
      fprintf (stream, "%d", (int) (INTVAL (x) & 0xff));
      fprintf (stream, "%d", (int) (INTVAL (x) & 0xff));
      return;
      return;
 
 
    case 'H':
    case 'H':
      /* Highpart.  Must be general register, and not the last one, as
      /* Highpart.  Must be general register, and not the last one, as
         that one cannot be part of a consecutive register pair.  */
         that one cannot be part of a consecutive register pair.  */
      if (regno > MMIX_LAST_GENERAL_REGISTER - 1)
      if (regno > MMIX_LAST_GENERAL_REGISTER - 1)
        internal_error ("MMIX Internal: Bad register: %d", regno);
        internal_error ("MMIX Internal: Bad register: %d", regno);
 
 
      /* This is big-endian, so the high-part is the first one.  */
      /* This is big-endian, so the high-part is the first one.  */
      fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno)]);
      fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno)]);
      return;
      return;
 
 
    case 'L':
    case 'L':
      /* Lowpart.  Must be CONST_INT or general register, and not the last
      /* Lowpart.  Must be CONST_INT or general register, and not the last
         one, as that one cannot be part of a consecutive register pair.  */
         one, as that one cannot be part of a consecutive register pair.  */
      if (GET_CODE (x) == CONST_INT)
      if (GET_CODE (x) == CONST_INT)
        {
        {
          fprintf (stream, "#%lx",
          fprintf (stream, "#%lx",
                   (unsigned long) (INTVAL (x)
                   (unsigned long) (INTVAL (x)
                                    & ((unsigned int) 0x7fffffff * 2 + 1)));
                                    & ((unsigned int) 0x7fffffff * 2 + 1)));
          return;
          return;
        }
        }
 
 
      if (GET_CODE (x) == SYMBOL_REF)
      if (GET_CODE (x) == SYMBOL_REF)
        {
        {
          output_addr_const (stream, x);
          output_addr_const (stream, x);
          return;
          return;
        }
        }
 
 
      if (regno > MMIX_LAST_GENERAL_REGISTER - 1)
      if (regno > MMIX_LAST_GENERAL_REGISTER - 1)
        internal_error ("MMIX Internal: Bad register: %d", regno);
        internal_error ("MMIX Internal: Bad register: %d", regno);
 
 
      /* This is big-endian, so the low-part is + 1.  */
      /* This is big-endian, so the low-part is + 1.  */
      fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno) + 1]);
      fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno) + 1]);
      return;
      return;
 
 
      /* Can't use 'a' because that's a generic modifier for address
      /* Can't use 'a' because that's a generic modifier for address
         output.  */
         output.  */
    case 'A':
    case 'A':
      mmix_output_shiftvalue_op_from_str (stream, "ANDN",
      mmix_output_shiftvalue_op_from_str (stream, "ANDN",
                                          ~(unsigned HOST_WIDEST_INT)
                                          ~(unsigned HOST_WIDEST_INT)
                                          mmix_intval (x));
                                          mmix_intval (x));
      return;
      return;
 
 
    case 'i':
    case 'i':
      mmix_output_shiftvalue_op_from_str (stream, "INC",
      mmix_output_shiftvalue_op_from_str (stream, "INC",
                                          (unsigned HOST_WIDEST_INT)
                                          (unsigned HOST_WIDEST_INT)
                                          mmix_intval (x));
                                          mmix_intval (x));
      return;
      return;
 
 
    case 'o':
    case 'o':
      mmix_output_shiftvalue_op_from_str (stream, "OR",
      mmix_output_shiftvalue_op_from_str (stream, "OR",
                                          (unsigned HOST_WIDEST_INT)
                                          (unsigned HOST_WIDEST_INT)
                                          mmix_intval (x));
                                          mmix_intval (x));
      return;
      return;
 
 
    case 's':
    case 's':
      mmix_output_shiftvalue_op_from_str (stream, "SET",
      mmix_output_shiftvalue_op_from_str (stream, "SET",
                                          (unsigned HOST_WIDEST_INT)
                                          (unsigned HOST_WIDEST_INT)
                                          mmix_intval (x));
                                          mmix_intval (x));
      return;
      return;
 
 
    case 'd':
    case 'd':
    case 'D':
    case 'D':
      mmix_output_condition (stream, x, (code == 'D'));
      mmix_output_condition (stream, x, (code == 'D'));
      return;
      return;
 
 
    case 'e':
    case 'e':
      /* Output an extra "e" to make fcmpe, fune.  */
      /* Output an extra "e" to make fcmpe, fune.  */
      if (TARGET_FCMP_EPSILON)
      if (TARGET_FCMP_EPSILON)
        fprintf (stream, "e");
        fprintf (stream, "e");
      return;
      return;
 
 
    case 'm':
    case 'm':
      /* Output the number minus 1.  */
      /* Output the number minus 1.  */
      if (GET_CODE (x) != CONST_INT)
      if (GET_CODE (x) != CONST_INT)
        {
        {
          fatal_insn ("MMIX Internal: Bad value for 'm', not a CONST_INT",
          fatal_insn ("MMIX Internal: Bad value for 'm', not a CONST_INT",
                      x);
                      x);
        }
        }
      fprintf (stream, HOST_WIDEST_INT_PRINT_DEC,
      fprintf (stream, HOST_WIDEST_INT_PRINT_DEC,
               (HOST_WIDEST_INT) (mmix_intval (x) - 1));
               (HOST_WIDEST_INT) (mmix_intval (x) - 1));
      return;
      return;
 
 
    case 'p':
    case 'p':
      /* Store the number of registers we want to save.  This was setup
      /* Store the number of registers we want to save.  This was setup
         by the prologue.  The actual operand contains the number of
         by the prologue.  The actual operand contains the number of
         registers to pass, but we don't use it currently.  Anyway, we
         registers to pass, but we don't use it currently.  Anyway, we
         need to output the number of saved registers here.  */
         need to output the number of saved registers here.  */
      fprintf (stream, "%d",
      fprintf (stream, "%d",
               cfun->machine->highest_saved_stack_register + 1);
               cfun->machine->highest_saved_stack_register + 1);
      return;
      return;
 
 
    case 'r':
    case 'r':
      /* Store the register to output a constant to.  */
      /* Store the register to output a constant to.  */
      if (! REG_P (x))
      if (! REG_P (x))
        fatal_insn ("MMIX Internal: Expected a register, not this", x);
        fatal_insn ("MMIX Internal: Expected a register, not this", x);
      mmix_output_destination_register = MMIX_OUTPUT_REGNO (regno);
      mmix_output_destination_register = MMIX_OUTPUT_REGNO (regno);
      return;
      return;
 
 
    case 'I':
    case 'I':
      /* Output the constant.  Note that we use this for floats as well.  */
      /* Output the constant.  Note that we use this for floats as well.  */
      if (GET_CODE (x) != CONST_INT
      if (GET_CODE (x) != CONST_INT
          && (GET_CODE (x) != CONST_DOUBLE
          && (GET_CODE (x) != CONST_DOUBLE
              || (GET_MODE (x) != VOIDmode && GET_MODE (x) != DFmode
              || (GET_MODE (x) != VOIDmode && GET_MODE (x) != DFmode
                  && GET_MODE (x) != SFmode)))
                  && GET_MODE (x) != SFmode)))
        fatal_insn ("MMIX Internal: Expected a constant, not this", x);
        fatal_insn ("MMIX Internal: Expected a constant, not this", x);
      mmix_output_register_setting (stream,
      mmix_output_register_setting (stream,
                                    mmix_output_destination_register,
                                    mmix_output_destination_register,
                                    mmix_intval (x), 0);
                                    mmix_intval (x), 0);
      return;
      return;
 
 
    case 'U':
    case 'U':
      /* An U for unsigned, if TARGET_ZERO_EXTEND.  Ignore the operand.  */
      /* An U for unsigned, if TARGET_ZERO_EXTEND.  Ignore the operand.  */
      if (TARGET_ZERO_EXTEND)
      if (TARGET_ZERO_EXTEND)
        putc ('U', stream);
        putc ('U', stream);
      return;
      return;
 
 
    case 'v':
    case 'v':
      mmix_output_shifted_value (stream, (HOST_WIDEST_INT) mmix_intval (x));
      mmix_output_shifted_value (stream, (HOST_WIDEST_INT) mmix_intval (x));
      return;
      return;
 
 
    case 'V':
    case 'V':
      mmix_output_shifted_value (stream, (HOST_WIDEST_INT) ~mmix_intval (x));
      mmix_output_shifted_value (stream, (HOST_WIDEST_INT) ~mmix_intval (x));
      return;
      return;
 
 
    case 'W':
    case 'W':
      if (GET_CODE (x) != CONST_INT)
      if (GET_CODE (x) != CONST_INT)
        fatal_insn ("MMIX Internal: Expected a CONST_INT, not this", x);
        fatal_insn ("MMIX Internal: Expected a CONST_INT, not this", x);
      fprintf (stream, "#%x", (int) (INTVAL (x) & 0xffff));
      fprintf (stream, "#%x", (int) (INTVAL (x) & 0xffff));
      return;
      return;
 
 
    case 0:
    case 0:
      /* Nothing to do.  */
      /* Nothing to do.  */
      break;
      break;
 
 
    default:
    default:
      /* Presumably there's a missing case above if we get here.  */
      /* Presumably there's a missing case above if we get here.  */
      internal_error ("MMIX Internal: Missing %qc case in mmix_print_operand", code);
      internal_error ("MMIX Internal: Missing %qc case in mmix_print_operand", code);
    }
    }
 
 
  switch (GET_CODE (modified_x))
  switch (GET_CODE (modified_x))
    {
    {
    case REG:
    case REG:
      regno = REGNO (modified_x);
      regno = REGNO (modified_x);
      if (regno >= FIRST_PSEUDO_REGISTER)
      if (regno >= FIRST_PSEUDO_REGISTER)
        internal_error ("MMIX Internal: Bad register: %d", regno);
        internal_error ("MMIX Internal: Bad register: %d", regno);
      fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno)]);
      fprintf (stream, "%s", reg_names[MMIX_OUTPUT_REGNO (regno)]);
      return;
      return;
 
 
    case MEM:
    case MEM:
      output_address (XEXP (modified_x, 0));
      output_address (XEXP (modified_x, 0));
      return;
      return;
 
 
    case CONST_INT:
    case CONST_INT:
      /* For -2147483648, mmixal complains that the constant does not fit
      /* For -2147483648, mmixal complains that the constant does not fit
         in 4 bytes, so let's output it as hex.  Take care to handle hosts
         in 4 bytes, so let's output it as hex.  Take care to handle hosts
         where HOST_WIDE_INT is longer than an int.
         where HOST_WIDE_INT is longer than an int.
 
 
         Print small constants +-255 using decimal.  */
         Print small constants +-255 using decimal.  */
 
 
      if (INTVAL (modified_x) > -256 && INTVAL (modified_x) < 256)
      if (INTVAL (modified_x) > -256 && INTVAL (modified_x) < 256)
        fprintf (stream, "%d", (int) (INTVAL (modified_x)));
        fprintf (stream, "%d", (int) (INTVAL (modified_x)));
      else
      else
        fprintf (stream, "#%x",
        fprintf (stream, "#%x",
                 (int) (INTVAL (modified_x)) & (unsigned int) ~0);
                 (int) (INTVAL (modified_x)) & (unsigned int) ~0);
      return;
      return;
 
 
    case CONST_DOUBLE:
    case CONST_DOUBLE:
      /* Do somewhat as CONST_INT.  */
      /* Do somewhat as CONST_INT.  */
      mmix_output_octa (stream, mmix_intval (modified_x), 0);
      mmix_output_octa (stream, mmix_intval (modified_x), 0);
      return;
      return;
 
 
    case CONST:
    case CONST:
      output_addr_const (stream, modified_x);
      output_addr_const (stream, modified_x);
      return;
      return;
 
 
    default:
    default:
      /* No need to test for all strange things.  Let output_addr_const do
      /* No need to test for all strange things.  Let output_addr_const do
         it for us.  */
         it for us.  */
      if (CONSTANT_P (modified_x)
      if (CONSTANT_P (modified_x)
          /* Strangely enough, this is not included in CONSTANT_P.
          /* Strangely enough, this is not included in CONSTANT_P.
             FIXME: Ask/check about sanity here.  */
             FIXME: Ask/check about sanity here.  */
          || GET_CODE (modified_x) == CODE_LABEL)
          || GET_CODE (modified_x) == CODE_LABEL)
        {
        {
          output_addr_const (stream, modified_x);
          output_addr_const (stream, modified_x);
          return;
          return;
        }
        }
 
 
      /* We need the original here.  */
      /* We need the original here.  */
      fatal_insn ("MMIX Internal: Cannot decode this operand", x);
      fatal_insn ("MMIX Internal: Cannot decode this operand", x);
    }
    }
}
}
 
 
/* PRINT_OPERAND_PUNCT_VALID_P.  */
/* PRINT_OPERAND_PUNCT_VALID_P.  */
 
 
int
int
mmix_print_operand_punct_valid_p (int code ATTRIBUTE_UNUSED)
mmix_print_operand_punct_valid_p (int code ATTRIBUTE_UNUSED)
{
{
  /* A '+' is used for branch prediction, similar to other ports.  */
  /* A '+' is used for branch prediction, similar to other ports.  */
  return code == '+'
  return code == '+'
    /* A '.' is used for the %d in the POP %d,0 return insn.  */
    /* A '.' is used for the %d in the POP %d,0 return insn.  */
    || code == '.';
    || code == '.';
}
}
 
 
/* PRINT_OPERAND_ADDRESS.  */
/* PRINT_OPERAND_ADDRESS.  */
 
 
void
void
mmix_print_operand_address (FILE *stream, rtx x)
mmix_print_operand_address (FILE *stream, rtx x)
{
{
  if (REG_P (x))
  if (REG_P (x))
    {
    {
      /* I find the generated assembly code harder to read without
      /* I find the generated assembly code harder to read without
         the ",0".  */
         the ",0".  */
      fprintf (stream, "%s,0", reg_names[MMIX_OUTPUT_REGNO (REGNO (x))]);
      fprintf (stream, "%s,0", reg_names[MMIX_OUTPUT_REGNO (REGNO (x))]);
      return;
      return;
    }
    }
  else if (GET_CODE (x) == PLUS)
  else if (GET_CODE (x) == PLUS)
    {
    {
      rtx x1 = XEXP (x, 0);
      rtx x1 = XEXP (x, 0);
      rtx x2 = XEXP (x, 1);
      rtx x2 = XEXP (x, 1);
 
 
      if (REG_P (x1))
      if (REG_P (x1))
        {
        {
          fprintf (stream, "%s,", reg_names[MMIX_OUTPUT_REGNO (REGNO (x1))]);
          fprintf (stream, "%s,", reg_names[MMIX_OUTPUT_REGNO (REGNO (x1))]);
 
 
          if (REG_P (x2))
          if (REG_P (x2))
            {
            {
              fprintf (stream, "%s",
              fprintf (stream, "%s",
                       reg_names[MMIX_OUTPUT_REGNO (REGNO (x2))]);
                       reg_names[MMIX_OUTPUT_REGNO (REGNO (x2))]);
              return;
              return;
            }
            }
          else if (GET_CODE (x2) == CONST_INT
          else if (GET_CODE (x2) == CONST_INT
                   && CONST_OK_FOR_LETTER_P (INTVAL (x2), 'I'))
                   && CONST_OK_FOR_LETTER_P (INTVAL (x2), 'I'))
            {
            {
              output_addr_const (stream, x2);
              output_addr_const (stream, x2);
              return;
              return;
            }
            }
        }
        }
    }
    }
 
 
  if (TARGET_BASE_ADDRESSES && mmix_legitimate_constant_p (x))
  if (TARGET_BASE_ADDRESSES && mmix_legitimate_constant_p (x))
    {
    {
      output_addr_const (stream, x);
      output_addr_const (stream, x);
      return;
      return;
    }
    }
 
 
  fatal_insn ("MMIX Internal: This is not a recognized address", x);
  fatal_insn ("MMIX Internal: This is not a recognized address", x);
}
}
 
 
/* ASM_OUTPUT_REG_PUSH.  */
/* ASM_OUTPUT_REG_PUSH.  */
 
 
void
void
mmix_asm_output_reg_push (FILE *stream, int regno)
mmix_asm_output_reg_push (FILE *stream, int regno)
{
{
  fprintf (stream, "\tSUBU %s,%s,8\n\tSTOU %s,%s,0\n",
  fprintf (stream, "\tSUBU %s,%s,8\n\tSTOU %s,%s,0\n",
           reg_names[MMIX_STACK_POINTER_REGNUM],
           reg_names[MMIX_STACK_POINTER_REGNUM],
           reg_names[MMIX_STACK_POINTER_REGNUM],
           reg_names[MMIX_STACK_POINTER_REGNUM],
           reg_names[MMIX_OUTPUT_REGNO (regno)],
           reg_names[MMIX_OUTPUT_REGNO (regno)],
           reg_names[MMIX_STACK_POINTER_REGNUM]);
           reg_names[MMIX_STACK_POINTER_REGNUM]);
}
}
 
 
/* ASM_OUTPUT_REG_POP.  */
/* ASM_OUTPUT_REG_POP.  */
 
 
void
void
mmix_asm_output_reg_pop (FILE *stream, int regno)
mmix_asm_output_reg_pop (FILE *stream, int regno)
{
{
  fprintf (stream, "\tLDOU %s,%s,0\n\tINCL %s,8\n",
  fprintf (stream, "\tLDOU %s,%s,0\n\tINCL %s,8\n",
           reg_names[MMIX_OUTPUT_REGNO (regno)],
           reg_names[MMIX_OUTPUT_REGNO (regno)],
           reg_names[MMIX_STACK_POINTER_REGNUM],
           reg_names[MMIX_STACK_POINTER_REGNUM],
           reg_names[MMIX_STACK_POINTER_REGNUM]);
           reg_names[MMIX_STACK_POINTER_REGNUM]);
}
}
 
 
/* ASM_OUTPUT_ADDR_DIFF_ELT.  */
/* ASM_OUTPUT_ADDR_DIFF_ELT.  */
 
 
void
void
mmix_asm_output_addr_diff_elt (FILE *stream,
mmix_asm_output_addr_diff_elt (FILE *stream,
                               rtx body ATTRIBUTE_UNUSED,
                               rtx body ATTRIBUTE_UNUSED,
                               int value,
                               int value,
                               int rel)
                               int rel)
{
{
  fprintf (stream, "\tTETRA L%d-L%d\n", value, rel);
  fprintf (stream, "\tTETRA L%d-L%d\n", value, rel);
}
}
 
 
/* ASM_OUTPUT_ADDR_VEC_ELT.  */
/* ASM_OUTPUT_ADDR_VEC_ELT.  */
 
 
void
void
mmix_asm_output_addr_vec_elt (FILE *stream, int value)
mmix_asm_output_addr_vec_elt (FILE *stream, int value)
{
{
  fprintf (stream, "\tOCTA L:%d\n", value);
  fprintf (stream, "\tOCTA L:%d\n", value);
}
}
 
 
/* ASM_OUTPUT_SKIP.  */
/* ASM_OUTPUT_SKIP.  */
 
 
void
void
mmix_asm_output_skip (FILE *stream, int nbytes)
mmix_asm_output_skip (FILE *stream, int nbytes)
{
{
  fprintf (stream, "\tLOC @+%d\n", nbytes);
  fprintf (stream, "\tLOC @+%d\n", nbytes);
}
}
 
 
/* ASM_OUTPUT_ALIGN.  */
/* ASM_OUTPUT_ALIGN.  */
 
 
void
void
mmix_asm_output_align (FILE *stream, int power)
mmix_asm_output_align (FILE *stream, int power)
{
{
  /* We need to record the needed alignment of this section in the object,
  /* We need to record the needed alignment of this section in the object,
     so we have to output an alignment directive.  Use a .p2align (not
     so we have to output an alignment directive.  Use a .p2align (not
     .align) so people will never have to wonder about whether the
     .align) so people will never have to wonder about whether the
     argument is in number of bytes or the log2 thereof.  We do it in
     argument is in number of bytes or the log2 thereof.  We do it in
     addition to the LOC directive, so nothing needs tweaking when
     addition to the LOC directive, so nothing needs tweaking when
     copy-pasting assembly into mmixal.  */
     copy-pasting assembly into mmixal.  */
 fprintf (stream, "\t.p2align %d\n", power);
 fprintf (stream, "\t.p2align %d\n", power);
 fprintf (stream, "\tLOC @+(%d-@)&%d\n", 1 << power, (1 << power) - 1);
 fprintf (stream, "\tLOC @+(%d-@)&%d\n", 1 << power, (1 << power) - 1);
}
}
 
 
/* DBX_REGISTER_NUMBER.  */
/* DBX_REGISTER_NUMBER.  */
 
 
int
int
mmix_dbx_register_number (int regno)
mmix_dbx_register_number (int regno)
{
{
  /* Adjust the register number to the one it will be output as, dammit.
  /* Adjust the register number to the one it will be output as, dammit.
     It'd be nice if we could check the assumption that we're filling a
     It'd be nice if we could check the assumption that we're filling a
     gap, but every register between the last saved register and parameter
     gap, but every register between the last saved register and parameter
     registers might be a valid parameter register.  */
     registers might be a valid parameter register.  */
  regno = MMIX_OUTPUT_REGNO (regno);
  regno = MMIX_OUTPUT_REGNO (regno);
 
 
  /* We need to renumber registers to get the number of the return address
  /* We need to renumber registers to get the number of the return address
     register in the range 0..255.  It is also space-saving if registers
     register in the range 0..255.  It is also space-saving if registers
     mentioned in the call-frame information (which uses this function by
     mentioned in the call-frame information (which uses this function by
     defaulting DWARF_FRAME_REGNUM to DBX_REGISTER_NUMBER) are numbered
     defaulting DWARF_FRAME_REGNUM to DBX_REGISTER_NUMBER) are numbered
     0 .. 63.  So map 224 .. 256+15 -> 0 .. 47 and 0 .. 223 -> 48..223+48.  */
     0 .. 63.  So map 224 .. 256+15 -> 0 .. 47 and 0 .. 223 -> 48..223+48.  */
  return regno >= 224 ? (regno - 224) : (regno + 48);
  return regno >= 224 ? (regno - 224) : (regno + 48);
}
}
 
 
/* End of target macro support functions.
/* End of target macro support functions.
 
 
   Now the MMIX port's own functions.  First the exported ones.  */
   Now the MMIX port's own functions.  First the exported ones.  */
 
 
/* Wrapper for get_hard_reg_initial_val since integrate.h isn't included
/* Wrapper for get_hard_reg_initial_val since integrate.h isn't included
   from insn-emit.c.  */
   from insn-emit.c.  */
 
 
rtx
rtx
mmix_get_hard_reg_initial_val (enum machine_mode mode, int regno)
mmix_get_hard_reg_initial_val (enum machine_mode mode, int regno)
{
{
  return get_hard_reg_initial_val (mode, regno);
  return get_hard_reg_initial_val (mode, regno);
}
}
 
 
/* Nonzero when the function epilogue is simple enough that a single
/* Nonzero when the function epilogue is simple enough that a single
   "POP %d,0" should be used even within the function.  */
   "POP %d,0" should be used even within the function.  */
 
 
int
int
mmix_use_simple_return (void)
mmix_use_simple_return (void)
{
{
  int regno;
  int regno;
 
 
  int stack_space_to_allocate
  int stack_space_to_allocate
    = (current_function_outgoing_args_size
    = (current_function_outgoing_args_size
       + current_function_pretend_args_size
       + current_function_pretend_args_size
       + get_frame_size () + 7) & ~7;
       + get_frame_size () + 7) & ~7;
 
 
  if (!TARGET_USE_RETURN_INSN || !reload_completed)
  if (!TARGET_USE_RETURN_INSN || !reload_completed)
    return 0;
    return 0;
 
 
  for (regno = 255;
  for (regno = 255;
       regno >= MMIX_FIRST_GLOBAL_REGNUM;
       regno >= MMIX_FIRST_GLOBAL_REGNUM;
       regno--)
       regno--)
    /* Note that we assume that the frame-pointer-register is one of these
    /* Note that we assume that the frame-pointer-register is one of these
       registers, in which case we don't count it here.  */
       registers, in which case we don't count it here.  */
    if ((((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
    if ((((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
          && regs_ever_live[regno] && !call_used_regs[regno]))
          && regs_ever_live[regno] && !call_used_regs[regno]))
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
      return 0;
      return 0;
 
 
  if (frame_pointer_needed)
  if (frame_pointer_needed)
    stack_space_to_allocate += 8;
    stack_space_to_allocate += 8;
 
 
  if (MMIX_CFUN_HAS_LANDING_PAD)
  if (MMIX_CFUN_HAS_LANDING_PAD)
    stack_space_to_allocate += 16;
    stack_space_to_allocate += 16;
  else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
  else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
    stack_space_to_allocate += 8;
    stack_space_to_allocate += 8;
 
 
  return stack_space_to_allocate == 0;
  return stack_space_to_allocate == 0;
}
}
 
 
 
 
/* Expands the function prologue into RTX.  */
/* Expands the function prologue into RTX.  */
 
 
void
void
mmix_expand_prologue (void)
mmix_expand_prologue (void)
{
{
  HOST_WIDE_INT locals_size = get_frame_size ();
  HOST_WIDE_INT locals_size = get_frame_size ();
  int regno;
  int regno;
  HOST_WIDE_INT stack_space_to_allocate
  HOST_WIDE_INT stack_space_to_allocate
    = (current_function_outgoing_args_size
    = (current_function_outgoing_args_size
       + current_function_pretend_args_size
       + current_function_pretend_args_size
       + locals_size + 7) & ~7;
       + locals_size + 7) & ~7;
  HOST_WIDE_INT offset = -8;
  HOST_WIDE_INT offset = -8;
 
 
  /* Add room needed to save global non-register-stack registers.  */
  /* Add room needed to save global non-register-stack registers.  */
  for (regno = 255;
  for (regno = 255;
       regno >= MMIX_FIRST_GLOBAL_REGNUM;
       regno >= MMIX_FIRST_GLOBAL_REGNUM;
       regno--)
       regno--)
    /* Note that we assume that the frame-pointer-register is one of these
    /* Note that we assume that the frame-pointer-register is one of these
       registers, in which case we don't count it here.  */
       registers, in which case we don't count it here.  */
    if ((((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
    if ((((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
          && regs_ever_live[regno] && !call_used_regs[regno]))
          && regs_ever_live[regno] && !call_used_regs[regno]))
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
      stack_space_to_allocate += 8;
      stack_space_to_allocate += 8;
 
 
  /* If we do have a frame-pointer, add room for it.  */
  /* If we do have a frame-pointer, add room for it.  */
  if (frame_pointer_needed)
  if (frame_pointer_needed)
    stack_space_to_allocate += 8;
    stack_space_to_allocate += 8;
 
 
  /* If we have a non-local label, we need to be able to unwind to it, so
  /* If we have a non-local label, we need to be able to unwind to it, so
     store the current register stack pointer.  Also store the return
     store the current register stack pointer.  Also store the return
     address if we do that.  */
     address if we do that.  */
  if (MMIX_CFUN_HAS_LANDING_PAD)
  if (MMIX_CFUN_HAS_LANDING_PAD)
    stack_space_to_allocate += 16;
    stack_space_to_allocate += 16;
  else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
  else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
    /* If we do have a saved return-address slot, add room for it.  */
    /* If we do have a saved return-address slot, add room for it.  */
    stack_space_to_allocate += 8;
    stack_space_to_allocate += 8;
 
 
  /* Make sure we don't get an unaligned stack.  */
  /* Make sure we don't get an unaligned stack.  */
  if ((stack_space_to_allocate % 8) != 0)
  if ((stack_space_to_allocate % 8) != 0)
    internal_error ("stack frame not a multiple of 8 bytes: %wd",
    internal_error ("stack frame not a multiple of 8 bytes: %wd",
                    stack_space_to_allocate);
                    stack_space_to_allocate);
 
 
  if (current_function_pretend_args_size)
  if (current_function_pretend_args_size)
    {
    {
      int mmix_first_vararg_reg
      int mmix_first_vararg_reg
        = (MMIX_FIRST_INCOMING_ARG_REGNUM
        = (MMIX_FIRST_INCOMING_ARG_REGNUM
           + (MMIX_MAX_ARGS_IN_REGS
           + (MMIX_MAX_ARGS_IN_REGS
              - current_function_pretend_args_size / 8));
              - current_function_pretend_args_size / 8));
 
 
      for (regno
      for (regno
             = MMIX_FIRST_INCOMING_ARG_REGNUM + MMIX_MAX_ARGS_IN_REGS - 1;
             = MMIX_FIRST_INCOMING_ARG_REGNUM + MMIX_MAX_ARGS_IN_REGS - 1;
           regno >= mmix_first_vararg_reg;
           regno >= mmix_first_vararg_reg;
           regno--)
           regno--)
        {
        {
          if (offset < 0)
          if (offset < 0)
            {
            {
              HOST_WIDE_INT stack_chunk
              HOST_WIDE_INT stack_chunk
                = stack_space_to_allocate > (256 - 8)
                = stack_space_to_allocate > (256 - 8)
                ? (256 - 8) : stack_space_to_allocate;
                ? (256 - 8) : stack_space_to_allocate;
 
 
              mmix_emit_sp_add (-stack_chunk);
              mmix_emit_sp_add (-stack_chunk);
              offset += stack_chunk;
              offset += stack_chunk;
              stack_space_to_allocate -= stack_chunk;
              stack_space_to_allocate -= stack_chunk;
            }
            }
 
 
          /* These registers aren't actually saved (as in "will be
          /* These registers aren't actually saved (as in "will be
             restored"), so don't tell DWARF2 they're saved.  */
             restored"), so don't tell DWARF2 they're saved.  */
          emit_move_insn (gen_rtx_MEM (DImode,
          emit_move_insn (gen_rtx_MEM (DImode,
                                       plus_constant (stack_pointer_rtx,
                                       plus_constant (stack_pointer_rtx,
                                                      offset)),
                                                      offset)),
                          gen_rtx_REG (DImode, regno));
                          gen_rtx_REG (DImode, regno));
          offset -= 8;
          offset -= 8;
        }
        }
    }
    }
 
 
  /* Store the frame-pointer.  */
  /* Store the frame-pointer.  */
 
 
  if (frame_pointer_needed)
  if (frame_pointer_needed)
    {
    {
      rtx insn;
      rtx insn;
 
 
      if (offset < 0)
      if (offset < 0)
        {
        {
          /* Get 8 less than otherwise, since we need to reach offset + 8.  */
          /* Get 8 less than otherwise, since we need to reach offset + 8.  */
          HOST_WIDE_INT stack_chunk
          HOST_WIDE_INT stack_chunk
            = stack_space_to_allocate > (256 - 8 - 8)
            = stack_space_to_allocate > (256 - 8 - 8)
            ? (256 - 8 - 8) : stack_space_to_allocate;
            ? (256 - 8 - 8) : stack_space_to_allocate;
 
 
          mmix_emit_sp_add (-stack_chunk);
          mmix_emit_sp_add (-stack_chunk);
 
 
          offset += stack_chunk;
          offset += stack_chunk;
          stack_space_to_allocate -= stack_chunk;
          stack_space_to_allocate -= stack_chunk;
        }
        }
 
 
      insn = emit_move_insn (gen_rtx_MEM (DImode,
      insn = emit_move_insn (gen_rtx_MEM (DImode,
                                          plus_constant (stack_pointer_rtx,
                                          plus_constant (stack_pointer_rtx,
                                                         offset)),
                                                         offset)),
                             hard_frame_pointer_rtx);
                             hard_frame_pointer_rtx);
      RTX_FRAME_RELATED_P (insn) = 1;
      RTX_FRAME_RELATED_P (insn) = 1;
      insn = emit_insn (gen_adddi3 (hard_frame_pointer_rtx,
      insn = emit_insn (gen_adddi3 (hard_frame_pointer_rtx,
                                    stack_pointer_rtx,
                                    stack_pointer_rtx,
                                    GEN_INT (offset + 8)));
                                    GEN_INT (offset + 8)));
      RTX_FRAME_RELATED_P (insn) = 1;
      RTX_FRAME_RELATED_P (insn) = 1;
      offset -= 8;
      offset -= 8;
    }
    }
 
 
  if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
  if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
    {
    {
      rtx tmpreg, retreg;
      rtx tmpreg, retreg;
      rtx insn;
      rtx insn;
 
 
      /* Store the return-address, if one is needed on the stack.  We
      /* Store the return-address, if one is needed on the stack.  We
         usually store it in a register when needed, but that doesn't work
         usually store it in a register when needed, but that doesn't work
         with -fexceptions.  */
         with -fexceptions.  */
 
 
      if (offset < 0)
      if (offset < 0)
        {
        {
          /* Get 8 less than otherwise, since we need to reach offset + 8.  */
          /* Get 8 less than otherwise, since we need to reach offset + 8.  */
          HOST_WIDE_INT stack_chunk
          HOST_WIDE_INT stack_chunk
            = stack_space_to_allocate > (256 - 8 - 8)
            = stack_space_to_allocate > (256 - 8 - 8)
            ? (256 - 8 - 8) : stack_space_to_allocate;
            ? (256 - 8 - 8) : stack_space_to_allocate;
 
 
          mmix_emit_sp_add (-stack_chunk);
          mmix_emit_sp_add (-stack_chunk);
 
 
          offset += stack_chunk;
          offset += stack_chunk;
          stack_space_to_allocate -= stack_chunk;
          stack_space_to_allocate -= stack_chunk;
        }
        }
 
 
      tmpreg = gen_rtx_REG (DImode, 255);
      tmpreg = gen_rtx_REG (DImode, 255);
      retreg = gen_rtx_REG (DImode, MMIX_rJ_REGNUM);
      retreg = gen_rtx_REG (DImode, MMIX_rJ_REGNUM);
 
 
      /* Dwarf2 code is confused by the use of a temporary register for
      /* Dwarf2 code is confused by the use of a temporary register for
         storing the return address, so we have to express it as a note,
         storing the return address, so we have to express it as a note,
         which we attach to the actual store insn.  */
         which we attach to the actual store insn.  */
      emit_move_insn (tmpreg, retreg);
      emit_move_insn (tmpreg, retreg);
 
 
      insn = emit_move_insn (gen_rtx_MEM (DImode,
      insn = emit_move_insn (gen_rtx_MEM (DImode,
                                          plus_constant (stack_pointer_rtx,
                                          plus_constant (stack_pointer_rtx,
                                                         offset)),
                                                         offset)),
                             tmpreg);
                             tmpreg);
      RTX_FRAME_RELATED_P (insn) = 1;
      RTX_FRAME_RELATED_P (insn) = 1;
      REG_NOTES (insn)
      REG_NOTES (insn)
        = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
        = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
                             gen_rtx_SET (VOIDmode,
                             gen_rtx_SET (VOIDmode,
                                          gen_rtx_MEM (DImode,
                                          gen_rtx_MEM (DImode,
                                                       plus_constant (stack_pointer_rtx,
                                                       plus_constant (stack_pointer_rtx,
                                                                      offset)),
                                                                      offset)),
                                          retreg),
                                          retreg),
                             REG_NOTES (insn));
                             REG_NOTES (insn));
 
 
      offset -= 8;
      offset -= 8;
    }
    }
  else if (MMIX_CFUN_HAS_LANDING_PAD)
  else if (MMIX_CFUN_HAS_LANDING_PAD)
    offset -= 8;
    offset -= 8;
 
 
  if (MMIX_CFUN_HAS_LANDING_PAD)
  if (MMIX_CFUN_HAS_LANDING_PAD)
    {
    {
      /* Store the register defining the numbering of local registers, so
      /* Store the register defining the numbering of local registers, so
         we know how long to unwind the register stack.  */
         we know how long to unwind the register stack.  */
 
 
      if (offset < 0)
      if (offset < 0)
        {
        {
          /* Get 8 less than otherwise, since we need to reach offset + 8.  */
          /* Get 8 less than otherwise, since we need to reach offset + 8.  */
          HOST_WIDE_INT stack_chunk
          HOST_WIDE_INT stack_chunk
            = stack_space_to_allocate > (256 - 8 - 8)
            = stack_space_to_allocate > (256 - 8 - 8)
            ? (256 - 8 - 8) : stack_space_to_allocate;
            ? (256 - 8 - 8) : stack_space_to_allocate;
 
 
          mmix_emit_sp_add (-stack_chunk);
          mmix_emit_sp_add (-stack_chunk);
 
 
          offset += stack_chunk;
          offset += stack_chunk;
          stack_space_to_allocate -= stack_chunk;
          stack_space_to_allocate -= stack_chunk;
        }
        }
 
 
      /* We don't tell dwarf2 about this one; we just have it to unwind
      /* We don't tell dwarf2 about this one; we just have it to unwind
         the register stack at landing pads.  FIXME: It's a kludge because
         the register stack at landing pads.  FIXME: It's a kludge because
         we can't describe the effect of the PUSHJ and PUSHGO insns on the
         we can't describe the effect of the PUSHJ and PUSHGO insns on the
         register stack at the moment.  Best thing would be to handle it
         register stack at the moment.  Best thing would be to handle it
         like stack-pointer offsets.  Better: some hook into dwarf2out.c
         like stack-pointer offsets.  Better: some hook into dwarf2out.c
         to produce DW_CFA_expression:s that specify the increment of rO,
         to produce DW_CFA_expression:s that specify the increment of rO,
         and unwind it at eh_return (preferred) or at the landing pad.
         and unwind it at eh_return (preferred) or at the landing pad.
         Then saves to $0..$G-1 could be specified through that register.  */
         Then saves to $0..$G-1 could be specified through that register.  */
 
 
      emit_move_insn (gen_rtx_REG (DImode, 255),
      emit_move_insn (gen_rtx_REG (DImode, 255),
                      gen_rtx_REG (DImode,
                      gen_rtx_REG (DImode,
                                   MMIX_rO_REGNUM));
                                   MMIX_rO_REGNUM));
      emit_move_insn (gen_rtx_MEM (DImode,
      emit_move_insn (gen_rtx_MEM (DImode,
                                   plus_constant (stack_pointer_rtx, offset)),
                                   plus_constant (stack_pointer_rtx, offset)),
                      gen_rtx_REG (DImode, 255));
                      gen_rtx_REG (DImode, 255));
      offset -= 8;
      offset -= 8;
    }
    }
 
 
  /* After the return-address and the frame-pointer, we have the local
  /* After the return-address and the frame-pointer, we have the local
     variables.  They're the ones that may have an "unaligned" size.  */
     variables.  They're the ones that may have an "unaligned" size.  */
  offset -= (locals_size + 7) & ~7;
  offset -= (locals_size + 7) & ~7;
 
 
  /* Now store all registers that are global, i.e. not saved by the
  /* Now store all registers that are global, i.e. not saved by the
     register file machinery.
     register file machinery.
 
 
     It is assumed that the frame-pointer is one of these registers, so it
     It is assumed that the frame-pointer is one of these registers, so it
     is explicitly excluded in the count.  */
     is explicitly excluded in the count.  */
 
 
  for (regno = 255;
  for (regno = 255;
       regno >= MMIX_FIRST_GLOBAL_REGNUM;
       regno >= MMIX_FIRST_GLOBAL_REGNUM;
       regno--)
       regno--)
    if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
    if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
         && regs_ever_live[regno] && ! call_used_regs[regno])
         && regs_ever_live[regno] && ! call_used_regs[regno])
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
      {
      {
        rtx insn;
        rtx insn;
 
 
        if (offset < 0)
        if (offset < 0)
          {
          {
            HOST_WIDE_INT stack_chunk
            HOST_WIDE_INT stack_chunk
              = (stack_space_to_allocate > (256 - offset - 8)
              = (stack_space_to_allocate > (256 - offset - 8)
                 ? (256 - offset - 8) : stack_space_to_allocate);
                 ? (256 - offset - 8) : stack_space_to_allocate);
 
 
            mmix_emit_sp_add (-stack_chunk);
            mmix_emit_sp_add (-stack_chunk);
            offset += stack_chunk;
            offset += stack_chunk;
            stack_space_to_allocate -= stack_chunk;
            stack_space_to_allocate -= stack_chunk;
          }
          }
 
 
        insn = emit_move_insn (gen_rtx_MEM (DImode,
        insn = emit_move_insn (gen_rtx_MEM (DImode,
                                            plus_constant (stack_pointer_rtx,
                                            plus_constant (stack_pointer_rtx,
                                                           offset)),
                                                           offset)),
                               gen_rtx_REG (DImode, regno));
                               gen_rtx_REG (DImode, regno));
        RTX_FRAME_RELATED_P (insn) = 1;
        RTX_FRAME_RELATED_P (insn) = 1;
        offset -= 8;
        offset -= 8;
      }
      }
 
 
  /* Finally, allocate room for outgoing args and local vars if room
  /* Finally, allocate room for outgoing args and local vars if room
     wasn't allocated above.  */
     wasn't allocated above.  */
  if (stack_space_to_allocate)
  if (stack_space_to_allocate)
    mmix_emit_sp_add (-stack_space_to_allocate);
    mmix_emit_sp_add (-stack_space_to_allocate);
}
}
 
 
/* Expands the function epilogue into RTX.  */
/* Expands the function epilogue into RTX.  */
 
 
void
void
mmix_expand_epilogue (void)
mmix_expand_epilogue (void)
{
{
  HOST_WIDE_INT locals_size = get_frame_size ();
  HOST_WIDE_INT locals_size = get_frame_size ();
  int regno;
  int regno;
  HOST_WIDE_INT stack_space_to_deallocate
  HOST_WIDE_INT stack_space_to_deallocate
    = (current_function_outgoing_args_size
    = (current_function_outgoing_args_size
       + current_function_pretend_args_size
       + current_function_pretend_args_size
       + locals_size + 7) & ~7;
       + locals_size + 7) & ~7;
 
 
  /* The first address to access is beyond the outgoing_args area.  */
  /* The first address to access is beyond the outgoing_args area.  */
  HOST_WIDE_INT offset = current_function_outgoing_args_size;
  HOST_WIDE_INT offset = current_function_outgoing_args_size;
 
 
  /* Add the space for global non-register-stack registers.
  /* Add the space for global non-register-stack registers.
     It is assumed that the frame-pointer register can be one of these
     It is assumed that the frame-pointer register can be one of these
     registers, in which case it is excluded from the count when needed.  */
     registers, in which case it is excluded from the count when needed.  */
  for (regno = 255;
  for (regno = 255;
       regno >= MMIX_FIRST_GLOBAL_REGNUM;
       regno >= MMIX_FIRST_GLOBAL_REGNUM;
       regno--)
       regno--)
    if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
    if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
         && regs_ever_live[regno] && !call_used_regs[regno])
         && regs_ever_live[regno] && !call_used_regs[regno])
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
      stack_space_to_deallocate += 8;
      stack_space_to_deallocate += 8;
 
 
  /* Add in the space for register stack-pointer.  If so, always add room
  /* Add in the space for register stack-pointer.  If so, always add room
     for the saved PC.  */
     for the saved PC.  */
  if (MMIX_CFUN_HAS_LANDING_PAD)
  if (MMIX_CFUN_HAS_LANDING_PAD)
    stack_space_to_deallocate += 16;
    stack_space_to_deallocate += 16;
  else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
  else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
    /* If we have a saved return-address slot, add it in.  */
    /* If we have a saved return-address slot, add it in.  */
    stack_space_to_deallocate += 8;
    stack_space_to_deallocate += 8;
 
 
  /* Add in the frame-pointer.  */
  /* Add in the frame-pointer.  */
  if (frame_pointer_needed)
  if (frame_pointer_needed)
    stack_space_to_deallocate += 8;
    stack_space_to_deallocate += 8;
 
 
  /* Make sure we don't get an unaligned stack.  */
  /* Make sure we don't get an unaligned stack.  */
  if ((stack_space_to_deallocate % 8) != 0)
  if ((stack_space_to_deallocate % 8) != 0)
    internal_error ("stack frame not a multiple of octabyte: %wd",
    internal_error ("stack frame not a multiple of octabyte: %wd",
                    stack_space_to_deallocate);
                    stack_space_to_deallocate);
 
 
  /* We will add back small offsets to the stack pointer as we go.
  /* We will add back small offsets to the stack pointer as we go.
     First, we restore all registers that are global, i.e. not saved by
     First, we restore all registers that are global, i.e. not saved by
     the register file machinery.  */
     the register file machinery.  */
 
 
  for (regno = MMIX_FIRST_GLOBAL_REGNUM;
  for (regno = MMIX_FIRST_GLOBAL_REGNUM;
       regno <= 255;
       regno <= 255;
       regno++)
       regno++)
    if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
    if (((regno != MMIX_FRAME_POINTER_REGNUM || !frame_pointer_needed)
         && regs_ever_live[regno] && !call_used_regs[regno])
         && regs_ever_live[regno] && !call_used_regs[regno])
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
        || IS_MMIX_EH_RETURN_DATA_REG (regno))
      {
      {
        if (offset > 255)
        if (offset > 255)
          {
          {
            mmix_emit_sp_add (offset);
            mmix_emit_sp_add (offset);
            stack_space_to_deallocate -= offset;
            stack_space_to_deallocate -= offset;
            offset = 0;
            offset = 0;
          }
          }
 
 
        emit_move_insn (gen_rtx_REG (DImode, regno),
        emit_move_insn (gen_rtx_REG (DImode, regno),
                        gen_rtx_MEM (DImode,
                        gen_rtx_MEM (DImode,
                                     plus_constant (stack_pointer_rtx,
                                     plus_constant (stack_pointer_rtx,
                                                    offset)));
                                                    offset)));
        offset += 8;
        offset += 8;
      }
      }
 
 
  /* Here is where the local variables were.  As in the prologue, they
  /* Here is where the local variables were.  As in the prologue, they
     might be of an unaligned size.  */
     might be of an unaligned size.  */
  offset += (locals_size + 7) & ~7;
  offset += (locals_size + 7) & ~7;
 
 
  /* The saved register stack pointer is just below the frame-pointer
  /* The saved register stack pointer is just below the frame-pointer
     register.  We don't need to restore it "manually"; the POP
     register.  We don't need to restore it "manually"; the POP
     instruction does that.  */
     instruction does that.  */
  if (MMIX_CFUN_HAS_LANDING_PAD)
  if (MMIX_CFUN_HAS_LANDING_PAD)
    offset += 16;
    offset += 16;
  else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
  else if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS)
    /* The return-address slot is just below the frame-pointer register.
    /* The return-address slot is just below the frame-pointer register.
       We don't need to restore it because we don't really use it.  */
       We don't need to restore it because we don't really use it.  */
    offset += 8;
    offset += 8;
 
 
  /* Get back the old frame-pointer-value.  */
  /* Get back the old frame-pointer-value.  */
  if (frame_pointer_needed)
  if (frame_pointer_needed)
    {
    {
      if (offset > 255)
      if (offset > 255)
        {
        {
          mmix_emit_sp_add (offset);
          mmix_emit_sp_add (offset);
 
 
          stack_space_to_deallocate -= offset;
          stack_space_to_deallocate -= offset;
          offset = 0;
          offset = 0;
        }
        }
 
 
      emit_move_insn (hard_frame_pointer_rtx,
      emit_move_insn (hard_frame_pointer_rtx,
                      gen_rtx_MEM (DImode,
                      gen_rtx_MEM (DImode,
                                   plus_constant (stack_pointer_rtx,
                                   plus_constant (stack_pointer_rtx,
                                                  offset)));
                                                  offset)));
      offset += 8;
      offset += 8;
    }
    }
 
 
  /* We do not need to restore pretended incoming args, just add back
  /* We do not need to restore pretended incoming args, just add back
     offset to sp.  */
     offset to sp.  */
  if (stack_space_to_deallocate != 0)
  if (stack_space_to_deallocate != 0)
    mmix_emit_sp_add (stack_space_to_deallocate);
    mmix_emit_sp_add (stack_space_to_deallocate);
 
 
  if (current_function_calls_eh_return)
  if (current_function_calls_eh_return)
    /* Adjust the (normal) stack-pointer to that of the receiver.
    /* Adjust the (normal) stack-pointer to that of the receiver.
       FIXME: It would be nice if we could also adjust the register stack
       FIXME: It would be nice if we could also adjust the register stack
       here, but we need to express it through DWARF 2 too.  */
       here, but we need to express it through DWARF 2 too.  */
    emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
    emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
                           gen_rtx_REG (DImode,
                           gen_rtx_REG (DImode,
                                        MMIX_EH_RETURN_STACKADJ_REGNUM)));
                                        MMIX_EH_RETURN_STACKADJ_REGNUM)));
}
}
 
 
/* Output an optimal sequence for setting a register to a specific
/* Output an optimal sequence for setting a register to a specific
   constant.  Used in an alternative for const_ints in movdi, and when
   constant.  Used in an alternative for const_ints in movdi, and when
   using large stack-frame offsets.
   using large stack-frame offsets.
 
 
   Use do_begin_end to say if a line-starting TAB and newline before the
   Use do_begin_end to say if a line-starting TAB and newline before the
   first insn and after the last insn is wanted.  */
   first insn and after the last insn is wanted.  */
 
 
void
void
mmix_output_register_setting (FILE *stream,
mmix_output_register_setting (FILE *stream,
                              int regno,
                              int regno,
                              HOST_WIDEST_INT value,
                              HOST_WIDEST_INT value,
                              int do_begin_end)
                              int do_begin_end)
{
{
  if (do_begin_end)
  if (do_begin_end)
    fprintf (stream, "\t");
    fprintf (stream, "\t");
 
 
  if (mmix_shiftable_wyde_value ((unsigned HOST_WIDEST_INT) value))
  if (mmix_shiftable_wyde_value ((unsigned HOST_WIDEST_INT) value))
    {
    {
      /* First, the one-insn cases.  */
      /* First, the one-insn cases.  */
      mmix_output_shiftvalue_op_from_str (stream, "SET",
      mmix_output_shiftvalue_op_from_str (stream, "SET",
                                          (unsigned HOST_WIDEST_INT)
                                          (unsigned HOST_WIDEST_INT)
                                          value);
                                          value);
      fprintf (stream, " %s,", reg_names[regno]);
      fprintf (stream, " %s,", reg_names[regno]);
      mmix_output_shifted_value (stream, (unsigned HOST_WIDEST_INT) value);
      mmix_output_shifted_value (stream, (unsigned HOST_WIDEST_INT) value);
    }
    }
  else if (mmix_shiftable_wyde_value (-(unsigned HOST_WIDEST_INT) value))
  else if (mmix_shiftable_wyde_value (-(unsigned HOST_WIDEST_INT) value))
    {
    {
      /* We do this to get a bit more legible assembly code.  The next
      /* We do this to get a bit more legible assembly code.  The next
         alternative is mostly redundant with this.  */
         alternative is mostly redundant with this.  */
 
 
      mmix_output_shiftvalue_op_from_str (stream, "SET",
      mmix_output_shiftvalue_op_from_str (stream, "SET",
                                          -(unsigned HOST_WIDEST_INT)
                                          -(unsigned HOST_WIDEST_INT)
                                          value);
                                          value);
      fprintf (stream, " %s,", reg_names[regno]);
      fprintf (stream, " %s,", reg_names[regno]);
      mmix_output_shifted_value (stream, -(unsigned HOST_WIDEST_INT) value);
      mmix_output_shifted_value (stream, -(unsigned HOST_WIDEST_INT) value);
      fprintf (stream, "\n\tNEGU %s,0,%s", reg_names[regno],
      fprintf (stream, "\n\tNEGU %s,0,%s", reg_names[regno],
               reg_names[regno]);
               reg_names[regno]);
    }
    }
  else if (mmix_shiftable_wyde_value (~(unsigned HOST_WIDEST_INT) value))
  else if (mmix_shiftable_wyde_value (~(unsigned HOST_WIDEST_INT) value))
    {
    {
      /* Slightly more expensive, the two-insn cases.  */
      /* Slightly more expensive, the two-insn cases.  */
 
 
      /* FIXME: We could of course also test if 0..255-N or ~(N | 1..255)
      /* FIXME: We could of course also test if 0..255-N or ~(N | 1..255)
         is shiftable, or any other one-insn transformation of the value.
         is shiftable, or any other one-insn transformation of the value.
         FIXME: Check first if the value is "shiftable" by two loading
         FIXME: Check first if the value is "shiftable" by two loading
         with two insns, since it makes more readable assembly code (if
         with two insns, since it makes more readable assembly code (if
         anyone else cares).  */
         anyone else cares).  */
 
 
      mmix_output_shiftvalue_op_from_str (stream, "SET",
      mmix_output_shiftvalue_op_from_str (stream, "SET",
                                          ~(unsigned HOST_WIDEST_INT)
                                          ~(unsigned HOST_WIDEST_INT)
                                          value);
                                          value);
      fprintf (stream, " %s,", reg_names[regno]);
      fprintf (stream, " %s,", reg_names[regno]);
      mmix_output_shifted_value (stream, ~(unsigned HOST_WIDEST_INT) value);
      mmix_output_shifted_value (stream, ~(unsigned HOST_WIDEST_INT) value);
      fprintf (stream, "\n\tNOR %s,%s,0", reg_names[regno],
      fprintf (stream, "\n\tNOR %s,%s,0", reg_names[regno],
               reg_names[regno]);
               reg_names[regno]);
    }
    }
  else
  else
    {
    {
      /* The generic case.  2..4 insns.  */
      /* The generic case.  2..4 insns.  */
      static const char *const higher_parts[] = {"L", "ML", "MH", "H"};
      static const char *const higher_parts[] = {"L", "ML", "MH", "H"};
      const char *op = "SET";
      const char *op = "SET";
      const char *line_begin = "";
      const char *line_begin = "";
      int insns = 0;
      int insns = 0;
      int i;
      int i;
      HOST_WIDEST_INT tmpvalue = value;
      HOST_WIDEST_INT tmpvalue = value;
 
 
      /* Compute the number of insns needed to output this constant.  */
      /* Compute the number of insns needed to output this constant.  */
      for (i = 0; i < 4 && tmpvalue != 0; i++)
      for (i = 0; i < 4 && tmpvalue != 0; i++)
        {
        {
          if (tmpvalue & 65535)
          if (tmpvalue & 65535)
            insns++;
            insns++;
          tmpvalue >>= 16;
          tmpvalue >>= 16;
        }
        }
      if (TARGET_BASE_ADDRESSES && insns == 3)
      if (TARGET_BASE_ADDRESSES && insns == 3)
        {
        {
          /* The number three is based on a static observation on
          /* The number three is based on a static observation on
             ghostscript-6.52.  Two and four are excluded because there
             ghostscript-6.52.  Two and four are excluded because there
             are too many such constants, and each unique constant (maybe
             are too many such constants, and each unique constant (maybe
             offset by 1..255) were used few times compared to other uses,
             offset by 1..255) were used few times compared to other uses,
             e.g. addresses.
             e.g. addresses.
 
 
             We use base-plus-offset addressing to force it into a global
             We use base-plus-offset addressing to force it into a global
             register; we just use a "LDA reg,VALUE", which will cause the
             register; we just use a "LDA reg,VALUE", which will cause the
             assembler and linker to DTRT (for constants as well as
             assembler and linker to DTRT (for constants as well as
             addresses).  */
             addresses).  */
          fprintf (stream, "LDA %s,", reg_names[regno]);
          fprintf (stream, "LDA %s,", reg_names[regno]);
          mmix_output_octa (stream, value, 0);
          mmix_output_octa (stream, value, 0);
        }
        }
      else
      else
        {
        {
          /* Output pertinent parts of the 4-wyde sequence.
          /* Output pertinent parts of the 4-wyde sequence.
             Still more to do if we want this to be optimal, but hey...
             Still more to do if we want this to be optimal, but hey...
             Note that the zero case has been handled above.  */
             Note that the zero case has been handled above.  */
          for (i = 0; i < 4 && value != 0; i++)
          for (i = 0; i < 4 && value != 0; i++)
            {
            {
              if (value & 65535)
              if (value & 65535)
                {
                {
                  fprintf (stream, "%s%s%s %s,#%x", line_begin, op,
                  fprintf (stream, "%s%s%s %s,#%x", line_begin, op,
                           higher_parts[i], reg_names[regno],
                           higher_parts[i], reg_names[regno],
                           (int) (value & 65535));
                           (int) (value & 65535));
                  /* The first one sets the rest of the bits to 0, the next
                  /* The first one sets the rest of the bits to 0, the next
                     ones add set bits.  */
                     ones add set bits.  */
                  op = "INC";
                  op = "INC";
                  line_begin = "\n\t";
                  line_begin = "\n\t";
                }
                }
 
 
              value >>= 16;
              value >>= 16;
            }
            }
        }
        }
    }
    }
 
 
  if (do_begin_end)
  if (do_begin_end)
    fprintf (stream, "\n");
    fprintf (stream, "\n");
}
}
 
 
/* Return 1 if value is 0..65535*2**(16*N) for N=0..3.
/* Return 1 if value is 0..65535*2**(16*N) for N=0..3.
   else return 0.  */
   else return 0.  */
 
 
int
int
mmix_shiftable_wyde_value (unsigned HOST_WIDEST_INT value)
mmix_shiftable_wyde_value (unsigned HOST_WIDEST_INT value)
{
{
  /* Shift by 16 bits per group, stop when we've found two groups with
  /* Shift by 16 bits per group, stop when we've found two groups with
     nonzero bits.  */
     nonzero bits.  */
  int i;
  int i;
  int has_candidate = 0;
  int has_candidate = 0;
 
 
  for (i = 0; i < 4; i++)
  for (i = 0; i < 4; i++)
    {
    {
      if (value & 65535)
      if (value & 65535)
        {
        {
          if (has_candidate)
          if (has_candidate)
            return 0;
            return 0;
          else
          else
            has_candidate = 1;
            has_candidate = 1;
        }
        }
 
 
      value >>= 16;
      value >>= 16;
    }
    }
 
 
  return 1;
  return 1;
}
}
 
 
/* Returns zero if code and mode is not a valid condition from a
/* Returns zero if code and mode is not a valid condition from a
   compare-type insn.  Nonzero if it is.  The parameter op, if non-NULL,
   compare-type insn.  Nonzero if it is.  The parameter op, if non-NULL,
   is the comparison of mode is CC-somethingmode.  */
   is the comparison of mode is CC-somethingmode.  */
 
 
int
int
mmix_valid_comparison (RTX_CODE code, enum machine_mode mode, rtx op)
mmix_valid_comparison (RTX_CODE code, enum machine_mode mode, rtx op)
{
{
  if (mode == VOIDmode && op != NULL_RTX)
  if (mode == VOIDmode && op != NULL_RTX)
    mode = GET_MODE (op);
    mode = GET_MODE (op);
 
 
  /* We don't care to look at these, they should always be valid.  */
  /* We don't care to look at these, they should always be valid.  */
  if (mode == CCmode || mode == CC_UNSmode || mode == DImode)
  if (mode == CCmode || mode == CC_UNSmode || mode == DImode)
    return 1;
    return 1;
 
 
  if ((mode == CC_FPmode || mode == DFmode)
  if ((mode == CC_FPmode || mode == DFmode)
      && (code == GT || code == LT))
      && (code == GT || code == LT))
    return 1;
    return 1;
 
 
  if ((mode == CC_FPEQmode || mode == DFmode)
  if ((mode == CC_FPEQmode || mode == DFmode)
      && (code == EQ || code == NE))
      && (code == EQ || code == NE))
    return 1;
    return 1;
 
 
  if ((mode == CC_FUNmode || mode == DFmode)
  if ((mode == CC_FUNmode || mode == DFmode)
      && (code == ORDERED || code == UNORDERED))
      && (code == ORDERED || code == UNORDERED))
    return 1;
    return 1;
 
 
  return 0;
  return 0;
}
}
 
 
/* X and Y are two things to compare using CODE.  Emit a compare insn if
/* X and Y are two things to compare using CODE.  Emit a compare insn if
   possible and return the rtx for the cc-reg in the proper mode, or
   possible and return the rtx for the cc-reg in the proper mode, or
   NULL_RTX if this is not a valid comparison.  */
   NULL_RTX if this is not a valid comparison.  */
 
 
rtx
rtx
mmix_gen_compare_reg (RTX_CODE code, rtx x, rtx y)
mmix_gen_compare_reg (RTX_CODE code, rtx x, rtx y)
{
{
  enum machine_mode ccmode = SELECT_CC_MODE (code, x, y);
  enum machine_mode ccmode = SELECT_CC_MODE (code, x, y);
  rtx cc_reg;
  rtx cc_reg;
 
 
  /* FIXME: Do we get constants here?  Of double mode?  */
  /* FIXME: Do we get constants here?  Of double mode?  */
  enum machine_mode mode
  enum machine_mode mode
    = GET_MODE (x) == VOIDmode
    = GET_MODE (x) == VOIDmode
    ? GET_MODE (y)
    ? GET_MODE (y)
    : GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT ? DFmode : DImode;
    : GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT ? DFmode : DImode;
 
 
  if (! mmix_valid_comparison (code, mode, x))
  if (! mmix_valid_comparison (code, mode, x))
    return NULL_RTX;
    return NULL_RTX;
 
 
  cc_reg = gen_reg_rtx (ccmode);
  cc_reg = gen_reg_rtx (ccmode);
 
 
  /* FIXME:  Can we avoid emitting a compare insn here?  */
  /* FIXME:  Can we avoid emitting a compare insn here?  */
  if (! REG_P (x) && ! REG_P (y))
  if (! REG_P (x) && ! REG_P (y))
    x = force_reg (mode, x);
    x = force_reg (mode, x);
 
 
  /* If it's not quite right yet, put y in a register.  */
  /* If it's not quite right yet, put y in a register.  */
  if (! REG_P (y)
  if (! REG_P (y)
      && (GET_CODE (y) != CONST_INT
      && (GET_CODE (y) != CONST_INT
          || ! CONST_OK_FOR_LETTER_P (INTVAL (y), 'I')))
          || ! CONST_OK_FOR_LETTER_P (INTVAL (y), 'I')))
    y = force_reg (mode, y);
    y = force_reg (mode, y);
 
 
  emit_insn (gen_rtx_SET (VOIDmode, cc_reg,
  emit_insn (gen_rtx_SET (VOIDmode, cc_reg,
                          gen_rtx_COMPARE (ccmode, x, y)));
                          gen_rtx_COMPARE (ccmode, x, y)));
 
 
  return cc_reg;
  return cc_reg;
}
}
 
 
/* Local (static) helper functions.  */
/* Local (static) helper functions.  */
 
 
static void
static void
mmix_emit_sp_add (HOST_WIDE_INT offset)
mmix_emit_sp_add (HOST_WIDE_INT offset)
{
{
  rtx insn;
  rtx insn;
 
 
  if (offset < 0)
  if (offset < 0)
    {
    {
      /* Negative stack-pointer adjustments are allocations and appear in
      /* Negative stack-pointer adjustments are allocations and appear in
         the prologue only.  We mark them as frame-related so unwind and
         the prologue only.  We mark them as frame-related so unwind and
         debug info is properly emitted for them.  */
         debug info is properly emitted for them.  */
      if (offset > -255)
      if (offset > -255)
        insn = emit_insn (gen_adddi3 (stack_pointer_rtx,
        insn = emit_insn (gen_adddi3 (stack_pointer_rtx,
                                      stack_pointer_rtx,
                                      stack_pointer_rtx,
                                      GEN_INT (offset)));
                                      GEN_INT (offset)));
      else
      else
        {
        {
          rtx tmpr = gen_rtx_REG (DImode, 255);
          rtx tmpr = gen_rtx_REG (DImode, 255);
          RTX_FRAME_RELATED_P (emit_move_insn (tmpr, GEN_INT (offset))) = 1;
          RTX_FRAME_RELATED_P (emit_move_insn (tmpr, GEN_INT (offset))) = 1;
          insn = emit_insn (gen_adddi3 (stack_pointer_rtx,
          insn = emit_insn (gen_adddi3 (stack_pointer_rtx,
                                        stack_pointer_rtx, tmpr));
                                        stack_pointer_rtx, tmpr));
        }
        }
      RTX_FRAME_RELATED_P (insn) = 1;
      RTX_FRAME_RELATED_P (insn) = 1;
    }
    }
  else
  else
    {
    {
      /* Positive adjustments are in the epilogue only.  Don't mark them
      /* Positive adjustments are in the epilogue only.  Don't mark them
         as "frame-related" for unwind info.  */
         as "frame-related" for unwind info.  */
      if (CONST_OK_FOR_LETTER_P (offset, 'L'))
      if (CONST_OK_FOR_LETTER_P (offset, 'L'))
        emit_insn (gen_adddi3 (stack_pointer_rtx,
        emit_insn (gen_adddi3 (stack_pointer_rtx,
                               stack_pointer_rtx,
                               stack_pointer_rtx,
                               GEN_INT (offset)));
                               GEN_INT (offset)));
      else
      else
        {
        {
          rtx tmpr = gen_rtx_REG (DImode, 255);
          rtx tmpr = gen_rtx_REG (DImode, 255);
          emit_move_insn (tmpr, GEN_INT (offset));
          emit_move_insn (tmpr, GEN_INT (offset));
          insn = emit_insn (gen_adddi3 (stack_pointer_rtx,
          insn = emit_insn (gen_adddi3 (stack_pointer_rtx,
                                        stack_pointer_rtx, tmpr));
                                        stack_pointer_rtx, tmpr));
        }
        }
    }
    }
}
}
 
 
/* Print operator suitable for doing something with a shiftable
/* Print operator suitable for doing something with a shiftable
   wyde.  The type of operator is passed as an asm output modifier.  */
   wyde.  The type of operator is passed as an asm output modifier.  */
 
 
static void
static void
mmix_output_shiftvalue_op_from_str (FILE *stream,
mmix_output_shiftvalue_op_from_str (FILE *stream,
                                    const char *mainop,
                                    const char *mainop,
                                    HOST_WIDEST_INT value)
                                    HOST_WIDEST_INT value)
{
{
  static const char *const op_part[] = {"L", "ML", "MH", "H"};
  static const char *const op_part[] = {"L", "ML", "MH", "H"};
  int i;
  int i;
 
 
  if (! mmix_shiftable_wyde_value (value))
  if (! mmix_shiftable_wyde_value (value))
    {
    {
      char s[sizeof ("0xffffffffffffffff")];
      char s[sizeof ("0xffffffffffffffff")];
      sprintf (s, HOST_WIDEST_INT_PRINT_HEX, value);
      sprintf (s, HOST_WIDEST_INT_PRINT_HEX, value);
      internal_error ("MMIX Internal: %s is not a shiftable int", s);
      internal_error ("MMIX Internal: %s is not a shiftable int", s);
    }
    }
 
 
  for (i = 0; i < 4; i++)
  for (i = 0; i < 4; i++)
    {
    {
      /* We know we're through when we find one-bits in the low
      /* We know we're through when we find one-bits in the low
         16 bits.  */
         16 bits.  */
      if (value & 0xffff)
      if (value & 0xffff)
        {
        {
          fprintf (stream, "%s%s", mainop, op_part[i]);
          fprintf (stream, "%s%s", mainop, op_part[i]);
          return;
          return;
        }
        }
      value >>= 16;
      value >>= 16;
    }
    }
 
 
  /* No bits set?  Then it must have been zero.  */
  /* No bits set?  Then it must have been zero.  */
  fprintf (stream, "%sL", mainop);
  fprintf (stream, "%sL", mainop);
}
}
 
 
/* Print a 64-bit value, optionally prefixed by assembly pseudo.  */
/* Print a 64-bit value, optionally prefixed by assembly pseudo.  */
 
 
static void
static void
mmix_output_octa (FILE *stream, HOST_WIDEST_INT value, int do_begin_end)
mmix_output_octa (FILE *stream, HOST_WIDEST_INT value, int do_begin_end)
{
{
  /* Snipped from final.c:output_addr_const.  We need to avoid the
  /* Snipped from final.c:output_addr_const.  We need to avoid the
     presumed universal "0x" prefix.  We can do it by replacing "0x" with
     presumed universal "0x" prefix.  We can do it by replacing "0x" with
     "#0" here; we must avoid a space in the operands and no, the zero
     "#0" here; we must avoid a space in the operands and no, the zero
     won't cause the number to be assumed in octal format.  */
     won't cause the number to be assumed in octal format.  */
  char hex_format[sizeof (HOST_WIDEST_INT_PRINT_HEX)];
  char hex_format[sizeof (HOST_WIDEST_INT_PRINT_HEX)];
 
 
  if (do_begin_end)
  if (do_begin_end)
    fprintf (stream, "\tOCTA ");
    fprintf (stream, "\tOCTA ");
 
 
  strcpy (hex_format, HOST_WIDEST_INT_PRINT_HEX);
  strcpy (hex_format, HOST_WIDEST_INT_PRINT_HEX);
  hex_format[0] = '#';
  hex_format[0] = '#';
  hex_format[1] = '0';
  hex_format[1] = '0';
 
 
  /* Provide a few alternative output formats depending on the number, to
  /* Provide a few alternative output formats depending on the number, to
     improve legibility of assembler output.  */
     improve legibility of assembler output.  */
  if ((value < (HOST_WIDEST_INT) 0 && value > (HOST_WIDEST_INT) -10000)
  if ((value < (HOST_WIDEST_INT) 0 && value > (HOST_WIDEST_INT) -10000)
      || (value >= (HOST_WIDEST_INT) 0 && value <= (HOST_WIDEST_INT) 16384))
      || (value >= (HOST_WIDEST_INT) 0 && value <= (HOST_WIDEST_INT) 16384))
    fprintf (stream, "%d", (int) value);
    fprintf (stream, "%d", (int) value);
  else if (value > (HOST_WIDEST_INT) 0
  else if (value > (HOST_WIDEST_INT) 0
           && value < ((HOST_WIDEST_INT) 1 << 31) * 2)
           && value < ((HOST_WIDEST_INT) 1 << 31) * 2)
    fprintf (stream, "#%x", (unsigned int) value);
    fprintf (stream, "#%x", (unsigned int) value);
  else
  else
    fprintf (stream, hex_format, value);
    fprintf (stream, hex_format, value);
 
 
  if (do_begin_end)
  if (do_begin_end)
    fprintf (stream, "\n");
    fprintf (stream, "\n");
}
}
 
 
/* Print the presumed shiftable wyde argument shifted into place (to
/* Print the presumed shiftable wyde argument shifted into place (to
   be output with an operand).  */
   be output with an operand).  */
 
 
static void
static void
mmix_output_shifted_value (FILE *stream, HOST_WIDEST_INT value)
mmix_output_shifted_value (FILE *stream, HOST_WIDEST_INT value)
{
{
  int i;
  int i;
 
 
  if (! mmix_shiftable_wyde_value (value))
  if (! mmix_shiftable_wyde_value (value))
    {
    {
      char s[16+2+1];
      char s[16+2+1];
      sprintf (s, HOST_WIDEST_INT_PRINT_HEX, value);
      sprintf (s, HOST_WIDEST_INT_PRINT_HEX, value);
      internal_error ("MMIX Internal: %s is not a shiftable int", s);
      internal_error ("MMIX Internal: %s is not a shiftable int", s);
    }
    }
 
 
  for (i = 0; i < 4; i++)
  for (i = 0; i < 4; i++)
    {
    {
      /* We know we're through when we find one-bits in the low 16 bits.  */
      /* We know we're through when we find one-bits in the low 16 bits.  */
      if (value & 0xffff)
      if (value & 0xffff)
        {
        {
          fprintf (stream, "#%x", (int) (value & 0xffff));
          fprintf (stream, "#%x", (int) (value & 0xffff));
          return;
          return;
        }
        }
 
 
    value >>= 16;
    value >>= 16;
  }
  }
 
 
  /* No bits set?  Then it must have been zero.  */
  /* No bits set?  Then it must have been zero.  */
  fprintf (stream, "0");
  fprintf (stream, "0");
}
}
 
 
/* Output an MMIX condition name corresponding to an operator
/* Output an MMIX condition name corresponding to an operator
   and operands:
   and operands:
   (comparison_operator [(comparison_operator ...) (const_int 0)])
   (comparison_operator [(comparison_operator ...) (const_int 0)])
   which means we have to look at *two* operators.
   which means we have to look at *two* operators.
 
 
   The argument "reversed" refers to reversal of the condition (not the
   The argument "reversed" refers to reversal of the condition (not the
   same as swapping the arguments).  */
   same as swapping the arguments).  */
 
 
static void
static void
mmix_output_condition (FILE *stream, rtx x, int reversed)
mmix_output_condition (FILE *stream, rtx x, int reversed)
{
{
  struct cc_conv
  struct cc_conv
  {
  {
    RTX_CODE cc;
    RTX_CODE cc;
 
 
    /* The normal output cc-code.  */
    /* The normal output cc-code.  */
    const char *const normal;
    const char *const normal;
 
 
    /* The reversed cc-code, or NULL if invalid.  */
    /* The reversed cc-code, or NULL if invalid.  */
    const char *const reversed;
    const char *const reversed;
  };
  };
 
 
  struct cc_type_conv
  struct cc_type_conv
  {
  {
    enum machine_mode cc_mode;
    enum machine_mode cc_mode;
 
 
    /* Terminated with {UNKNOWN, NULL, NULL} */
    /* Terminated with {UNKNOWN, NULL, NULL} */
    const struct cc_conv *const convs;
    const struct cc_conv *const convs;
  };
  };
 
 
#undef CCEND
#undef CCEND
#define CCEND {UNKNOWN, NULL, NULL}
#define CCEND {UNKNOWN, NULL, NULL}
 
 
  static const struct cc_conv cc_fun_convs[]
  static const struct cc_conv cc_fun_convs[]
    = {{ORDERED, "Z", "P"},
    = {{ORDERED, "Z", "P"},
       {UNORDERED, "P", "Z"},
       {UNORDERED, "P", "Z"},
       CCEND};
       CCEND};
  static const struct cc_conv cc_fp_convs[]
  static const struct cc_conv cc_fp_convs[]
    = {{GT, "P", NULL},
    = {{GT, "P", NULL},
       {LT, "N", NULL},
       {LT, "N", NULL},
       CCEND};
       CCEND};
  static const struct cc_conv cc_fpeq_convs[]
  static const struct cc_conv cc_fpeq_convs[]
    = {{NE, "Z", "P"},
    = {{NE, "Z", "P"},
       {EQ, "P", "Z"},
       {EQ, "P", "Z"},
       CCEND};
       CCEND};
  static const struct cc_conv cc_uns_convs[]
  static const struct cc_conv cc_uns_convs[]
    = {{GEU, "NN", "N"},
    = {{GEU, "NN", "N"},
       {GTU, "P", "NP"},
       {GTU, "P", "NP"},
       {LEU, "NP", "P"},
       {LEU, "NP", "P"},
       {LTU, "N", "NN"},
       {LTU, "N", "NN"},
       CCEND};
       CCEND};
  static const struct cc_conv cc_signed_convs[]
  static const struct cc_conv cc_signed_convs[]
    = {{NE, "NZ", "Z"},
    = {{NE, "NZ", "Z"},
       {EQ, "Z", "NZ"},
       {EQ, "Z", "NZ"},
       {GE, "NN", "N"},
       {GE, "NN", "N"},
       {GT, "P", "NP"},
       {GT, "P", "NP"},
       {LE, "NP", "P"},
       {LE, "NP", "P"},
       {LT, "N", "NN"},
       {LT, "N", "NN"},
       CCEND};
       CCEND};
  static const struct cc_conv cc_di_convs[]
  static const struct cc_conv cc_di_convs[]
    = {{NE, "NZ", "Z"},
    = {{NE, "NZ", "Z"},
       {EQ, "Z", "NZ"},
       {EQ, "Z", "NZ"},
       {GE, "NN", "N"},
       {GE, "NN", "N"},
       {GT, "P", "NP"},
       {GT, "P", "NP"},
       {LE, "NP", "P"},
       {LE, "NP", "P"},
       {LT, "N", "NN"},
       {LT, "N", "NN"},
       {GTU, "NZ", "Z"},
       {GTU, "NZ", "Z"},
       {LEU, "Z", "NZ"},
       {LEU, "Z", "NZ"},
       CCEND};
       CCEND};
#undef CCEND
#undef CCEND
 
 
  static const struct cc_type_conv cc_convs[]
  static const struct cc_type_conv cc_convs[]
    = {{CC_FUNmode, cc_fun_convs},
    = {{CC_FUNmode, cc_fun_convs},
       {CC_FPmode, cc_fp_convs},
       {CC_FPmode, cc_fp_convs},
       {CC_FPEQmode, cc_fpeq_convs},
       {CC_FPEQmode, cc_fpeq_convs},
       {CC_UNSmode, cc_uns_convs},
       {CC_UNSmode, cc_uns_convs},
       {CCmode, cc_signed_convs},
       {CCmode, cc_signed_convs},
       {DImode, cc_di_convs}};
       {DImode, cc_di_convs}};
 
 
  size_t i;
  size_t i;
  int j;
  int j;
 
 
  enum machine_mode mode = GET_MODE (XEXP (x, 0));
  enum machine_mode mode = GET_MODE (XEXP (x, 0));
  RTX_CODE cc = GET_CODE (x);
  RTX_CODE cc = GET_CODE (x);
 
 
  for (i = 0; i < ARRAY_SIZE (cc_convs); i++)
  for (i = 0; i < ARRAY_SIZE (cc_convs); i++)
    {
    {
      if (mode == cc_convs[i].cc_mode)
      if (mode == cc_convs[i].cc_mode)
        {
        {
          for (j = 0; cc_convs[i].convs[j].cc != UNKNOWN; j++)
          for (j = 0; cc_convs[i].convs[j].cc != UNKNOWN; j++)
            if (cc == cc_convs[i].convs[j].cc)
            if (cc == cc_convs[i].convs[j].cc)
              {
              {
                const char *mmix_cc
                const char *mmix_cc
                  = (reversed ? cc_convs[i].convs[j].reversed
                  = (reversed ? cc_convs[i].convs[j].reversed
                     : cc_convs[i].convs[j].normal);
                     : cc_convs[i].convs[j].normal);
 
 
                if (mmix_cc == NULL)
                if (mmix_cc == NULL)
                  fatal_insn ("MMIX Internal: Trying to output invalidly\
                  fatal_insn ("MMIX Internal: Trying to output invalidly\
 reversed condition:", x);
 reversed condition:", x);
 
 
                fprintf (stream, "%s", mmix_cc);
                fprintf (stream, "%s", mmix_cc);
                return;
                return;
              }
              }
 
 
          fatal_insn ("MMIX Internal: What's the CC of this?", x);
          fatal_insn ("MMIX Internal: What's the CC of this?", x);
        }
        }
    }
    }
 
 
  fatal_insn ("MMIX Internal: What is the CC of this?", x);
  fatal_insn ("MMIX Internal: What is the CC of this?", x);
}
}
 
 
/* Return the bit-value for a const_int or const_double.  */
/* Return the bit-value for a const_int or const_double.  */
 
 
static HOST_WIDEST_INT
static HOST_WIDEST_INT
mmix_intval (rtx x)
mmix_intval (rtx x)
{
{
  unsigned HOST_WIDEST_INT retval;
  unsigned HOST_WIDEST_INT retval;
 
 
  if (GET_CODE (x) == CONST_INT)
  if (GET_CODE (x) == CONST_INT)
    return INTVAL (x);
    return INTVAL (x);
 
 
  /* We make a little song and dance because converting to long long in
  /* We make a little song and dance because converting to long long in
     gcc-2.7.2 is broken.  I still want people to be able to use it for
     gcc-2.7.2 is broken.  I still want people to be able to use it for
     cross-compilation to MMIX.  */
     cross-compilation to MMIX.  */
  if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == VOIDmode)
  if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == VOIDmode)
    {
    {
      if (sizeof (HOST_WIDE_INT) < sizeof (HOST_WIDEST_INT))
      if (sizeof (HOST_WIDE_INT) < sizeof (HOST_WIDEST_INT))
        {
        {
          retval = (unsigned) CONST_DOUBLE_LOW (x) / 2;
          retval = (unsigned) CONST_DOUBLE_LOW (x) / 2;
          retval *= 2;
          retval *= 2;
          retval |= CONST_DOUBLE_LOW (x) & 1;
          retval |= CONST_DOUBLE_LOW (x) & 1;
 
 
          retval |=
          retval |=
            (unsigned HOST_WIDEST_INT) CONST_DOUBLE_HIGH (x)
            (unsigned HOST_WIDEST_INT) CONST_DOUBLE_HIGH (x)
              << (HOST_BITS_PER_LONG);
              << (HOST_BITS_PER_LONG);
        }
        }
      else
      else
        retval = CONST_DOUBLE_HIGH (x);
        retval = CONST_DOUBLE_HIGH (x);
 
 
      return retval;
      return retval;
    }
    }
 
 
  if (GET_CODE (x) == CONST_DOUBLE)
  if (GET_CODE (x) == CONST_DOUBLE)
    {
    {
      REAL_VALUE_TYPE value;
      REAL_VALUE_TYPE value;
 
 
      /* FIXME:  This macro is not in the manual but should be.  */
      /* FIXME:  This macro is not in the manual but should be.  */
      REAL_VALUE_FROM_CONST_DOUBLE (value, x);
      REAL_VALUE_FROM_CONST_DOUBLE (value, x);
 
 
      if (GET_MODE (x) == DFmode)
      if (GET_MODE (x) == DFmode)
        {
        {
          long bits[2];
          long bits[2];
 
 
          REAL_VALUE_TO_TARGET_DOUBLE (value, bits);
          REAL_VALUE_TO_TARGET_DOUBLE (value, bits);
 
 
          /* The double cast is necessary to avoid getting the long
          /* The double cast is necessary to avoid getting the long
             sign-extended to unsigned long long(!) when they're of
             sign-extended to unsigned long long(!) when they're of
             different size (usually 32-bit hosts).  */
             different size (usually 32-bit hosts).  */
          return
          return
            ((unsigned HOST_WIDEST_INT) (unsigned long) bits[0]
            ((unsigned HOST_WIDEST_INT) (unsigned long) bits[0]
             << (unsigned HOST_WIDEST_INT) 32U)
             << (unsigned HOST_WIDEST_INT) 32U)
            | (unsigned HOST_WIDEST_INT) (unsigned long) bits[1];
            | (unsigned HOST_WIDEST_INT) (unsigned long) bits[1];
        }
        }
      else if (GET_MODE (x) == SFmode)
      else if (GET_MODE (x) == SFmode)
        {
        {
          long bits;
          long bits;
          REAL_VALUE_TO_TARGET_SINGLE (value, bits);
          REAL_VALUE_TO_TARGET_SINGLE (value, bits);
 
 
          return (unsigned long) bits;
          return (unsigned long) bits;
        }
        }
    }
    }
 
 
  fatal_insn ("MMIX Internal: This is not a constant:", x);
  fatal_insn ("MMIX Internal: This is not a constant:", x);
}
}
 
 
/* Worker function for TARGET_STRUCT_VALUE_RTX.  */
/* Worker function for TARGET_STRUCT_VALUE_RTX.  */
 
 
static rtx
static rtx
mmix_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED,
mmix_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED,
                       int incoming ATTRIBUTE_UNUSED)
                       int incoming ATTRIBUTE_UNUSED)
{
{
  return gen_rtx_REG (Pmode, MMIX_STRUCT_VALUE_REGNUM);
  return gen_rtx_REG (Pmode, MMIX_STRUCT_VALUE_REGNUM);
}
}
 
 
/*
/*
 * Local variables:
 * Local variables:
 * eval: (c-set-style "gnu")
 * eval: (c-set-style "gnu")
 * indent-tabs-mode: t
 * indent-tabs-mode: t
 * End:
 * End:
 */
 */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.