OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [insn.scm] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jlechner
; Instruction definitions.
2
; Copyright (C) 2000, 2009 Red Hat, Inc.
3
; This file is part of CGEN.
4
; See file COPYING.CGEN for details.
5
 
6
; Used to explicitly specify mnemonic, now it's computed from
7
 
8
;mnemonic
9
; Instruction syntax string.
10
; The insn fields as specified in the .cpu file.
11
; Also contains values for constant fields.
12
; Lazily computed cache
13
; RTL source of assertions of ifield values or #f if none.
14
; This is used, for example, by the decoder to help
15
 
16
; specification.  It is also used by decode-split support.
17
; ??? It could also be used the the assembler/disassembler
18
 
19
; The <fmt-desc> of the insn.
20
; This is used to help calculate the ifmt,sfmt members.
21
; The <iformat> of the insn.
22
; The <sformat> of the insn.
23
 
24
; Instruction semantics.
25
; This is the rtl in source form or #f if there is none.
26
;
27
; There are a few issues (ick, I hate that word) to consider
28
; here:
29
; - some apps don't need the trap checks (e.g. SIGSEGV)
30
; - some apps treat the pieces in different ways
31
 
32
;   to reduce code size in a pbb simulator
33
;
34
; Some insns don't have any semantics at all, they are defined
35
 
36
;
37
; ??? GCC-like apps will need a new field to allow specifying
38
 
39
; ??? May wish to put this and the compiled forms in a
40
; separate class.
41
 
42
; be a sequence with an #:errchk modifier or some such.
43
; The processed form of the above.
44
 
45
; The mapping of the semantics onto the host.
46
; FIXME: Not sure what its value will be.
47
; Another thing that will be needed is [in some cases] a more
48
; simplified version of the RTL for use by apps like compilers.
49
; Perhaps that's what this will become.
50
; The function unit usage of the instruction.
51
; Accessor fns
52
; Return a boolean indicating if X is an <insn>.
53
; Return a list of the machs that support INSN.
54
; ??? wip
55
; Return the length of INSN in bits.
56
; Return the length of INSN in bytes.
57
; Return instruction mnemonic.
58
; This is computed from the syntax string.
59
; The mnemonic, as we define it, is everything up to, but not including, the
60
; first space or '$'.
61
; FIXME: Rename to syntax-mnemonic, and take a syntax string argument.
62
; FIXME: Doesn't handle \$ to indicate a $ is actually in the mnemonic.
63
; Return enum cgen_insn_types value for INSN.
64
"@ARCH@_INSN_"; Return enum for insn named INSN-NAME.
65
 
66
; [Though obviously having such an object seems like a good idea.]
67
"@ARCH@_INSN_"; Insns with derived operands (see define-derived-operand).
68
; ??? These are [currently] recorded separately to minimize impact on existing
69
 
70
;
71
; The class is called <multi-insn> because the insn has multiple variants,
72
; one for each combination of "anyof" alternatives.
73
; Internally we create one <insn> per alternative.  The theory is that this
74
; will remain an internal implementation issue.  When appropriate applications
75
; will collapse the number of insns in a way that is appropriate for them.
76
 
77
; ??? Another way to do this is with insn templates.  One problem the current
78
; way has is that it requires each operand's assembler syntax to be self
79
; contained (one way to fix this is to use "fake" operands like before).
80
; Insn templates needn't have this problem.  On the other hand insn templates
81
; [seem to] require more description file entries.
82
 
83
; ??? This doesn't use all of the members of <insn>.
84
; The <multi-insn> class is wip, but should eventually reorganize <insn>.
85
; This reorganization might also take into account real, virtual, etc. insns.
86
; An <insn> is created for each combination of "anyof"
87
 
88
; list of them is recorded here as well.
89
 
90
; Return a boolean indicating if X is a <multi-insn>.
91
; Subroutine of -sub-insn-make! to create the ifield list.
92
; Return encoding of {insn} with each element of {anyof-operands} replaced
93
; with {new-values}.
94
 
95
; (debug-repl-env insn anyof-operands value-names new-values)
96
; Delete ifields of {anyof-operands} and add those for {new-values}.
97
; Delete ifields in {anyof-operands}.
98
 
99
; Return the last ifield of OWNER in IFLD-LIST.
100
 
101
; For ifields, the owner is the ifield itself.
102
 
103
; For derived operands, the owner is the "anyof" parent.
104
 
105
;(debug-repl-env ifld-list owner)
106
; This is the interesting case.  The instantiated choice of
107
; {owner} is in {ifld-list}.  We have to find it.
108
 
109
; derived operands are handled here too
110
 
111
; Bad worst case performance but ifield lists aren't usually that long.
112
; FIXME: Doesn't handle A following B following C.
113
; Subroutine of multi-insn-instantiate! to instantiate one insn.
114
 
115
; ANYOF-OPERANDS is a list of the <anyof-operand>'s of INSN.
116
 
