Opcodes and assembler support for Nios II R2

2015-07-01  Sandra Loosemore  <sandra@codesourcery.com>
	    Cesar Philippidis  <cesar@codesourcery.com>

	gas/
	* config/tc-nios2.c (nios2_min_align): New.
	(nop): Replace with....
	(nop_r1, nop_r2, nop_r2_cdx, nop32, nop16): New.
	(nios2_align): Handle alignment on 2-byte boundaries when CDX
	instructions may be present.
	(s_nios2_align): Adjust reference to nop.
	(CDXBRANCH, IS_CDXBRANCH): New.
	(CDX_UBRANCH_SUBTYPE, CDX_CBRANCH_SUBTYPE): New.
	(nios2_relax_subtype_size): Handle 2-byte CDX branches.
	(nios2_relax_frag): Likewise.
	(md_convert_frag): Handle R2 encodings.
	(nios2_check_overflow): Check that low-order bits are zero
	before applying rightshift from howto.
	(nios2_check_overflow): Correct negative overflow calculation.
	(nios2_diagnose_overflow): Handle signed_immed12_overflow.  Issue
	generic overflow messages for miscellaneous instruction formats.
	(md_apply_fix): Recognize new R2 relocations.  For pc_relative
	relocations, store fixup in *valP.
	(nios2_reglist_mask, nios2_reglist_dir): New.
	(nios2_parse_reglist): New.
	(nios2_parse_base_register): New.
	(nios2_assemble_expression): Handle constant expressions designated
	by BFD_RELOC_NONE.
	(nios2_assemble_reg3): New.
	(nios2_assemble_arg_c): Handle R2 instruction formats.
	(nios2_assemble_arg_d): Likewise.
	(nios2_assemble_arg_s): Likewise.
	(nios2_assemble_arg_t): Likewise.
	(nios2_assemble_arg_D): New.
	(nios2_assemble_arg_S): New.
	(nios2_assemble_arg_T): New.
	(nios2_assemble_arg_i): Handle R2 instruction formats.
	(nios2_assemble_arg_I): New.
	(nios2_assemble_arg_u): Handle R2 instruction formats.
	(nios2_assemble_arg_U): New.
	(nios2_assemble_arg_V): New.
	(nios2_assemble_arg_W): New.
	(nios2_assemble_arg_X): New.
	(nios2_assemble_arg_Y): New.
	(nios2_assemble_arg_o): Handle R2 instruction formats.
	(nios2_assemble_arg_O): New.
	(nios2_assemble_arg_P): New.
	(nios2_assemble_arg_j): Handle R2 instruction formats.
	(nios2_assemble_arg_k): New.
	(nios2_assemble_arg_l): Handle R2 instruction formats.
	(nios2_assemble_arg_m): Likewise.
	(nios2_assemble_arg_M): New.
	(nios2_assemble_arg_N): New.
	(nios2_assemble_arg_e): New.
	(nios2_assemble_arg_f): New.
	(nios2_assemble_arg_g): New.
	(nios2_assemble_arg_h): New.
	(nios2_assemble_arg_R): New.
	(nios2_assemble_arg_B): New.
	(nios2_assemble_args): Handle new argument letters.
	(nios2_consume_arg): Likewise.
	(nios2_translate_pseudo_insn): Avoid dereferencing null pointer
	in error message.
	(nios2_ps_insn_info_structs): Add nop.n.
	(output_ubranch): Handle CDX branches.
	(output_cbranch): Likewise.
	(output_call): Handle R2 encodings.
	(output_movia): Likewise.
	(md_begin): Initialize nios2_min_align.
	(md_assemble): Align to nios2_min_align.  Adjust nios2_min_align
	if a 16-bit instruction is seen.
	(nios2_cons_align): Use appropriate nop pattern.

	include/opcode/
	* nios2.h (enum iw_format_type): Add R2 formats.
	(enum overflow_type): Add signed_immed12_overflow and
	enumeration_overflow for R2.
	(struct nios2_opcode): Document new argument letters for R2.
	(REG_3BIT, REG_LDWM, REG_POP): Define.
	(includes): Include nios2r2.h.
	(nios2_r2_opcodes, nios2_num_r2_opcodes): Declare.
	(nios2_r2_asi_n_mappings, nios2_num_r2_asi_n_mappings): Declare.
	(nios2_r2_shi_n_mappings, nios2_num_r2_shi_n_mappings): Declare.
	(nios2_r2_andi_n_mappings, nios2_num_r2_andi_n_mappings): Declare.
	(nios2_r2_reg3_mappings, nios2_num_r2_reg3_mappings): Declare.
	(nios2_r2_reg_range_mappings, nios2_num_r2_reg_range_mappings):
	Declare.
	* nios2r2.h: New file.

	opcodes/
	* nios2-dis.c (nios2_extract_opcode): New.
	(nios2_disassembler_state): New.
	(nios2_find_opcode_hash): Use mach parameter to select correct
	disassembler state.
	(nios2_print_insn_arg): Extend to support new R2 argument letters
	and formats.
	(print_insn_nios2): Check for 16-bit instruction at end of memory.
	* nios2-opc.c (nios2_builtin_regs): Add R2 register attributes.
	(NIOS2_NUM_OPCODES): Rename to...
	(NIOS2_NUM_R1_OPCODES): This.
	(nios2_r2_opcodes): New.
	(NIOS2_NUM_R2_OPCODES): New.
	(nios2_num_r2_opcodes): New.
	(nios2_r2_asi_n_mappings, nios2_num_r2_asi_n_mappings): New.
	(nios2_r2_shi_n_mappings, nios2_num_r2_shi_n_mappings): New.
	(nios2_r2_andi_n_mappings, nios2_num_r2_andi_n_mappings): New.
	(nios2_r2_reg3_mappings, nios2_num_r2_reg3_mappings): New.
	(nios2_r2_reg_range_mappings, nios2_num_r2_reg_range_mappings):	New.
