OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [h8300/] [genmova.sh] - Diff between revs 38 and 154

Only display areas with differences | Details | Blame | View Log

Rev 38 Rev 154
#!/bin/sh
#!/bin/sh
# Generate mova.md, a file containing patterns that can be implemented
# Generate mova.md, a file containing patterns that can be implemented
# using the h8sx mova instruction.
# using the h8sx mova instruction.
 
 
echo ";; -*- buffer-read-only: t -*-"
echo ";; -*- buffer-read-only: t -*-"
echo ";; Generated automatically from genmova.sh"
echo ";; Generated automatically from genmova.sh"
 
 
# Loop over modes for the source operand (the index).  Only 8-bit and
# Loop over modes for the source operand (the index).  Only 8-bit and
# 16-bit indices are allowed.
# 16-bit indices are allowed.
for s in QI HI; do
for s in QI HI; do
 
 
  # Set $src to the operand syntax for this size of index.
  # Set $src to the operand syntax for this size of index.
  case $s in
  case $s in
    QI) src=%X1.b;;
    QI) src=%X1.b;;
    HI) src=%T1.w;;
    HI) src=%T1.w;;
  esac
  esac
 
 
  # A match_operand for the source.
  # A match_operand for the source.
  operand="(match_operand:$s 1 \"h8300_dst_operand\" \"0,rQ\")"
  operand="(match_operand:$s 1 \"h8300_dst_operand\" \"0,rQ\")"
 
 
  # Loop over the destination register's mode.  The QI and HI versions use
  # Loop over the destination register's mode.  The QI and HI versions use
  # the same instructions as the SI ones, they just ignore the upper bits
  # the same instructions as the SI ones, they just ignore the upper bits
  # of the result.
  # of the result.
  for d in QI HI SI; do
  for d in QI HI SI; do
 
 
    # If the destination is larger than the source, include a
    # If the destination is larger than the source, include a
    # zero_extend/plus pattern.  We could also match zero extensions
    # zero_extend/plus pattern.  We could also match zero extensions
    # of memory without the plus, but it's not any smaller or faster
    # of memory without the plus, but it's not any smaller or faster
    # than separate insns.
    # than separate insns.
    case $d:$s in
    case $d:$s in
      SI:QI | SI:HI | HI:QI)
      SI:QI | SI:HI | HI:QI)
        cat <<EOF
        cat <<EOF
(define_insn ""
(define_insn ""
  [(set (match_operand:$d 0 "register_operand" "=r,r")
  [(set (match_operand:$d 0 "register_operand" "=r,r")
        (plus:$d (zero_extend:$d $operand)
        (plus:$d (zero_extend:$d $operand)
                 (match_operand:$d 2 "immediate_operand" "i,i")))]
                 (match_operand:$d 2 "immediate_operand" "i,i")))]
  "TARGET_H8300SX"
  "TARGET_H8300SX"
  "mova/b.l @(%o2,$src),%S0"
  "mova/b.l @(%o2,$src),%S0"
  [(set_attr "length_table" "mova")
  [(set_attr "length_table" "mova")
   (set_attr "cc" "none")])
   (set_attr "cc" "none")])
 
 
EOF
EOF
        ;;
        ;;
    esac
    esac
 
 
    # Loop over the shift amount.
    # Loop over the shift amount.
    for shift in 1 2; do
    for shift in 1 2; do
      case $shift in
      case $shift in
        1) opsize=w mult=2;;
        1) opsize=w mult=2;;
        2) opsize=l mult=4;;
        2) opsize=l mult=4;;
      esac
      esac
 
 
      # Calculate the mask of bits that will be nonzero after the source
      # Calculate the mask of bits that will be nonzero after the source
      # has been extended and shifted.
      # has been extended and shifted.
      case $s:$shift in
      case $s:$shift in
        QI:1) mask=510;;
        QI:1) mask=510;;
        QI:2) mask=1020;;
        QI:2) mask=1020;;
        HI:1) mask=131070;;
        HI:1) mask=131070;;
        HI:2) mask=262140;;
        HI:2) mask=262140;;
      esac
      esac
 
 
      # There doesn't seem to be a well-established canonical form for
      # There doesn't seem to be a well-established canonical form for
      # some of the patterns we need.  Emit both shift and multiplication
      # some of the patterns we need.  Emit both shift and multiplication
      # patterns.
      # patterns.
      for form in mult ashift; do
      for form in mult ashift; do
        case $form in
        case $form in
          mult) amount=$mult;;
          mult) amount=$mult;;
          ashift) amount=$shift;;
          ashift) amount=$shift;;
        esac
        esac
 
 
        case $d:$s in
        case $d:$s in
          # If the source and destination are the same size, we can treat
          # If the source and destination are the same size, we can treat
          # mova as a sort of multiply-add instruction.
          # mova as a sort of multiply-add instruction.
          QI:QI | HI:HI)
          QI:QI | HI:HI)
            cat <<EOF
            cat <<EOF
(define_insn ""
(define_insn ""
  [(set (match_operand:$d 0 "register_operand" "=r,r")
  [(set (match_operand:$d 0 "register_operand" "=r,r")
        (plus:$d ($form:$d $operand
        (plus:$d ($form:$d $operand
                           (const_int $amount))
                           (const_int $amount))
                 (match_operand:$d 2 "immediate_operand" "i,i")))]
                 (match_operand:$d 2 "immediate_operand" "i,i")))]
  "TARGET_H8300SX"
  "TARGET_H8300SX"
  "mova/$opsize.l @(%o2,$src),%S0"
  "mova/$opsize.l @(%o2,$src),%S0"
  [(set_attr "length_table" "mova")
  [(set_attr "length_table" "mova")
   (set_attr "cc" "none")])
   (set_attr "cc" "none")])
 
 
