160484Sobrien/* GAS cgen support. 2218822Sdim Copyright 1998, 1999, 2000, 2001, 2002, 2003 3218822Sdim Free Software Foundation, Inc. 460484Sobrien 560484Sobrien This file is part of GAS, the GNU Assembler. 660484Sobrien 760484Sobrien GAS is free software; you can redistribute it and/or modify 860484Sobrien it under the terms of the GNU General Public License as published by 960484Sobrien the Free Software Foundation; either version 2, or (at your option) 1060484Sobrien any later version. 1160484Sobrien 1260484Sobrien GAS is distributed in the hope that it will be useful, 1360484Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1460484Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1560484Sobrien GNU General Public License for more details. 1660484Sobrien 1760484Sobrien You should have received a copy of the GNU General Public License 1860484Sobrien along with GAS; see the file COPYING. If not, write to the Free 19218822Sdim Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 20218822Sdim 02110-1301, USA. */ 2160484Sobrien 2260484Sobrien#ifndef GAS_CGEN_H 2360484Sobrien#define GAS_CGEN_H 2460484Sobrien 2560484Sobrien/* Opcode table handle. */ 2660484Sobrienextern CGEN_CPU_DESC gas_cgen_cpu_desc; 2760484Sobrien 2860484Sobrien/* Maximum number of fixups in an insn. 2960484Sobrien If you need to change this, allow target to override and do so there. */ 3085815Sobrien#ifndef GAS_CGEN_MAX_FIXUPS 3160484Sobrien#define GAS_CGEN_MAX_FIXUPS 3 3285815Sobrien#endif 3360484Sobrien 3460484Sobrien/* Struct defining result of gas_cgen_finish_insn. */ 3560484Sobrientypedef struct { 3660484Sobrien /* frag containing the insn */ 3760484Sobrien fragS * frag; 3860484Sobrien /* Address of insn in frag. */ 3960484Sobrien char * addr; 4060484Sobrien /* Number of fixups this insn has. */ 4160484Sobrien int num_fixups; 4260484Sobrien /* Array of fixups. */ 4360484Sobrien fixS * fixups[GAS_CGEN_MAX_FIXUPS]; 4460484Sobrien} finished_insnS; 4560484Sobrien 4660484Sobrien/* Callback for operand parsing. 4760484Sobrien The result is an error message or NULL for success. 4860484Sobrien The parsed value is stored in the bfd_vma *. */ 4960484Sobrienextern const char * gas_cgen_parse_operand 50130561Sobrien (CGEN_CPU_DESC, enum cgen_parse_operand_type, 51130561Sobrien const char **, int, int, enum cgen_parse_operand_result *, 52130561Sobrien bfd_vma *); 5360484Sobrien 5460484Sobrien/* Call this from md_assemble to initialize the assembler callback. */ 55130561Sobrienextern void gas_cgen_init_parse (void); 5660484Sobrien 57104834Sobrien/* Routines and macros for saving fixup chains. */ 58130561Sobrienextern void gas_cgen_save_fixups (int); 59130561Sobrienextern void gas_cgen_restore_fixups (int); 60130561Sobrienextern void gas_cgen_swap_fixups (int); 61130561Sobrienextern void gas_cgen_initialize_saved_fixups_array (void); 6289857Sobrien#define MAX_SAVED_FIXUP_CHAINS 50 6385815Sobrien 6460484Sobrien/* Add a register to the assembler's hash table. 6560484Sobrien This makes lets GAS parse registers for us. 6660484Sobrien ??? This isn't currently used, but it could be in the future. */ 67130561Sobrienextern void cgen_asm_record_register (char *, int); 6860484Sobrien 6960484Sobrien/* After CGEN_SYM (assemble_insn) is done, this is called to 7060484Sobrien output the insn and record any fixups. */ 71130561Sobrienextern void gas_cgen_finish_insn (const CGEN_INSN *, 72130561Sobrien CGEN_INSN_BYTES_PTR, unsigned int, 73130561Sobrien int, finished_insnS *); 7460484Sobrien 7560484Sobrien/* Record a fixup. */ 76130561Sobrienextern fixS * gas_cgen_record_fixup (fragS *, int, const CGEN_INSN *, 77130561Sobrien int, const CGEN_OPERAND *, int, 78130561Sobrien symbolS *, offsetT); 79130561Sobrienextern fixS * gas_cgen_record_fixup_exp (fragS *, int, const CGEN_INSN *, 80130561Sobrien int, const CGEN_OPERAND *, int, 81130561Sobrien expressionS *); 8260484Sobrien 83218822Sdim/* md_apply_fix handler */ 84218822Sdimextern void gas_cgen_md_apply_fix (fixS *, valueT *, segT); 8560484Sobrien 8660484Sobrien/* tc_gen_reloc handler */ 87130561Sobrienextern arelent *gas_cgen_tc_gen_reloc (asection *, fixS *); 8860484Sobrien 8960484Sobrien/* Target supplied routine to lookup a reloc. */ 9060484Sobrienextern bfd_reloc_code_real_type 91130561Sobrienmd_cgen_lookup_reloc (const CGEN_INSN *, const CGEN_OPERAND *, fixS *); 9260484Sobrien 9360484Sobrien/* Optional target supplied routine to record a fixup for an expression. */ 9460484Sobrienextern fixS * 95130561Sobrienmd_cgen_record_fixup_exp (fragS *, int, const CGEN_INSN *, int, 96130561Sobrien const CGEN_OPERAND *, int, expressionS *); 9760484Sobrien 98130561Sobrienextern void gas_cgen_md_operand (expressionS *); 9989857Sobrien 100130561Sobrien/* Perform any cgen specific initialisation for gas. */ 101130561Sobrienextern void gas_cgen_begin (void); 102130561Sobrien 10360484Sobrien#endif /* GAS_CGEN_H */ 104