cgen.h revision 89857
143105Sdfr/* GAS cgen support.
243105Sdfr   Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
343105Sdfr
443105Sdfr   This file is part of GAS, the GNU Assembler.
543105Sdfr
643105Sdfr   GAS is free software; you can redistribute it and/or modify
743105Sdfr   it under the terms of the GNU General Public License as published by
843105Sdfr   the Free Software Foundation; either version 2, or (at your option)
943105Sdfr   any later version.
1043105Sdfr
1143105Sdfr   GAS is distributed in the hope that it will be useful,
1243105Sdfr   but WITHOUT ANY WARRANTY; without even the implied warranty of
1343105Sdfr   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1443105Sdfr   GNU General Public License for more details.
1543105Sdfr
1643105Sdfr   You should have received a copy of the GNU General Public License
1743105Sdfr   along with GAS; see the file COPYING.  If not, write to the Free
1843105Sdfr   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1943105Sdfr   02111-1307, USA.  */
2043105Sdfr
2143105Sdfr#ifndef GAS_CGEN_H
2243105Sdfr#define GAS_CGEN_H
2343105Sdfr
2443105Sdfr/* Opcode table handle.  */
2543105Sdfrextern CGEN_CPU_DESC gas_cgen_cpu_desc;
2643105Sdfr
27116181Sobrien/* Maximum number of fixups in an insn.
28116181Sobrien   If you need to change this, allow target to override and do so there.  */
29116181Sobrien#ifndef GAS_CGEN_MAX_FIXUPS
3043105Sdfr#define GAS_CGEN_MAX_FIXUPS 3
3143105Sdfr#endif
3243105Sdfr
3343105Sdfr/* Struct defining result of gas_cgen_finish_insn.  */
3443105Sdfrtypedef struct {
3543105Sdfr  /* frag containing the insn */
3643105Sdfr  fragS * frag;
37142833Siedowse  /* Address of insn in frag.  */
38129880Sphk  char * addr;
3948104Syokota  /* Number of fixups this insn has.  */
4043105Sdfr  int num_fixups;
4148104Syokota  /* Array of fixups.  */
4243105Sdfr  fixS * fixups[GAS_CGEN_MAX_FIXUPS];
4348104Syokota} finished_insnS;
4448104Syokota
4548104Syokota/* Callback for operand parsing.
4648104Syokota   The result is an error message or NULL for success.
4748104Syokota   The parsed value is stored in the bfd_vma *.  */
4843105Sdfrextern const char * gas_cgen_parse_operand
4943105Sdfr     PARAMS ((CGEN_CPU_DESC, enum cgen_parse_operand_type,
5043105Sdfr	      const char **, int, int, enum cgen_parse_operand_result *,
5143105Sdfr	      bfd_vma *));
52114384Speter
5343105Sdfr/* Call this from md_assemble to initialize the assembler callback.  */
54114384Speterextern void gas_cgen_init_parse PARAMS ((void));
5543105Sdfr
5643105Sdfr/* Routines and macros for saving fixup chains. */
5743105Sdfrextern void gas_cgen_save_fixups PARAMS ((int));
5843105Sdfrextern void gas_cgen_restore_fixups PARAMS ((int));
5943105Sdfrextern void gas_cgen_swap_fixups PARAMS ((int));
6043105Sdfrextern void gas_cgen_initialize_saved_fixups_array PARAMS ((void));
6143105Sdfr#define MAX_SAVED_FIXUP_CHAINS 50
6248104Syokota
6348104Syokota/* Add a register to the assembler's hash table.
6443105Sdfr   This makes lets GAS parse registers for us.
6548104Syokota   ??? This isn't currently used, but it could be in the future.  */
6643105Sdfrextern void cgen_asm_record_register PARAMS ((char *, int));
6743105Sdfr
6843105Sdfr/* After CGEN_SYM (assemble_insn) is done, this is called to
6948104Syokota   output the insn and record any fixups.  */
7048104Syokotaextern void gas_cgen_finish_insn PARAMS ((const CGEN_INSN *,
7148104Syokota					  CGEN_INSN_BYTES_PTR, unsigned int,
7248104Syokota					  int, finished_insnS *));
7348104Syokota
7448104Syokota/* Record a fixup.  */
7543105Sdfrextern fixS * gas_cgen_record_fixup PARAMS ((fragS *, int, const CGEN_INSN *,
7648104Syokota					     int, const CGEN_OPERAND *, int,
77126080Sphk					     symbolS *, offsetT));
78126080Sphkextern fixS * gas_cgen_record_fixup_exp PARAMS ((fragS *, int, const CGEN_INSN *,
79111815Sphk						 int, const CGEN_OPERAND *, int,
80111815Sphk						 expressionS *));
81111815Sphk
82111815Sphk/* md_apply_fix3 handler */
83111815Sphkextern void gas_cgen_md_apply_fix3 PARAMS ((fixS *, valueT *, segT));
84111815Sphk
85111815Sphk/* tc_gen_reloc handler */
8643105Sdfrextern arelent *gas_cgen_tc_gen_reloc PARAMS ((asection *, fixS *));
8743105Sdfr
8843105Sdfr/* Target supplied routine to lookup a reloc.  */
8943105Sdfrextern bfd_reloc_code_real_type
9062225Spetermd_cgen_lookup_reloc PARAMS ((const CGEN_INSN *, const CGEN_OPERAND *,
9162225Speter			      fixS *));
9262225Speter
9362225Speter/* Optional target supplied routine to record a fixup for an expression.  */
9462225Speterextern fixS *
9562225Spetermd_cgen_record_fixup_exp PARAMS ((fragS *, int, const CGEN_INSN *, int,
9643105Sdfr				  const CGEN_OPERAND *, int,
9743105Sdfr				  expressionS *));
9843105Sdfr
9948104Syokotaextern void gas_cgen_md_operand PARAMS ((expressionS *));
10048104Syokota
10143105Sdfr#endif /* GAS_CGEN_H */
10247618Sdfr