From 4670103e86f59a80259fd593a6949d693382e536 Mon Sep 17 00:00:00 2001 From: Claudiu Zissulescu Date: Wed, 10 Feb 2016 12:09:01 +0000 Subject: Add support for ARC instruction relaxation in the assembler. gas/ 2016-01-26 Claudiu Zissulescu Janek van Oirschot * config/tc-arc.h (TC_FRAG_TYPE, TC_PCREL_ADJUST, MAX_INSN_ARGS) (MAX_INSN_FLGS, MAX_FLAG_NAME_LENGHT, TC_GENERIC_RELAX_TABLE): Define. (arc_flags, arc_relax_type): New structure. * config/tc-arc.c (FRAG_MAX_GROWTH, RELAX_TABLE_ENTRY) (RELAX_TABLE_ENTRY_MAX): New define. (relaxation_state, md_relax_table, arc_relaxable_insns) (arc_num_relaxable_ins): New variable. (rlx_operand_type, arc_rlx_types): New enums. (arc_relaxable_ins): New structure. (OPTION_RELAX): New option. (arc_insn): New relax member. (arc_flags): Remove. (relax_insn_p): New function. (apply_fixups): Likewise. (relaxable_operand): Likewise. (may_relax_expr): Likewise. (relaxable_flag): Likewise. (arc_pcrel_adjust): Likewise. (md_estimate_size_before_relax): Implement. (md_convert_frag): Likewise. (md_parse_option): Handle new mrelax option. (md_show_usage): Likewise. (assemble_insn): Set relax member. (emit_insn0): New function. (emit_insn1): Likewise. (emit_insn): Handle relaxation case. * NEWS: Mention the new relaxation option. * doc/c-arc.texi (ARC Options): Document new mrelax option. gas/testsuite 2016-01-26 Claudiu Zissulescu * gas/arc/relax-avoid1.d: New file. * gas/arc/relax-avoid1.s: Likewise. * gas/arc/relax-avoid2.d: Likewise. * gas/arc/relax-avoid2.s: Likewise. * gas/arc/relax-avoid3.d: Likewise. * gas/arc/relax-avoid3.s: Likewise. * gas/arc/relax-b.d: Likewise. * gas/arc/relax-b.s: Likewise. include/opcode/ 2016-01-26 Claudiu Zissulescu Janek van Oirschot * arc.h (arc_opcode arc_relax_opcodes, arc_num_relax_opcodes): Declare. opcodes/ 2016-01-26 Claudiu Zissulescu Janek van Oirschot * arc-opc.c (arc_relax_opcodes, arc_num_relax_opcodes): New variable. --- gas/config/tc-arc.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'gas/config/tc-arc.h') diff --git a/gas/config/tc-arc.h b/gas/config/tc-arc.h index ca5b152..acd007b 100644 --- a/gas/config/tc-arc.h +++ b/gas/config/tc-arc.h @@ -177,6 +177,14 @@ extern long md_pcrel_from_section (struct fix *, segT); /* This hook is required to parse register names as operands. */ #define md_parse_name(name, exp, m, c) arc_parse_name (name, exp) +/* Used within frags to pass some information to some relaxation + machine dependent values. */ +#define TC_FRAG_TYPE struct arc_relax_type + +/* Adjust non PC-rel values at relaxation time. */ +#define TC_PCREL_ADJUST(F) arc_pcrel_adjust (F) + +extern int arc_pcrel_adjust (fragS *); extern bfd_boolean arc_parse_name (const char *, struct expressionS *); extern int tc_arc_fix_adjustable (struct fix *); extern void arc_handle_align (fragS *); @@ -193,3 +201,51 @@ extern void arc_frob_label (symbolS *); #define NOP_OPCODE_S 0x000078E0 #define NOP_OPCODE_L 0x264A7000 /* mov 0,0. */ +#define MAX_FLAG_NAME_LENGHT 3 + +struct arc_flags +{ + /* Name of the parsed flag. */ + char name[MAX_FLAG_NAME_LENGHT + 1]; + + /* The code of the parsed flag. Valid when is not zero. */ + unsigned char code; +}; + +#ifndef MAX_INSN_ARGS +#define MAX_INSN_ARGS 6 +#endif + +#ifndef MAX_INSN_FLGS +#define MAX_INSN_FLGS 3 +#endif + +extern const relax_typeS md_relax_table[]; +#define TC_GENERIC_RELAX_TABLE md_relax_table + +/* Used to construct instructions at md_convert_frag stage of + relaxation. */ +struct arc_relax_type +{ + /* Dictates whether the pc-relativity should be kept in mind when + relax_frag is called or whether the pc-relativity should be + solved outside of relaxation. For clarification: BL(_S) and + B(_S) use pcrel == 1 and ADD with a solvable expression as 3rd + operand use pcrel == 0. */ + unsigned char pcrel; + + /* Expressions that dictate the operands. Used for re-assembling in + md_convert_frag. */ + expressionS tok[MAX_INSN_ARGS]; + + /* Number of tok (i.e. number of operands). Used for re-assembling + in md_convert_frag. */ + int ntok; + + /* Flags of instruction. Used for re-assembling in + md_convert_frag. */ + struct arc_flags pflags[MAX_INSN_FLGS]; + + /* Number of flags. Used for re-assembling in md_convert_frag. */ + int nflg; +}; -- cgit v1.1