OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [mips/] [predicates.md] - Blame information for rev 645

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
;; Predicate definitions for MIPS.
2
;; Copyright (C) 2004, 2007 Free Software Foundation, Inc.
3
;;
4
;; This file is part of GCC.
5
;;
6
;; GCC is free software; you can redistribute it and/or modify
7
;; it under the terms of the GNU General Public License as published by
8
;; the Free Software Foundation; either version 3, or (at your option)
9
;; any later version.
10
;;
11
;; GCC is distributed in the hope that it will be useful,
12
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
;; GNU General Public License for more details.
15
;;
16
;; You should have received a copy of the GNU General Public License
17
;; along with GCC; see the file COPYING3.  If not see
18
;; .
19
 
20
(define_predicate "const_uns_arith_operand"
21
  (and (match_code "const_int")
22
       (match_test "SMALL_OPERAND_UNSIGNED (INTVAL (op))")))
23
 
24
(define_predicate "uns_arith_operand"
25
  (ior (match_operand 0 "const_uns_arith_operand")
26
       (match_operand 0 "register_operand")))
27
 
28
(define_predicate "const_arith_operand"
29
  (and (match_code "const_int")
30
       (match_test "SMALL_OPERAND (INTVAL (op))")))
31
 
32
(define_predicate "arith_operand"
33
  (ior (match_operand 0 "const_arith_operand")
34
       (match_operand 0 "register_operand")))
35
 
36
(define_predicate "const_uimm6_operand"
37
  (and (match_code "const_int")
38
       (match_test "UIMM6_OPERAND (INTVAL (op))")))
39
 
40
(define_predicate "const_imm10_operand"
41
  (and (match_code "const_int")
42
       (match_test "IMM10_OPERAND (INTVAL (op))")))
43
 
44
(define_predicate "reg_imm10_operand"
45
  (ior (match_operand 0 "const_imm10_operand")
46
       (match_operand 0 "register_operand")))
47
 
48
(define_predicate "sle_operand"
49
  (and (match_code "const_int")
50
       (match_test "SMALL_OPERAND (INTVAL (op) + 1)")))
51
 
52
(define_predicate "sleu_operand"
53
  (and (match_operand 0 "sle_operand")
54
       (match_test "INTVAL (op) + 1 != 0")))
55
 
56
(define_predicate "const_0_operand"
57
  (and (match_code "const_int,const_double,const_vector")
58
       (match_test "op == CONST0_RTX (GET_MODE (op))")))
59
 
60
(define_predicate "reg_or_0_operand"
61
  (ior (and (match_operand 0 "const_0_operand")
62
            (match_test "!TARGET_MIPS16"))
63
       (match_operand 0 "register_operand")))
64
 
65
(define_predicate "const_1_operand"
66
  (and (match_code "const_int,const_double,const_vector")
67
       (match_test "op == CONST1_RTX (GET_MODE (op))")))
68
 
69
(define_predicate "reg_or_1_operand"
70
  (ior (match_operand 0 "const_1_operand")
71
       (match_operand 0 "register_operand")))
72
 
73
;; This is used for indexing into vectors, and hence only accepts const_int.
74
(define_predicate "const_0_or_1_operand"
75
  (and (match_code "const_int")
76
       (ior (match_test "op == CONST0_RTX (GET_MODE (op))")
77
            (match_test "op == CONST1_RTX (GET_MODE (op))"))))
78
 
79
(define_predicate "fpr_operand"
80
  (and (match_code "reg")
81
       (match_test "FP_REG_P (REGNO (op))")))
82
 
83
(define_predicate "lo_operand"
84
  (and (match_code "reg")
85
       (match_test "REGNO (op) == LO_REGNUM")))
86
 
87
(define_predicate "fcc_reload_operand"
88
  (and (match_code "reg,subreg")
89
       (match_test "ST_REG_P (true_regnum (op))")))
90
 