EOF
EOF
            ;;
            ;;
 
 
          # Handle the cases where the source is smaller than the
          # Handle the cases where the source is smaller than the
          # destination.  Sometimes combine will keep the extension,
          # destination.  Sometimes combine will keep the extension,
          # sometimes it will use an AND.
          # sometimes it will use an AND.
          SI:QI | SI:HI | HI:QI)
          SI:QI | SI:HI | HI:QI)
 
 
            # Emit the forms that use zero_extend.
            # Emit the forms that use zero_extend.
            cat <<EOF
            cat <<EOF
(define_insn ""
(define_insn ""
  [(set (match_operand:$d 0 "register_operand" "=r,r")
  [(set (match_operand:$d 0 "register_operand" "=r,r")
        ($form:$d (zero_extend:$d $operand)
        ($form:$d (zero_extend:$d $operand)
                  (const_int $amount)))]
                  (const_int $amount)))]
  "TARGET_H8300SX"
  "TARGET_H8300SX"
  "mova/$opsize.l @(0,$src),%S0"
  "mova/$opsize.l @(0,$src),%S0"
  [(set_attr "length_table" "mova_zero")
  [(set_attr "length_table" "mova_zero")
   (set_attr "cc" "none")])
   (set_attr "cc" "none")])
 
 
(define_insn ""
(define_insn ""
  [(set (match_operand:$d 0 "register_operand" "=r,r")
  [(set (match_operand:$d 0 "register_operand" "=r,r")
        (plus:$d ($form:$d (zero_extend:$d $operand)
        (plus:$d ($form:$d (zero_extend:$d $operand)
                           (const_int $amount))
                           (const_int $amount))
                 (match_operand:$d 2 "immediate_operand" "i,i")))]
                 (match_operand:$d 2 "immediate_operand" "i,i")))]
  "TARGET_H8300SX"
  "TARGET_H8300SX"
  "mova/$opsize.l @(%o2,$src),%S0"
  "mova/$opsize.l @(%o2,$src),%S0"
  [(set_attr "length_table" "mova")
  [(set_attr "length_table" "mova")
   (set_attr "cc" "none")])
   (set_attr "cc" "none")])
 
 
EOF
EOF
 
 
            # Now emit the forms that use AND.  When the index is a register,
            # Now emit the forms that use AND.  When the index is a register,
            # these forms are effectively $d-mode operations: the index will
            # these forms are effectively $d-mode operations: the index will
            # be a $d-mode REG or SUBREG.  When the index is a memory
            # be a $d-mode REG or SUBREG.  When the index is a memory
            # location, we will have a paradoxical subreg such as:
            # location, we will have a paradoxical subreg such as:
            #
            #
            #   (and:SI (mult:SI (subreg:SI (mem:QI ...) 0)
            #   (and:SI (mult:SI (subreg:SI (mem:QI ...) 0)
            #                    (const_int 4))
            #                    (const_int 4))
            #           (const_int 1020))
            #           (const_int 1020))
            #
            #
            # Match the two case separately: a $d-mode register_operand
            # Match the two case separately: a $d-mode register_operand
            # or a $d-mode subreg of an $s-mode memory_operand.  Match the
            # or a $d-mode subreg of an $s-mode memory_operand.  Match the
            # memory form first since register_operand accepts mem subregs
            # memory form first since register_operand accepts mem subregs
            # before reload.
            # before reload.
            memory="(match_operand:$s 1 \"memory_operand\" \"m\")"
            memory="(match_operand:$s 1 \"memory_operand\" \"m\")"
            memory="(subreg:$d $memory 0)"
            memory="(subreg:$d $memory 0)"
            register="(match_operand:$d 1 \"register_operand\" \"0\")"
            register="(match_operand:$d 1 \"register_operand\" \"0\")"
            for paradoxical in "$memory" "$register"; do
            for paradoxical in "$memory" "$register"; do
              cat <<EOF
              cat <<EOF
(define_insn ""
(define_insn ""
  [(set (match_operand:$d 0 "register_operand" "=r")
  [(set (match_operand:$d 0 "register_operand" "=r")
        (and:$d ($form:$d $paradoxical
        (and:$d ($form:$d $paradoxical
                          (const_int $amount))
                          (const_int $amount))
                (const_int $mask)))]
                (const_int $mask)))]
  "TARGET_H8300SX"
  "TARGET_H8300SX"
  "mova/$opsize.l @(0,$src),%S0"
  "mova/$opsize.l @(0,$src),%S0"
  [(set_attr "length_table" "mova_zero")
  [(set_attr "length_table" "mova_zero")
   (set_attr "cc" "none")])
   (set_attr "cc" "none")])
 
 
(define_insn ""
(define_insn ""
  [(set (match_operand:$d 0 "register_operand" "=r")
  [(set (match_operand:$d 0 "register_operand" "=r")
        (plus:$d (and:$d ($form:$d $paradoxical
        (plus:$d (and:$d ($form:$d $paradoxical
                                   (const_int $amount))
                                   (const_int $amount))
                         (const_int $mask))
                         (const_int $mask))
                 (match_operand:$d 2 "immediate_operand" "i")))]
                 (match_operand:$d 2 "immediate_operand" "i")))]
  "TARGET_H8300SX"
  "TARGET_H8300SX"
  "mova/$opsize.l @(%o2,$src),%S0"
  "mova/$opsize.l @(%o2,$src),%S0"
  [(set_attr "length_table" "mova")
  [(set_attr "length_table" "mova")
   (set_attr "cc" "none")])
   (set_attr "cc" "none")])
 
 
EOF
EOF
              done
              done
            ;;
            ;;
        esac
        esac
      done
      done
    done
    done
  done
  done
done
done
 
 

powered by: WebSVN 2.1.0

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