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

Subversion Repositories scarts

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jlechner
; Top level file for reading and recording .cpu file contents.
2
; Copyright (C) 2000, 2001, 2006, 2009 Red Hat, Inc.
3
; This file is part of CGEN.
4
; See file COPYING.CGEN for details.
5
 
6
; possible).  That lives at a layer above us.
7
; A .cpu file consists of several sections:
8
 
9
; - basic definitions (e.g. cpu variants, word size, endianness, etc.)
10
; - enums (enums are used throughout so by convention there is a special
11
;   section in which they're defined)
12
; - attributes
13
; - instruction fields and formats
14
; - hardware descriptions (e.g. registers, allowable immediate values)
15
; - model descriptions (e.g. pipelines, latencies, etc.)
16
; - instruction operands (mapping of insn fields to associated hardware)
17
; - instruction definitions
18
; - macro instruction definitions
19
; TODO:
20
; - memory access, layout, etc.
21
 
22
; - ability to describe an ABI
23
; - anything else that comes along
24
; Notes:
25
; - by convention most objects are subclasses of <ident> (having name, comment,
26
;   and attrs elements and they are the first three elements of any .cpu file
27
 
28
; Guidelines:
29
; - Try to conform to R5RS, try to limit guile-ness.
30
;   The current code is undoubtedly off in many places.
31
; Conventions:
32
 
33
; adhered to.  ??? There's probably a few violations here and there.
34
; No big deal - fix them!]
35
; These conventions are subject to revision.
36
 
37
; - procs/vars local to a file are named "-foo"
38
; - only routines that emit application code begin with "gen-"
39
; - symbols beginning with "c-" are either variables containing C code
40
;   or procedures that generate C code, similarily for C++ and "c++-"
41
; - variables containing C code begin with "c-"
42
; - only routines that emit an entire file begin with "cgen-"
43
; - all .cpu file elements shall have -foo-parse and -foo-read procedures
44
; - global vars containing class definitions shall be named "<class-name>"
45
; - procs related to a particular class shall be named "class-name-proc-name",
46
;   class-name may be abbreviated
47
; - procs that test whether something is an object of a particular class
48
;   shall be named "class-name?"
49
; - in keeping with Scheme conventions, predicates shall have a "?" suffix
50
; - in keeping with Scheme conventions, methods and procedures that modify an
51
;   argument or have other side effects shall have a "!" suffix,
52
;   usually these procs return "*UNSPECIFIED*"
53
; - all -foo-parse,parse-foo procs shall have `context' as the first arg
54
;   [FIXME: not all such procs have been converted]
55
; - stay away from non-portable C symbols.
56
; Variables representing misc. global constants.
57
; A list of three numbers designating the cgen version: major minor fixlevel.
58
; The "50" is a generic indicator that we're between 1.1 and 1.2.
59
; A list of two numbers designating the description language version.
60
; Note that this is different from -CGEN-VERSION.
61
; See section "RTL Versions" of the docs.
62
 
63
"Invalid major version number""Invalid minor version number""Unsupported/invalid rtl version""Setting RTL version to ""."" ...\n"; Which application is in use (UNKNOWN, DESC, OPCODES, SIMULATOR, ???).
64
 
65
; Things are organized so that files can be compiled with Hobbit for
66
; experimentation.  Thus we need one file that loads all the other files.
67
; This is that file, though it would make sense to move the code in this
68
; file to another.
69
; If a routine to initialize compiled-in code is defined, run it.
70
; If this is set to #f, the file is always loaded.
71
 
72
; Unlink file if we're reloaded (say in an interactive session).
73
; Dynamic loading is enabled by setting LIBCPU.SO to the pathname of the .so.
74
; List of loaded files.
75
; Return non-zero if FILE was loaded last time through.
76
; Record FILE as compiled in.
77
; Load FILE if SYM is not compiled in.
78
; Return non-#f if FUNC is present in DYNOBJ.
79
 
80
"slib/pp"; Used by pretty-print.
81
"slib/random""slib/genwrite""utils""utils-cgen""utils_cgen""attr""enum""mach""model""types""mode""ifield""iformat""hardware""operand""insn""minsn""decode""rtl""rtl""rtl-traverse""rtl_traverse""rtl-xform""rtx_simplify""rtx-funcs""rtx_funcs""rtl-c""rtl_c""semantics""sem-frags""sem_frags""utils-gen""utils_gen""pgmr-tools""pgmr_tools"; Reader state data.
82
 
83
; class <reader>.
84
; Class to record info for each top-level `command' (for lack of a better
85
; word) in the description file.
86
; Top level commands are things like define-*.
87
; argument spec to `lambda'
88
 
89
; Return help text for COMMAND.
90
"Arguments: ""\n"; A pair of two lists: machs to keep, machs to drop.
91
; The default is "keep all machs", "drop none".
92
; Main reader state class.
93
; Selected machs to keep.
94
; A pair of two lists: the car lists the machs to keep, the cdr
95
 
96
; `base'.  Both are only valid in the keep list.  `base' is a
97
; place holder for objects that are common to all machine
98
; variants in the architecture, it is the default value of the
99
 
