Home | History | Annotate | Line # | Download | only in rl78
constraints.md revision 1.1
      1 ;;  Machine Description for Renesas RL78 processors
      2 ;;  Copyright (C) 2011-2013 Free Software Foundation, Inc.
      3 ;;  Contributed by Red Hat.
      4 
      5 ;; This file is part of GCC.
      6 
      7 ;; GCC is free software; you can redistribute it and/or modify
      8 ;; it under the terms of the GNU General Public License as published by
      9 ;; the Free Software Foundation; either version 3, or (at your option)
     10 ;; any later version.
     11 
     12 ;; GCC is distributed in the hope that it will be useful,
     13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 ;; GNU General Public License for more details.
     16 
     17 ;; You should have received a copy of the GNU General Public License
     18 ;; along with GCC; see the file COPYING3.  If not see
     19 ;; <http://www.gnu.org/licenses/>.
     20 
     22 ; Constraints in use:
     23 
     24 ; core:
     25 ; V X g i m n o p r s < >
     26 ; 0..9
     27 ; I..Q - integers
     28 ;   Int8 = 0..255
     29 ;   Int3 = 1..7
     30 ;   J = -255..0
     31 ;   K = 1
     32 ;   L = -1
     33 ;   M = 0
     34 ;   N = 2
     35 ;   O = -2
     36 ;   P = 1..15
     37 
     38 ; E..H - float constants
     39 
     40 ; RL78-specific
     41 ; a x b c d e h l w - 8-bit regs
     42 ; A B D T S - 16-bit regs
     43 ; R = all regular registers (A-L)
     44 ; Y - any valid memory
     45 ; Wxx - various memory addressing modes
     46 ; Qxx - conditionals
     47 ; v = virtual registers
     48 ; Zxx = specific virtual registers
     49 
     50 (define_constraint "Int8"
     51   "Integer constant in the range 0 @dots{} 255."
     52   (and (match_code "const_int")
     53        (match_test "IN_RANGE (ival, 0, 255)")))
     54 
     55 (define_constraint "Int3"
     56   "Integer constant in the range 1 @dots{} 7."
     57   (and (match_code "const_int")
     58        (match_test "IN_RANGE (ival, 1, 7)")))
     59 
     60 (define_constraint "J"
     61   "Integer constant in the range -255 @dots{} 0"
     62   (and (match_code "const_int")
     63        (match_test "IN_RANGE (ival, -255, 0)")))
     64 
     65 (define_constraint "K"
     66   "Integer constant 1."
     67   (and (match_code "const_int")
     68        (match_test "IN_RANGE (ival, 1, 1)")))
     69 
     70 (define_constraint "L"
     71   "Integer constant -1."
     72   (and (match_code "const_int")
     73        (match_test "IN_RANGE (ival, -1, -1)")))
     74 
     75 (define_constraint "M"
     76   "Integer constant 0."
     77   (and (match_code "const_int")
     78        (match_test "IN_RANGE (ival, 0, 0)")))
     79 
     80 (define_constraint "N"
     81   "Integer constant 2."
     82   (and (match_code "const_int")
     83        (match_test "IN_RANGE (ival, 2, 2)")))
     84 
     85 (define_constraint "O"
     86   "Integer constant -2."
     87   (and (match_code "const_int")
     88        (match_test "IN_RANGE (ival, -2, -2)")))
     89 
     90 (define_constraint "P"
     91   "Integer constant 1..15"
     92   (and (match_code "const_int")
     93        (match_test "IN_RANGE (ival, 1, 15)")))
     94 
     95 (define_register_constraint "R" "QI_REGS"
     96  "@code{A} through @code{L} registers.")
     97 
     98 (define_register_constraint "a" "AREG"
     99  "The @code{A} register.")
    100 
    101 (define_register_constraint "x" "XREG"
    102  "The @code{X} register.")
    103 
    104 (define_register_constraint "b" "BREG"
    105  "The @code{B} register.")
    106 
    107 (define_register_constraint "c" "CREG"
    108  "The @code{C} register.")
    109 
    110 (define_register_constraint "d" "DREG"
    111  "The @code{D} register.")
    112 
    113 (define_register_constraint "e" "EREG"
    114  "The @code{E} register.")
    115 
    116 (define_register_constraint "h" "HREG"
    117  "The @code{H} register.")
    118 
    119 (define_register_constraint "l" "LREG"
    120  "The @code{L} register.")
    121 
    122 (define_register_constraint "w" "PSWREG"
    123  "The @code{PSW} register.")
    124 
    125 (define_register_constraint "A" "AXREG"
    126  "The @code{AX} register.")
    127 
    128 (define_register_constraint "B" "BCREG"
    129  "The @code{BC} register.")
    130 
    131 (define_register_constraint "D" "DEREG"
    132  "The @code{DE} register.")
    133 
    134 ; because H + L = T, assuming A=1.
    135 (define_register_constraint "T" "HLREG"
    136  "The @code{HL} register.")
    137 
    138 (define_register_constraint "S" "SPREG"
    139  "The @code{SP} register.")
    140 
    141 (define_register_constraint "v" "V_REGS"
    142  "The virtual registers.")
    143 
    144 (define_register_constraint "Z08W" "R8W_REGS"
    145  "The R8 register, HImode.")
    146 
    147 (define_register_constraint "Z10W" "R10W_REGS"
    148  "The R10 register, HImode.")
    149 
    150 (define_register_constraint "Zint" "INT_REGS"
    151  "The interrupt registers.")
    152 
    153 ; All the memory addressing schemes the RL78 supports
    154 ; of the form W {register} {bytes of offset}
    155 ;          or W {register} {register}
    156 
    157 ; absolute address
    158 (define_memory_constraint "Wab"
    159   "[addr]"
    160   (and (match_code "mem")
    161        (ior (match_test "CONSTANT_P (XEXP (op, 0))")
    162 	    (match_test "GET_CODE (XEXP (op, 0)) == PLUS && GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF"))
    163 	    )
    164   )
    165 
    166 (define_memory_constraint "Wbc"
    167   "word16[BC]"
    168   (and (match_code "mem")
    169        (ior
    170 	(and (match_code "reg" "0")
    171 	     (match_test "REGNO (XEXP (op, 0)) == BC_REG"))
    172 	(and (match_code "plus" "0")
    173 	     (and (and (match_code "reg" "00")
    174 		       (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == BC_REG"))
    175 		       (match_test "uword_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
    176        )
    177   )
    178 
    179 (define_memory_constraint "Wde"
    180   "[DE]"
    181   (and (match_code "mem")
    182        (and (match_code "reg" "0")
    183 	    (match_test "REGNO (XEXP (op, 0)) == DE_REG")))
    184   )
    185 
    186 (define_memory_constraint "Wca"
    187   "[AX..HL] for calls"
    188   (and (match_code "mem")
    189        (and (match_code "reg" "0")
    190 	    (match_test "REGNO (XEXP (op, 0)) <= HL_REG")))
    191   )
    192 
    193 (define_memory_constraint "Wcv"
    194   "[AX..HL,r8-r23] for calls"
    195   (and (match_code "mem")
    196        (and (match_code "reg" "0")
    197 	    (match_test "REGNO (XEXP (op, 0)) < 24")))
    198   )
    199 
    200 (define_memory_constraint "Wd2"
    201   "word16[DE]"
    202   (and (match_code "mem")
    203        (ior
    204 	(and (match_code "reg" "0")
    205 	     (match_test "REGNO (XEXP (op, 0)) == DE_REG"))
    206 	(and (match_code "plus" "0")
    207 	     (and (and (match_code "reg" "00")
    208 		       (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == DE_REG"))
    209 		       (match_test "uword_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
    210        )
    211   )
    212 
    213 (define_memory_constraint "Whl"
    214   "[HL]"
    215   (and (match_code "mem")
    216        (and (match_code "reg" "0")
    217 	    (match_test "REGNO (XEXP (op, 0)) == HL_REG")))
    218   )
    219 
    220 (define_memory_constraint "Wh1"
    221   "byte8[HL]"
    222   (and (match_code "mem")
    223        (and (match_code "plus" "0")
    224 	    (and (and (match_code "reg" "00")
    225 		      (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == HL_REG"))
    226 		      (match_test "ubyte_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
    227   )
    228 
    229 (define_memory_constraint "Whb"
    230   "[HL+B]"
    231   (and (match_code "mem")
    232        (match_test "rl78_hl_b_c_addr_p (XEXP (op, 0))"))
    233   )
    234 
    235 (define_memory_constraint "Ws1"
    236   "word8[SP]"
    237   (and (match_code "mem")
    238        (ior
    239 	(and (match_code "reg" "0")
    240 	     (match_test "REGNO (XEXP (op, 0)) == SP_REG"))
    241 	(and (match_code "plus" "0")
    242 	     (and (and (match_code "reg" "00")
    243 		       (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == SP_REG"))
    244 		       (match_test "ubyte_operand (XEXP (XEXP (op, 0), 1), VOIDmode)"))))
    245        )
    246   )
    247 
    248 (define_memory_constraint "Wfr"
    249   "ES/CS far pointer"
    250   (and (match_code "mem")
    251        (match_test "rl78_far_p (op)"))
    252   )
    253 
    254 (define_memory_constraint "Y"
    255   "any near legitimate memory access"
    256   (and (match_code "mem")
    257        (match_test "!rl78_far_p (op) && rl78_as_legitimate_address (VOIDmode, XEXP (op, 0), true, ADDR_SPACE_GENERIC)"))
    258 )
    259 
    260 
    261 (define_memory_constraint "Qbi"
    262   "built-in compare types"
    263   (match_code "eq,ne,gtu,ltu,geu,leu"))
    264 
    265 (define_memory_constraint "Qsc"
    266   "synthetic compares"
    267   (match_code "gt,lt,ge,le"))
    268