📄 convex.c
字号:
/* Subroutines for insn-output.c for Convex. Copyright (C) 1988, 1993, 1994, 1997 Free Software Foundation, Inc.This file is part of GNU CC.GNU CC 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 1, or (at your option)any later version.GNU CC 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 GNU CC; 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 <stdio.h>#include "tree.h"#include "rtl.h"#include "regs.h"#include "hard-reg-set.h"#include "real.h"#include "insn-config.h"#include "conditions.h"#include "insn-flags.h"#include "insn-attr.h"#include "output.h"#include "expr.h"/* Tables used in convex.h */char regno_ok_for_index_p_base[1 + LAST_VIRTUAL_REGISTER + 1];enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];enum reg_class reg_class_from_letter[256];/* Target cpu index. */int target_cpu;/* Boolean to keep track of whether the current section is .text or not. Used by .align handler in convex.h. */int current_section_is_text;/* Communication between output_compare and output_condjump. */static rtx cmp_operand0, cmp_operand1;static char cmp_modech;/* Forwards */static rtx frame_argblock;static int frame_argblock_size;static rtx convert_arg_pushes ();static void expand_movstr_call ();/* Here from OVERRIDE_OPTIONS at startup. Initialize constant tables. */init_convex (){ int regno; /* Set A and S reg classes. */ for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) if (A_REGNO_P (regno)) { regno_ok_for_index_p[regno] = 1; regno_reg_class[regno] = INDEX_REGS; } else { regno_ok_for_index_p[regno] = 0; regno_reg_class[regno] = S_REGS; } /* Can't index off the stack pointer, register 0. */ regno_ok_for_index_p[STACK_POINTER_REGNUM] = 0; regno_reg_class[STACK_POINTER_REGNUM] = SP_REGS; /* Can't index off aliases of the stack pointer. */ regno_ok_for_index_p[VIRTUAL_INCOMING_ARGS_REGNUM] = 1; regno_ok_for_index_p[VIRTUAL_STACK_VARS_REGNUM] = 1; regno_ok_for_index_p[VIRTUAL_STACK_DYNAMIC_REGNUM] = 0; regno_ok_for_index_p[VIRTUAL_OUTGOING_ARGS_REGNUM] = 0; /* Can't index off hard reg -1 == pseudos not assigned */ regno_ok_for_index_p[-1] = 0; /* Set reg class letters */ reg_class_from_letter['a'] = A_REGS; reg_class_from_letter['A'] = INDEX_REGS; reg_class_from_letter['d'] = S_REGS; /* Turn off floating point exception enables in the psw. */ psw_disable_float ();}psw_disable_float (){#if __convex__ && __GNUC__ register int *p; asm ("mov fp,%0" : "=a" (p)); while (p) { p[1] &= ~0x1000c400; p = (int *) p[2]; }#endif }/* Here to output code for a compare insn. Output nothing, just record the operands and their mode. */char *output_cmp (operand0, operand1, modech) rtx operand0, operand1; char modech;{ cmp_operand0 = operand0; cmp_operand1 = operand1; cmp_modech = modech; return "";}/* Output code for a conditional jump. The preceding instruction is necessarily a compare. Output two instructions, for example eq.w a1,a2 jbra.t L5 for (cmpsi a1 a2) (beq L5) */char *output_condjump (label, cond, jbr_sense) rtx label; char *cond; char jbr_sense;{ rtx operands[3]; char cmp_op[4]; char buf[80]; char jbr_regch; strcpy (cmp_op, cond); /* [BL] mean the value is being compared against immediate 0. Use neg.x, which produces the same carry that eq.x #0 would if it existed. In this case operands[1] is a scratch register, not a compare operand. */ if (cmp_modech == 'B' || cmp_modech == 'L') { cmp_modech = cmp_modech - 'A' + 'a'; strcpy (cmp_op, "neg"); } /* [WH] mean the value being compared resulted from "add.[wh] #-1,rk" when rk was nonnegative -- we can omit equality compares against -1 or inequality compares against 0. */ else if (cmp_modech == 'W' || cmp_modech == 'H') { if (! strcmp (cmp_op, "eq") && cmp_operand1 == constm1_rtx) jbr_sense ^= 't' ^ 'f'; else if (! strcmp (cmp_op, "lt") && cmp_operand1 == const0_rtx) ; else cmp_modech = cmp_modech - 'A' + 'a'; } /* Constant must be first; swap operands if necessary. If lt, le, ltu, leu are swapped, change to le, lt, leu, ltu and reverse the sense of the jump. */ if (! REG_P (cmp_operand1)) { operands[0] = cmp_operand1; operands[1] = cmp_operand0; if (cmp_op[0] == 'l') { cmp_op[1] ^= 'e' ^ 't'; jbr_sense ^= 't' ^ 'f'; } } else { operands[0] = cmp_operand0; operands[1] = cmp_operand1; } operands[2] = label; if (S_REG_P (operands[1])) jbr_regch = 's'; else if (A_REG_P (operands[1])) jbr_regch = 'a'; else abort (); if (cmp_modech == 'W' || cmp_modech == 'H') sprintf (buf, "jbr%c.%c %%l2", jbr_regch, jbr_sense); else sprintf (buf, "%s.%c %%0,%%1\n\tjbr%c.%c %%l2", cmp_op, cmp_modech, jbr_regch, jbr_sense); output_asm_insn (buf, operands); return "";}/* Return 1 if OP is valid for cmpsf. In IEEE mode, +/- zero compares are not handled by the immediate versions of eq.s and on some machines, lt.s, and le.s. So disallow 0.0 as the immediate operand of xx.s compares in IEEE mode. */intnonmemory_cmpsf_operand (op, mode) rtx op; enum machine_mode mode;{#if _IEEE_FLOAT_ if (op == CONST0_RTX (SFmode)) return 0;#endif return nonmemory_operand (op, mode);}/* Convex /bin/as does not like unary minus in some contexts. Simplify CONST addresses to remove it. */rtxsimplify_for_convex (x) rtx x;{ switch (GET_CODE (x)) { case MINUS: if (GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) < 0) { PUT_CODE (x, PLUS); XEXP (x, 1) = GEN_INT (- INTVAL (XEXP (x, 1))); } break; case CONST: return simplify_for_convex (XEXP (x, 0)); } return x;}/* Routines to separate CONST_DOUBLEs into component parts. */intconst_double_high_int (x) rtx x;{ if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) return CONST_DOUBLE_LOW (x); else return CONST_DOUBLE_HIGH (x);}intconst_double_low_int (x) rtx x;{ if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) return CONST_DOUBLE_HIGH (x); else return CONST_DOUBLE_LOW (x);}/* Inline block copy. */voidexpand_movstr (operands) rtx *operands;{ rtx dest = operands[0]; rtx src = operands[1]; int align = INTVAL (operands[3]); int nregs, maxsize; unsigned len; enum machine_mode mode; rtx reg, load, store, prev_store, prev_store_2; int size; /* Decide how many regs to use, depending on load latency, and what size pieces to move, depending on whether machine does unaligned loads and stores efficiently. */ if (TARGET_C1) { /* ld.l latency is 4, no alignment problems. */ nregs = 3, maxsize = 8; } else if (TARGET_C2) { /* loads are latency 2 if we avoid ld.l not at least word aligned. */ if (align >= 4) nregs = 2, maxsize = 8; else nregs = 2, maxsize = 4; } else if (TARGET_C34) { /* latency is 4 if aligned, horrible if not. */ nregs = 3, maxsize = align; } else if (TARGET_C38) { /* latency is 2 if at least word aligned, 3 or 4 if unaligned. */ if (align >= 4) nregs = 2, maxsize = 8; else nregs = 3, maxsize = 8; } else abort (); /* Caller is not necessarily prepared for us to fail in this expansion. So fall back by generating memcpy call here. */ if (GET_CODE (operands[2]) != CONST_INT || (len = INTVAL (operands[2])) > (unsigned) 32 * maxsize) { expand_movstr_call (operands); return; } reg = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -