OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [sparc/] [predicates.md] - Blame information for rev 801

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

Line No. Rev Author Line
1 709 jeremybenn
;; Predicate definitions for SPARC.
2
;; Copyright (C) 2005, 2007, 2008, 2010, 2012 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
;; Predicates for numerical constants.
21
 
22
;; Return true if OP is the zero constant for MODE.
23
(define_predicate "const_zero_operand"
24
  (and (match_code "const_int,const_double,const_vector")
25
       (match_test "op == CONST0_RTX (mode)")))
26
 
27
;; Return true if the integer representation of OP is
28
;; all-ones.
29
(define_predicate "const_all_ones_operand"
30
  (match_code "const_int,const_double,const_vector")
31
{
32
  if (GET_CODE (op) == CONST_INT && INTVAL (op) == -1)
33
    return true;
34
#if HOST_BITS_PER_WIDE_INT == 32
35
  if (GET_CODE (op) == CONST_DOUBLE
36
      && GET_MODE (op) == VOIDmode
37
      && CONST_DOUBLE_HIGH (op) == ~(HOST_WIDE_INT)0
38
      && CONST_DOUBLE_LOW (op) == ~(HOST_WIDE_INT)0)
39
    return true;
40
#endif
41
  if (GET_CODE (op) == CONST_VECTOR)
42
    {
43
      int i, num_elem = CONST_VECTOR_NUNITS (op);
44
 
45
      for (i = 0; i < num_elem; i++)
46
        {
47
          rtx n = CONST_VECTOR_ELT (op, i);
48
          if (! const_all_ones_operand (n, mode))
49
            return false;
50
        }
51
      return true;
52
    }
53
  return false;
54
})
55
 
56
;; Return true if OP is the integer constant 4096.
57
(define_predicate "const_4096_operand"
58
  (and (match_code "const_int")
59
       (match_test "INTVAL (op) == 4096")))
60
 
61
;; Return true if OP is a constant that is representable by a 13-bit
62
;; signed field.  This is an acceptable immediate operand for most
63
;; 3-address instructions.
64
(define_predicate "small_int_operand"
65
  (and (match_code "const_int")
66
       (match_test "SPARC_SIMM13_P (INTVAL (op))")))
67
 
68
;; Return true if OP is a constant operand for the umul instruction.  That
69
;; instruction sign-extends immediate values just like all other SPARC
70
;; instructions, but interprets the extended result as an unsigned number.
71
(define_predicate "uns_small_int_operand"
72
  (match_code "const_int,const_double")
73
{
74
#if HOST_BITS_PER_WIDE_INT == 32
75
  return ((GET_CODE (op) == CONST_INT && (unsigned) INTVAL (op) < 0x1000)
76
          || (GET_CODE (op) == CONST_DOUBLE
77
              && CONST_DOUBLE_HIGH (op) == 0
78
              && (unsigned) CONST_DOUBLE_LOW (op) - 0xFFFFF000 < 0x1000));
79
#else
80
  return (GET_CODE (op) == CONST_INT
81
          && ((INTVAL (op) >= 0 && INTVAL (op) < 0x1000)
82
              || (INTVAL (op) >= 0xFFFFF000
83
                  && INTVAL (op) <= 0xFFFFFFFF)));
84
#endif
85
})
86
 
87
;; Return true if OP is a constant that can be loaded by the sethi instruction.
88
;; The first test avoids emitting sethi to load zero for example.
89
(define_predicate "const_high_operand"
90
  (and (match_code "const_int")
91
       (and (not (match_operand 0 "small_int_operand"))
92
            (match_test "SPARC_SETHI_P (INTVAL (op) & GET_MODE_MASK (mode))"))))
93
 
94
;; Return true if OP is a constant whose 1's complement can be loaded by the
95
;; sethi instruction.
96
(define_predicate "const_compl_high_operand"
97
  (and (match_code "const_int")
98
       (and (not (match_operand 0 "small_int_operand"))
99
            (match_test "SPARC_SETHI_P (~INTVAL (op) & GET_MODE_MASK (mode))"))))
100
 
101
;; Return true if OP is a FP constant that needs to be loaded by the sethi/losum
102
;; pair of instructions.
103
(define_predicate "fp_const_high_losum_operand"
104
  (match_operand 0 "const_double_operand")
105
{
106
  gcc_assert (mode == SFmode);
107
  return fp_high_losum_p (op);
108
})
109
 
