1/* md.h -machine dependent- */
2
3/* Copyright (C) 1987 Free Software Foundation, Inc.
4
5This file is part of Gas, the GNU Assembler.
6
7The GNU assembler is distributed in the hope that it will be
8useful, but WITHOUT ANY WARRANTY.  No author or distributor
9accepts responsibility to anyone for the consequences of using it
10or for whether it serves any particular purpose or works at all,
11unless he says so in writing.  Refer to the GNU Assembler General
12Public License for full details.
13
14Everyone is granted permission to copy, modify and redistribute
15the GNU Assembler, but only under the conditions described in the
16GNU Assembler General Public License.  A copy of this license is
17supposed to have been given to you along with the GNU Assembler
18so you can know your rights and responsibilities.  It should be
19in a file named COPYING.  Among other things, the copyright
20notice and this notice must be preserved on all copies.  */
21
22#import <mach/machine.h>
23#import "stuff/bytesex.h"
24#import "frags.h"
25#import "relax.h"
26#import "struc-symbol.h"
27#import "fixes.h"
28#import "read.h"
29
30/* These are the default cputype and cpusubtype for this target MACHINE */
31extern const cpu_type_t md_cputype;
32extern cpu_subtype_t md_cpusubtype;
33
34/* This is the byte sex for this target MACHINE */
35extern const enum byte_sex md_target_byte_sex;
36
37/* These characters start a comment anywhere on the line */
38extern const char md_comment_chars[];
39
40/* These characters only start a comment at the beginning of a line */
41extern const char md_line_comment_chars[];
42
43/*
44 * These characters can be used to separate mantissa decimal digits from
45 * exponent decimal digits in floating point numbers.
46 */
47extern const char md_EXP_CHARS[];
48
49/*
50 * The characters after a leading 0 that means this number is a floating point
51 * constant as in 0f123.456 or 0d1.234E-12 (the characters 'f' and 'd' in these
52 * case).
53 */
54extern const char md_FLT_CHARS[];
55
56/*
57 * This is the machine dependent pseudo opcode table for this target MACHINE.
58 */
59extern const pseudo_typeS md_pseudo_table[];
60
61/*
62 * This is the machine dependent table that is used to drive the span dependent
63 * branch algorithm in relax_section() in layout.c.  See the comments in relax.h
64 * on how this table is used.  For machines with all instructions of the same
65 * size (RISC machines) this this table is just a zero filled element and not
66 * used.
67 */
68extern const relax_typeS md_relax_table[];
69
70/*
71 * md_parse_option() is called from main() in as.c to parse target machine
72 * dependent command line options.  This routine returns 0 if it is passed an
73 * option that is not recognized non-zero otherwise.
74 */
75extern int md_parse_option(
76    char **argP,
77    int *cntP,
78    char ***vecP);
79
80/*
81 * md_begin() is called from main() in as.c before assembly begins.  It is used
82 * to allow target machine dependent initialization.
83 */
84extern void md_begin(
85    void);
86
87/*
88 * md_end() is called from main() in as.c after assembly ends.  It is used
89 * to allow target machine dependent clean up.
90 */
91extern void md_end(
92    void);
93
94/*
95 * md_assemble() is passed a pointer to a string that should be a assembly
96 * statement for the target machine.  This routine assembles the string into
97 * a machine instruction.
98 */
99extern void md_assemble(
100    char *str);
101
102/*
103 * md_atof() turns a string pointed to by input_line_pointer into a floating
104 * point constant of type type, and store the appropriate bytes in *litP.
105 * The number of LITTLENUMS emitted is stored indirectly through *sizeP.
106 * An error message is returned, or a string containg only a '\0' for OK.
107 */
108extern char *md_atof(
109    int type,
110    char *litP,
111    int *sizeP);
112
113/*
114 * md_number_to_chars() is the target machine dependent routine that puts out
115 * a binary value of size 8, 4, 2, or 1 bytes into the specified buffer.  This
116 * is done in the target machine's byte sex.
117 */
118extern void md_number_to_chars(
119    char *buf,
120    signed_expr_t val,
121    int n);
122/* FROM tc.h line 55 */
123void   md_apply_fix3 (fixS *, valueT *, segT);
124
125/*
126 * md_number_to_imm() is the target machine dependent routine that puts out
127 * a binary value of size 4, 2, or 1 bytes into the specified buffer with
128 * reguard to a possible relocation entry (the fixP->fx_r_type field in the fixS
129 * structure pointed to by fixP) for the section with the ordinal nsect.  This
130 * is done in the target machine's byte sex using it's relocation types.
131 */
132extern void md_number_to_imm(
133    unsigned char *buf,
134    signed_expr_t val,
135    int n,
136    fixS *fixP,
137    int nsect);
138
139/*
140 * md_estimate_size_before_relax() is called as part of the algorithm in
141 * relax_section() in layout.c that drives the span dependent branch algorithm.
142 * It is called once for each machine dependent frag to allow things like
143 * braches to undefined symbols to be "relaxed" to their maximum size.
144 * For machines with all instructions of the same size (RISC machines) this
145 * won't ever be called.
146 */
147extern int md_estimate_size_before_relax(
148    fragS *fragP,
149    int nsect);
150
151/*
152 * md_convert_frag() is called on each machine dependent frag after the span
153 * dependent branch algorithm has been run to determine the sizes and addresses
154 * of all the fragments.  This routine is to put the bytes inside the fragment
155 * and make it conform to the "relaxed" final size.  For machines with all
156 * instructions of the same size (RISC machines) this won't ever be called.
157 */
158extern void md_convert_frag(
159    fragS *fragP);
160
161/*
162 * md_pcrel_from() returns the PC-relative offset from the given fixup.
163 * This is not implemented or used for most targets.
164 */
165extern int32_t md_pcrel_from(
166    const fixS *fixP);
167