github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/m68k/m68k-defs.m4 (about)

     1  divert(-1)
     2  
     3  dnl  m4 macros for 68k assembler.
     4  
     5  dnl  Copyright 2001-2003 Free Software Foundation, Inc.
     6  
     7  dnl  This file is part of the GNU MP Library.
     8  dnl
     9  dnl  The GNU MP Library is free software; you can redistribute it and/or modify
    10  dnl  it under the terms of either:
    11  dnl
    12  dnl    * the GNU Lesser General Public License as published by the Free
    13  dnl      Software Foundation; either version 3 of the License, or (at your
    14  dnl      option) any later version.
    15  dnl
    16  dnl  or
    17  dnl
    18  dnl    * the GNU General Public License as published by the Free Software
    19  dnl      Foundation; either version 2 of the License, or (at your option) any
    20  dnl      later version.
    21  dnl
    22  dnl  or both in parallel, as here.
    23  dnl
    24  dnl  The GNU MP Library is distributed in the hope that it will be useful, but
    25  dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    26  dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    27  dnl  for more details.
    28  dnl
    29  dnl  You should have received copies of the GNU General Public License and the
    30  dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
    31  dnl  see https://www.gnu.org/licenses/.
    32  
    33  
    34  dnl  The default m4 `#' commenting interferes with the assembler syntax for
    35  dnl  immediates.  `|' would be correct, but it interferes with "||" in
    36  dnl  eval().  Would like to disable commenting, but that's not possible (see
    37  dnl  mpn/asm-defs.m4), so use `;' which should be harmless.
    38  
    39  changecom(;)
    40  
    41  
    42  dnl  Called: PROLOGUE_cpu(GSYM_PREFIX`'foo)
    43  dnl
    44  dnl  Same as the standard PROLOGUE, but align to 2 bytes not 4.
    45  
    46  define(`PROLOGUE_cpu',
    47  m4_assert_numargs(1)
    48  `	TEXT
    49  	ALIGN(2)
    50  	GLOBL	`$1' GLOBL_ATTR
    51  	TYPE(`$1',`function')
    52  `$1'LABEL_SUFFIX')
    53  
    54  
    55  dnl  Usage: d0, etc
    56  dnl
    57  dnl  Expand to d0 or %d0 according to the assembler's requirements.
    58  dnl
    59  dnl  Actually d0 expands to `d0' or %`d0', the quotes protecting against
    60  dnl  further expansion.  Definitions are made even if d0 is to be just `d0',
    61  dnl  so that any m4 quoting problems will show up everywhere, not just on a
    62  dnl  %d0 system.
    63  dnl
    64  dnl  Care must be taken with quoting when using these in a definition.  For
    65  dnl  instance the quotes in the following are essential or two %'s will be
    66  dnl  produced when `counter' is used.
    67  dnl
    68  dnl         define(counter, `d7')
    69  dnl
    70  
    71  dnl  Called: m68k_reg(r)
    72  define(m68k_reg,
    73  m4_assert_numargs(1)
    74  m4_assert_defined(`WANT_REGISTER_PERCENT')
    75  `ifelse(WANT_REGISTER_PERCENT,yes,%)`$1'')
    76  
    77  dnl  Usage: m68k_defreg(r)
    78  define(m68k_defreg,
    79  m4_assert_numargs(1)
    80  `deflit($1,`m68k_reg(`$1')')')
    81  
    82  m68k_defreg(d0)
    83  m68k_defreg(d1)
    84  m68k_defreg(d2)
    85  m68k_defreg(d3)
    86  m68k_defreg(d4)
    87  m68k_defreg(d5)
    88  m68k_defreg(d6)
    89  m68k_defreg(d7)
    90  
    91  m68k_defreg(a0)
    92  m68k_defreg(a1)
    93  m68k_defreg(a2)
    94  m68k_defreg(a3)
    95  m68k_defreg(a4)
    96  m68k_defreg(a5)
    97  m68k_defreg(a6)
    98  m68k_defreg(a7)
    99  
   100  m68k_defreg(sp)
   101  m68k_defreg(pc)
   102  
   103  
   104  dnl  Usage: M(base)
   105  dnl         M(base,displacement)
   106  dnl         M(base,index,size)
   107  dnl         M(base,index,size,scale)
   108  dnl         M(base,+)
   109  dnl         M(-,base)
   110  dnl
   111  dnl  `base' is an address register, `index' is a data register, `size' is w
   112  dnl  or l, and scale is 1, 2, 4 or 8.
   113  dnl
   114  dnl  M(-,base) has it's arguments that way around to emphasise it's a
   115  dnl  pre-decrement, as opposed to M(base,+) a post-increment.
   116  dnl
   117  dnl  Enhancement: Add the memory indirect modes, if/when they're needed.
   118  
   119  define(M,
   120  m4_assert_numargs_range(1,4)
   121  m4_assert_defined(`WANT_ADDRESSING')
   122  `ifelse(WANT_ADDRESSING,mit,
   123  `ifelse($#,1, ``$1'@')dnl
   124  ifelse($#,2,
   125  `ifelse($2,+, ``$1'@+',
   126  `ifelse($1,-, ``$2'@-',
   127                ``$1'@($2)')')')dnl
   128  ifelse($#,3,  ``$1'@(`$2':`$3')')dnl
   129  ifelse($#,4,  ``$1'@(`$2':`$3':$4)')',
   130  
   131  dnl  WANT_ADDRESSING `motorola'
   132  `ifelse($#,1, `(`$1')')dnl
   133  ifelse($#,2,
   134  `ifelse($2,+, `(`$1')+',
   135  `ifelse($1,-, `-(`$2')',
   136                `$2(`$1')')')')dnl
   137  ifelse($#,3,  `(`$1',`$2'.$3)')dnl
   138  ifelse($#,4,  `(`$1',`$2'.$3*$4)')')')
   139  
   140  
   141  dnl  Usage: addl etc
   142  dnl
   143  dnl  m68k instructions with special handling for the suffix, with for
   144  dnl  instance addl expanding to addl or add.l as necessary.
   145  dnl
   146  dnl  See also t-m68k-defs.pl which verifies all mnemonics used in the asm
   147  dnl  files have entries here.
   148  
   149  dnl  Called: m68k_insn(mnemonic,suffix)
   150  define(m68k_insn,
   151  m4_assert_numargs(2)
   152  m4_assert_defined(`WANT_DOT_SIZE')
   153  `ifelse(WANT_DOT_SIZE,yes, ``$1'.``$2''',
   154                             ``$1$2'')')
   155  
   156  dnl  Usage: m68k_definsn(mnemonic,suffix)
   157  define(m68k_definsn,
   158  m4_assert_numargs(2)
   159  `deflit($1`'$2,`m68k_insn(`$1',`$2')')')
   160  
   161  m68k_definsn(add,  l)
   162  m68k_definsn(addx, l)
   163  m68k_definsn(addq, l)
   164  m68k_definsn(asl,  l)
   165  m68k_definsn(cmp,  l)
   166  m68k_definsn(cmp,  w)
   167  m68k_definsn(clr,  l)
   168  m68k_definsn(divu, l)
   169  m68k_definsn(eor,  w)
   170  m68k_definsn(lsl,  l)
   171  m68k_definsn(lsr,  l)
   172  m68k_definsn(move, l)
   173  m68k_definsn(move, w)
   174  m68k_definsn(movem,l)
   175  m68k_definsn(moveq,l)
   176  m68k_definsn(mulu, l)
   177  m68k_definsn(neg,  l)
   178  m68k_definsn(or,   l)
   179  m68k_definsn(roxl, l)
   180  m68k_definsn(roxr, l)
   181  m68k_definsn(sub,  l)
   182  m68k_definsn(subx, l)
   183  m68k_definsn(subq, l)
   184  
   185  
   186  dnl  Usage: bra etc
   187  dnl
   188  dnl  Expand to `bra', `jra' or `jbra' according to what the assembler will
   189  dnl  accept.  The latter two give variable-sized branches in gas.
   190  dnl
   191  dnl  See also t-m68k-defs.pl which verifies all the bXX branches used in the
   192  dnl  asm files have entries here.
   193  
   194  dnl  Called: m68k_branch(cond)
   195  define(m68k_branch,
   196  m4_assert_numargs(1)
   197  m4_assert_defined(`WANT_BRANCHES')
   198  `ifelse(WANT_BRANCHES,jra, `j$1',
   199  `ifelse(WANT_BRANCHES,jbra,`jb$1',
   200                             ``b$1'')')')
   201  
   202  dnl  Called: m68k_defbranch(cond)
   203  define(m68k_defbranch,
   204  m4_assert_numargs(1)
   205  `deflit(b$1,`m68k_branch(`$1')')')
   206  
   207  m68k_defbranch(ra)
   208  m68k_defbranch(cc)
   209  m68k_defbranch(cs)
   210  m68k_defbranch(ls)
   211  m68k_defbranch(eq)
   212  m68k_defbranch(ne)
   213  
   214  
   215  dnl  Usage: scale_available_p
   216  dnl
   217  dnl  Expand to 1 if a scale factor can be used in addressing modes, or 0 if
   218  dnl  not.  M(a0,d0,l,4), meaning a0+d0*4, is not available in 68000 or
   219  dnl  68010, but is in CPU32 and in 68020 and up.
   220  
   221  define(scale_available_p,
   222  `m4_ifdef_anyof_p(
   223  `HAVE_HOST_CPU_m68360'
   224  `HAVE_HOST_CPU_m68020'
   225  `HAVE_HOST_CPU_m68030'
   226  `HAVE_HOST_CPU_m68040'
   227  `HAVE_HOST_CPU_m68060')')
   228  
   229  
   230  divert