2006-10-26 Joseph S. Myers <joseph@codesourcery.com>
[binutils.git] / gas / cgen.h
blobacb9f48d459b47aa2bf5d49a5914fd6d647e4674
1 /* GAS cgen support.
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
22 #ifndef GAS_CGEN_H
23 #define GAS_CGEN_H
25 /* Opcode table handle. */
26 extern CGEN_CPU_DESC gas_cgen_cpu_desc;
28 /* Maximum number of fixups in an insn.
29 If you need to change this, allow target to override and do so there. */
30 #ifndef GAS_CGEN_MAX_FIXUPS
31 #define GAS_CGEN_MAX_FIXUPS 3
32 #endif
34 /* Struct defining result of gas_cgen_finish_insn. */
35 typedef struct {
36 /* frag containing the insn */
37 fragS * frag;
38 /* Address of insn in frag. */
39 char * addr;
40 /* Number of fixups this insn has. */
41 int num_fixups;
42 /* Array of fixups. */
43 fixS * fixups[GAS_CGEN_MAX_FIXUPS];
44 } finished_insnS;
46 /* Callback for operand parsing.
47 The result is an error message or NULL for success.
48 The parsed value is stored in the bfd_vma *. */
49 extern const char * gas_cgen_parse_operand
50 (CGEN_CPU_DESC, enum cgen_parse_operand_type,
51 const char **, int, int, enum cgen_parse_operand_result *,
52 bfd_vma *);
54 /* Call this from md_assemble to initialize the assembler callback. */
55 extern void gas_cgen_init_parse (void);
57 /* Routines and macros for saving fixup chains. */
58 extern void gas_cgen_save_fixups (int);
59 extern void gas_cgen_restore_fixups (int);
60 extern void gas_cgen_swap_fixups (int);
61 extern void gas_cgen_initialize_saved_fixups_array (void);
62 #define MAX_SAVED_FIXUP_CHAINS 50
64 /* Add a register to the assembler's hash table.
65 This makes lets GAS parse registers for us.
66 ??? This isn't currently used, but it could be in the future. */
67 extern void cgen_asm_record_register (char *, int);
69 /* After CGEN_SYM (assemble_insn) is done, this is called to
70 output the insn and record any fixups. */
71 extern void gas_cgen_finish_insn (const CGEN_INSN *,
72 CGEN_INSN_BYTES_PTR, unsigned int,
73 int, finished_insnS *);
75 /* Record a fixup. */
76 extern fixS * gas_cgen_record_fixup (fragS *, int, const CGEN_INSN *,
77 int, const CGEN_OPERAND *, int,
78 symbolS *, offsetT);
79 extern fixS * gas_cgen_record_fixup_exp (fragS *, int, const CGEN_INSN *,
80 int, const CGEN_OPERAND *, int,
81 expressionS *);
83 /* md_apply_fix handler */
84 extern void gas_cgen_md_apply_fix (fixS *, valueT *, segT);
86 /* tc_gen_reloc handler */
87 extern arelent *gas_cgen_tc_gen_reloc (asection *, fixS *);
89 /* Target supplied routine to lookup a reloc. */
90 extern bfd_reloc_code_real_type
91 md_cgen_lookup_reloc (const CGEN_INSN *, const CGEN_OPERAND *, fixS *);
93 /* Optional target supplied routine to record a fixup for an expression. */
94 extern fixS *
95 md_cgen_record_fixup_exp (fragS *, int, const CGEN_INSN *, int,
96 const CGEN_OPERAND *, int, expressionS *);
98 extern void gas_cgen_md_operand (expressionS *);
100 /* Perform any cgen specific initialisation for gas. */
101 extern void gas_cgen_begin (void);
103 #endif /* GAS_CGEN_H */