;; Predicate definitions for Motorola 68000.
-;; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2020 Free Software Foundation, Inc.
;;
;; This file is part of GCC.
;;
&& (INTVAL (op) >= (-0x7fffffff - 1) && INTVAL (op) <= 0x7fffffff));
})
-;; Return true if X is a valid comparison operator for the dbcc
-;; instruction. Note it rejects floating point comparison
-;; operators. (In the future we could use Fdbcc). It also rejects
-;; some comparisons when CC_NO_OVERFLOW is set.
-
-(define_predicate "valid_dbcc_comparison_p"
- (and (match_code "eq,ne,gtu,ltu,geu,leu,gt,lt,ge,le")
- (match_test "valid_dbcc_comparison_p_2 (op, mode)")))
+(define_predicate "m68k_cstore_comparison_operator"
+ (if_then_else (match_test "TARGET_68881")
+ (match_operand 0 "comparison_operator")
+ (match_operand 0 "ordered_comparison_operator")))
;; Check for sign_extend or zero_extend. Used for bit-count operands.
(match_code "sign_extend,zero_extend"))
;; Returns true if OP is either a symbol reference or a sum of a
-;; symbol reference and a constant.
+;; symbol reference and a constant. This predicate is for "raw"
+;; symbol references not yet processed by legitimize*_address,
+;; hence we do not handle UNSPEC_{XGOT, TLS, XTLS} here.
(define_predicate "symbolic_operand"
(match_code "symbol_ref,label_ref,const")
(and (match_code "mem")
(match_test "GET_CODE (XEXP (op, 0)) == PRE_DEC")))
+;; A zero constant.
+(define_predicate "const0_operand"
+ (and (match_code "const_int,const_double,const_vector")
+ (match_test "op == CONST0_RTX (mode)")))
+
+;; A one constant (operand for conditional_trap).
+(define_predicate "const1_operand"
+ (and (match_code "const_int")
+ (match_test "op == const1_rtx")))
+
+;; A valid operand for a conditional operation.
+;; ColdFire has tst patterns for HImode and QImode, but not cmp patterns.
+(define_predicate "m68k_comparison_operand"
+ (if_then_else (match_test "TARGET_COLDFIRE && mode != SImode")
+ (and (match_code "const_int")
+ (match_test "op == const0_rtx"))
+ (match_operand 0 "general_src_operand")))
+
;; An operand for movsi_const0 pattern.
(define_predicate "movsi_const0_operand"
(and (match_operand 0 "nonimmediate_operand")
;; Special case of general_src_operand, which rejects a few fp
;; constants (which we prefer in registers) before reload.
+;; Used only in comparisons, and we do want to allow zero.
(define_predicate "fp_src_operand"
(match_operand 0 "general_src_operand")
{
- return !CONSTANT_P (op)
- || (TARGET_68881
- && (!standard_68881_constant_p (op)
- || reload_in_progress
- || reload_completed));
+ return (!CONSTANT_P (op)
+ || op == CONST0_RTX (mode)
+ || (TARGET_68881
+ && (!standard_68881_constant_p (op)
+ || reload_in_progress
+ || reload_completed)));
+})
+
+;; Used to detect constants that are valid for addq/subq instructions
+(define_predicate "addq_subq_operand"
+ (match_code "const_int")
+{
+ return ((INTVAL (op) <= 8 && INTVAL (op) > 0)
+ || (INTVAL (op) >= -8 && INTVAL (op) < 0));
+})
+
+;; Used to detect equality and non-equality operators
+(define_predicate "equality_comparison_operator"
+ (match_code "eq,ne"))
+
+;; Used to detect when an operand is either a register
+;; or a constant that is all ones in its lower bits.
+;; Used by insv pattern to help detect when we're initializing
+;; a bitfield to all ones.
+
+(define_predicate "reg_or_pow2_m1_operand"
+ (match_code "reg,const_int")
+{
+ return (REG_P (op) || pow2_m1_operand (op, VOIDmode));
+})
+
+;; Used to detect a constant that is all ones in its lower bits.
+(define_predicate "pow2_m1_operand"
+ (match_code "const_int")
+{
+ return (GET_CODE (op) == CONST_INT && exact_log2 (INTVAL (op) + 1) >= 0);
})
+
+;; Used to detect valid targets for conditional branches
+;; Used to detect (pc) or (label_ref) in some jumping patterns to cut down
+(define_predicate "pc_or_label_operand"
+ (match_code "pc,label_ref"))
+
+(define_predicate "swap_peephole_relational_operator"
+ (match_code "gtu,leu,gt,le"))
+
+(define_predicate "address_reg_operand"
+ (match_test ("ADDRESS_REG_P (op)")))