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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [attr.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
; Attributes.
2
; Copyright (C) 2000, 2003, 2005, 2009 Red Hat, Inc.
3
; This file is part of CGEN.
4
; See file COPYING.CGEN for details.
5
 
6
; attributes are really enum attributes with two possible values, but they
7
; occur frequently enough that they are special cased.
8
;
9
; All objects that use attributes must have two methods:
10
; - 'get-atlist - returns the object's attr-list
11
; - 'set-atlist! - set the object's attr-list
12
;
13
; In .cpu files, attribute lists are associative lists of (NAME VALUE).
14
; Boolean attributes are specified as (NAME #t) or (NAME #f),
15
; but for convenience ATTR and !ATTR are also supported.
16
; integer/enum attrs are specified as (ATTR value).
17
; string attrs are specified as (ATTR value).
18
; Bitset attrs are specified as (ATTR val1,val2,val3).
19
; In all cases the value needn't be constant, and can be an expression,
20
; though expressions are currently only supported for META-attributes
21
; (attributes that don't appear in any generated code).
22
;
23
; Example:
24
; (FOO1 !FOO2 (BAR 3) (FOO3 X) (MACH sparc,sparclite))
25
;
26
; ??? Implementation of expressions is being postponed as long
27
; as possible, avoiding adding complications for complication's sake, and
28
; because I'm not completely sure how I want to do them.
29
; The syntax for an expression value is (ATTR (rtx-func ...)).
30
;
31
; ??? May wish to allow a bitset attribute like (ATTR val1,!val2), where `!'
32
; means to turn off that particular bit (or bits if val2 refers to several).
33
;
34
; ??? May wish to allow specifying enum attributes by only having to
35
; specify the value (move names into "enum space" or some such).
36
; An attr-list (or "atlist") is a collection of attributes.
37
 
38
; There is possible confusion between "alist" (associative-list) and
39
; "atlist" (attribute-list) but in practice I haven't had a problem.
40
; ??? May wish to change this to a list of objects, as the alist doesn't carry
41
; enough info.  However the alist is simple and fast.
42
; An empty attribute-list.
43
""; The attribute baseclass.
44
 
45
; [meaning attributes themselves can have attributes].
46
 
47
; An odd notion that is of some use.  It's current raison d'etre is to
48
; support sanitization of attributes [which is implemented with the
49
 
50
; List of object types this attribute is for.
51
 
52
; attr, enum, cpu, mach, model, ifield, hardware, operand,
53
 
54
; A value of #f means the attribute is for everything.
55
 
56
; A class for each type of attribute.
57
; `values' exists for boolean-attribute to simplify the code, it's ignored.
58
; Ditto for `default'.  The default for boolean-attribute is always #f.
59
; VALUES is ignored for string-attribute.
60
; For bitset attributes VALUES is a list of
61
; (symbol bit-number-or-#f attr-list comment-or-#f),
62
; one for each bit.
63
 
64
; Int's are used to record the bitset in the generated code so there's a limit
65
; of 32 elements, though there's nothing inherent in the description language
66
; that precludes removing the limit.
67
; NOTE: While one might want to record each element as an object, there's
68
; currently no need for the added complexity.
69
; For integer attributes VALUES is a list of (int),
70
; one for each possible value,
71
; or the empty list of all values are permissible.
72
; Note that each element is itself a list.  This is for consistency.
73
; For enum attributes VALUES is a list of
74
; (symbol enum-value-or-#f attr-list comment-or-#f),
75
; one for each possible.
76
; If enum-value is #f (unspecified) cgen will apply the standard rule for
77
 
78
; NOTE: While one might want to record each element as an object, there's
79
 
80
; Return a boolean indicating if X is a <boolean-attribute> object.
81
 
82
; Return a symbol indicating the kind of attribute ATTR is.
83
 
84
"attr-kind: internal error, not an attribute class"; Accessors.
85
; Create an attribute.
86
 
87
; rather than an object containing the value, so we only have to cons
88
; NAME and VALUE rather than building some object.  This is for simplicity
89
; and speed.  We try to incrementally complicate things, only as necessary.
90
; VALUE must be #f or #t.
91
; VALUES must be a comma separated list of symbols
92
; (e.g. val1,val2 not (val1 val2)).
93
 
94
; VALUE must be a number (or maybe a symbol).
95
 
96
;;; Return a procedure to parse an attribute.
97
;;; RIGHT-TYPE? is a procedure that verifies the value is the right type.
98
;;; MESSAGE is printed if there is an error.
99
; A boolean attribute's value is either #t or #f.
100
"boolean attribute not one of #f/#t""invalid argument to string attribute"; A bitset attribute's value is a comma separated list of elements.
101
; We don't validate the values.  In the case of the MACH attribute,
102
 
103
; been read in.
104
; ??? Need to decide whether all define-mach's must appear before any
105
; define-insn's.  It would be nice to be able to spread an architecture's
106
; description over several .cpu files.
107
; ??? On the other hand, all machs are specified in define-arch.
108
; Perhaps creation of builtins could be defered until then.
109
"improper bitset attribute"; An integer attribute's value is a number
110
; (or maybe a symbol representing that value).
111
"improper integer attribute"; An enum attribute's value is a symbol representing that value.
112
 
113
"boolean value list must be (#f #t)"; Ignore values for strings.  We can't do any error checking since
114
; the default value is (#f #t).
115
; Parse a bitset attribute's value definition.
116
; FIXME: treated as enum?
117
""; Parse an integer attribute's value definition.
118
; VALUES may be #f which means any value is ok.
119
 
120
; See parse-enum-vals for more info.
121
""; Make an attribute list object from a list of name/value pairs.
122
; Parse an attribute definition.
123
; This is the main routine for building an attribute object from a
124
 
125
; All arguments are in raw (non-evaluated) form.
126
; TYPE-CLASS is the class of the object to create.
127
; i.e. one of <{boolean,bitset,integer,enum,string}-attribute>.
128
; If DEFAULT is #f, use the first value.
129
; ??? Allowable values for integer attributes is wip.
130
"Processing attribute "" ...\n";; Pick out name first to augment the error context.
131
 
132
"invalid default""""invalid default""invalid default""invalid default"; Read an attribute description
133
; This is the main routine for analyzing attributes in the .cpu file.
134
; CONTEXT is a <context> object for error messages.
135
; ARG-LIST is an associative list of field name and field value.
136
; -attr-parse is invoked to create the attribute object.
137
; attribute type
138
""; assume for everything
139
 
140
; #f indicates "not set"
141
; Loop over each element in ARG-LIST, recording what's found.
142
"invalid attribute type""invalid attribute arg"; Must have type now.
143
"type not specified"; Establish proper defaults now that we know the type.
144
; really a nop, but for consistency
145
;; FIXME
146
 
147
; really a nop, but for consistency
148
 
149
"enum-attribute default not specified""bitset-attribute values not specified"; Now that we've identified the elements, build the object.
150
 
151
"define-attr"; Query routines.
152
 
153
; The result is the object or #f if not found.
154
 
155
; attribute alist ALIST.
156
; Note that if the attribute isn't present, it is defined to be #f.
157
 
158
; attribute alist ALIST.
159
; Expand attribute value ATVAL, which is an rtx expression.
160
; OWNER is the containing object or #f if there is none.
161
; OWNER is needed if an attribute is defined in terms of other attributes.
162
; If it's #f obviously ATVAL can't be defined in terms of others.
163
"-attr-eval: internal error, unsupported result:"; Return value of ATTR in attribute alist ALIST.
164
; If not present, return the default value.
165
; OWNER is the containing object or #f if there is none.
166
; pair? -> cheap non-null-list?
167
; Return the value of ATTR in ATLIST.
168
 
169
; Same as atlist-attr-value but return nil if attribute not present.
170
 
171
; Return the default for attribute A.
172
; If A isn't a non-boolean attribute, we assume it's a boolean one, and
173
 
174
; OWNER is the containing object or #f if there is none.
175
; pair? -> cheap non-null-list?
176
; If no default was provided, use the first value.
177
; Return a boolean indicating if X is present in BITSET.
178
; Bitset values are recorded as val1,val2,....
179
 
180
; Get/set attributes of OBJ.
181
 
182
; As a speed up, we allow objects to specify an empty attribute list
183
 
184
; ??? There is atlist-empty now which should be used directly.
185
; Add attribute ATTR to OBJ.
186
; The attribute is prepended to the front so it overrides any existing
187
 
188
; Add attribute list ATLIST to OBJ.
189
 
190
; Must have same prefix.
191
 
192
; OBJ is any object that supports attributes.
193
 
194
; Return a boolean indicating if attribute ATTR is present in OBJ.
195
 
196
; If the attribute isn't present, the default is returned.
197
 
198
; Return boolean of whether OBJ has attribute ATTR value VALUE or not.
199
; OBJ is any object that supports attributes.
200
; NOTE: The default value of the attribute IS considered.
201
 
202
; or not.
203
; OBJ is any object that supports attributes.
204
; NOTE: The default value of the attribute IS NOT considered.
205
; Utilities.
206
; Convert a bitset value "a,b,c" into a list (a b c).
207
; Generate a list representing a bit mask of the indices of 'values'
208
; within 'all-values'. Each element in the resulting list represents a byte.
209
; Both bits and bytes are indexed from left to right starting at 0
210
 
211
"charmask-bytes for "" ""\n""indices: ""\n""result: ""\n"; Convert a bitset value into a bit string based on the
212
 
213
"{ "", \"""\\x""\" }"; Return the enum of ATTR-NAME for type TYPE.
214
; TYPE is one of 'ifld, 'hw, 'operand, 'insn.
215
"CGEN_""_"; Return a list of enum value definitions for gen-enum-decl.
216
; Attributes numbers are organized as follows: booleans are numbered 0-31.
217
 
218
; are left unused.  Non-booleans are numbered starting at 32.
219
; An alternative is start numbering the booleans at 32.  The generated code
220
; is simpler with the current way (the "- 32" to get back the bit number or
221
 
222
;
223
; Three special values are created:
224
; END-BOOLS - mark end of boolean attributes
225
; END-NBOOLS - mark end of non-boolean attributes
226
; START-NBOOLS - marks the start of the non-boolean attributes
227
; (needed in case first non-bool is sanytized out).
228
;
229
; ATTR-OBJ-LIST is a list of <attribute> objects (always subclassed of course).
230
; Sort an alist of attributes so non-boolean attributes are at the front.
231
 
232
; This is required by the C support code (cgen.h:CGEN_ATTR_VALUE).
233
; Boolean attributes appear as (NAME . #t/#f), non-boolean ones appear as
234
; (NAME . VALUE).  Attributes of the same type are sorted by name.
235
;(display (list a b "\n"))
236
; we know b is non-bool here
237
 
238
; Sort ATTR-LIST into two lists: bools and non-bools.
239
; The car of the result is the bools, the cdr is the non-bools.
240
 
241
; and used for the few special attributes that are refered to by
242
; architecture independent code.
243
; For each of non-bools and bools, put attributes with the INDEX attribute
244
; first.  This is used to sort a list of attributes for output (e.g. define
245
; the attr enum).
246
 
247
; FIXME: Record index number with the INDEX attribute and sort on it.
248
 
249
; Return number of non-bools in attributes ATLIST.
250
; Given an alist of attributes, return the non-bools.
251
; Given an alist of attributes, return the bools.
252
; Parse an attribute spec.
253
; CONTEXT is a <context> object or #f if there is none.
254
 
255
; The result is the attribute alist.
256
 
257
"unknown attribute""unknown attribute""improper attribute"; Parse an object attribute spec.
258
; ATTRS is a list of attribute specs (e.g. (FOO !BAR (BAZ 3))).
259
; The result is an <attr-list> object.
260
; Return the source form of an atlist's values.
261
; Externally attributes are ((name1 value1) (name2 value2) ...).
262
; Internally they are ((name1 . value1) (name2 . value2) ...).
263
; Cons an attribute to an attribute list to create a new attribute list.
264
 
265
; signify an empty attribute list, in which case we make the prefix of the
266
; result "").
267
 
268
; The prefix for the new atlist is taken from the first one.
269
; Remove meta-attributes from ALIST.
270
; "meta" may be the wrong adjective to use here.
271
; The attributes in question are not intended to appear in generated files.
272
 
273
; FIXME: Why not use find?
274
; Remove meta-attributes from ATTR-LIST.
275
 
276
; The attributes in question are not intended to appear in generated files.
277
; They started out being attributes of attributes, hence the name "meta".
278
; FIXME: Why not use find?
279
; Remove duplicates from ATTRS, a list of attributes.
280
; Attribute lists are typically small so we use a simple O^2 algorithm.
281
 
282
; defined to pick the first entry of each attribute.
283
; Return a list of all attrs in TABLE-LIST, a list of lists of arbitrary
284
 
285
; attributes where the insns and macro-insns are on separate lists and
286
; appending them into one list would be unnecessarily expensive.
287
; ACCESSOR is a function to access the attrs field from TABLE-LIST.
288
; Duplicates are eliminated and the list is sorted so non-boolean attributes
289
; are at the front (required by the C code that fetches attribute values).
290
; STD-ATTRS is an `attr-list' object of attrs that are always available.
291
; The actual values returned are random (e.g. #t vs #f).  We could
292
; canonicalize them.
293
; The result is an alist of all the attributes that are used in TABLE-LIST.
294
; ??? The cdr of each element is some random value.  Perhaps it should be
295
; the default value or perhaps we should just return a list of names.
296
; ??? No longer used.
297
; Return lists of attributes for particular object types.
298
 
299
; Current behaviour puts the non-bools at the front.
300
; Methods to emit the C value of an attribute.
301
 
302
; independent part of CGEN), but there isn't a better place for them
303
; (maybe utils-cgen.scm?) and there's only a few of them.
304
"0""1";(string-upcase (string-append (obj:str-name self) "_" value)))
305
"isa""|(1<<""_"")""{ ""isa""{ ""|(1<<""_"")"", 0 }"" }""{ { "", 0 } }""_""{ { "", 0 } }";; Doesn't handle escape sequences.
306
"\"""\""; Called before loading a .cpu file to initialize.
307
 
308
Define an attribute, name/value pair list version.
309
 
310
; One thing this does is define all attributes requiring a fixed index,
311
 
312
; ??? Perhaps it would make sense to define all predefined attributes here.
313
"virtual object"; The meta attribute is used for attributes that aren't to appear in
314
; generated output (need a better name).
315
; Objects to keep local to a generated file.
316
; Attributes requiring fixed indices.
317
; ALIAS is used for instructions that are aliases of more general insns.
318
; ALIAS insns are ignored by the simulator.
319
"insn is an alias of another"; Called after loading a .cpu file to perform any post-processing required.
320
 

powered by: WebSVN 2.1.0

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