100
; processed.
101
; Selected isas to keep or `all'.
102
; Boolean indicating if command tracing is on.
103
; Boolean indicating if pmacro tracing is on.
104
 
105
; Some applications don't care, and this is moderately
106
; expensive to compute so we use delay/force.
107
 
108
; (e.g. define-insn, etc.).
109
; Each entry is (name . command-object).
110
; The current source location.
111
; This is recorded here by the higher level reader and is
112
 
113
; Accessors.
114
; Reader state for current .cpu file.
115
; Return the current source location in readable form.
116
; FIXME: Currently unused, keep for reference for awhile.
117
;; Blech, we don't have a current reader location.  That's odd.
118
;; Fall back to the current input port's location.
119
"<input>"":"":";;; Signal a parse error while reading a .cpu file.
120
;;; If CONTEXT is #f, use a default context of the current reader location
121
;;; and an empty prefix.
122
 
123
;;; Multiple lines of help text need embedded newlines, and should be no longer
124
 
125
"While reading description""Error"": ""\n~A:\n@ ~A:\n\n~A: ~A: ~S~A""""\n\n"; Return the current source location.
126
;
127
 
128
; This is done so that things like define-pmacro work in interactive mode.
129
 
130
;; Set the current source location for better diagnostics.
131
;; Access with current-reader-location.
132
"Processing command:\n  @ ""location unknown""\n";; Variable number of trailing arguments.
133
 
134
"Incorrect number of arguments to "", expecting ""unknown entry type";; Process 1 or more macro-expanded entries.
135
 
136
;; NOTE: This is "public" so the .eval pmacro can use it.
137
;; This is also used by -cmd-if.
138
;; () is used to indicate a no-op
139
;; nothing to do
140
;; `begin' is used to group a collection of entries into one,
141
 
142
;; Scheme of course).
143
 