91
(define_special_predicate "pc_or_label_operand"
92
  (match_code "pc,label_ref"))
93
 
94
(define_predicate "const_call_insn_operand"
95
  (match_code "const,symbol_ref,label_ref")
96
{
97
  enum mips_symbol_type symbol_type;
98
 
99
  if (!mips_symbolic_constant_p (op, &symbol_type))
100
    return false;
101
 
102
  switch (symbol_type)
103
    {
104
    case SYMBOL_GENERAL:
105
      /* We can only use direct calls for TARGET_ABSOLUTE_ABICALLS if we
106
         are sure that the target function does not need $25 to be live
107
         on entry.  This is true for any locally-defined function because
108
         any such function will use %hi/%lo accesses to set up $gp.  */
109
      if (TARGET_ABSOLUTE_ABICALLS
110
          && !(GET_CODE (op) == SYMBOL_REF
111
               && SYMBOL_REF_DECL (op)
112
               && !DECL_EXTERNAL (SYMBOL_REF_DECL (op))))
113
        return false;
114
 
115
      /* If -mlong-calls, force all calls to use register addressing.  Also,
116
         if this function has the long_call attribute, we must use register
117
         addressing.  */
118
      return (!TARGET_LONG_CALLS
119
              && !(GET_CODE (op) == SYMBOL_REF
120
                   && SYMBOL_REF_LONG_CALL_P (op)));
121
 
122
    case SYMBOL_GOT_GLOBAL:
123
      /* Without explicit relocs, there is no special syntax for
124
         loading the address of a call destination into a register.
125
         Using "la $25,foo; jal $25" would prevent the lazy binding
126
         of "foo", so keep the address of global symbols with the
127
         jal macro.  */
128
      return !TARGET_EXPLICIT_RELOCS;
129
 
130
    default:
131
      return false;
132
    }
133
})
134
 
135
(define_predicate "call_insn_operand"
136
  (ior (match_operand 0 "const_call_insn_operand")
137
       (match_operand 0 "register_operand")))
138
 
139
;; A legitimate CONST_INT operand that takes more than one instruction
140
;; to load.
141
(define_predicate "splittable_const_int_operand"
142
  (match_code "const_int")
143
{
144
  /* When generating mips16 code, LEGITIMATE_CONSTANT_P rejects
145
     CONST_INTs that can't be loaded using simple insns.  */
146
  if (TARGET_MIPS16)
147
    return false;
148
 
149
  /* Don't handle multi-word moves this way; we don't want to introduce
150
     the individual word-mode moves until after reload.  */
151
  if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
152
    return false;
153
 
154
  /* Otherwise check whether the constant can be loaded in a single
155
     instruction.  */
156
  return !LUI_INT (op) && !SMALL_INT (op) && !SMALL_INT_UNSIGNED (op);
157
})
158
 
159
;; A legitimate symbolic operand that takes more than one instruction
160
;; to load.
161
(define_predicate "splittable_symbolic_operand"
162
  (match_code "const,symbol_ref,label_ref")
163
{
164
  enum mips_symbol_type symbol_type;
165
  return (mips_symbolic_constant_p (op, &symbol_type)
166
          && mips_split_p[symbol_type]);
167
})
168
 
