OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [tools/] [riscv-gnu-toolchain-master/] [gcc/] [gcc/] [config/] [riscv/] [predicates.md] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
;; Predicate description for RISC-V target.
2
;; Copyright (C) 2011-2014 Free Software Foundation, Inc.
3
;; Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley.
4
;; Based on MIPS target for GNU compiler.
5
;;
6
;; This file is part of GCC.
7
;;
8
;; GCC is free software; you can redistribute it and/or modify
9
;; it under the terms of the GNU General Public License as published by
10
;; the Free Software Foundation; either version 3, or (at your option)
11
;; any later version.
12
;;
13
;; GCC is distributed in the hope that it will be useful,
14
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
;; GNU General Public License for more details.
17
;;
18
;; You should have received a copy of the GNU General Public License
19
;; along with GCC; see the file COPYING3.  If not see
20
;; .
21
 
22
(define_predicate "const_arith_operand"
23
  (and (match_code "const_int")
24
       (match_test "SMALL_OPERAND (INTVAL (op))")))
25
 
26
(define_predicate "arith_operand"
27
  (ior (match_operand 0 "const_arith_operand")
28
       (match_operand 0 "register_operand")))
29
 
30
(define_predicate "sle_operand"
31
  (and (match_code "const_int")
32
       (match_test "SMALL_OPERAND (INTVAL (op) + 1)")))
33
 
34
(define_predicate "sleu_operand"
35
  (and (match_operand 0 "sle_operand")
36
       (match_test "INTVAL (op) + 1 != 0")))
37
 
38
(define_predicate "const_0_operand"
39
  (and (match_code "const_int,const_double,const_vector")
40
       (match_test "op == CONST0_RTX (GET_MODE (op))")))
41
 
42
(define_predicate "reg_or_0_operand"
43
  (ior (match_operand 0 "const_0_operand")
44
       (match_operand 0 "register_operand")))
45
 
46
(define_predicate "const_1_operand"
47
  (and (match_code "const_int,const_double,const_vector")
48
       (match_test "op == CONST1_RTX (GET_MODE (op))")))
49
 
50
(define_predicate "reg_or_1_operand"
51
  (ior (match_operand 0 "const_1_operand")
52
       (match_operand 0 "register_operand")))
53
 
54
;; Only use branch-on-bit sequences when the mask is not an ANDI immediate.
55
(define_predicate "branch_on_bit_operand"
56
  (and (match_code "const_int")
57
       (match_test "INTVAL (op) >= IMM_BITS - 1")))
58
 
59
;; This is used for indexing into vectors, and hence only accepts const_int.
60
(define_predicate "const_0_or_1_operand"
61
  (and (match_code "const_int")
62
       (ior (match_test "op == CONST0_RTX (GET_MODE (op))")
63
            (match_test "op == CONST1_RTX (GET_MODE (op))"))))
64
 
65
(define_special_predicate "pc_or_label_operand"
66
  (match_code "pc,label_ref"))
67
 
68
;; A legitimate CONST_INT operand that takes more than one instruction
69
;; to load.
70
(define_predicate "splittable_const_int_operand"
71
  (match_code "const_int")
72
{
73
  /* Don't handle multi-word moves this way; we don't want to introduce
74
     the individual word-mode moves until after reload.  */
75
  if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
76
    return false;
77
 
78
  /* Otherwise check whether the constant can be loaded in a single
79
     instruction.  */
80
  return !LUI_INT (op) && !SMALL_INT (op);
81
})
82
 
83
(define_predicate "move_operand"
84
  (match_operand 0 "general_operand")
85
{
86
  enum riscv_symbol_type symbol_type;
87
 
88
  /* The thinking here is as follows:
89
 
90
     (1) The move expanders should split complex load sequences into
91
         individual instructions.  Those individual instructions can
92
         then be optimized by all rtl passes.
93
 
94
     (2) The target of pre-reload load sequences should not be used
95
         to store temporary results.  If the target register is only
96
         assigned one value, reload can rematerialize that value
97
         on demand, rather than spill it to the stack.
98
 
99
     (3) If we allowed pre-reload passes like combine and cse to recreate
100
         complex load sequences, we would want to be able to split the
101
         sequences before reload as well, so that the pre-reload scheduler
102
         can see the individual instructions.  This falls foul of (2);
103
         the splitter would be forced to reuse the target register for
104
         intermediate results.
105
 
106
     (4) We want to define complex load splitters for combine.  These
107
         splitters can request a temporary scratch register, which avoids
108
         the problem in (2).  They allow things like:
109
 
110
              (set (reg T1) (high SYM))
111
              (set (reg T2) (low (reg T1) SYM))
112
              (set (reg X) (plus (reg T2) (const_int OFFSET)))
113
 
114
         to be combined into:
115
 
116
              (set (reg T3) (high SYM+OFFSET))
117
              (set (reg X) (lo_sum (reg T3) SYM+OFFSET))
118
 
119
         if T2 is only used this once.  */
120
  switch (GET_CODE (op))
121
    {
122
    case CONST_INT:
123
      return !splittable_const_int_operand (op, mode);
124
 
125
    case CONST:
126
    case SYMBOL_REF:
127
    case LABEL_REF:
128
      return (riscv_symbolic_constant_p (op, &symbol_type)
129
              && !riscv_hi_relocs[symbol_type]);
130
 
131
    case HIGH:
132
      op = XEXP (op, 0);
133
      return riscv_symbolic_constant_p (op, &symbol_type);
134
 
135
    default:
136
      return true;
137
    }
138
})
139
 
140
(define_predicate "consttable_operand"
141
  (match_test "CONSTANT_P (op)"))
142
 
143
(define_predicate "symbolic_operand"
144
  (match_code "const,symbol_ref,label_ref")
145
{
146
  enum riscv_symbol_type type;
147
  return riscv_symbolic_constant_p (op, &type);
148
})
149
 
150
(define_predicate "absolute_symbolic_operand"
151
  (match_code "const,symbol_ref,label_ref")
152
{
153
  enum riscv_symbol_type type;
154
  return (riscv_symbolic_constant_p (op, &type)
155
          && type == SYMBOL_ABSOLUTE);
156
})
157
 
158
(define_predicate "plt_symbolic_operand"
159
  (match_code "const,symbol_ref,label_ref")
160
{
161
  enum riscv_symbol_type type;
162
  return (riscv_symbolic_constant_p (op, &type)
163
          && type == SYMBOL_GOT_DISP && !SYMBOL_REF_WEAK (op) && TARGET_PLT);
164
})
165
 
166
(define_predicate "call_insn_operand"
167
  (ior (match_operand 0 "absolute_symbolic_operand")
168
       (match_operand 0 "plt_symbolic_operand")
169
       (match_operand 0 "register_operand")))
170
 
171
(define_predicate "symbol_ref_operand"
172
  (match_code "symbol_ref"))
173
 
174
(define_predicate "modular_operator"
175
  (match_code "plus,minus,mult,ashift"))
176
 
177
(define_predicate "equality_operator"
178
  (match_code "eq,ne"))
179
 
180
(define_predicate "order_operator"
181
  (match_code "eq,ne,lt,ltu,le,leu,ge,geu,gt,gtu"))
182
 
183
(define_predicate "fp_order_operator"
184
  (match_code "eq,ne,lt,le,gt,ge"))

powered by: WebSVN 2.1.0

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