File: mips-formats.h

package info (click to toggle)
binutils 2.31.1-16
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 309,412 kB
  • sloc: ansic: 1,161,194; asm: 638,508; cpp: 128,829; exp: 68,580; makefile: 55,828; sh: 22,360; yacc: 14,238; lisp: 13,272; perl: 2,111; ada: 1,681; lex: 1,652; pascal: 1,446; cs: 879; sed: 195; python: 154; xml: 95; awk: 25
file content (147 lines) | stat: -rw-r--r-- 4,334 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* mips-formats.h
   Copyright (C) 2013-2018 Free Software Foundation, Inc.

   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   It is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING3. If not,
   see <http://www.gnu.org/licenses/>.  */

/* For ARRAY_SIZE.  */
#include "libiberty.h"

#define INT_BIAS(SIZE, LSB, MAX_VAL, BIAS, SHIFT, PRINT_HEX) \
  { \
    static const struct mips_int_operand op = { \
      { OP_INT, SIZE, LSB }, MAX_VAL, BIAS, SHIFT, PRINT_HEX \
    }; \
    return &op.root; \
  }

#define INT_ADJ(SIZE, LSB, MAX_VAL, SHIFT, PRINT_HEX) \
  INT_BIAS(SIZE, LSB, MAX_VAL, 0, SHIFT, PRINT_HEX)

#define UINT(SIZE, LSB) \
  INT_ADJ(SIZE, LSB, (1 << (SIZE)) - 1, 0, FALSE)

#define SINT(SIZE, LSB) \
  INT_ADJ(SIZE, LSB, (1 << ((SIZE) - 1)) - 1, 0, FALSE)

#define HINT(SIZE, LSB) \
  INT_ADJ(SIZE, LSB, (1 << (SIZE)) - 1, 0, TRUE)

#define BIT(SIZE, LSB, BIAS) \
  { \
    static const struct mips_int_operand op = { \
      { OP_INT, SIZE, LSB }, (1 << (SIZE)) - 1, BIAS, 0, TRUE \
    }; \
    return &op.root; \
  }

#define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \
  { \
    typedef char ATTRIBUTE_UNUSED \
      static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
    static const struct mips_mapped_int_operand op = { \
      { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \
    }; \
    return &op.root; \
  }

#define MSB(SIZE, LSB, BIAS, ADD_LSB, OPSIZE) \
  { \
    static const struct mips_msb_operand op = { \
      { OP_MSB, SIZE, LSB }, BIAS, ADD_LSB, OPSIZE \
    }; \
    return &op.root; \
  }

#define REG(SIZE, LSB, BANK) \
  { \
    static const struct mips_reg_operand op = { \
      { OP_REG, SIZE, LSB }, OP_REG_##BANK, 0 \
    }; \
    return &op.root; \
  }

#define OPTIONAL_REG(SIZE, LSB, BANK) \
  { \
    static const struct mips_reg_operand op = { \
      { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, 0 \
    }; \
    return &op.root; \
  }

#define MAPPED_REG(SIZE, LSB, BANK, MAP) \
  { \
    typedef char ATTRIBUTE_UNUSED \
      static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
    static const struct mips_reg_operand op = { \
      { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
    }; \
    return &op.root; \
  }

#define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \
  { \
    typedef char ATTRIBUTE_UNUSED \
      static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
    static const struct mips_reg_operand op = { \
      { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
    }; \
    return &op.root; \
  }

#define REG_PAIR(SIZE, LSB, BANK, MAP) \
  { \
    typedef char ATTRIBUTE_UNUSED \
      static_assert1[(1 << (SIZE)) == ARRAY_SIZE (MAP##1)]; \
    typedef char ATTRIBUTE_UNUSED \
      static_assert2[(1 << (SIZE)) == ARRAY_SIZE (MAP##2)]; \
    static const struct mips_reg_pair_operand op = { \
      { OP_REG_PAIR, SIZE, LSB }, OP_REG_##BANK, MAP##1, MAP##2 \
    }; \
    return &op.root; \
  }

#define PCREL(SIZE, LSB, IS_SIGNED, SHIFT, ALIGN_LOG2, INCLUDE_ISA_BIT, \
              FLIP_ISA_BIT) \
  { \
    static const struct mips_pcrel_operand op = { \
      { { OP_PCREL, SIZE, LSB }, \
	(1 << ((SIZE) - (IS_SIGNED))) - 1, 0, SHIFT, TRUE }, \
      ALIGN_LOG2, INCLUDE_ISA_BIT, FLIP_ISA_BIT \
    }; \
    return &op.root.root; \
  }

#define JUMP(SIZE, LSB, SHIFT) \
  PCREL (SIZE, LSB, FALSE, SHIFT, SIZE + SHIFT, TRUE, FALSE)

#define JALX(SIZE, LSB, SHIFT) \
  PCREL (SIZE, LSB, FALSE, SHIFT, SIZE + SHIFT, TRUE, TRUE)

#define BRANCH(SIZE, LSB, SHIFT) \
  PCREL (SIZE, LSB, TRUE, SHIFT, 0, TRUE, FALSE)

#define SPECIAL(SIZE, LSB, TYPE) \
  { \
    static const struct mips_operand op = { OP_##TYPE, SIZE, LSB }; \
    return &op; \
  }

#define PREV_CHECK(SIZE, LSB, GT_OK, LT_OK, EQ_OK, ZERO_OK) \
  { \
    static const struct mips_check_prev_operand op = { \
      { OP_CHECK_PREV, SIZE, LSB }, GT_OK, LT_OK, EQ_OK, ZERO_OK \
    }; \
    return &op.root; \
  }