Home | History | Annotate | Line # | Download | only in rl78
      1   1.1  mrg ;;  Machine Description for Renesas RL78 processors
      2  1.11  mrg ;;  Copyright (C) 2011-2022 Free Software Foundation, Inc.
      3   1.1  mrg ;;  Contributed by Red Hat.
      4   1.1  mrg 
      5   1.1  mrg ;; This file is part of GCC.
      6   1.1  mrg 
      7   1.1  mrg ;; GCC is free software; you can redistribute it and/or modify
      8   1.1  mrg ;; it under the terms of the GNU General Public License as published by
      9   1.1  mrg ;; the Free Software Foundation; either version 3, or (at your option)
     10   1.1  mrg ;; any later version.
     11   1.1  mrg 
     12   1.1  mrg ;; GCC is distributed in the hope that it will be useful,
     13   1.1  mrg ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     14   1.1  mrg ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15   1.1  mrg ;; GNU General Public License for more details.
     16   1.1  mrg 
     17   1.1  mrg ;; You should have received a copy of the GNU General Public License
     18   1.1  mrg ;; along with GCC; see the file COPYING3.  If not see
     19   1.1  mrg ;; <http://www.gnu.org/licenses/>.
     20   1.1  mrg 
     22   1.1  mrg ;;---------- Moving ------------------------
     23   1.1  mrg 
     24   1.1  mrg (define_expand "movqi"
     25   1.1  mrg   [(set (match_operand:QI 0 "nonimmediate_operand")
     26   1.1  mrg 	(match_operand:QI 1 "general_operand"))]
     27   1.1  mrg   ""
     28   1.3  mrg   {
     29   1.3  mrg     if (MEM_P (operands[0]) && MEM_P (operands[1]))
     30   1.3  mrg       operands[1] = copy_to_mode_reg (QImode, operands[1]);
     31   1.3  mrg     if (rl78_far_p (operands[0]) && rl78_far_p (operands[1]))
     32   1.3  mrg       operands[1] = copy_to_mode_reg (QImode, operands[1]);
     33   1.3  mrg 
     34   1.3  mrg     /* GCC can generate (SUBREG (SYMBOL_REF)) when it has to store a symbol
     35   1.3  mrg        into a bitfield, or a packed ordinary field.  We can handle this
     36   1.3  mrg        provided that the destination is a register.  If not, then load the
     37   1.3  mrg        source into a register first.  */
     38   1.3  mrg     if (GET_CODE (operands[1]) == SUBREG
     39   1.3  mrg         && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
     40   1.3  mrg 	&& ! REG_P (operands[0]))
     41   1.3  mrg 	operands[1] = copy_to_mode_reg (QImode, operands[1]);
     42   1.3  mrg 
     43   1.3  mrg     /* Similarly for (SUBREG (CONST (PLUS (SYMBOL_REF)))).
     44   1.3  mrg        cf. g++.dg/abi/packed.C.  */
     45   1.3  mrg     if (GET_CODE (operands[1]) == SUBREG
     46   1.3  mrg 	&& GET_CODE (XEXP (operands[1], 0)) == CONST
     47   1.3  mrg         && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == PLUS
     48   1.3  mrg         && GET_CODE (XEXP (XEXP (XEXP (operands[1], 0), 0), 0)) == SYMBOL_REF
     49   1.3  mrg 	&& ! REG_P (operands[0]))
     50   1.1  mrg 	operands[1] = copy_to_mode_reg (QImode, operands[1]);
     51   1.5  mrg 
     52   1.1  mrg     if (CONST_INT_P (operands[1]) && ! IN_RANGE (INTVAL (operands[1]), (HOST_WIDE_INT_M1U << 8) + 1, (1 << 8) - 1))
     53   1.1  mrg       FAIL;
     54   1.1  mrg   }
     55   1.1  mrg )
     56   1.1  mrg 
     57   1.1  mrg (define_expand "movhi"
     58   1.1  mrg   [(set (match_operand:HI 0 "nonimmediate_operand")
     59   1.1  mrg 	(match_operand:HI 1 "general_operand"))]
     60   1.1  mrg   ""
     61   1.3  mrg   {
     62   1.3  mrg     if (MEM_P (operands[0]) && MEM_P (operands[1]))
     63   1.3  mrg       operands[1] = copy_to_mode_reg (HImode, operands[1]);
     64   1.3  mrg     if (rl78_far_p (operands[0]) && rl78_far_p (operands[1]))
     65   1.1  mrg       operands[1] = copy_to_mode_reg (HImode, operands[1]);
     66   1.1  mrg 
     67   1.1  mrg     /* FIXME: Not sure how GCC can generate (SUBREG (SYMBOL_REF)),
     68   1.3  mrg        but it does.  Since this makes no sense, reject it here.  */
     69   1.3  mrg     if (GET_CODE (operands[1]) == SUBREG
     70   1.3  mrg         && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
     71   1.3  mrg       FAIL;
     72   1.3  mrg     /* Similarly for (SUBREG (CONST (PLUS (SYMBOL_REF)))).  */
     73   1.3  mrg     if (GET_CODE (operands[1]) == SUBREG
     74   1.3  mrg 	&& GET_CODE (XEXP (operands[1], 0)) == CONST
     75   1.3  mrg         && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == PLUS
     76   1.1  mrg         && GET_CODE (XEXP (XEXP (XEXP (operands[1], 0), 0), 0)) == SYMBOL_REF)
     77   1.1  mrg       FAIL;
     78   1.1  mrg   }
     79   1.1  mrg )
     80   1.3  mrg 
     81   1.3  mrg (define_insn_and_split "movsi"
     82   1.3  mrg   [(set (match_operand:SI 0 "nonimmediate_operand" "=vYS,v,Wfr")
     83   1.3  mrg 	(match_operand:SI 1 "general_operand" "viYS,Wfr,v"))]
     84   1.3  mrg   ""
     85   1.3  mrg   "#"
     86   1.3  mrg   ""
     87   1.3  mrg   [(set (match_operand:HI 2 "nonimmediate_operand")
     88   1.3  mrg 	(match_operand:HI 4 "general_operand"))
     89   1.3  mrg    (set (match_operand:HI 3 "nonimmediate_operand")
     90   1.3  mrg 	(match_operand:HI 5 "general_operand"))]
     91   1.3  mrg   "rl78_split_movsi (operands, SImode);"
     92   1.3  mrg   [(set_attr "valloc" "op1")]
     93   1.3  mrg )
     94   1.3  mrg 
     95   1.3  mrg (define_insn_and_split "movsf"
     96   1.3  mrg   [(set (match_operand:SF 0 "nonimmediate_operand" "=vYS,v,Wfr")
     97   1.3  mrg 	(match_operand:SF 1 "general_operand" "viYS,Wfr,v"))]
     98   1.3  mrg   ""
     99   1.3  mrg   "#"
    100   1.3  mrg   ""
    101   1.3  mrg   [(set (match_operand:HI 2 "nonimmediate_operand")
    102   1.3  mrg 	(match_operand:HI 4 "general_operand"))
    103   1.3  mrg    (set (match_operand:HI 3 "nonimmediate_operand")
    104   1.3  mrg 	(match_operand:HI 5 "general_operand"))]
    105   1.3  mrg   "rl78_split_movsi (operands, SFmode);"
    106   1.1  mrg   [(set_attr "valloc" "op1")]
    107   1.1  mrg )
    108   1.8  mrg 
    109   1.8  mrg (define_expand "bswaphi2"
    110   1.8  mrg   [(set (match_operand:HI           0 "nonimmediate_operand")
    111   1.8  mrg         (bswap:HI (match_operand:HI 1 "general_operand")))]
    112   1.8  mrg   ""
    113   1.8  mrg   "if (rl78_force_nonfar_2 (operands, gen_bswaphi2))
    114   1.8  mrg      DONE;"
    115   1.8  mrg )
    116   1.1  mrg 
    117   1.1  mrg ;;---------- Conversions ------------------------
    118   1.1  mrg 
    119   1.1  mrg (define_expand "zero_extendqihi2"
    120   1.1  mrg   [(set (match_operand:HI                 0 "nonimmediate_operand")
    121   1.1  mrg 	(zero_extend:HI (match_operand:QI 1 "general_operand")))]
    122   1.1  mrg   ""
    123   1.1  mrg   "if (rl78_force_nonfar_2 (operands, gen_zero_extendqihi2))
    124   1.1  mrg      DONE;"
    125   1.1  mrg   )
    126   1.1  mrg 
    127   1.1  mrg (define_expand "extendqihi2"
    128   1.1  mrg   [(set (match_operand:HI                 0 "nonimmediate_operand")
    129   1.1  mrg 	(sign_extend:HI (match_operand:QI 1 "general_operand")))]
    130   1.1  mrg   ""
    131   1.1  mrg   "if (rl78_force_nonfar_2 (operands, gen_extendqihi2))
    132   1.1  mrg      DONE;"
    133   1.1  mrg   )
    134   1.1  mrg 
    135   1.1  mrg ;;---------- Arithmetic ------------------------
    136   1.1  mrg 
    137   1.1  mrg (define_expand "add<mode>3"
    138   1.1  mrg   [(set (match_operand:QHI           0 "nonimmediate_operand")
    139   1.1  mrg 	(plus:QHI (match_operand:QHI 1 "general_operand")
    140   1.1  mrg 		  (match_operand:QHI 2 "general_operand")))
    141   1.1  mrg    ]
    142   1.1  mrg   ""
    143   1.1  mrg   "if (rl78_force_nonfar_3 (operands, gen_add<mode>3))
    144   1.1  mrg      DONE;"
    145   1.1  mrg )
    146   1.1  mrg 
    147   1.1  mrg (define_expand "sub<mode>3"
    148   1.1  mrg   [(set (match_operand:QHI            0 "nonimmediate_operand")
    149   1.1  mrg 	(minus:QHI (match_operand:QHI 1 "general_operand")
    150   1.1  mrg 		   (match_operand:QHI 2 "general_operand")))
    151   1.1  mrg    ]
    152   1.1  mrg   ""
    153   1.1  mrg   "if (rl78_force_nonfar_3 (operands, gen_sub<mode>3))
    154   1.1  mrg      DONE;"
    155   1.1  mrg )
    156   1.1  mrg 
    157   1.1  mrg (define_expand "neg<mode>2"
    158   1.1  mrg   [(set (match_operand:QHI            0 "nonimmediate_operand")
    159   1.1  mrg 	(minus:QHI (const_int 0)
    160   1.1  mrg 		   (match_operand:QHI 1 "general_operand")))
    161   1.1  mrg    ]
    162   1.1  mrg   ""
    163   1.1  mrg   "if (rl78_force_nonfar_2 (operands, gen_neg<mode>2))
    164   1.1  mrg      DONE;"
    165   1.1  mrg )
    166   1.1  mrg 
    167   1.1  mrg (define_expand "umulqihi3"
    168   1.1  mrg   [(set (match_operand:HI 0 "register_operand")
    169   1.1  mrg         (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand"))
    170   1.4  mrg                  (zero_extend:HI (match_operand:QI 2 "register_operand"))))]
    171   1.1  mrg   ""
    172   1.1  mrg   ""
    173   1.1  mrg )
    174   1.1  mrg 
    175   1.3  mrg (define_expand "andqi3"
    176   1.3  mrg   [(set (match_operand:QI         0 "rl78_nonimmediate_operand")
    177   1.3  mrg 	(and:QI (match_operand:QI 1 "rl78_general_operand")
    178   1.1  mrg 		(match_operand:QI 2 "rl78_general_operand")))
    179   1.1  mrg    ]
    180   1.1  mrg   ""
    181   1.1  mrg   "if (rl78_force_nonfar_3 (operands, gen_andqi3))
    182   1.1  mrg      DONE;"
    183   1.1  mrg )
    184   1.1  mrg 
    185   1.3  mrg (define_expand "iorqi3"
    186   1.3  mrg   [(set (match_operand:QI         0 "rl78_nonimmediate_operand")
    187   1.3  mrg 	(ior:QI (match_operand:QI 1 "rl78_general_operand")
    188   1.1  mrg 		(match_operand:QI 2 "rl78_general_operand")))
    189   1.1  mrg    ]
    190   1.1  mrg   ""
    191   1.1  mrg   "if (rl78_force_nonfar_3 (operands, gen_iorqi3))
    192   1.1  mrg      DONE;"
    193   1.1  mrg )
    194   1.1  mrg 
    195   1.3  mrg (define_expand "xorqi3"
    196   1.3  mrg   [(set (match_operand:QI         0 "rl78_nonimmediate_operand")
    197   1.3  mrg 	(xor:QI (match_operand:QI 1 "rl78_general_operand")
    198   1.1  mrg 		(match_operand:QI 2 "rl78_general_operand")))
    199   1.1  mrg    ]
    200   1.1  mrg   ""
    201   1.1  mrg   "if (rl78_force_nonfar_3 (operands, gen_xorqi3))
    202   1.1  mrg      DONE;"
    203   1.1  mrg )
    204   1.1  mrg 
    205   1.1  mrg (define_expand "one_cmplqi2"
    206   1.1  mrg   [(set (match_operand:QI         0 "nonimmediate_operand")
    207   1.3  mrg 	(xor:QI (match_operand:QI 1 "general_operand")
    208   1.1  mrg 		(const_int -1)))
    209   1.1  mrg    ]
    210   1.1  mrg   ""
    211   1.1  mrg   "if (rl78_force_nonfar_2 (operands, gen_one_cmplqi2))
    212   1.1  mrg      DONE;"
    213   1.1  mrg )
    214   1.1  mrg 
    215   1.1  mrg ;;---------- Shifts ------------------------
    216   1.1  mrg 
    217   1.1  mrg (define_expand "ashl<mode>3"
    218   1.1  mrg   [(set (match_operand:QHI             0 "nonimmediate_operand")
    219   1.1  mrg 	(ashift:QHI (match_operand:QHI 1 "general_operand")
    220   1.1  mrg 		    (match_operand:QI  2 "general_operand")))
    221   1.1  mrg    ]
    222   1.1  mrg   ""
    223   1.1  mrg   "if (rl78_force_nonfar_3 (operands, gen_ashl<mode>3))
    224   1.1  mrg      DONE;"
    225   1.1  mrg )
    226   1.1  mrg 
    227   1.1  mrg (define_expand "ashr<mode>3"
    228   1.1  mrg   [(set (match_operand:QHI               0 "nonimmediate_operand")
    229   1.1  mrg 	(ashiftrt:QHI (match_operand:QHI 1 "general_operand")
    230   1.1  mrg 		      (match_operand:QI  2 "general_operand")))
    231   1.1  mrg    ]
    232   1.1  mrg   ""
    233   1.1  mrg   "if (rl78_force_nonfar_3 (operands, gen_ashr<mode>3))
    234   1.1  mrg      DONE;"
    235   1.1  mrg )
    236   1.1  mrg 
    237   1.1  mrg (define_expand "lshr<mode>3"
    238   1.1  mrg   [(set (match_operand:QHI               0 "nonimmediate_operand")
    239   1.1  mrg 	(lshiftrt:QHI (match_operand:QHI 1 "general_operand")
    240   1.1  mrg 		      (match_operand:QI  2 "general_operand")))
    241   1.1  mrg    ]
    242   1.1  mrg   ""
    243   1.1  mrg   "if (rl78_force_nonfar_3 (operands, gen_lshr<mode>3))
    244   1.1  mrg      DONE;"
    245   1.1  mrg )
    246   1.1  mrg 
    247   1.3  mrg (define_expand "ashrsi3"
    248   1.3  mrg   [(parallel [(set (match_operand:SI               0 "nonimmediate_operand")
    249   1.3  mrg 		   (ashiftrt:SI (match_operand:SI  1 "nonimmediate_operand")
    250   1.3  mrg 				(match_operand:SI  2 "nonmemory_operand")))
    251   1.3  mrg 	      (clobber (reg:HI X_REG))])
    252   1.3  mrg    ]
    253   1.3  mrg   ""
    254   1.3  mrg   ""
    255   1.3  mrg )
    256   1.3  mrg 
    257   1.3  mrg (define_expand "lshrsi3"
    258   1.3  mrg   [(parallel [(set (match_operand:SI               0 "nonimmediate_operand")
    259   1.3  mrg 		   (lshiftrt:SI (match_operand:SI  1 "nonimmediate_operand")
    260   1.3  mrg 				(match_operand:SI  2 "nonmemory_operand")))
    261   1.1  mrg 	      (clobber (reg:HI X_REG))])
    262   1.1  mrg    ]
    263   1.3  mrg   ""
    264   1.3  mrg   ""
    265   1.3  mrg )
    266   1.3  mrg 
    267   1.3  mrg (define_expand "ashlsi3"
    268   1.3  mrg   [(parallel [(set (match_operand:SI            0 "nonimmediate_operand")
    269   1.3  mrg 		   (ashift:SI (match_operand:SI 1 "nonimmediate_operand")
    270   1.3  mrg 			      (match_operand:SI 2 "nonmemory_operand")))
    271   1.3  mrg 	      (clobber (reg:HI X_REG))])
    272   1.3  mrg    ]
    273   1.3  mrg   ""
    274   1.1  mrg   ""
    275   1.1  mrg )
    276   1.1  mrg 
    277   1.1  mrg ;;---------- Branching ------------------------
    278   1.1  mrg 
    279   1.1  mrg (define_expand "indirect_jump"
    280   1.1  mrg   [(set (pc)
    281   1.1  mrg 	(match_operand:HI 0 "nonimmediate_operand"))]
    282   1.1  mrg   ""
    283   1.1  mrg   ""
    284   1.1  mrg )
    285   1.1  mrg 
    286   1.1  mrg (define_expand "call"
    287   1.1  mrg   [(call (match_operand:HI 0 "memory_operand")
    288   1.1  mrg 	 (match_operand 1 ""))]
    289   1.1  mrg   ""
    290   1.1  mrg   ""
    291   1.1  mrg )
    292   1.1  mrg 
    293   1.1  mrg (define_expand "call_value"
    294   1.1  mrg   [(set (match_operand          0 "register_operand")
    295   1.1  mrg 	(call (match_operand:HI 1 "memory_operand")
    296   1.1  mrg 	      (match_operand    2 "")))]
    297   1.1  mrg   ""
    298   1.1  mrg   ""
    299   1.1  mrg )
    300   1.1  mrg 
    301   1.1  mrg (define_expand "cbranchqi4"
    302   1.1  mrg   [(set (pc) (if_then_else
    303   1.1  mrg 	      (match_operator                    0 "rl78_cmp_operator"
    304   1.1  mrg 			      [(match_operand:QI 1 "general_operand")
    305   1.1  mrg 			       (match_operand:QI 2 "general_operand")])
    306   1.1  mrg               (label_ref (match_operand 3 "" ""))
    307   1.1  mrg 	      (pc)))]
    308   1.1  mrg   ""
    309   1.1  mrg   "rl78_expand_compare (operands);"
    310   1.1  mrg )
    311   1.1  mrg 
    312   1.1  mrg (define_expand "cbranchhi4"
    313   1.1  mrg   [(set (pc) (if_then_else
    314   1.1  mrg 	      (match_operator                    0 "rl78_cmp_operator"
    315   1.1  mrg 			      [(match_operand:HI 1 "general_operand")
    316   1.1  mrg 			       (match_operand:HI 2 "general_operand")])
    317   1.1  mrg               (label_ref (match_operand 3 "" ""))
    318   1.1  mrg 	      (pc)))]
    319   1.1  mrg   ""
    320   1.1  mrg   "rl78_expand_compare (operands);"
    321   1.3  mrg )
    322   1.3  mrg 
    323   1.3  mrg (define_expand "cbranchsi4"
    324   1.3  mrg   [(parallel [(set (pc) (if_then_else
    325   1.3  mrg 			 (match_operator 0 "rl78_cmp_operator"
    326   1.3  mrg 					 [(match_operand:SI 1 "general_operand")
    327   1.3  mrg 					  (match_operand:SI 2 "nonmemory_operand")])
    328   1.3  mrg 			 (label_ref (match_operand 3 "" ""))
    329   1.3  mrg 			 (pc)))
    330   1.3  mrg 	      (clobber (reg:HI AX_REG))
    331   1.3  mrg 	      ])]
    332   1.3  mrg   "1"
    333   1.3  mrg   "rl78_expand_compare (operands);"
    334            )
    335