110
;; Return true if OP is a const_double or const_vector.
111
(define_predicate "const_double_or_vector_operand"
112
  (match_code "const_double,const_vector"))
113
 
114
;; Return true if OP is Zero, or if the target is V7.
115
(define_predicate "zero_or_v7_operand"
116
  (and (match_code "const_int")
117
       (ior (match_test "INTVAL (op) == 0")
118
            (match_test "!TARGET_V8 && !TARGET_V9"))))
119
 
120
;; Predicates for symbolic constants.
121
 
122
;; Return true if OP is either a symbol reference or a sum of a symbol
123
;; reference and a constant.
124
(define_predicate "symbolic_operand"
125
  (match_code "symbol_ref,label_ref,const")
126
{
127
  enum machine_mode omode = GET_MODE (op);
128
 
129
  if (omode != mode && omode != VOIDmode && mode != VOIDmode)
130
    return false;
131
 
132
  switch (GET_CODE (op))
133
    {
134
    case SYMBOL_REF:
135
      return !SYMBOL_REF_TLS_MODEL (op);
136
 
137
    case LABEL_REF:
138
      return true;
139
 
140
    case CONST:
141
      op = XEXP (op, 0);
142
      return (((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
143
                && !SYMBOL_REF_TLS_MODEL (XEXP (op, 0)))
144
               || GET_CODE (XEXP (op, 0)) == LABEL_REF)
145
              && GET_CODE (XEXP (op, 1)) == CONST_INT);
146
 
147
    default:
148
      gcc_unreachable ();
149
    }
150
})
151
 