This commit is contained in:
Sandra Loosemore
2015-07-01 16:08:03 -07:00
parent 8c163c5a87
commit c8c8175b62
8 changed files with 3603 additions and 167 deletions

View File

@@ -1,3 +1,21 @@
2015-07-01 Sandra Loosemore <sandra@codesourcery.com>
Cesar Philippidis <cesar@codesourcery.com>
* nios2.h (enum iw_format_type): Add R2 formats.
(enum overflow_type): Add signed_immed12_overflow and
enumeration_overflow for R2.
(struct nios2_opcode): Document new argument letters for R2.
(REG_3BIT, REG_LDWM, REG_POP): Define.
(includes): Include nios2r2.h.
(nios2_r2_opcodes, nios2_num_r2_opcodes): Declare.
(nios2_r2_asi_n_mappings, nios2_num_r2_asi_n_mappings): Declare.
(nios2_r2_shi_n_mappings, nios2_num_r2_shi_n_mappings): Declare.
(nios2_r2_andi_n_mappings, nios2_num_r2_andi_n_mappings): Declare.
(nios2_r2_reg3_mappings, nios2_num_r2_reg3_mappings): Declare.
(nios2_r2_reg_range_mappings, nios2_num_r2_reg_range_mappings):
Declare.
* nios2r2.h: New file.
2015-06-19 Peter Bergner <bergner@vnet.ibm.com>
* ppc.h (PPC_OPERAND_OPTIONAL_VALUE): New.

View File