144
; Process file entry ENTRY.
145
; LOC is a <location> object for ENTRY.
146
"improperly formed entry"; First do macro expansion, but not if define-pmacro of course.
147
; ??? Singling out define-pmacro this way seems a bit odd.  The way to look
148
; at it, I guess, is to think of define-pmacro as (currently) the only
149
; "syntactic" command (it doesn't pre-evaluate its arguments).
150
; Read in and process FILE.
151
 
152
; It would be nice to get the line number of the beginning of the object,
153
; but that's extra work, so for now we do the simple thing and use
154
; port-line after we've read an entry.
155
; done
156
;; ??? The location we pass here isn't ideal.
157
;; Ideally we'd pass the start location of the
158
;; expression, instead we currently pass the end
159
;; location (it's easier).
160
;; ??? Use source-properties of entry, and only if
161
;; not present fall back on current-input-location.
162
; Cpu data is recorded in an object of class <arch>.
163
; This is necessary as we need to allow recording of multiple cpu descriptions
164
; simultaneously.
165
 
166
; Global containing all data of the currently selected architecture.
167
; `keep-mach' processing.
168
; Return the currently selected cpu family.
169
; If a specific cpu family has been selected, each machine that is kept must
170
; be in that cpu family [so there's no ambiguity in the result].
171
; This is a moderately expensive computation so use delay/force.
172
; Return a boolean indicating if CPU-NAME is to be kept.
173
; ??? Currently this is always true.  Note that this doesn't necessarily apply
174
; to machs in CPU-NAME.
175
; Cover proc to set `keep-mach'.
176
; MACH-NAME-LIST is a comma separated string of machines to keep and drop
177
; (if prefixed with !).
178
; Reset current-cpu.
179
"no machs selected""machs from different cpu families selected"; Validate the user-provided keep-mach list against the list of machs
180
; specified in the .cpu file (in define-arch).
181
"unknown mach to keep:""unknown mach to drop:"; Return #t if a machine in MACH-LIST, a list of symbols, is to be kept.
182
; If any machine in MACH-LIST is to be kept, the result is #t.
183
; If MACH-LIST is the empty list (no particular mach specified, thus the base
184
; mach), the result is #t.
185
; keep if K(ept) or ALL? and not D(ropped)
186
; Return non-#f if the object containing ATLIST is to be kept.
187
; OBJ is the container object or #f if there is none.
188
; The object is kept if its attribute list specifies a `MACH' that is
189
; kept (and not dropped) or does not have the `MACH' attribute (which means
190
; it has the default value which means it's for use with all machines).
191
; The MACH attribute is not created until the .cpu file is read in which
192
; is too late for us [we will get called for builtin objects].
193
; Thus we peek inside the attribute list directly.
194
; ??? Maybe postpone creation of builtins until after define-arch?
195
; Return a boolean indicating if the object containing ATLIST is to be kept.
196
; OBJ is the container object or #f if there is none.
197
; The object is kept if both its isa and its mach are kept.
198
; Return a boolean indicating if multiple cpu families are being kept.
199
 
200
; Ensure all cpu families were kept, necessary for generating files that
201
; encompass the entire architecture.
202
"no can do, all cpu families not selected"; Ensure exactly one cpu family was kept, necessary for generating files that
203
 
204
"no can do, multiple cpu families selected"; `keep-isa' processing.
205
; Cover proc to set `keep-isa'.
206
; ISA-NAME-LIST is a comma separated string of isas to keep.
207
 
208
; Perhaps we should as otherwise there are two different styles the user
209
; has to remember.  On the other hand, !drop support is moderately complicated,
210
; and it can be added in an upward compatible manner later.
211
; Validate the user-provided keep-isa list against the list of isas
212
; specified in the .cpu file (in define-arch).
213
"unknown isa to keep:"; Return currently selected isa (there must be exactly one).
214
"multiple isas selected""multiple isas selected"; Return #t if an isa in ISA-LIST, a list of symbols, is to be kept.
215
; If any isa in ISA-LIST is to be kept, the result is #t.
216
; If ISA-LIST is the empty list (no particular isa specified) use the default
217
; isa.
218
; Return #t if the object containing ATLIST is to be kept.
219
 
220
; The object is kept if its attribute list specifies an `ISA' that is
221
; kept or does not have the `ISA' attribute (which means it has the default
222
 
223
; Return non-#f if object OBJ is to be kept, according to its ISA attribute.
224
 
225
; Return list of isa names currently being kept.
226
;; Tracing support.
227
;; This is akin to the "logit" support, but is for specific things that
228
;; can be named (whereas logit support is based on a simple integer verbosity
229
;; level).
230
;;; Enable the specified tracing.
231
;;; TRACE-OPTIONS is a comma-separated list of things to trace.
232
 
233
;;; Currently supported tracing:
234
;;; commands - trace invocation of description file commands (e.g. define-insn)
235
 
236
;;; all      - trace everything
237
 
238
;;; [If we later need to support disabling some tracing, one way is to
239
 
240
"commands""pmacros""all""commands""pmacros""all";; handled above
241
"-t "; If #f, treat reserved fields as operands and extract them with the insn.
242
; Code can then be emitted in the extraction routines to validate them.
243
; If #t, treat reserved fields as part of the opcode.
244
; This complicates the decoding process as these fields have to be
245
; checked too.
246
; ??? Unimplemented.
247
; Process options passed in on the command line.
248
; OPTIONS is a space separated string of name=value values.
249
; Each application is required to provide: option-init!, option-set!.
250
; ignore extraneous spaces
251
"Setting option `""' to \"""\".\n"; Application specific object creation support.
252
;
253
 
254
; Each application adds functionality by subclassing the container
255
; and registering with set-for-new! the proper class to create.
256
 
257
; complexity down while not requiring as dynamic a language as I had before.
258
; ??? Class local variables would provide a more efficient way to do this.
259
 
260
; Lookup the class registered with set-for-new!
261
; If none registered, return PARENT.
262
 
263
;; Initialize a new <reader> object.
264
;; This doesn't add cgen-specific commands, leaving each element (ifield,
265
;; hardware, etc.) to add their own.
266
;; The "result" is stored in global CURRENT-READER.
267
 
268
; the pmacro commands here.
269
"\
270
Define a preprocessor-style macro.
271
"; Prepare to parse a .cpu file.
272
 
273
; KEEP-MACH specifies what machs to keep.
274
; KEEP-ISA specifies what isas to keep.
275
; OPTIONS is a list of options to control code generation.
276
; The values are application dependent.
277
; The order here is important.
278
; Must be done first.
279
; Install any builtin objects.
280
 
281
; One reason is that attributes MACH and ISA don't exist until then.
282
 
283
; This is mainly for the insn attributes.
284
; Do anything necessary for the application independent parts after parsing
285
; a .cpu file.
286
; The lists get cons'd in reverse order.  One thing this does is change them
287
; back to file order, it makes things easier for the human viewer.
288
; The order here is generally the reverse of init-parse-cpu!.
289
; Must be done last.
290
; Perform a global error checking pass after the .cpu file has been read in.
291
 
292
; TODO:
293
; - all hardware elements with same name must have same rank and
294
;   compatible modes (which for now means same float mode or all int modes)
295
; .cpu file include mechanism
296
"Including file ""/"" ...\n""/""Resuming previous file ...\n"; Version of `if' invokable at the top level of a description file.
297
; This is a work-in-progress.  Its presence in the description file is ok,
298
; but the implementation will need to evolve.
299
 
300
"only (if (keep-mach?|keep-isa?|application-is? ...) ...) are currently supported"; Top level routine for loading .cpu files.
301
; FILE is the name of the .cpu file to load.
302
; KEEP-MACH is a string of comma separated machines to keep
303
 
304
; KEEP-ISA is a string of comma separated isas to keep.
305
 
306
; TRACE-OPTIONS is a random list of things to trace.
307
 
308
; to call after -init-parse-cpu!
309
; APP-FINISHER! is an application specific zero argument proc to call after
310
 
311
; ANALYZER! is a zero argument proc to call after loading the .cpu file.
312
; It is expected to set up various tables and things useful for the application
313
; in question.
314
;
315
; This function isn't local because it's used by dev.scm.
316
"Loading cpu description "" ...\n""Processing cpu description "" ...\n"; Argument parsing utilities.
317
; Generate a usage message.
318
; ERRTYPE is one of 'help, 'unknown, 'missing.
319
; OPTION is the option that had the error or "" if ERRTYPE is 'help.
320
"Unknown option: ""\n""Missing argument: ""\n""Unknown error!\n""Usage: cgen arguments ...\n"" """"  - ""\n""""\n""...\n"; Poor man's getopt.
321
; [We don't know where to find the real one until we've parsed the args,
322
; and this isn't something we need to get too fancy about anyways.]
323
 
324
; If the argument is valid, the result is ((opt-spec . arg) . remaining-argv),
325
; or (('unknown . option) . remaining-argv) if `option' isn't recognized,
326
; or (('missing . option) . remaining argv) if `option' is missing a required
327
; argument,
328
; or ((#f . #f) . #f) if there are no more arguments.
329
; OPT-SPEC is a list of option specs.
330
 
331
; `option' is a string or symbol naming the option.  e.g. -a, --help, "-i".
332
; symbols are supported for backward compatibility, -i is a complex number.
333
; `argument' is a string naming the argument or #f if the option takes no
334
 
335
; `help-text' is a string that is printed with the usage information.
336
; Elements beyond `help-text' are ignored.
337
; must be option that doesn't take an argument
338
; Return (cadr args) or print a pretty error message if not possible.
339
"option processing""missing argument to"; List of common arguments.
340
 
341
; ??? Another useful arg would be one that says "do file generation with
342
; arguments specified up til now, then continue with next batch of args".
343
"-a""arch-file""specify path of .cpu file to load""-b""use debugging evaluator, for backtraces""-d""start interactive debugging session""-f""flags""specify a set of flags to control code generation""-h""print usage information""--help""print usage information""-i""isa-list""specify isa-list entries to keep""-m""mach-list""specify mach-list entries to keep""-s""srcdir""set srcdir""-t""trace-options""specify list of things to trace""Options:""commands - trace cgen commands (e.g. define-insn)""pmacros  - trace pmacro expansion""all      - trace everything""-v""increment verbosity level""--version""print version info"; Default place to look.
344
; This gets overridden to point to the directory of the loaded .cpu file.
345
; ??? Ideally this would be local to this file.
346
"/cpu"; Accessors for application option specs
347
; Parse options and call generators.
348
; ARGS is a #:keyword delimited list of arguments.
349
; #:app-name name
350
; #:arg-spec optspec ; FIXME: rename to #:opt-spec
351
; #:init init-routine
352
; #:finish finish-routine
353
; #:analyze analysis-routine
354
 
355
;
356
; ARGSPEC is a list of (option option-arg comment option-handler) elements.
357
; OPTION-HANDLER is either (lambda () ...) or (lambda (arg) ...) and
358
; processes the option.
359
 
360
; application's args are queued here
361
"all"; default is all machs
362
"all"; default is all isas
363
""; default is off, for speed
364
"""-a""-b""-d""cgen-""> ""-f""-h""""--help""""-i""-m""-s"; ignore, already processed by caller
365
 
366
; Record it for later processing.  Note that they're
367
 
368
; later.
369
; end of loop
370
 
371
"-a option missing, no architecture specified";; Start another repl loop if -d.
372
;; Awkward.  Both places are useful, though this is more useful.
373
;; Done with processing the arguments.  Application arguments
374
 
375
;; have arguments that specify things that affect file
376
;; generation (e.g. to specify another input file) and we
377
;; don't want to require an ordering of the options.
378
; end of lambda
379
; Main entry point called by application file generators.
380
 

powered by: WebSVN 2.1.0

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