169
(define_predicate "move_operand"
170
  (match_operand 0 "general_operand")
171
{
172
  enum mips_symbol_type symbol_type;
173
 
174
  /* The thinking here is as follows:
175
 
176
     (1) The move expanders should split complex load sequences into
177
         individual instructions.  Those individual instructions can
178
         then be optimized by all rtl passes.
179
 
180
     (2) The target of pre-reload load sequences should not be used
181
         to store temporary results.  If the target register is only
182
         assigned one value, reload can rematerialize that value
183
         on demand, rather than spill it to the stack.
184
 
185
     (3) If we allowed pre-reload passes like combine and cse to recreate
186
         complex load sequences, we would want to be able to split the
187
         sequences before reload as well, so that the pre-reload scheduler
188
         can see the individual instructions.  This falls foul of (2);
189
         the splitter would be forced to reuse the target register for
190
         intermediate results.
191
 
192
     (4) We want to define complex load splitters for combine.  These
193
         splitters can request a temporary scratch register, which avoids
194
         the problem in (2).  They allow things like:
195
 
196
              (set (reg T1) (high SYM))
197
              (set (reg T2) (low (reg T1) SYM))
198
              (set (reg X) (plus (reg T2) (const_int OFFSET)))
199
 
200
         to be combined into:
201
 
202
              (set (reg T3) (high SYM+OFFSET))
203
              (set (reg X) (lo_sum (reg T3) SYM+OFFSET))
204
 
205
         if T2 is only used this once.  */
206
  switch (GET_CODE (op))
207
    {
208
    case CONST_INT:
209
      return !splittable_const_int_operand (op, mode);
210
 
211
    case CONST:
212
    case SYMBOL_REF:
213
    case LABEL_REF:
214
      if (CONST_GP_P (op))
215
        return true;
216
      return (mips_symbolic_constant_p (op, &symbol_type)
217
              && !mips_split_p[symbol_type]);
218
 
219
    default:
220
      return true;
221
    }
222
})
223
 
224
(define_predicate "consttable_operand"
225
  (match_test "CONSTANT_P (op)"))
226
 
227
(define_predicate "symbolic_operand"
228
  (match_code "const,symbol_ref,label_ref")
229
{
230
  enum mips_symbol_type type;
231
  return mips_symbolic_constant_p (op, &type);
232
})
233
 
234
(define_predicate "general_symbolic_operand"
235
  (match_code "const,symbol_ref,label_ref")
236
{
237
  enum mips_symbol_type type;
238
  return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GENERAL;
239
})
240
 
241
(define_predicate "global_got_operand"
242
  (match_code "const,symbol_ref,label_ref")
243
{
244
  enum mips_symbol_type type;
245
  return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GOT_GLOBAL;
246
})
247
 
248
(define_predicate "local_got_operand"
249
  (match_code "const,symbol_ref,label_ref")
250
{
251
  enum mips_symbol_type type;
252
  return mips_symbolic_constant_p (op, &type) && type == SYMBOL_GOT_LOCAL;
253
})
254
 
255
(define_predicate "stack_operand"
256
  (and (match_code "mem")
257
       (match_test "mips_stack_address_p (XEXP (op, 0), GET_MODE (op))")))
258
 
259
(define_predicate "macc_msac_operand"
260
  (ior (and (match_code "plus") (match_test "ISA_HAS_MACC"))
261
       (and (match_code "minus") (match_test "ISA_HAS_MSAC")))
262
{
263
  rtx mult = XEXP (op, GET_CODE (op) == PLUS ? 0 : 1);
264
  rtx accum = XEXP (op, GET_CODE (op) == PLUS ? 1 : 0);
265
  return (GET_CODE (mult) == MULT
266
          && REG_P (XEXP (mult, 0))
267
          && REG_P (XEXP (mult, 1))
268
          && REG_P (accum));
269
})
270
 
271
 
272
(define_predicate "equality_operator"
273
  (match_code "eq,ne"))
274
 
275
(define_predicate "extend_operator"
276
  (match_code "zero_extend,sign_extend"))
277
 
278
(define_predicate "trap_comparison_operator"
279
  (match_code "eq,ne,lt,ltu,ge,geu"))
280
 
281
(define_predicate "order_operator"
282
  (match_code "lt,ltu,le,leu,ge,geu,gt,gtu"))
283
 
284
 
285
(define_predicate "small_data_pattern"
286
  (and (match_code "set,parallel,unspec,unspec_volatile,prefetch")
287
       (match_test "mips_small_data_pattern_p (op)")))

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.