117
; ANYOF-OPERANDS.  Each element is a <derived-operand>.
118
;(debug-repl-env insn anyof-operands new-values)
119
"Instantiating "":"" ""="" ...\n";  (if (eq? '@sib+disp8-QI-disp32-8
120
 
121
;      (debug-repl-env insn anyof-operands new-values))
122
; Don't create insn if ifield assertions fail.
123
; FIXME
124
"   instantiated.\n";; FIXME: Hack to remove differences in generated code when we
125
;; switched to recording insns in hash tables.
126
;; See similar comment in arch-analyze-insns!.
127
 
128
;; Subtract 2 because mach.scm:-get-next-ordinal! adds 1.
129
"    failed ifield assertions.\n"; Instantiate all sub-insns of MULTI-INSN.
130
; ??? Might be better to return the list of insns, rather than add them to
131
; the global list, and leave it to the caller to add them.
132
; We shouldn't get called more than once.
133
; What we want to create here is the set of all "anyof" alternatives.
134
; From that we create one <insn> per alternative.
135
"  anyof: ""\n""    choices: ""\n"; Iterate over all combinations.
136
 
137
; Each element is in turn a list of all choices (<derived-operands>'s)
138
 
139
; derived from nested <anyof-operand>'s.
140
; ??? anyof-all-choices should cache the results. [Still useful?]
141
; ??? Need to cache results of assertion processing in addition or
142
 
143
"Instantiating "" multi-insns for "" ...\n"; ??? One might prefer a `do' loop here, but every time I see one I
144
; have to spend too long remembering its syntax.
145
"Derived: ""\n"; Parse an instruction description.
146
 
147
; description in the .cpu file.
148
; All arguments are in raw (non-evaluated) form.
149
; The result is the parsed object or #f if insn isn't for selected mach(s).
150
 
151
"cgen_insn"" format"; If there are no semantics, mark this as an alias.
152
; ??? Not sure this makes sense for multi-insns.
153
"Ignoring "".\n"; Read an instruction description.
154
; This is the main routine for analyzing instructions in the .cpu file.
155
; This is also used to create virtual insns by apps like simulators.
156
; CONTEXT is a <context> object for error messages.
157
; ARG-LIST is an associative list of field name and field value.
158
; -insn-parse is invoked to create the <insn> object.
159
""; Loop over each element in ARG-LIST, recording what's found.
160
"invalid insn arg"; Now that we've identified the elements, build the object.
161
; Define an instruction object, name/value pair list version.
162
"define-insn"; Define an instruction object, all arguments specified.
163
"define-full-insn"; Parsing support.
164
; Parse an insn syntax field.
165
; SYNTAX is either a string or a list of strings, each element of which may
166
; in turn be a list of strings.
167
; ??? Not sure this extra flexibility is worth it yet.
168
"improper syntax"; Subroutine of -parse-insn-format to parse a symbol ifield spec.
169
;(debug-repl-env sym)
170
 
171
; the associated derived ifield.
172
; An insn-enum?
173
"bad format element, expecting symbol to be operand or insn enum"; Subroutine of -parse-insn-format to parse an (ifield-name value) ifield spec.
174
;
175
; The last element is the ifield's value.  It must be an integer.
176
; ??? Whether it can be negative is still unspecified.
177
; ??? While there might be a case where allowing floating point values is
178
; desirable, supporting them would require precise conversion routines.
179
; They should be rare enough that we instead punt.
180
;
181
; ??? May wish to support something like "(% startbit bitsize value)".
182
;
183
 
184
"bad ifield format, should be (ifield-name value)"; ??? This use to allow (ifield-name operand-name).  That's how
185
; `operand-name' elements are handled, but there's no current need
186
; to handle (ifield-name operand-name).
187
"symbolic ifield value not an enum""ifield value not an integer or enum"; Subroutine of -parse-insn-format to parse an
188
 
189
; ??? There is room for growth in the specification syntax here.
190
 
191
"unknown ifield"; Given an insn format field from a .cpu file, replace it with a list of
192
 
193
;
194
 
195
; All bits must be specified, including reserved bits
196
; [at present no checking is made of this, but the rule still holds].
197
;
198
; A normal entry begins with `+' and then consist of the following:
199
 
200
; - (ifield-name [options] value)
201
; - (operand-name [options] [value])
202
 
203
;
204
; Example: (+ OP1_ADD (f-res2 0) dr src1 (f-src2 1) (f-res1 #xea))
205
;
206
; where OP1_ADD is an enum, dr and src1 are operands, and f-src2 and f-res1
207
; are ifield's.  The `+' allows for future extension.
208
;
209
; The other form of entry begins with `=' and is followed by an instruction
210
; name that has the same format.  The specified instruction must already be
211
; defined.  Instructions with this form typically also include an
212
; `ifield-assertion' spec to keep them separate.
213
;
214
 
215
; VIRTUAL insns have this.
216
;
217
; This is one of the more important routines to be efficient.
218
; It's called for each instruction, and is one of the more expensive routines
219
; in insn parsing.
220
; field list unspecified
221
; ??? This use to allow <ifield> objects
222
; in the `car' position.  Checked for below.
223
"FIXME: <ifield> object in format spec""bad format element, neither symbol nor ifield spec""bad `=' format spec, should be `(= insn-name)'""unknown insn""format must begin with `+' or `='"; Return a boolean indicating if IFLD-LIST contains anyof operands.
224
; Insn utilities.
225
; ??? multi-insn support wip, may require changes here.
226
; Return a boolean indicating if INSN is an alias insn.
227
; Return a list of instructions that are not aliases in INSN-LIST.
228
; Return a boolean indicating if INSN is a "real" INSN
229
; (not ALIAS and not VIRTUAL and not a <multi-insn>).
230
; Return a list of real instructions in INSN-LIST.
231
; Return a boolean indicating if INSN is a virtual insn.
232
; Return a list of virtual instructions in INSN-LIST.
233
; Return a list of non-alias/non-pbb insns in INSN-LIST.
234
; Return a list of multi-insns in INSN-LIST.
235
; And the opposite:
236
; Filter out instructions whose ifield patterns are strict supersets of
237
; another, keeping the less general cousin.  Used to resolve ambiguity
238
; when there are no more bits to consider.
239
"Filtering "" instructions for non specializations.\n"; insn2: possible submatch (more mask bits)
240
"Instruction "" specialization-filtered by ""\n"; Filter out instructions whose ifield patterns are identical.
241
"Filtering "" instructions for identical variants.\n"; Helper function for above: does (m1,v1) match a STRICT superset of (m2,v2) ?
242
;
243
; eg> mask-superset? #b1100 #b1000 #b1110 #b1010 -> #t
244
; eg> mask-superset? #b1100 #b1000 #b1010 #b1010 -> #f
245
; eg> mask-superset? #b1100 #b1000 #b1110 #b1100 -> #f
246
 
247
; 
248
"("","")"" contains ""("","")""\n"; Return a boolean indicating if INSN is a cti [control transfer insn].
249
; This includes SKIP-CTI insns even though they don't terminate a basic block.
250
; ??? SKIP-CTI insns are wip, waiting for more examples of how they're used.
251
; Return a boolean indicating if INSN can be executed in parallel.
252
; Such insns are required to have enum attribute PARALLEL != NO.
253
; This is worded specifically to allow the PARALLEL attribute to have more
254
; than just NO/YES values (should a target want to do so).
255
; This specification may not be sufficient, but the intent is explicit.
256
; Return a list of the insns that support parallel execution in INSN-LIST.
257
; Instruction field utilities.
258
 
259
 
260
; Given INSN, return the length in bits of the base mask (insn-base-mask).
261
; Given INSN, return the bitmask of constant values (the opcode field)
262
; in the base part.
263
; Given INSN, return the sum of the constant values in the insn
264
; (i.e. the opcode field).
265
 
266
; See also (compute-insn-base-mask).
267
;
268
; Insn operand utilities.
269
; Lookup operand SEM-NAME in INSN.
270
; Insn syntax utilities.
271
; Create a list of syntax strings broken up into a list of characters and
272
; operand objects.
273
; ??? The style of the following could be more Scheme-like.  Later.
274
; Handle escaped syntax metacharacters.
275
"syntax-break-out: missing char after '\\' in "; Handle operand reference.
276
; Extract the symbol from the string, get the operand.
277
; FIXME: Will crash if $ is last char in string.
278
; Handle everything else.
279
; Given a list of syntax elements (e.g. the result of syntax-break-out),
280
; create a syntax string.
281
 
282
"\
283
Define an instruction, name/value pair list version.
284
""\
285
 
286
"; Called before a .cpu file is read in to install any builtins.
287
; Standard insn attributes.
288
; ??? Some of these can be combined into one.
289
 
290
; executed (or skipped)
291
"skip cti"; DELAY-SLOT: insn has one or more delay slots (wip)
292
"insn has a delay slot"; RELAXABLE: Insn has one or more identical but larger variants.
293
; The assembler tries this one first and then the relaxation phase
294
 
295
; All insns of identical behaviour have a RELAX_FOO attribute that groups
296
; them together.
297
; FIXME: This is a case where we need one attribute with several values.
298
; Presently each RELAX_FOO will use up a bit.
299
"insn is relaxable"; RELAXED: Large relaxable variant.  Avoided by assembler in first pass.
300
"relaxed form of insn"; NO-DIS: For macro insns, do not use during disassembly.
301
"don't use for disassembly"; PBB: Virtual insn used for PBB support.
302
"virtual insn used for PBB support"; DECODE-SPLIT: insn resulted from decode-split processing
303
"insn split from another insn for decoding purposes"; Also (defined elsewhere):
304
; VIRTUAL: Helper insn used by the simulator.
305
; Called after the .cpu file has been read in.
306
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.