Home | History | Annotate | Line # | Download | only in ft32
      1 ;; Constraint definitions for FT32
      2 ;; Copyright (C) 2015-2022 Free Software Foundation, Inc.
      3 ;; Contributed by FTDI <support (a] ftdi.com>
      4 
      5 ;; This file is part of GCC.
      6 
      7 ;; GCC is free software; you can redistribute it and/or modify it
      8 ;; under the terms of the GNU General Public License as published
      9 ;; by the Free Software Foundation; either version 3, or (at your
     10 ;; option) any later version.
     11 
     12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
     13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     14 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
     15 ;; 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 
     21 ;; -------------------------------------------------------------------------
     22 ;; Constraints
     23 ;; -------------------------------------------------------------------------
     24 
     25 (define_memory_constraint "A"
     26   "An absolute address."
     27   (and (match_code "mem")
     28        (match_test "(!ft32_is_mem_pm(op))")
     29        (ior (match_test "GET_CODE (XEXP (op, 0)) == SYMBOL_REF")
     30             (match_test "GET_CODE (XEXP (op, 0)) == LABEL_REF")
     31             (match_test "GET_CODE (XEXP (op, 0)) == CONST_INT")
     32             (and (match_test "(GET_CODE (XEXP (op, 0)) == PLUS)")
     33                  (ior (match_test "GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF")
     34                       (match_test "GET_CODE (XEXP (XEXP (op, 0), 0)) == LABEL_REF")
     35                       (match_test "GET_CODE (XEXP (XEXP (op, 0), 0)) == CONST_INT"))
     36                  (ior (match_test "GET_CODE (XEXP (XEXP (op, 0), 1)) == SYMBOL_REF")
     37                       (match_test "GET_CODE (XEXP (XEXP (op, 0), 1)) == LABEL_REF")
     38                       (match_test "GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT"))))))
     39 
     40 (define_memory_constraint "B"
     41   "An offset address."
     42   (and (match_code "mem")
     43        (match_test "(!ft32_is_mem_pm(op))")
     44        (match_test "(GET_CODE (XEXP (op, 0)) == PLUS)")))
     45 
     46 (define_memory_constraint "W"
     47   "A register indirect memory operand."
     48   (and (match_code "mem")
     49        (match_test "!ft32_is_mem_pm(op)
     50         && REG_P (XEXP (op, 0))
     51 		    && REGNO_OK_FOR_BASE_P (REGNO (XEXP (op, 0)))")))
     52 
     53 (define_memory_constraint "e"
     54   "An offset address."
     55   (and (match_code "mem")
     56        (match_test "ft32_is_mem_pm(op) && (
     57           (GET_CODE (XEXP (op, 0)) == SYMBOL_REF) ||
     58           (GET_CODE (XEXP (op, 0)) == LABEL_REF) ||
     59           (GET_CODE (XEXP (op, 0)) == CONST_INT) ||
     60           (GET_CODE (XEXP (op, 0)) == CONST))"
     61        )))
     62 
     63 (define_memory_constraint "f"
     64   "An offset address."
     65   (and (match_code "mem")
     66        (match_test "ft32_is_mem_pm(op) && (
     67           ((GET_CODE (XEXP (op, 0)) == PLUS)) ||
     68           (GET_CODE (XEXP (op, 0)) == REG))"
     69        )))
     70 
     71 (define_constraint "O"
     72   "The constant zero or one"
     73   (and (match_code "const_int")
     74        (match_test "((ival == 0) || (ival == 1))")))
     75 
     76 (define_constraint "I"
     77   "A 16-bit signed constant (-32768..32767)"
     78   (and (match_code "const_int")
     79        (match_test "ival >= -32768 && ival <= 32767")))
     80 
     81 (define_constraint "w"
     82   "A bitfield mask suitable for bext or bins"
     83   (and (match_code "const_int")
     84        (match_test "ft32_as_bitfield(ival) != -1")))
     85 
     86 (define_constraint "x"
     87   "An inverted bitfield mask suitable for bext or bins"
     88   (and (match_code "const_int")
     89        (match_test "ft32_as_bitfield(0xffffffff ^ ival) != -1")))
     90 
     91 (define_constraint "L"
     92   "A 16-bit unsigned constant, multiple of 4 (-65532..0)"
     93   (and (match_code "const_int")
     94        (match_test "ival >= -65532 && ival <= 0 && (ival & 3) == 0")))
     95 
     96 (define_constraint "S"
     97   "A 20-bit signed constant (-524288..524287)"
     98   (ior
     99     (and (match_code "const_int")
    100          (match_test "ival >= -524288 && ival <= 524287"))
    101     (match_test "GET_CODE (op) == LABEL_REF")
    102     (match_test "GET_CODE (op) == SYMBOL_REF")
    103     (match_test "GET_CODE (op) == CONST")))
    104 
    105 (define_constraint "b"
    106   "A constant for a bitfield width (1..16)"
    107   (and (match_code "const_int")
    108        (match_test "ival >= 1 && ival <= 16")))
    109 
    110 (define_constraint "KA"
    111   "A 10-bit signed constant (-512..511)"
    112   (and (match_code "const_int")
    113        (match_test "ival >= -512 && ival <= 511")))
    114