add39d2344
Its a bit shorter and simpler than raw xmalloc. gas/ChangeLog: 2016-05-13 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * app.c (app_push): Use XNEW and related macros. * as.c (parse_args): Likewise. * cgen.c (make_right_shifted_expr): Likewise. (gas_cgen_tc_gen_reloc): Likewise. * config/bfin-defs.h: Likewise. * config/bfin-parse.y: Likewise. * config/obj-coff.c (stack_init): Likewise. (stack_push): Likewise. (coff_obj_symbol_new_hook): Likewise. (coff_obj_symbol_clone_hook): Likewise. (add_lineno): Likewise. (coff_frob_symbol): Likewise. * config/obj-elf.c (obj_elf_section_name): Likewise. (build_group_lists): Likewise. * config/obj-evax.c (evax_symbol_new_hook): Likewise. * config/obj-macho.c (obj_mach_o_indirect_symbol): Likewise. * config/tc-aarch64.c (insert_reg_alias): Likewise. (find_or_make_literal_pool): Likewise. (add_to_lit_pool): Likewise. (fill_instruction_hash_table): Likewise. * config/tc-alpha.c (load_expression): Likewise. (emit_jsrjmp): Likewise. (s_alpha_ent): Likewise. (s_alpha_end): Likewise. (s_alpha_linkage): Likewise. (md_begin): Likewise. (tc_gen_reloc): Likewise. * config/tc-arc.c (arc_insert_opcode): Likewise. (arc_extcorereg): Likewise. * config/tc-bfin.c: Likewise. * config/tc-cr16.c: Likewise. * config/tc-cris.c: Likewise. * config/tc-crx.c (preprocess_reglist): Likewise. * config/tc-d10v.c: Likewise. * config/tc-frv.c (frv_insert_vliw_insn): Likewise. (frv_tomcat_shuffle): Likewise. * config/tc-h8300.c: Likewise. * config/tc-i370.c (i370_macro): Likewise. * config/tc-i386.c (lex_got): Likewise. (md_parse_option): Likewise. * config/tc-ia64.c (alloc_record): Likewise. (set_imask): Likewise. (save_prologue_count): Likewise. (dot_proc): Likewise. (dot_endp): Likewise. (ia64_frob_label): Likewise. (add_qp_imply): Likewise. (add_qp_mutex): Likewise. (mark_resource): Likewise. (dot_alias): Likewise. * config/tc-m68hc11.c: Likewise. * config/tc-m68k.c (m68k_frob_label): Likewise. (s_save): Likewise. (mri_control_label): Likewise. (push_mri_control): Likewise. (build_mri_control_operand): Likewise. (s_mri_else): Likewise. (s_mri_break): Likewise. (s_mri_next): Likewise. (s_mri_for): Likewise. (s_mri_endw): Likewise. * config/tc-metag.c (create_mnemonic_htab): Likewise. * config/tc-microblaze.c: Likewise. * config/tc-mmix.c (s_loc): Likewise. * config/tc-nds32.c (nds32_relax_hint): Likewise. * config/tc-nios2.c (nios2_insn_reloc_new): Likewise. * config/tc-rl78.c: Likewise. * config/tc-rx.c (rx_include): Likewise. * config/tc-sh.c: Likewise. * config/tc-sh64.c (shmedia_frob_section_type): Likewise. * config/tc-sparc.c: Likewise. * config/tc-spu.c: Likewise. * config/tc-tic6x.c (static tic6x_unwind_info *tic6x_get_unwind): Likewise. (tic6x_start_unwind_section): Likewise. * config/tc-tilegx.c: Likewise. * config/tc-tilepro.c: Likewise. * config/tc-v850.c: Likewise. * config/tc-visium.c: Likewise. * config/tc-xgate.c: Likewise. * config/tc-xtensa.c (xtensa_translate_old_userreg_ops): Likewise. (new_resource_table): Likewise. (resize_resource_table): Likewise. (xtensa_create_trampoline_frag): Likewise. (xtensa_maybe_create_literal_pool_frag): Likewise. (cache_literal_section): Likewise. * config/xtensa-relax.c (append_transition): Likewise. (append_condition): Likewise. (append_value_condition): Likewise. (append_constant_value_condition): Likewise. (append_literal_op): Likewise. (append_label_op): Likewise. (append_constant_op): Likewise. (append_field_op): Likewise. (append_user_fn_field_op): Likewise. (enter_opname_n): Likewise. (enter_opname): Likewise. (split_string): Likewise. (parse_insn_templ): Likewise. (clone_req_or_option_list): Likewise. (clone_req_option_list): Likewise. (parse_option_cond): Likewise. (parse_insn_pattern): Likewise. (parse_insn_repl): Likewise. (build_transition): Likewise. (build_transition_table): Likewise. * dw2gencfi.c (alloc_fde_entry): Likewise. (alloc_cfi_insn_data): Likewise. (cfi_add_CFA_remember_state): Likewise. (dot_cfi_escape): Likewise. (dot_cfi_fde_data): Likewise. (select_cie_for_fde): Likewise. * dwarf2dbg.c (dwarf2_directive_loc): Likewise. * ecoff.c (ecoff_add_bytes): Likewise. (ecoff_build_debug): Likewise. * input-scrub.c (input_scrub_push): Likewise. (input_scrub_begin): Likewise. (input_scrub_next_buffer): Likewise. * itbl-ops.c (append_insns_as_macros): Likewise. (alloc_entry): Likewise. (alloc_field): Likewise. * listing.c (listing_newline): Likewise. (listing_listing): Likewise. * macro.c (get_any_string): Likewise. (delete_macro): Likewise. * stabs.c (generate_asm_file): Likewise. (stabs_generate_asm_lineno): Likewise. * subsegs.c (subseg_change): Likewise. (subseg_get): Likewise. * symbols.c (define_dollar_label): Likewise. (symbol_relc_make_sym): Likewise. * write.c (write_relocs): Likewise.
397 lines
9.0 KiB
C
397 lines
9.0 KiB
C
/* bfin-defs.h ADI Blackfin gas header file
|
|
Copyright (C) 2005-2016 Free Software Foundation, Inc.
|
|
|
|
This file is part of GAS, the GNU Assembler.
|
|
|
|
GAS 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.
|
|
|
|
GAS 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 GAS; see the file COPYING. If not, write to the Free
|
|
Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
|
|
02110-1301, USA. */
|
|
|
|
#ifndef BFIN_PARSE_H
|
|
#define BFIN_PARSE_H
|
|
|
|
#include "opcode/bfin.h"
|
|
|
|
#define PCREL 1
|
|
#define CODE_FRAG_SIZE 4096 /* 1 page. */
|
|
|
|
|
|
/* Definition for all status bits. */
|
|
typedef enum
|
|
{
|
|
c_0,
|
|
c_1,
|
|
c_4,
|
|
c_2,
|
|
c_uimm2,
|
|
c_uimm3,
|
|
c_imm3,
|
|
c_pcrel4,
|
|
c_imm4,
|
|
c_uimm4s4,
|
|
c_uimm4,
|
|
c_uimm4s2,
|
|
c_negimm5s4,
|
|
c_imm5,
|
|
c_uimm5,
|
|
c_imm6,
|
|
c_imm7,
|
|
c_imm8,
|
|
c_uimm8,
|
|
c_pcrel8,
|
|
c_uimm8s4,
|
|
c_pcrel8s4,
|
|
c_lppcrel10,
|
|
c_pcrel10,
|
|
c_pcrel12,
|
|
c_imm16s4,
|
|
c_luimm16,
|
|
c_imm16,
|
|
c_huimm16,
|
|
c_rimm16,
|
|
c_imm16s2,
|
|
c_uimm16s4,
|
|
c_uimm16,
|
|
c_pcrel24
|
|
} const_forms_t;
|
|
|
|
|
|
/* High-Nibble: group code, low nibble: register code. */
|
|
|
|
|
|
#define T_REG_R 0x00
|
|
#define T_REG_P 0x10
|
|
#define T_REG_I 0x20
|
|
#define T_REG_B 0x30
|
|
#define T_REG_L 0x34
|
|
#define T_REG_M 0x24
|
|
#define T_REG_A 0x40
|
|
|
|
/* All registers above this value don't
|
|
belong to a usuable register group. */
|
|
#define T_NOGROUP 0xa0
|
|
|
|
/* Flags. */
|
|
#define F_REG_NONE 0
|
|
#define F_REG_HIGH 1
|
|
#define F_REG_LOW 2
|
|
|
|
enum machine_registers
|
|
{
|
|
REG_R0 = T_REG_R, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7,
|
|
REG_P0 = T_REG_P, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
|
|
REG_I0 = T_REG_I, REG_I1, REG_I2, REG_I3,
|
|
REG_M0 = T_REG_M, REG_M1, REG_M2, REG_M3,
|
|
REG_B0 = T_REG_B, REG_B1, REG_B2, REG_B3,
|
|
REG_L0 = T_REG_L, REG_L1, REG_L2, REG_L3,
|
|
REG_A0x = T_REG_A, REG_A0w, REG_A1x, REG_A1w,
|
|
REG_ASTAT = 0x46,
|
|
REG_RETS = 0x47,
|
|
REG_LC0 = 0x60, REG_LT0, REG_LB0, REG_LC1, REG_LT1, REG_LB1,
|
|
REG_CYCLES, REG_CYCLES2,
|
|
REG_USP = 0x70, REG_SEQSTAT, REG_SYSCFG,
|
|
REG_RETI, REG_RETX, REG_RETN, REG_RETE, REG_EMUDAT,
|
|
|
|
/* These don't have groups. */
|
|
REG_sftreset = T_NOGROUP, REG_omode, REG_excause, REG_emucause,
|
|
REG_idle_req, REG_hwerrcause,
|
|
REG_A0 = 0xc0, REG_A1, REG_CC,
|
|
/* Pseudo registers, used only for distinction from symbols. */
|
|
REG_RL0, REG_RL1, REG_RL2, REG_RL3,
|
|
REG_RL4, REG_RL5, REG_RL6, REG_RL7,
|
|
REG_RH0, REG_RH1, REG_RH2, REG_RH3,
|
|
REG_RH4, REG_RH5, REG_RH6, REG_RH7,
|
|
REG_LASTREG
|
|
};
|
|
|
|
/* Status register flags. */
|
|
|
|
enum statusflags
|
|
{
|
|
S_AZ = 0,
|
|
S_AN,
|
|
S_AC0_COPY,
|
|
S_V_COPY,
|
|
S_AQ = 6,
|
|
S_RND_MOD = 8,
|
|
S_AC0 = 12,
|
|
S_AC1,
|
|
S_AV0 = 16,
|
|
S_AV0S,
|
|
S_AV1,
|
|
S_AV1S,
|
|
S_V = 24,
|
|
S_VS = 25
|
|
};
|
|
|
|
|
|
enum reg_class
|
|
{
|
|
rc_dregs_lo,
|
|
rc_dregs_hi,
|
|
rc_dregs,
|
|
rc_dregs_pair,
|
|
rc_pregs,
|
|
rc_spfp,
|
|
rc_dregs_hilo,
|
|
rc_accum_ext,
|
|
rc_accum_word,
|
|
rc_accum,
|
|
rc_iregs,
|
|
rc_mregs,
|
|
rc_bregs,
|
|
rc_lregs,
|
|
rc_dpregs,
|
|
rc_gregs,
|
|
rc_regs,
|
|
rc_statbits,
|
|
rc_ignore_bits,
|
|
rc_ccstat,
|
|
rc_counters,
|
|
rc_dregs2_sysregs1,
|
|
rc_open,
|
|
rc_sysregs2,
|
|
rc_sysregs3,
|
|
rc_allregs,
|
|
LIM_REG_CLASSES
|
|
};
|
|
|
|
/* Register type checking macros. */
|
|
|
|
#define CODE_MASK 0x07
|
|
#define CLASS_MASK 0xf0
|
|
|
|
#define REG_SAME(a, b) ((a).regno == (b).regno)
|
|
#define REG_EQUAL(a, b) (((a).regno & CODE_MASK) == ((b).regno & CODE_MASK))
|
|
#define REG_CLASS(a) ((a).regno & 0xf0)
|
|
#define IS_A1(a) ((a).regno == REG_A1)
|
|
#define IS_H(a) ((a).flags & F_REG_HIGH ? 1: 0)
|
|
#define IS_EVEN(r) ((r).regno % 2 == 0)
|
|
#define IS_HCOMPL(a, b) (REG_EQUAL(a, b) && \
|
|
((a).flags & F_REG_HIGH) != ((b).flags & F_REG_HIGH))
|
|
|
|
/* register type checking. */
|
|
#define _TYPECHECK(r, x) (((r).regno & CLASS_MASK) == T_REG_##x)
|
|
|
|
#define IS_DREG(r) _TYPECHECK(r, R)
|
|
#define IS_DREG_H(r) (_TYPECHECK(r, R) && IS_H(r))
|
|
#define IS_DREG_L(r) (_TYPECHECK(r, R) && !IS_H(r))
|
|
#define IS_PREG(r) _TYPECHECK(r, P)
|
|
#define IS_IREG(r) (((r).regno & 0xf4) == T_REG_I)
|
|
#define IS_MREG(r) (((r).regno & 0xf4) == T_REG_M)
|
|
#define IS_BREG(r) (((r).regno & 0xf4) == T_REG_B)
|
|
#define IS_LREG(r) (((r).regno & 0xf4) == T_REG_L)
|
|
#define IS_CREG(r) ((r).regno == REG_LC0 || (r).regno == REG_LC1)
|
|
#define IS_EMUDAT(r) ((r).regno == REG_EMUDAT)
|
|
#define IS_ALLREG(r) ((r).regno < T_NOGROUP)
|
|
|
|
#define IS_GENREG(r) \
|
|
(IS_DREG (r) || IS_PREG (r) \
|
|
|| (r).regno == REG_A0x || (r).regno == REG_A0w \
|
|
|| (r).regno == REG_A1x || (r).regno == REG_A1w)
|
|
|
|
#define IS_DAGREG(r) \
|
|
(IS_IREG (r) || IS_MREG (r) || IS_BREG (r) || IS_LREG (r))
|
|
|
|
#define IS_SYSREG(r) \
|
|
((r).regno == REG_ASTAT || (r).regno == REG_SEQSTAT \
|
|
|| (r).regno == REG_SYSCFG || (r).regno == REG_RETI \
|
|
|| (r).regno == REG_RETX || (r).regno == REG_RETN \
|
|
|| (r).regno == REG_RETE || (r).regno == REG_RETS \
|
|
|| (r).regno == REG_LC0 || (r).regno == REG_LC1 \
|
|
|| (r).regno == REG_LT0 || (r).regno == REG_LT1 \
|
|
|| (r).regno == REG_LB0 || (r).regno == REG_LB1 \
|
|
|| (r).regno == REG_CYCLES || (r).regno == REG_CYCLES2 \
|
|
|| (r).regno == REG_EMUDAT)
|
|
|
|
/* Expression value macros. */
|
|
|
|
typedef enum
|
|
{
|
|
ones_compl,
|
|
twos_compl,
|
|
mult,
|
|
divide,
|
|
mod,
|
|
add,
|
|
sub,
|
|
lsh,
|
|
rsh,
|
|
logand,
|
|
logior,
|
|
logxor
|
|
} expr_opcodes_t;
|
|
|
|
struct expressionS;
|
|
|
|
#define SYMBOL_T symbolS*
|
|
|
|
struct expression_cell
|
|
{
|
|
int value;
|
|
SYMBOL_T symbol;
|
|
};
|
|
|
|
/* User Type Definitions. */
|
|
struct bfin_insn
|
|
{
|
|
unsigned long value;
|
|
struct bfin_insn *next;
|
|
struct expression_cell *exp;
|
|
int pcrel;
|
|
int reloc;
|
|
};
|
|
|
|
#define INSTR_T struct bfin_insn*
|
|
#define EXPR_T struct expression_cell*
|
|
|
|
typedef struct expr_node_struct Expr_Node;
|
|
|
|
extern INSTR_T gencode (unsigned long x);
|
|
extern INSTR_T conscode (INSTR_T head, INSTR_T tail);
|
|
extern INSTR_T conctcode (INSTR_T head, INSTR_T tail);
|
|
extern INSTR_T note_reloc
|
|
(INSTR_T code, Expr_Node *, int reloc,int pcrel);
|
|
extern INSTR_T note_reloc1
|
|
(INSTR_T code, const char * sym, int reloc, int pcrel);
|
|
extern INSTR_T note_reloc2
|
|
(INSTR_T code, const char *symbol, int reloc, int value, int pcrel);
|
|
|
|
/* Types of expressions. */
|
|
typedef enum
|
|
{
|
|
Expr_Node_Binop, /* Binary operator. */
|
|
Expr_Node_Unop, /* Unary operator. */
|
|
Expr_Node_Reloc, /* Symbol to be relocated. */
|
|
Expr_Node_GOT_Reloc, /* Symbol to be relocated using the GOT. */
|
|
Expr_Node_Constant /* Constant. */
|
|
} Expr_Node_Type;
|
|
|
|
/* Types of operators. */
|
|
typedef enum
|
|
{
|
|
Expr_Op_Type_Add,
|
|
Expr_Op_Type_Sub,
|
|
Expr_Op_Type_Mult,
|
|
Expr_Op_Type_Div,
|
|
Expr_Op_Type_Mod,
|
|
Expr_Op_Type_Lshift,
|
|
Expr_Op_Type_Rshift,
|
|
Expr_Op_Type_BAND, /* Bitwise AND. */
|
|
Expr_Op_Type_BOR, /* Bitwise OR. */
|
|
Expr_Op_Type_BXOR, /* Bitwise exclusive OR. */
|
|
Expr_Op_Type_LAND, /* Logical AND. */
|
|
Expr_Op_Type_LOR, /* Logical OR. */
|
|
Expr_Op_Type_NEG,
|
|
Expr_Op_Type_COMP /* Complement. */
|
|
} Expr_Op_Type;
|
|
|
|
/* The value that can be stored ... depends on type. */
|
|
typedef union
|
|
{
|
|
const char *s_value; /* if relocation symbol, the text. */
|
|
long long i_value; /* if constant, the value. */
|
|
Expr_Op_Type op_value; /* if operator, the value. */
|
|
} Expr_Node_Value;
|
|
|
|
/* The expression node. */
|
|
struct expr_node_struct
|
|
{
|
|
Expr_Node_Type type;
|
|
Expr_Node_Value value;
|
|
Expr_Node *Left_Child;
|
|
Expr_Node *Right_Child;
|
|
};
|
|
|
|
|
|
/* Operations on the expression node. */
|
|
Expr_Node *Expr_Node_Create (Expr_Node_Type type,
|
|
Expr_Node_Value value,
|
|
Expr_Node *Left_Child,
|
|
Expr_Node *Right_Child);
|
|
|
|
/* Generate the reloc structure as a series of instructions. */
|
|
INSTR_T Expr_Node_Gen_Reloc (Expr_Node *head, int parent_reloc);
|
|
|
|
#define MKREF(x) mkexpr (0,x)
|
|
|
|
#define NULL_CODE ((INSTR_T) 0)
|
|
|
|
#ifndef EXPR_VALUE
|
|
#define EXPR_VALUE(x) (((x)->type == Expr_Node_Constant) ? ((x)->value.i_value) : 0)
|
|
#endif
|
|
#ifndef EXPR_SYMBOL
|
|
#define EXPR_SYMBOL(x) ((x)->symbol)
|
|
#endif
|
|
|
|
|
|
typedef long reg_t;
|
|
|
|
|
|
typedef struct _register
|
|
{
|
|
reg_t regno; /* Register ID as defined in machine_registers. */
|
|
int flags;
|
|
} Register;
|
|
|
|
|
|
typedef struct _macfunc
|
|
{
|
|
char n;
|
|
char op;
|
|
char w;
|
|
char P;
|
|
Register dst;
|
|
Register s0;
|
|
Register s1;
|
|
} Macfunc;
|
|
|
|
typedef struct _opt_mode
|
|
{
|
|
int MM;
|
|
int mod;
|
|
} Opt_mode;
|
|
|
|
typedef enum
|
|
{
|
|
SEMANTIC_ERROR,
|
|
NO_INSN_GENERATED,
|
|
INSN_GENERATED
|
|
} parse_state;
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
extern int debug_codeselection;
|
|
|
|
void error (const char *format, ...);
|
|
void warn (char *format, ...);
|
|
int semantic_error (char *syntax);
|
|
void semantic_error_2 (char *syntax);
|
|
|
|
EXPR_T mkexpr (int, SYMBOL_T);
|
|
|
|
/* Defined in bfin-lex.l. */
|
|
void set_start_state (void);
|
|
|
|
extern int insn_regmask (int, int);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* BFIN_PARSE_H */
|
|
|