--- gcc/config/1750a/1750a.c 2018/04/24 18:22:37 1.1 +++ gcc/config/1750a/1750a.c 2018/04/24 18:30:22 1.1.1.2 @@ -1,6 +1,6 @@ /* Subroutines for insn-output.c for MIL-STD-1750. - Copyright (C) 1994 Free Software Foundation, Inc. - Contributed by O.M.Kellogg, DASA (okellogg@salyko.cube.net). + Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Contributed by O.M.Kellogg, DASA (kellogg@space.otn.dasa.de) This file is part of GNU CC. @@ -16,11 +16,13 @@ GNU General Public License for more deta You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ #ifndef FILE #include #endif +#include #define __datalbl #include "config.h" @@ -38,7 +40,7 @@ int jmplbl_ndx = -1; int label_pending = 0, program_counter = 0; enum section current_section = Normal; char *sectname[4] = -{"Normal", "Init", "Konst", "Static"}; +{"Init", "Normal", "Konst", "Static"}; int notice_update_cc (exp) @@ -50,24 +52,18 @@ notice_update_cc (exp) /* Jumps do not alter the cc's. */ if (SET_DEST (exp) == pc_rtx) return; - /* Moving register into memory doesn't alter the cc's. - It may invalidate the RTX's which we remember the cc's came from. */ - if (GET_CODE (SET_DEST (exp)) == MEM) - { - if (cc_status.value1 && GET_CODE (cc_status.value1) == MEM) - cc_status.value1 = 0; - if (cc_status.value2 && GET_CODE (cc_status.value2) == MEM) - cc_status.value2 = 0; - return; - } + /* Moving a register or constant into memory doesn't alter the cc's. */ + if (GET_CODE (SET_DEST (exp)) == MEM + && (src_code == REG || src_code == CONST_INT)) + return; /* Function calls clobber the cc's. */ - else if (src_code == CALL) + if (src_code == CALL) { CC_STATUS_INIT; return; } /* Emulated longword bit-ops leave cc's incorrect */ - else if (GET_MODE (SET_DEST (exp)) == HImode ? + if (GET_MODE (SET_DEST (exp)) == HImode ? src_code == AND || src_code == IOR || src_code == XOR || src_code == NOT : 0) { @@ -75,24 +71,17 @@ notice_update_cc (exp) return; } /* Tests and compares set the cc's in predictable ways. */ - else if (SET_DEST (exp) == cc0_rtx) + if (SET_DEST (exp) == cc0_rtx) { CC_STATUS_INIT; cc_status.value1 = SET_SRC (exp); return; } - /* Anything that lands in a reg will set cc_status. */ - else if (REG_P (SET_DEST (exp))) - { - cc_status.flags = CC_NO_OVERFLOW; - cc_status.value1 = SET_SRC (exp); - cc_status.value2 = SET_DEST (exp); - return; - } - else - { - CC_STATUS_INIT; - } + /* Anything else will set cc_status. */ + cc_status.flags = CC_NO_OVERFLOW; + cc_status.value1 = SET_SRC (exp); + cc_status.value2 = SET_DEST (exp); + return; } else if (GET_CODE (exp) == PARALLEL && GET_CODE (XVECEXP (exp, 0, 0)) == SET) @@ -195,7 +184,8 @@ float_label (code, value) char * -movcnt_regno_adjust (rtx * op) +movcnt_regno_adjust (op) + rtx *op; { static char outstr[40]; int cntreg = REGNO (op[2]), cntreg_1750 = REGNO (op[0]) + 1; @@ -216,7 +206,9 @@ movcnt_regno_adjust (rtx * op) } char * -mod_regno_adjust (char *instr, rtx * op) +mod_regno_adjust (instr, op) + char *instr; + rtx *op; { static char outstr[40]; char *r = (!strncmp (instr, "dvr", 3) ? "r" : ""); @@ -235,7 +227,8 @@ mod_regno_adjust (char *instr, rtx * op) Check if op is a valid memory operand for 1750A arith./logic (non-move) instructions. */ int -memop_valid (register rtx op) +memop_valid (op) + rtx op; { if (GET_MODE (op) != Pmode && GET_MODE (op) != VOIDmode) return 0; @@ -267,7 +260,9 @@ memop_valid (register rtx op) /* extra predicate for recog: */ int -nonindirect_operand (register rtx op, enum machine_mode mode) +nonindirect_operand (op, mode) + rtx op; + enum machine_mode mode; { int retval; @@ -287,18 +282,47 @@ nonindirect_operand (register rtx op, en /* predicate for the STC instruction: */ int -small_nonneg_const (register rtx op, enum machine_mode mode) +small_nonneg_const (op, mode) + rtx op; + enum machine_mode mode; { if (GET_CODE (op) == CONST_INT && INTVAL (op) >= 0 && INTVAL (op) <= 15) return 1; return 0; } + +/* predicate for 1750 `B' addressing mode (Base Register with Offset) + memory operand */ +int +b_mode_operand (op) + rtx op; +{ + if (GET_CODE (op) == MEM) + { + rtx inner = XEXP (op, 0); + if (GET_CODE (inner) == PLUS) + { + rtx plus_op0 = XEXP (inner, 0); + if (GET_CODE (plus_op0) == REG && REG_OK_FOR_INDEX_P (plus_op0)) + { + rtx plus_op1 = XEXP (inner, 1); + if (GET_CODE (plus_op1) == CONST_INT + && INTVAL (plus_op1) >= 0 + && INTVAL (plus_op1) <= 255) + return 1; + } + } + } + return 0; +} + /* Decide whether to output a conditional jump as a "Jump Conditional" or as a "Branch Conditional": */ int -find_jmplbl (int labelnum) +find_jmplbl (labelnum) + int labelnum; { int i, found = 0; @@ -314,7 +338,9 @@ find_jmplbl (int labelnum) } char * -branch_or_jump (char *condition, int targetlabel_number) +branch_or_jump (condition, targetlabel_number) + char *condition; + int targetlabel_number; { static char buf[30]; int index; @@ -330,6 +356,40 @@ branch_or_jump (char *condition, int tar } +int +unsigned_comparison_operator (insn) + rtx insn; +{ + switch (GET_CODE (insn)) + { + case GEU: + case GTU: + case LEU: + case LTU: + return 1; + default: + return 0; + } +} + +int +next_cc_user_is_unsigned (insn) + rtx insn; +{ + if ( !(insn = next_cc0_user (insn))) + abort (); + else if (GET_CODE (insn) == JUMP_INSN + && GET_CODE (PATTERN (insn)) == SET + && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE) + return unsigned_comparison_operator (XEXP (SET_SRC (PATTERN (insn)), 0)); + else if (GET_CODE (insn) == INSN + && GET_CODE (PATTERN (insn)) == SET) + return unsigned_comparison_operator (SET_SRC (PATTERN (insn))); + else + abort (); +} + + /* The PRINT_OPERAND and PRINT_OPERAND_ADDRESS macros have been made functions: */ @@ -350,7 +410,12 @@ print_operand (file, x, kode) case LABEL_REF: case CONST: case MEM: - output_address (XEXP (x, 0)); + if (kode == 'Q') + fprintf (file, "r%d,%d", + REGNO (XEXP (XEXP (x, 0), 0)), + INTVAL (XEXP (XEXP (x, 0), 1))); + else + output_address (XEXP (x, 0)); break; case CONST_DOUBLE: /* { @@ -486,12 +551,18 @@ print_operand_address (file, addr) fprintf (file, "%s,r%d ; P_O_A reg + sym", XSTR (y, 0), REGNO (x)); break; + case LABEL_REF: + output_address (XEXP (y, 0)); + fprintf (file, ",r%d ; P_O_A reg + label", REGNO (x)); + break; default: fprintf (file, "[P_O_A reg%d+UFO code=%d]", REGNO (x), GET_CODE (y)); } break; case LABEL_REF: + output_address (XEXP (x, 0)); + break; case SYMBOL_REF: switch (GET_CODE (y)) { @@ -548,6 +619,9 @@ print_operand_address (file, addr) output_address (XEXP (addr, 0)); fprintf (file, " ;P_O_A const"); break; + case CODE_LABEL: + fprintf (file, "L%d", XINT (addr, 3)); + break; default: fprintf (file, " p_o_a UFO, code=%d val=0x%x", (int) GET_CODE (addr), INTVAL (addr)); @@ -555,34 +629,3 @@ print_operand_address (file, addr) } } - -/* -ASM_FILE_END(file) - FILE *file; -{ - if (datalbl_ndx >= 0) { - int i, cum_size=0; - fprintf(file,"\n\tstatic\ninit_srel\n"); - for (i = 0; i <= datalbl_ndx; i++) { - if (datalbl[i].name == NULL) - { - fprintf (stderr, "asm_file_end intern err (datalbl)\n"); - exit (0); - } - fprintf(file,"%s\t block %d\n", - datalbl[i].name,datalbl[i].size); - cum_size += datalbl[i].size; - } - fprintf(file,"\n\tinit\n"); - fprintf(file,"\tLIM R0,init_srel ;dst\n"); - fprintf(file,"\tLIM R1,%d ;cnt\n",cum_size); - fprintf(file,"\tLIM R2,K%s ;src\n",datalbl[0].name); - fprintf(file,"\tMOV R0,R2\n"); - fprintf(file,"\n\tnormal\n"); - datalbl_ndx = -1; - for (i = 0; i < DATALBL_ARRSIZ; i++) - datalbl[i].size = 0; - } - fprintf(file,"\n\tend\n"); -} - */