📄 vax.c
字号:
/* Subroutines for insn-output.c for VAX. Copyright (C) 1987, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.This file is part of GCC.GCC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GCC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GCC; see the file COPYING. If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA. */#include "config.h"#include "system.h"#include "coretypes.h"#include "tm.h"#include "rtl.h"#include "tree.h"#include "regs.h"#include "hard-reg-set.h"#include "real.h"#include "insn-config.h"#include "conditions.h"#include "function.h"#include "output.h"#include "insn-attr.h"#include "recog.h"#include "expr.h"#include "optabs.h"#include "flags.h"#include "debug.h"#include "toplev.h"#include "tm_p.h"#include "target.h"#include "target-def.h"static void vax_output_function_prologue (FILE *, HOST_WIDE_INT);static void vax_file_start (void);static void vax_init_libfuncs (void);static void vax_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree);static int vax_address_cost_1 (rtx);static int vax_address_cost (rtx);static bool vax_rtx_costs (rtx, int, int, int *);static rtx vax_struct_value_rtx (tree, int);/* Initialize the GCC target structure. */#undef TARGET_ASM_ALIGNED_HI_OP#define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"#undef TARGET_ASM_FUNCTION_PROLOGUE#define TARGET_ASM_FUNCTION_PROLOGUE vax_output_function_prologue#undef TARGET_ASM_FILE_START#define TARGET_ASM_FILE_START vax_file_start#undef TARGET_ASM_FILE_START_APP_OFF#define TARGET_ASM_FILE_START_APP_OFF true#undef TARGET_INIT_LIBFUNCS#define TARGET_INIT_LIBFUNCS vax_init_libfuncs#undef TARGET_ASM_OUTPUT_MI_THUNK#define TARGET_ASM_OUTPUT_MI_THUNK vax_output_mi_thunk#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK#define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall#undef TARGET_RTX_COSTS#define TARGET_RTX_COSTS vax_rtx_costs#undef TARGET_ADDRESS_COST#define TARGET_ADDRESS_COST vax_address_cost#undef TARGET_PROMOTE_PROTOTYPES#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true#undef TARGET_STRUCT_VALUE_RTX#define TARGET_STRUCT_VALUE_RTX vax_struct_value_rtxstruct gcc_target targetm = TARGET_INITIALIZER;/* Set global variables as needed for the options enabled. */voidoverride_options (void){ /* We're VAX floating point, not IEEE floating point. */ if (TARGET_G_FLOAT) REAL_MODE_FORMAT (DFmode) = &vax_g_format;}/* Generate the assembly code for function entry. FILE is a stdio stream to output the code to. SIZE is an int: how many units of temporary storage to allocate. Refer to the array `regs_ever_live' to determine which registers to save; `regs_ever_live[I]' is nonzero if register number I is ever used in the function. This function is responsible for knowing which registers should not be saved even if used. */static voidvax_output_function_prologue (FILE * file, HOST_WIDE_INT size){ register int regno; register int mask = 0; for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) if (regs_ever_live[regno] && !call_used_regs[regno]) mask |= 1 << regno; fprintf (file, "\t.word 0x%x\n", mask); if (dwarf2out_do_frame ()) { const char *label = dwarf2out_cfi_label (); int offset = 0; for (regno = FIRST_PSEUDO_REGISTER-1; regno >= 0; --regno) if (regs_ever_live[regno] && !call_used_regs[regno]) dwarf2out_reg_save (label, regno, offset -= 4); dwarf2out_reg_save (label, PC_REGNUM, offset -= 4); dwarf2out_reg_save (label, FRAME_POINTER_REGNUM, offset -= 4); dwarf2out_reg_save (label, ARG_POINTER_REGNUM, offset -= 4); dwarf2out_def_cfa (label, FRAME_POINTER_REGNUM, -(offset - 4)); } size -= STARTING_FRAME_OFFSET; if (size >= 64) asm_fprintf (file, "\tmovab %wd(%Rsp),%Rsp\n", -size); else if (size) asm_fprintf (file, "\tsubl2 $%wd,%Rsp\n", size);}/* When debugging with stabs, we want to output an extra dummy label so that gas can distinguish between D_float and G_float prior to processing the .stabs directive identifying type double. */static voidvax_file_start (void){ default_file_start (); if (write_symbols == DBX_DEBUG) fprintf (asm_out_file, "___vax_%c_doubles:\n", ASM_DOUBLE_CHAR);}/* We can use the BSD C library routines for the libgcc calls that are still generated, since that's what they boil down to anyways. When ELF, avoid the user's namespace. */static voidvax_init_libfuncs (void){ set_optab_libfunc (udiv_optab, SImode, TARGET_ELF ? "*__udiv" : "*udiv"); set_optab_libfunc (umod_optab, SImode, TARGET_ELF ? "*__urem" : "*urem");}/* This is like nonimmediate_operand with a restriction on the type of MEM. */voidsplit_quadword_operands (rtx * operands, rtx * low, int n ATTRIBUTE_UNUSED){ int i; /* Split operands. */ low[0] = low[1] = low[2] = 0; for (i = 0; i < 3; i++) { if (low[i]) /* it's already been figured out */; else if (GET_CODE (operands[i]) == MEM && (GET_CODE (XEXP (operands[i], 0)) == POST_INC)) { rtx addr = XEXP (operands[i], 0); operands[i] = low[i] = gen_rtx_MEM (SImode, addr); if (which_alternative == 0 && i == 0) { addr = XEXP (operands[i], 0); operands[i+1] = low[i+1] = gen_rtx_MEM (SImode, addr); } } else { low[i] = operand_subword (operands[i], 0, 0, DImode); operands[i] = operand_subword (operands[i], 1, 0, DImode); } }}voidprint_operand_address (FILE * file, register rtx addr){ register rtx reg1, breg, ireg; rtx offset; retry: switch (GET_CODE (addr)) { case MEM: fprintf (file, "*"); addr = XEXP (addr, 0); goto retry; case REG: fprintf (file, "(%s)", reg_names[REGNO (addr)]); break; case PRE_DEC: fprintf (file, "-(%s)", reg_names[REGNO (XEXP (addr, 0))]); break; case POST_INC: fprintf (file, "(%s)+", reg_names[REGNO (XEXP (addr, 0))]); break; case PLUS: /* There can be either two or three things added here. One must be a REG. One can be either a REG or a MULT of a REG and an appropriate constant, and the third can only be a constant or a MEM. We get these two or three things and put the constant or MEM in OFFSET, the MULT or REG in IREG, and the REG in BREG. If we have a register and can't tell yet if it is a base or index register, put it into REG1. */ reg1 = 0; ireg = 0; breg = 0; offset = 0; if (CONSTANT_ADDRESS_P (XEXP (addr, 0)) || GET_CODE (XEXP (addr, 0)) == MEM) { offset = XEXP (addr, 0); addr = XEXP (addr, 1); } else if (CONSTANT_ADDRESS_P (XEXP (addr, 1)) || GET_CODE (XEXP (addr, 1)) == MEM) { offset = XEXP (addr, 1); addr = XEXP (addr, 0); } else if (GET_CODE (XEXP (addr, 1)) == MULT) { ireg = XEXP (addr, 1); addr = XEXP (addr, 0); } else if (GET_CODE (XEXP (addr, 0)) == MULT) { ireg = XEXP (addr, 0); addr = XEXP (addr, 1); } else if (GET_CODE (XEXP (addr, 1)) == REG) { reg1 = XEXP (addr, 1); addr = XEXP (addr, 0); } else if (GET_CODE (XEXP (addr, 0)) == REG) { reg1 = XEXP (addr, 0); addr = XEXP (addr, 1); } else abort (); if (GET_CODE (addr) == REG) { if (reg1) ireg = addr; else reg1 = addr; } else if (GET_CODE (addr) == MULT) ireg = addr; else if (GET_CODE (addr) == PLUS) { if (CONSTANT_ADDRESS_P (XEXP (addr, 0)) || GET_CODE (XEXP (addr, 0)) == MEM) { if (offset) { if (GET_CODE (offset) == CONST_INT) offset = plus_constant (XEXP (addr, 0), INTVAL (offset)); else if (GET_CODE (XEXP (addr, 0)) == CONST_INT) offset = plus_constant (offset, INTVAL (XEXP (addr, 0))); else abort (); } offset = XEXP (addr, 0); } else if (GET_CODE (XEXP (addr, 0)) == REG) { if (reg1) ireg = reg1, breg = XEXP (addr, 0), reg1 = 0; else reg1 = XEXP (addr, 0); } else if (GET_CODE (XEXP (addr, 0)) == MULT) { if (ireg) abort (); ireg = XEXP (addr, 0); } else abort (); if (CONSTANT_ADDRESS_P (XEXP (addr, 1)) || GET_CODE (XEXP (addr, 1)) == MEM) { if (offset) { if (GET_CODE (offset) == CONST_INT) offset = plus_constant (XEXP (addr, 1), INTVAL (offset)); else if (GET_CODE (XEXP (addr, 1)) == CONST_INT) offset = plus_constant (offset, INTVAL (XEXP (addr, 1))); else abort (); } offset = XEXP (addr, 1); } else if (GET_CODE (XEXP (addr, 1)) == REG) { if (reg1) ireg = reg1, breg = XEXP (addr, 1), reg1 = 0; else reg1 = XEXP (addr, 1); } else if (GET_CODE (XEXP (addr, 1)) == MULT) { if (ireg) abort (); ireg = XEXP (addr, 1); } else abort (); } else abort (); /* If REG1 is nonzero, figure out if it is a base or index register. */ if (reg1) { if (breg != 0 || (offset && GET_CODE (offset) == MEM)) { if (ireg) abort (); ireg = reg1; } else breg = reg1; } if (offset != 0) output_address (offset); if (breg != 0) fprintf (file, "(%s)", reg_names[REGNO (breg)]); if (ireg != 0) { if (GET_CODE (ireg) == MULT) ireg = XEXP (ireg, 0); if (GET_CODE (ireg) != REG) abort (); fprintf (file, "[%s]", reg_names[REGNO (ireg)]); } break; default: output_addr_const (file, addr); }}const char *rev_cond_name (rtx op){ switch (GET_CODE (op)) { case EQ: return "neq"; case NE: return "eql"; case LT: return "geq"; case LE: return "gtr"; case GT: return "leq"; case GE: return "lss"; case LTU: return "gequ"; case LEU: return "gtru"; case GTU: return "lequ"; case GEU: return "lssu"; default: abort (); }}intvax_float_literal(register rtx c){ register enum machine_mode mode; REAL_VALUE_TYPE r, s; int i; if (GET_CODE (c) != CONST_DOUBLE) return 0; mode = GET_MODE (c); if (c == const_tiny_rtx[(int) mode][0] || c == const_tiny_rtx[(int) mode][1] || c == const_tiny_rtx[(int) mode][2]) return 1; REAL_VALUE_FROM_CONST_DOUBLE (r, c); for (i = 0; i < 7; i++) { int x = 1 << i; REAL_VALUE_FROM_INT (s, x, 0, mode); if (REAL_VALUES_EQUAL (r, s)) return 1; if (!exact_real_inverse (mode, &s)) abort (); if (REAL_VALUES_EQUAL (r, s)) return 1; } return 0;}/* Return the cost in cycles of a memory address, relative to register indirect. Each of the following adds the indicated number of cycles: 1 - symbolic address 1 - pre-decrement 1 - indexing and/or offset(register)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -