Home | History | Annotate | Line # | Download | only in opcode
arc-func.h revision 1.1
      1  1.1  christos /* Replace functions for the ARC relocs.
      2  1.1  christos    Copyright 2015
      3  1.1  christos    Free Software Foundation, Inc.
      4  1.1  christos 
      5  1.1  christos    This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and
      6  1.1  christos    the GNU Binutils.
      7  1.1  christos 
      8  1.1  christos    GAS/GDB is free software; you can redistribute it and/or modify
      9  1.1  christos    it under the terms of the GNU General Public License as published by
     10  1.1  christos    the Free Software Foundation; either version 3, or (at your option)
     11  1.1  christos    any later version.
     12  1.1  christos 
     13  1.1  christos    GAS/GDB is distributed in the hope that it will be useful,
     14  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
     16  1.1  christos    GNU General Public License for more details.
     17  1.1  christos 
     18  1.1  christos    You should have received a copy of the GNU General Public License
     19  1.1  christos    along with GAS or GDB; see the file COPYING3.  If not, write to
     20  1.1  christos    the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
     21  1.1  christos    MA 02110-1301, USA.  */
     22  1.1  christos 
     23  1.1  christos /* mask  = 00000000000000000000000000000000.  */
     24  1.1  christos #ifndef REPLACE_none
     25  1.1  christos #define REPLACE_none
     26  1.1  christos ATTRIBUTE_UNUSED static unsigned
     27  1.1  christos replace_none (unsigned insn, int value ATTRIBUTE_UNUSED)
     28  1.1  christos {
     29  1.1  christos 
     30  1.1  christos   return insn;
     31  1.1  christos }
     32  1.1  christos 
     33  1.1  christos #endif /* REPLACE_none */
     34  1.1  christos 
     35  1.1  christos /* mask  = 11111111.  */
     36  1.1  christos #ifndef REPLACE_bits8
     37  1.1  christos #define REPLACE_bits8
     38  1.1  christos ATTRIBUTE_UNUSED static unsigned
     39  1.1  christos replace_bits8 (unsigned insn, int value ATTRIBUTE_UNUSED)
     40  1.1  christos {
     41  1.1  christos   insn |= ((value >> 0) & 0x00ff) << 0;
     42  1.1  christos 
     43  1.1  christos   return insn;
     44  1.1  christos }
     45  1.1  christos 
     46  1.1  christos #endif /* REPLACE_bits8 */
     47  1.1  christos 
     48  1.1  christos /* mask  = 1111111111111111.  */
     49  1.1  christos #ifndef REPLACE_bits16
     50  1.1  christos #define REPLACE_bits16
     51  1.1  christos ATTRIBUTE_UNUSED static unsigned
     52  1.1  christos replace_bits16 (unsigned insn, int value ATTRIBUTE_UNUSED)
     53  1.1  christos {
     54  1.1  christos   insn |= ((value >> 0) & 0xffff) << 0;
     55  1.1  christos 
     56  1.1  christos   return insn;
     57  1.1  christos }
     58  1.1  christos 
     59  1.1  christos #endif /* REPLACE_bits16 */
     60  1.1  christos 
     61  1.1  christos /* mask  = 111111111111111111111111.  */
     62  1.1  christos #ifndef REPLACE_bits24
     63  1.1  christos #define REPLACE_bits24
     64  1.1  christos ATTRIBUTE_UNUSED static unsigned
     65  1.1  christos replace_bits24 (unsigned insn, int value ATTRIBUTE_UNUSED)
     66  1.1  christos {
     67  1.1  christos   insn |= ((value >> 0) & 0xffffff) << 0;
     68  1.1  christos 
     69  1.1  christos   return insn;
     70  1.1  christos }
     71  1.1  christos 
     72  1.1  christos #endif /* REPLACE_bits24 */
     73  1.1  christos 
     74  1.1  christos /* mask  = 11111111111111111111111111111111.  */
     75  1.1  christos #ifndef REPLACE_word32
     76  1.1  christos #define REPLACE_word32
     77  1.1  christos ATTRIBUTE_UNUSED static unsigned
     78  1.1  christos replace_word32 (unsigned insn, int value ATTRIBUTE_UNUSED)
     79  1.1  christos {
     80  1.1  christos   insn |= ((value >> 0) & 0xffffffff) << 0;
     81  1.1  christos 
     82  1.1  christos   return insn;
     83  1.1  christos }
     84  1.1  christos 
     85  1.1  christos #endif /* REPLACE_word32 */
     86  1.1  christos 
     87  1.1  christos /* mask  = 0000000000000000000000000000000011111111111111111111111111111111.  */
     88  1.1  christos #ifndef REPLACE_limm
     89  1.1  christos #define REPLACE_limm
     90  1.1  christos ATTRIBUTE_UNUSED static unsigned
     91  1.1  christos replace_limm (unsigned insn, int value ATTRIBUTE_UNUSED)
     92  1.1  christos {
     93  1.1  christos   insn |= ((value >> 0) & 0xffffffff) << 0;
     94  1.1  christos 
     95  1.1  christos   return insn;
     96  1.1  christos }
     97  1.1  christos 
     98  1.1  christos #endif /* REPLACE_limm */
     99  1.1  christos 
    100  1.1  christos /* mask  = 000000000000000011111111111111111111111111111111.  */
    101  1.1  christos #ifndef REPLACE_limms
    102  1.1  christos #define REPLACE_limms
    103  1.1  christos ATTRIBUTE_UNUSED static unsigned
    104  1.1  christos replace_limms (unsigned insn, int value ATTRIBUTE_UNUSED)
    105  1.1  christos {
    106  1.1  christos   insn |= ((value >> 0) & 0xffffffff) << 0;
    107  1.1  christos 
    108  1.1  christos   return insn;
    109  1.1  christos }
    110  1.1  christos 
    111  1.1  christos #endif /* REPLACE_limms */
    112  1.1  christos 
    113  1.1  christos /* mask  = 00000111111111102222222222000000.  */
    114  1.1  christos #ifndef REPLACE_disp21h
    115  1.1  christos #define REPLACE_disp21h
    116  1.1  christos ATTRIBUTE_UNUSED static unsigned
    117  1.1  christos replace_disp21h (unsigned insn, int value ATTRIBUTE_UNUSED)
    118  1.1  christos {
    119  1.1  christos   insn |= ((value >> 0) & 0x03ff) << 17;
    120  1.1  christos   insn |= ((value >> 10) & 0x03ff) << 6;
    121  1.1  christos 
    122  1.1  christos   return insn;
    123  1.1  christos }
    124  1.1  christos 
    125  1.1  christos #endif /* REPLACE_disp21h */
    126  1.1  christos 
    127  1.1  christos /* mask  = 00000111111111002222222222000000.  */
    128  1.1  christos #ifndef REPLACE_disp21w
    129  1.1  christos #define REPLACE_disp21w
    130  1.1  christos ATTRIBUTE_UNUSED static unsigned
    131  1.1  christos replace_disp21w (unsigned insn, int value ATTRIBUTE_UNUSED)
    132  1.1  christos {
    133  1.1  christos   insn |= ((value >> 0) & 0x01ff) << 18;
    134  1.1  christos   insn |= ((value >> 9) & 0x03ff) << 6;
    135  1.1  christos 
    136  1.1  christos   return insn;
    137  1.1  christos }
    138  1.1  christos 
    139  1.1  christos #endif /* REPLACE_disp21w */
    140  1.1  christos 
    141  1.1  christos /* mask  = 00000111111111102222222222003333.  */
    142  1.1  christos #ifndef REPLACE_disp25h
    143  1.1  christos #define REPLACE_disp25h
    144  1.1  christos ATTRIBUTE_UNUSED static unsigned
    145  1.1  christos replace_disp25h (unsigned insn, int value ATTRIBUTE_UNUSED)
    146  1.1  christos {
    147  1.1  christos   insn |= ((value >> 0) & 0x03ff) << 17;
    148  1.1  christos   insn |= ((value >> 10) & 0x03ff) << 6;
    149  1.1  christos   insn |= ((value >> 20) & 0x000f) << 0;
    150  1.1  christos 
    151  1.1  christos   return insn;
    152  1.1  christos }
    153  1.1  christos 
    154  1.1  christos #endif /* REPLACE_disp25h */
    155  1.1  christos 
    156  1.1  christos /* mask  = 00000111111111002222222222003333.  */
    157  1.1  christos #ifndef REPLACE_disp25w
    158  1.1  christos #define REPLACE_disp25w
    159  1.1  christos ATTRIBUTE_UNUSED static unsigned
    160  1.1  christos replace_disp25w (unsigned insn, int value ATTRIBUTE_UNUSED)
    161  1.1  christos {
    162  1.1  christos   insn |= ((value >> 0) & 0x01ff) << 18;
    163  1.1  christos   insn |= ((value >> 9) & 0x03ff) << 6;
    164  1.1  christos   insn |= ((value >> 19) & 0x000f) << 0;
    165  1.1  christos 
    166  1.1  christos   return insn;
    167  1.1  christos }
    168  1.1  christos 
    169  1.1  christos #endif /* REPLACE_disp25w */
    170  1.1  christos 
    171  1.1  christos /* mask  = 00000000000000000000000111111111.  */
    172  1.1  christos #ifndef REPLACE_disp9
    173  1.1  christos #define REPLACE_disp9
    174  1.1  christos ATTRIBUTE_UNUSED static unsigned
    175  1.1  christos replace_disp9 (unsigned insn, int value ATTRIBUTE_UNUSED)
    176  1.1  christos {
    177  1.1  christos   insn |= ((value >> 0) & 0x01ff) << 0;
    178  1.1  christos 
    179  1.1  christos   return insn;
    180  1.1  christos }
    181  1.1  christos 
    182  1.1  christos #endif /* REPLACE_disp9 */
    183  1.1  christos 
    184  1.1  christos /* mask  = 00000000111111112000000000000000.  */
    185  1.1  christos #ifndef REPLACE_disp9ls
    186  1.1  christos #define REPLACE_disp9ls
    187  1.1  christos ATTRIBUTE_UNUSED static unsigned
    188  1.1  christos replace_disp9ls (unsigned insn, int value ATTRIBUTE_UNUSED)
    189  1.1  christos {
    190  1.1  christos   insn |= ((value >> 0) & 0x00ff) << 16;
    191  1.1  christos   insn |= ((value >> 8) & 0x0001) << 15;
    192  1.1  christos 
    193  1.1  christos   return insn;
    194  1.1  christos }
    195  1.1  christos 
    196  1.1  christos #endif /* REPLACE_disp9ls */
    197  1.1  christos 
    198  1.1  christos /* mask  = 0000000111111111.  */
    199  1.1  christos #ifndef REPLACE_disp9s
    200  1.1  christos #define REPLACE_disp9s
    201  1.1  christos ATTRIBUTE_UNUSED static unsigned
    202  1.1  christos replace_disp9s (unsigned insn, int value ATTRIBUTE_UNUSED)
    203  1.1  christos {
    204  1.1  christos   insn |= ((value >> 0) & 0x01ff) << 0;
    205  1.1  christos 
    206  1.1  christos   return insn;
    207  1.1  christos }
    208  1.1  christos 
    209  1.1  christos #endif /* REPLACE_disp9s */
    210  1.1  christos 
    211  1.1  christos /* mask  = 0000011111111111.  */
    212  1.1  christos #ifndef REPLACE_disp13s
    213  1.1  christos #define REPLACE_disp13s
    214  1.1  christos ATTRIBUTE_UNUSED static unsigned
    215  1.1  christos replace_disp13s (unsigned insn, int value ATTRIBUTE_UNUSED)
    216  1.1  christos {
    217  1.1  christos   insn |= ((value >> 0) & 0x07ff) << 0;
    218  1.1  christos 
    219  1.1  christos   return insn;
    220  1.1  christos }
    221  1.1  christos 
    222  1.1  christos #endif /* REPLACE_disp13s */
    223  1.1  christos 
    224  1.1  christos /* mask  = 0000022222200111.  */
    225  1.1  christos #ifndef REPLACE_disp9s1
    226  1.1  christos #define REPLACE_disp9s1
    227  1.1  christos ATTRIBUTE_UNUSED static unsigned
    228  1.1  christos replace_disp9s1 (unsigned insn, int value ATTRIBUTE_UNUSED)
    229  1.1  christos {
    230  1.1  christos   insn |= ((value >> 0) & 0x0007) << 0;
    231  1.1  christos   insn |= ((value >> 3) & 0x003f) << 5;
    232  1.1  christos 
    233  1.1  christos   return insn;
    234  1.1  christos }
    235  1.1  christos 
    236  1.1  christos #endif /* REPLACE_disp9s1 */
    237