@@ -37,11 +37,38 @@ extern "C" {
/* Instruction encoding formats. */
enum iw_format_type {
/* R1 formats */
/* R1 formats. */
iw_i_type,
iw_r_type,
iw_j_type,
iw_custom_type
iw_custom_type,
/* 32-bit R2 formats. */
iw_L26_type,
iw_F2I16_type,
iw_F2X4I12_type,
iw_F1X4I12_type,
iw_F1X4L17_type,
iw_F3X6L5_type,
iw_F2X6L10_type,
iw_F3X6_type,
iw_F3X8_type,
/* 16-bit R2 formats. */
iw_I10_type,
iw_T1I7_type,
iw_T2I4_type,
iw_T1X1I6_type,
iw_X1I7_type,
iw_L5I4X1_type,
iw_T2X1L3_type,
iw_T2X1I3_type,
iw_T3X1_type,
iw_T2X3_type,
iw_F1X1_type,
iw_X2L5_type,
iw_F1I5_type,
iw_F2_type
};
/* Identify different overflow situations for error messages. */
@@ -53,7 +80,9 @@ enum overflow_type
signed_immed16_overflow,
unsigned_immed16_overflow,
unsigned_immed5_overflow,
signed_immed12_overflow,
custom_opcode_overflow,
enumeration_overflow,
no_overflow
};
@@ -65,12 +94,32 @@ enum overflow_type
d - a 5-bit destination register index
s - a 5-bit left source register index
t - a 5-bit right source register index
D - a 3-bit encoded destination register
S - a 3-bit encoded left source register
T - a 3-bit encoded right source register
i - a 16-bit signed immediate
u - a 16-bit unsigned immediate
o - a 16-bit signed program counter relative offset
j - a 5-bit unsigned immediate
k - a (second) 5-bit unsigned immediate
l - a 8-bit custom instruction constant
m - a 26-bit unsigned immediate
o - a 16-bit signed pc-relative offset
u - a 16-bit unsigned immediate
I - a 12-bit signed immediate
M - a 6-bit unsigned immediate
N - a 6-bit unsigned immediate with 2-bit shift
O - a 10-bit signed pc-relative offset with 1-bit shift
P - a 7-bit signed pc-relative offset with 1-bit shift
U - a 7-bit unsigned immediate with 2-bit shift
V - a 5-bit unsigned immediate with 2-bit shift
W - a 4-bit unsigned immediate with 2-bit shift
X - a 4-bit unsigned immediate with 1-bit shift
Y - a 4-bit unsigned immediate
e - an immediate coded as an enumeration for addi.n/subi.n
f - an immediate coded as an enumeration for slli.n/srli.n
g - an immediate coded as an enumeration for andi.n
h - an immediate coded as an enumeration for movi.n
R - a reglist for ldwm/stwm or push.n/pop.n
B - a base register specifier and option list for ldwm/stwm
Literal ',', '(', and ')' characters may also appear in the args as
delimiters.
@@ -130,6 +179,9 @@ struct nios2_opcode
#define REG_NORMAL (1<<0) /* Normal registers. */
#define REG_CONTROL (1<<1) /* Control registers. */
#define REG_COPROCESSOR (1<<2) /* For custom instructions. */
#define REG_3BIT (1<<3) /* For R2 CDX instructions. */
#define REG_LDWM (1<<4) /* For R2 ldwm/stwm. */
#define REG_POP (1<<5) /* For R2 pop.n/push.n. */
struct nios2_reg
{
@@ -140,10 +192,13 @@ struct nios2_reg
/* Pull in the instruction field accessors, opcodes, and masks. */
#include "nios2r1.h"
#include "nios2r2.h"
/* These are the data structures used to hold the instruction information. */
extern const struct nios2_opcode nios2_r1_opcodes[];
extern const int nios2_num_r1_opcodes;
extern const struct nios2_opcode nios2_r2_opcodes[];
extern const int nios2_num_r2_opcodes;
extern struct nios2_opcode *nios2_opcodes;
extern int nios2_num_opcodes;
@@ -157,6 +212,22 @@ extern int nios2_num_regs;
extern const struct nios2_opcode *
nios2_find_opcode_hash (unsigned long, unsigned long);
/* Lookup tables for R2 immediate decodings. */
extern unsigned int nios2_r2_asi_n_mappings[];
extern const int nios2_num_r2_asi_n_mappings;
extern unsigned int nios2_r2_shi_n_mappings[];
extern const int nios2_num_r2_shi_n_mappings;
extern unsigned int nios2_r2_andi_n_mappings[];
extern const int nios2_num_r2_andi_n_mappings;
/* Lookup table for 3-bit register decodings. */
extern int nios2_r2_reg3_mappings[];
extern const int nios2_num_r2_reg3_mappings;
/* Lookup table for REG_RANGE value list decodings. */
extern unsigned long nios2_r2_reg_range_mappings[];
extern const int nios2_num_r2_reg_range_mappings;
#ifdef __cplusplus
}
#endif

1081
include/opcode/nios2r2.h Normal file

File diff suppressed because it is too large Load Diff