152
;; Return true if OP is a symbolic operand for the TLS Global Dynamic model.
153
(define_predicate "tgd_symbolic_operand"
154
  (and (match_code "symbol_ref")
155
       (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC")))
156
 
157
;; Return true if OP is a symbolic operand for the TLS Local Dynamic model.
158
(define_predicate "tld_symbolic_operand"
159
  (and (match_code "symbol_ref")
160
       (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC")))
161
 
162
;; Return true if OP is a symbolic operand for the TLS Initial Exec model.
163
(define_predicate "tie_symbolic_operand"
164
  (and (match_code "symbol_ref")
165
       (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC")))
166
 
167
;; Return true if OP is a symbolic operand for the TLS Local Exec model.
168
(define_predicate "tle_symbolic_operand"
169
  (and (match_code "symbol_ref")
170
       (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))
171
 
172
;; Return true if the operand is an argument used in generating PIC references
173
;; in either the medium/low or embedded medium/anywhere code models on V9.
174
;; Check for (const (minus (symbol_ref:GOT)
175
;;                         (const (minus (label) (pc)))))
176
(define_predicate "medium_pic_operand"
177
  (match_code "const")
178
{
179
  /* Check for (const (minus (symbol_ref:GOT)
180
                             (const (minus (label) (pc))))).  */
181
  op = XEXP (op, 0);
182
  return GET_CODE (op) == MINUS
183
         && GET_CODE (XEXP (op, 0)) == SYMBOL_REF
184
         && GET_CODE (XEXP (op, 1)) == CONST
185
         && GET_CODE (XEXP (XEXP (op, 1), 0)) == MINUS;
186
})
187
 
188
;; Return true if OP is a LABEL_REF of mode MODE.
189
(define_predicate "label_ref_operand"
190
  (and (match_code "label_ref")
191
       (match_test "GET_MODE (op) == mode")))
192
 
193
;; Return true if OP is a data segment reference.  This includes the readonly
194
;; data segment or, in other words, anything but the text segment.
195
;; This is needed in the embedded medium/anywhere code model on V9.  These
196
;; values are accessed with EMBMEDANY_BASE_REG.  */
197
(define_predicate "data_segment_operand"
198
  (match_code "symbol_ref,plus,const")
199
{
200
  switch (GET_CODE (op))
201
    {
202
    case SYMBOL_REF :
203
      return ! SYMBOL_REF_FUNCTION_P (op);
204
    case PLUS :
205
      /* Assume canonical format of symbol + constant.
206
         Fall through.  */
207
    case CONST :
208
      return data_segment_operand (XEXP (op, 0), VOIDmode);
209
    default :
210
      gcc_unreachable ();
211
    }
212
})
213
 
214
;; Return true if OP is a text segment reference.
215
;; This is needed in the embedded medium/anywhere code model on V9.
216
(define_predicate "text_segment_operand"
217
  (match_code "label_ref,symbol_ref,plus,const")
218
{
219
  switch (GET_CODE (op))
220
    {
221
    case LABEL_REF :
222
      return true;
223
    case SYMBOL_REF :
224
      return SYMBOL_REF_FUNCTION_P (op);
225
    case PLUS :
226
      /* Assume canonical format of symbol + constant.
227
         Fall through.  */
228
    case CONST :
229
      return text_segment_operand (XEXP (op, 0), VOIDmode);
230
    default :
231
      gcc_unreachable ();
232
    }
233
})
234
 
235
 
236
;; Predicates for registers.
237
 
238
;; Return true if OP is either the zero constant or a register.
239
(define_predicate "register_or_zero_operand"
240
  (ior (match_operand 0 "register_operand")
241
       (match_operand 0 "const_zero_operand")))
242
 
243
(define_predicate "register_or_v9_zero_operand"
244
  (ior (match_operand 0 "register_operand")
245
       (and (match_test "TARGET_V9")
246
            (match_operand 0 "const_zero_operand"))))
247
 
248
;; Return true if OP is either the zero constant, the all-ones
249
;; constant, or a register.
250
(define_predicate "register_or_zero_or_all_ones_operand"
251
  (ior (match_operand 0 "register_or_zero_operand")
252
       (match_operand 0 "const_all_ones_operand")))
253
 
254
;; Return true if OP is a register operand in a floating point register.
255
(define_predicate "fp_register_operand"
256
  (match_operand 0 "register_operand")
257
{
258
  if (GET_CODE (op) == SUBREG)
259
    op = SUBREG_REG (op); /* Possibly a MEM */
260
  return REG_P (op) && SPARC_FP_REG_P (REGNO (op));
261
})
262
 
263
;; Return true if OP is an integer register.
264
(define_special_predicate "int_register_operand"
265
  (ior (match_test "register_operand (op, SImode)")
266
       (match_test "TARGET_ARCH64 && register_operand (op, DImode)")))
267
 
268
;; Return true if OP is a floating point condition code register.
269
(define_predicate "fcc_register_operand"
270
  (match_code "reg")
271
{
272
  if (mode != VOIDmode && mode != GET_MODE (op))
273
    return false;
274
  if (mode == VOIDmode
275
      && (GET_MODE (op) != CCFPmode && GET_MODE (op) != CCFPEmode))
276
    return false;
277
 
278
#if 0 /* ??? 1 when %fcc0-3 are pseudos first.  See gen_compare_reg().  */
279
  if (reg_renumber == 0)
280
    return REGNO (op) >= FIRST_PSEUDO_REGISTER;
281
  return REGNO_OK_FOR_CCFP_P (REGNO (op));
282
#else
283
  return ((unsigned) REGNO (op) - SPARC_FIRST_V9_FCC_REG) < 4;
284
#endif
285
})
286
 
287
;; Return true if OP is the floating point condition code register fcc0.
288
(define_predicate "fcc0_register_operand"
289
  (match_code "reg")
290
{
291
  if (mode != VOIDmode && mode != GET_MODE (op))
292
    return false;
293
  if (mode == VOIDmode
294
      && (GET_MODE (op) != CCFPmode && GET_MODE (op) != CCFPEmode))
295
    return false;
296
 
297
  return REGNO (op) == SPARC_FCC_REG;
298
})
299
 
300
;; Return true if OP is an integer or floating point condition code register.
301
(define_predicate "icc_or_fcc_register_operand"
302
  (match_code "reg")
303
{
304
  if (REGNO (op) == SPARC_ICC_REG)
305
    {
306
      if (mode != VOIDmode && mode != GET_MODE (op))
307
        return false;
308
      if (mode == VOIDmode
309
          && GET_MODE (op) != CCmode && GET_MODE (op) != CCXmode)
310
        return false;
311
 
312
      return true;
313
    }
314
 
315
  return fcc_register_operand (op, mode);
316
})
317
 
318
 
319
;; Predicates for arithmetic instructions.
320
 
321
;; Return true if OP is a register, or is a constant that is representable
322
;; by a 13-bit signed field.  This is an acceptable operand for most
323
;; 3-address instructions.
324
(define_predicate "arith_operand"
325
  (ior (match_operand 0 "register_operand")
326
       (match_operand 0 "small_int_operand")))
327
 
328
;; 64-bit: Same as above.
329
;; 32-bit: Return true if OP is a register, or is a constant that is
330
;; representable by a couple of 13-bit signed fields.  This is an
331
;; acceptable operand for most 3-address splitters.
332
(define_predicate "arith_double_operand"
333
  (match_code "const_int,const_double,reg,subreg")
334
{
335
  bool arith_simple_operand = arith_operand (op, mode);
336
  HOST_WIDE_INT m1, m2;
337
 
338
  if (TARGET_ARCH64 || arith_simple_operand)
339
    return arith_simple_operand;
340
 
341
#if HOST_BITS_PER_WIDE_INT == 32
342
  if (GET_CODE (op) != CONST_DOUBLE)
343
    return false;
344
  m1 = CONST_DOUBLE_LOW (op);
345
  m2 = CONST_DOUBLE_HIGH (op);
346
#else
347
  if (GET_CODE (op) != CONST_INT)
348
    return false;
349
  m1 = trunc_int_for_mode (INTVAL (op), SImode);
350
  m2 = trunc_int_for_mode (INTVAL (op) >> 32, SImode);
351
#endif
352
 
353
  return SPARC_SIMM13_P (m1) && SPARC_SIMM13_P (m2);
354
})
355
 
356
;; Return true if OP is suitable as second operand for add/sub.
357
(define_predicate "arith_add_operand"
358
  (ior (match_operand 0 "arith_operand")
359
       (match_operand 0 "const_4096_operand")))
360
 
361
;; Return true if OP is suitable as second double operand for add/sub.
362
(define_predicate "arith_double_add_operand"
363
  (match_code "const_int,const_double,reg,subreg")
364
{
365
  bool _arith_double_operand = arith_double_operand (op, mode);
366
 
367
  if (_arith_double_operand)
368
    return true;
369
 
370
  return TARGET_ARCH64 && const_4096_operand (op, mode);
371
})
372
 
373
;; Return true if OP is a register, or is a CONST_INT that can fit in a
374
;; signed 10-bit immediate field.  This is an acceptable SImode operand for
375
;; the movrcc instructions.
376
(define_predicate "arith10_operand"
377
  (ior (match_operand 0 "register_operand")
378
       (and (match_code "const_int")
379
            (match_test "SPARC_SIMM10_P (INTVAL (op))"))))
380
 
381
;; Return true if OP is a register, or is a CONST_INT that can fit in a
382
;; signed 11-bit immediate field.  This is an acceptable SImode operand for
383
;; the movcc instructions.
384
(define_predicate "arith11_operand"
385
  (ior (match_operand 0 "register_operand")
386
       (and (match_code "const_int")
387
            (match_test "SPARC_SIMM11_P (INTVAL (op))"))))
388
 
389
;; Return true if OP is a register or a constant for the umul instruction.
390
(define_predicate "uns_arith_operand"
391
  (ior (match_operand 0 "register_operand")
392
       (match_operand 0 "uns_small_int_operand")))
393
 
394
 
395
;; Predicates for miscellaneous instructions.
396
 
397
;; Return true if OP is valid for the lhs of a comparison insn.
398
(define_predicate "compare_operand"
399
  (match_code "reg,subreg,zero_extract")
400
{
401
  if (GET_CODE (op) == ZERO_EXTRACT)
402
    return (register_operand (XEXP (op, 0), mode)
403
            && small_int_operand (XEXP (op, 1), mode)
404
            && small_int_operand (XEXP (op, 2), mode)
405
            /* This matches cmp_zero_extract.  */
406
            && ((mode == SImode
407
                 && INTVAL (XEXP (op, 2)) > 19)
408
                /* This matches cmp_zero_extract_sp64.  */
409
                || (TARGET_ARCH64
410
                    && mode == DImode
411
                    && INTVAL (XEXP (op, 2)) > 51)));
412
  else
413
    return register_operand (op, mode);
414
})
415
 
416
;; Return true if OP is a valid operand for the source of a move insn.
417
(define_predicate "input_operand"
418
  (match_code "const_int,const_double,const_vector,reg,subreg,mem")
419
{
420
  enum mode_class mclass;
421
 
422
  /* If both modes are non-void they must be the same.  */
423
  if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op))
424
    return false;
425
 
426
  mclass = GET_MODE_CLASS (mode);
427
 
428
  /* Allow any 1-instruction integer constant.  */
429
  if (mclass == MODE_INT
430
      && (small_int_operand (op, mode) || const_high_operand (op, mode)))
431
    return true;
432
 
433
  /* If 32-bit mode and this is a DImode constant, allow it
434
     so that the splits can be generated.  */
435
  if (TARGET_ARCH32
436
      && mode == DImode
437
      && (GET_CODE (op) == CONST_DOUBLE || GET_CODE (op) == CONST_INT))
438
    return true;
439
 
440
  if (mclass == MODE_FLOAT && GET_CODE (op) == CONST_DOUBLE)
441
    return true;
442
 
443
  if (mclass == MODE_VECTOR_INT && GET_CODE (op) == CONST_VECTOR
444
      && (const_zero_operand (op, mode)
445
          || const_all_ones_operand (op, mode)))
446
    return true;
447
 
448
  if (register_operand (op, mode))
449
    return true;
450
 
451
  /* If this is a SUBREG, look inside so that we handle paradoxical ones.  */
452
  if (GET_CODE (op) == SUBREG)
453
    op = SUBREG_REG (op);
454
 
455
  /* Check for valid MEM forms.  */
456
  if (GET_CODE (op) == MEM)
457
    return memory_address_p (mode, XEXP (op, 0));
458
 
459
  return false;
460
})
461
 
462
;; Return true if OP is an address suitable for a call insn.
463
;; Call insn on SPARC can take a PC-relative constant address
464
;; or any regular memory address.
465
(define_predicate "call_address_operand"
466
  (ior (match_operand 0 "symbolic_operand")
467
       (match_test "memory_address_p (Pmode, op)")))
468
 
469
;; Return true if OP is an operand suitable for a call insn.
470
(define_predicate "call_operand"
471
  (and (match_code "mem")
472
       (match_test "call_address_operand (XEXP (op, 0), mode)")))
473
 
474
 
475
(define_predicate "mem_noofs_operand"
476
  (and (match_code "mem")
477
       (match_code "reg" "0")))
478
 
479
;; Predicates for operators.
480
 
481
;; Return true if OP is a comparison operator.  This allows the use of
482
;; MATCH_OPERATOR to recognize all the branch insns.
483
(define_predicate "noov_compare_operator"
484
  (match_code "ne,eq,ge,gt,le,lt,geu,gtu,leu,ltu")
485
{
486
  enum rtx_code code = GET_CODE (op);
487
  if (GET_MODE (XEXP (op, 0)) == CC_NOOVmode
488
      || GET_MODE (XEXP (op, 0)) == CCX_NOOVmode)
489
    /* These are the only branches which work with CC_NOOVmode.  */
490
    return (code == EQ || code == NE || code == GE || code == LT);
491
  return true;
492
})
493
 
494
;; Return true if OP is a 64-bit comparison operator.  This allows the use of
495
;; MATCH_OPERATOR to recognize all the branch insns.
496
(define_predicate "noov_compare64_operator"
497
  (and (match_code "ne,eq,ge,gt,le,lt,geu,gtu,leu,ltu")
498
       (match_test "TARGET_V9"))
499
{
500
  enum rtx_code code = GET_CODE (op);
501
  if (GET_MODE (XEXP (op, 0)) == CCX_NOOVmode)
502
    /* These are the only branches which work with CCX_NOOVmode.  */
503
    return (code == EQ || code == NE || code == GE || code == LT);
504
  return (GET_MODE (XEXP (op, 0)) == CCXmode);
505
})
506
 
507
;; Return true if OP is a comparison operator suitable for use in V9
508
;; conditional move or branch on register contents instructions.
509
(define_predicate "v9_register_compare_operator"
510
  (match_code "eq,ne,ge,lt,le,gt"))
511
 
512
;; Return true if OP is an operator which can set the condition codes
513
;; explicitly.  We do not include PLUS and MINUS because these
514
;; require CC_NOOVmode, which we handle explicitly.
515
(define_predicate "cc_arith_operator"
516
  (match_code "and,ior,xor"))
517
 
518
;; Return true if OP is an operator which can bitwise complement its
519
;; second operand and set the condition codes explicitly.
520
;; XOR is not here because combine canonicalizes (xor (not ...) ...)
521
;; and (xor ... (not ...)) to (not (xor ...)).  */
522
(define_predicate "cc_arith_not_operator"
523
  (match_code "and,ior"))

powered by: WebSVN 2.1.0

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