📄 predicates.md
字号:
;; Predicate definitions for Renesas / SuperH SH.;; Copyright (C) 2005 Free Software Foundation, Inc.;;;; This file is part of GCC.;;;; GCC is free software; you can redistribute it and/or modify;; it under the terms of the GNU General Public License as published by;; the 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 of;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the;; GNU General Public License for more details.;;;; You should have received a copy of the GNU General Public License;; along with GCC; see the file COPYING. If not, write to;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,;; Boston, MA 02110-1301, USA.;; TODO: Add a comment here.(define_predicate "trapping_target_operand" (match_code "if_then_else"){ rtx cond, mem, res, tar, and; if (GET_MODE (op) != PDImode) return 0; cond = XEXP (op, 0); mem = XEXP (op, 1); res = XEXP (op, 2); if (GET_CODE (mem) != MEM || (GET_CODE (res) != SIGN_EXTEND && GET_CODE (res) != TRUNCATE)) return 0; tar = XEXP (res, 0); if (!rtx_equal_p (XEXP (mem, 0), tar) || GET_MODE (tar) != Pmode) return 0; if (GET_CODE (cond) == CONST) { cond = XEXP (cond, 0); if (!EXTRA_CONSTRAINT_Csy (tar)) return 0; if (GET_CODE (tar) == CONST) tar = XEXP (tar, 0); } else if (!arith_reg_operand (tar, VOIDmode) && ! EXTRA_CONSTRAINT_Csy (tar)) return 0; if (GET_CODE (cond) != EQ) return 0; and = XEXP (cond, 0); return (GET_CODE (and) == AND && rtx_equal_p (XEXP (and, 0), tar) && GET_CODE (XEXP (and, 1)) == CONST_INT && GET_CODE (XEXP (cond, 1)) == CONST_INT && INTVAL (XEXP (and, 1)) == 3 && INTVAL (XEXP (cond, 1)) == 3);});; TODO: Add a comment here.(define_predicate "and_operand" (match_code "subreg,reg,const_int"){ if (logical_operand (op, mode)) return 1; /* Check mshflo.l / mshflhi.l opportunities. */ if (TARGET_SHMEDIA && mode == DImode && GET_CODE (op) == CONST_INT && CONST_OK_FOR_J16 (INTVAL (op))) return 1; return 0;});; Like arith_reg_dest, but this predicate is defined with;; define_special_predicate, not define_predicate.(define_special_predicate "any_arith_reg_dest" (match_code "subreg,reg"){ return arith_reg_dest (op, mode);});; Like register_operand, but this predicate is defined with;; define_special_predicate, not define_predicate.(define_special_predicate "any_register_operand" (match_code "subreg,reg"){ return register_operand (op, mode);});; Returns 1 if OP is a valid source operand for an arithmetic insn.(define_predicate "arith_operand" (match_code "subreg,reg,const_int,truncate"){ if (arith_reg_operand (op, mode)) return 1; if (TARGET_SHMEDIA) { /* FIXME: We should be checking whether the CONST_INT fits in a CONST_OK_FOR_I16 here, but this causes reload_cse to crash when attempting to transform a sequence of two 64-bit sets of the same register from literal constants into a set and an add, when the difference is too wide for an add. */ if (GET_CODE (op) == CONST_INT || EXTRA_CONSTRAINT_C16 (op)) return 1; else if (GET_CODE (op) == TRUNCATE && ! system_reg_operand (XEXP (op, 0), VOIDmode) && (mode == VOIDmode || mode == GET_MODE (op)) && (GET_MODE_SIZE (GET_MODE (op)) < GET_MODE_SIZE (GET_MODE (XEXP (op, 0)))) && (! FP_REGISTER_P (REGNO (XEXP (op, 0))) || GET_MODE_SIZE (GET_MODE (op)) == 4)) return register_operand (XEXP (op, 0), VOIDmode); else return 0; } else if (GET_CODE (op) == CONST_INT && CONST_OK_FOR_I08 (INTVAL (op))) return 1; return 0;});; Like above, but for DImode destinations: forbid paradoxical DImode;; subregs, because this would lead to missing sign extensions when;; truncating from DImode to SImode.(define_predicate "arith_reg_dest" (match_code "subreg,reg"){ if (mode == DImode && GET_CODE (op) == SUBREG && GET_MODE_SIZE (GET_MODE (SUBREG_REG (op))) < 8 && TARGET_SHMEDIA) return 0; return arith_reg_operand (op, mode);});; Returns 1 if OP is a normal arithmetic register.(define_predicate "arith_reg_operand" (match_code "subreg,reg,sign_extend"){ if (register_operand (op, mode)) { int regno; if (GET_CODE (op) == REG) regno = REGNO (op); else if (GET_CODE (op) == SUBREG && GET_CODE (SUBREG_REG (op)) == REG) regno = REGNO (SUBREG_REG (op)); else return 1; return (regno != T_REG && regno != PR_REG && ! TARGET_REGISTER_P (regno) && (regno != FPUL_REG || TARGET_SH4) && regno != MACH_REG && regno != MACL_REG); } /* Allow a no-op sign extension - compare LOAD_EXTEND_OP. We allow SImode here, as not using an FP register is just a matter of proper register allocation. */ if (TARGET_SHMEDIA && GET_MODE (op) == DImode && GET_CODE (op) == SIGN_EXTEND && GET_MODE (XEXP (op, 0)) == SImode && GET_CODE (XEXP (op, 0)) != SUBREG) return register_operand (XEXP (op, 0), VOIDmode);#if 0 /* Can't do this because of PROMOTE_MODE for unsigned vars. */ if (GET_MODE (op) == SImode && GET_CODE (op) == SIGN_EXTEND && GET_MODE (XEXP (op, 0)) == HImode && GET_CODE (XEXP (op, 0)) == REG && REGNO (XEXP (op, 0)) <= LAST_GENERAL_REG) return register_operand (XEXP (op, 0), VOIDmode);#endif if (GET_MODE_CLASS (GET_MODE (op)) == MODE_VECTOR_INT && GET_CODE (op) == SUBREG && GET_MODE (SUBREG_REG (op)) == DImode && GET_CODE (SUBREG_REG (op)) == SIGN_EXTEND && GET_MODE (XEXP (SUBREG_REG (op), 0)) == SImode && GET_CODE (XEXP (SUBREG_REG (op), 0)) != SUBREG) return register_operand (XEXP (SUBREG_REG (op), 0), VOIDmode); return 0;});; Returns 1 if OP is a valid source operand for a compare insn.(define_predicate "arith_reg_or_0_operand" (match_code "subreg,reg,const_int,const_vector"){ if (arith_reg_operand (op, mode)) return 1; if (EXTRA_CONSTRAINT_Z (op)) return 1; return 0;});; TODO: Add a comment here.(define_predicate "binary_float_operator" (match_code "plus,minus,mult,div"){ if (GET_MODE (op) != mode) return 0; switch (GET_CODE (op)) { case PLUS: case MINUS: case MULT: case DIV: return 1; default: break; } return 0;});; TODO: Add a comment here.(define_predicate "binary_logical_operator" (match_code "and,ior,xor"){ if (GET_MODE (op) != mode) return 0; switch (GET_CODE (op)) { case IOR: case AND: case XOR: return 1; default: break; } return 0;});; TODO: Add a comment here.(define_predicate "cache_address_operand" (match_code "plus,reg"){ if (GET_CODE (op) == PLUS) { if (GET_CODE (XEXP (op, 0)) != REG) return 0; if (GET_CODE (XEXP (op, 1)) != CONST_INT || (INTVAL (XEXP (op, 1)) & 31)) return 0; } else if (GET_CODE (op) != REG) return 0; return address_operand (op, mode);});; Return 1 if OP is a valid source operand for shmedia cmpgt / cmpgtu.(define_predicate "cmp_operand" (match_code "subreg,reg,const_int"){ if (GET_CODE (op) == CONST_INT && CONST_OK_FOR_N (INTVAL (op))) return 1; if (TARGET_SHMEDIA && mode != DImode && GET_CODE (op) == SUBREG && GET_MODE_SIZE (GET_MODE (SUBREG_REG (op))) > 4) return 0; return arith_reg_operand (op, mode);});; TODO: Add a comment here.(define_predicate "cmpsi_operand" (match_code "subreg,reg,const_int"){ if (GET_CODE (op) == REG && REGNO (op) == T_REG && GET_MODE (op) == SImode && TARGET_SH1) return 1; return arith_operand (op, mode);});; TODO: Add a comment here.(define_predicate "commutative_float_operator" (match_code "plus,mult"){ if (GET_MODE (op) != mode) return 0; switch (GET_CODE (op)) { case PLUS: case MULT: return 1; default: break; } return 0;});; TODO: Add a comment here.(define_predicate "equality_comparison_operator" (match_code "eq,ne"){ return ((mode == VOIDmode || GET_MODE (op) == mode) && (GET_CODE (op) == EQ || GET_CODE (op) == NE));});; TODO: Add a comment here.(define_predicate "extend_reg_operand" (match_code "subreg,reg,truncate"){ return (GET_CODE (op) == TRUNCATE ? arith_operand : arith_reg_operand) (op, mode);});; TODO: Add a comment here.(define_predicate "extend_reg_or_0_operand" (match_code "subreg,reg,truncate,const_int"){ return (GET_CODE (op) == TRUNCATE ? arith_operand : arith_reg_or_0_operand) (op, mode);});; Like arith_reg_operand, but this predicate does not accept SIGN_EXTEND.(define_predicate "ext_dest_operand" (match_code "subreg,reg"){ return arith_reg_operand (op, mode);});; TODO: Add a comment here.(define_predicate "fp_arith_reg_dest" (match_code "subreg,reg"){ if (mode == DImode && GET_CODE (op) == SUBREG && GET_MODE_SIZE (GET_MODE (SUBREG_REG (op))) < 8) return 0; return fp_arith_reg_operand (op, mode);});; TODO: Add a comment here.(define_predicate "fp_arith_reg_operand" (match_code "subreg,reg"){ if (register_operand (op, mode)) { int regno; if (GET_CODE (op) == REG) regno = REGNO (op); else if (GET_CODE (op) == SUBREG && GET_CODE (SUBREG_REG (op)) == REG) regno = REGNO (SUBREG_REG (op)); else return 1; return (regno >= FIRST_PSEUDO_REGISTER || FP_REGISTER_P (regno)); } return 0;});; TODO: Add a comment here.(define_predicate "fpscr_operand" (match_code "reg"){ return (GET_CODE (op) == REG && (REGNO (op) == FPSCR_REG || (REGNO (op) >= FIRST_PSEUDO_REGISTER && !(reload_in_progress || reload_completed))) && GET_MODE (op) == PSImode);});; TODO: Add a comment here.(define_predicate "fpul_operand" (match_code "reg"){ if (TARGET_SHMEDIA) return fp_arith_reg_operand (op, mode); return (GET_CODE (op) == REG && (REGNO (op) == FPUL_REG || REGNO (op) >= FIRST_PSEUDO_REGISTER) && GET_MODE (op) == mode);});; TODO: Add a comment here.(define_predicate "general_extend_operand" (match_code "subreg,reg,mem,truncate"){ return (GET_CODE (op) == TRUNCATE ? arith_operand : nonimmediate_operand) (op, mode);});; Returns 1 if OP can be source of a simple move operation. Same as;; general_operand, but a LABEL_REF is valid, PRE_DEC is invalid as;; are subregs of system registers.(define_predicate "general_movsrc_operand" (match_code "subreg,reg,const_int,const_double,mem,symbol_ref,label_ref,const,const_vector"){ if (GET_CODE (op) == MEM) { rtx inside = XEXP (op, 0); if (GET_CODE (inside) == CONST) inside = XEXP (inside, 0); if (GET_CODE (inside) == LABEL_REF) return 1; if (GET_CODE (inside) == PLUS && GET_CODE (XEXP (inside, 0)) == LABEL_REF && GET_CODE (XEXP (inside, 1)) == CONST_INT) return 1; /* Only post inc allowed. */ if (GET_CODE (inside) == PRE_DEC) return 0; } if ((mode == QImode || mode == HImode) && (GET_CODE (op) == SUBREG && GET_CODE (XEXP (op, 0)) == REG && system_reg_operand (XEXP (op, 0), mode))) return 0; if (TARGET_SHMEDIA && (GET_CODE (op) == PARALLEL || GET_CODE (op) == CONST_VECTOR) && sh_rep_vec (op, mode)) return 1; if (TARGET_SHMEDIA && 1 && GET_CODE (op) == SUBREG && GET_MODE (op) == mode && SUBREG_REG (op) == const0_rtx && subreg_lowpart_p (op)) /* FIXME */ abort (); /* return 1; */ return general_operand (op, mode);});; Returns 1 if OP can be a destination of a move. Same as;; general_operand, but no preinc allowed.(define_predicate "general_movdst_operand" (match_code "subreg,reg,mem")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -