binutils-gdb/opcodes/mips-formats.h
Richard Sandiford 3ccad066ac include/opcode/
* mips.h (mips_pcrel_operand): Inherit from mips_int_operand.
	(mips_int_operand_min, mips_int_operand_max): New functions.
	(mips_decode_pcrel_operand): Use mips_decode_int_operand.

opcodes/
	* mips-formats.h (PCREL): Reorder parameters and update the definition
	to match new mips_pcrel_operand layout.
	(JUMP, JALX, BRANCH): Update accordingly.
	* mips16-opc.c (decode_mips16_operand): Likewise.

gas/
	* config/tc-mips.c (match_int_operand): Use mips_int_operand_min
	and mips_int_operand_max.
	(mips16_immed_operand, mips16_immed_operands, MIPS16_NUM_IMMED):
	Delete.
	(mips16_immed_operand, mips16_immed_in_range_p): New functions.
	(mips16_immed, mips16_extended_frag): Use them.  Use mips_int_operand
	instead of mips16_immed_operand.
2013-08-03 10:49:48 +00:00

119 lines
3.4 KiB
C

/* mips-formats.h
Copyright 2013 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_ADJ(SIZE, LSB, MAX_VAL, SHIFT, PRINT_HEX) \
{ \
static const struct mips_int_operand op = { \
{ OP_INT, SIZE, LSB }, MAX_VAL, 0, SHIFT, PRINT_HEX \
}; \
return &op.root; \
}
#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 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 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; \
}