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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [utils-gen.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
; Application independent utilities for C/C++ code generation.
2
; Copyright (C) 2000, 2001, 2005, 2009 Red Hat, Inc.
3
; This file is part of CGEN.
4
; See file COPYING.CGEN for details.
5
 
6
"""""""static const CGEN_ATTR_ENTRY ""_attr [] ATTRIBUTE_UNUSED = \n{\n  {\"integer\", ""},\n  { 0, 0 }\n};\n\n""_""static const CGEN_ATTR_ENTRY ""_attr""[] ATTRIBUTE_UNUSED =\n{\n""  { ""\"""\", ""_"" },\n""  { 0, 0 }\n""};\n\n"; Ifield extraction utilities.
7
 
8
; <ifield> from an insn.  Usually this is just an int, but for register
9
 
10
; Then there's floats (??? which aren't handled yet).
11
 
12
; MACRO? is #t if the result is part of a macro.
13
 
14
;
15
; TOTAL-LENGTH is the total length of the value in VAL.
16
; BASE-VALUE is a C expression (string) containing the base part of the insn.
17
"EXTRACT_""LSB0_""MSB0_""INT""UINT""unsupported mode class"" ("", "", "; ??? Is passing total-length right here?
18
 
19
; just return the raw extracted value.  Otherwise, emit
20
; the expression.
21
; cadr: fetches expression to be evaluated
22
; caar: fetches symbol in arglist
23
; cadar: fetches `pc' symbol in arglist
24
"pc"; Subroutine of -gen-ifld-extract-beyond to extract the relevant value
25
 
26
"(""EXTRACT_""LSB0""MSB0"; Only want sign extension for word with sign bit.
27
"_INT (""_UINT ("; What to extract from.
28
", "; Size of this chunk.
29
", "; MSB of this chunk.
30
", "; Length of field within this chunk.
31
") << "; Adjustment for this chunk within a full field.
32
")"; Return C code to extract a field that extends beyond the base insn.
33
;
34
; Things get tricky in the non-integral-insn case (no kidding).
35
; This case includes every architecture with at least one insn larger
36
; than 32 bits, and all architectures where insns smaller than 32 bits
37
; can't be interpreted as an int.
38
; ??? And maybe other architectures not considered yet.
39
; We want to handle these reasonably fast as this includes architectures like
40
; the ARC and I960 where 99% of the insns are 32 bits, with a few insns that
41
; take a 32 bit immediate.  It would be a real shame to unnecessarily slow down
42
; handling of 99% of the instruction set just for a few insns.  Fortunately
43
; for these chips base-insn includes these insns, so things fall out naturally.
44
;
45
; BASE-LENGTH is base-insn-bitsize.
46
; TOTAL-LENGTH is the total length of the insn.
47
; VAR-LIST is a list of variables containing the insn.
48
; Each element in VAR-LIST is (name start length).
49
; The contents of the insn are in several variables: insn, word_[123...],
50
 
51
; recording the rest of the insn, 32 bits at a time (with the last one
52
; containing whatever is left over).
53
; First compute the list of variables that contains pieces of the
54
; desired value.
55
 
56
;(word-length (ifld-word-length f))
57
; extraction code
58
; extra processing to perform on extracted value
59
; Find which vars are needed and move the value into place.
60
 
61
; raw extracted value.  Otherwise, emit the expression.
62
 
63
; caar: fetches symbol in arglist
64
; cadar: fetches `pc' symbol in arglist
65
"pc"; Return C code to extract <ifield> F.
66
" = "";"" \\\n""\n"; Return C code to extract a <multi-ifield> from an insn.
67
 
68
; made methods in application code.
69
; The subfields must have already been extracted.
70
;; First, the block that extract the multi-ifield into the ifld variable
71
 
72
"  "" = ""pc"";\n""""\n"; Return C symbol of variable containing the extracted field value
73
; in the extraction code.  E.g. f_rd = EXTRACT_UINT (insn, ...).
74
 
75
; to extract values beyond the base insn.
76
; This is also used by gen-define-ifields to know how many vars are needed.
77
;
78
; The result is a list of (offset . length) pairs.
79
 
80
; ??? Here's a case where explicitly defined instruction formats can
81
; help - without them we can only use heuristics (which must evolve).
82
; At least all the details are tucked away here.
83
; For the aligned and forced case split the insn up into base-insn
84
 
85
; 32 was chosen because the values are extracted into portable ints.
86
"unknown alignment"; Always fetch full CHUNK-LENGTH-sized chunks here,
87
; even if we don't actually need that many bytes.
88
; gen-ifetch only handles "normal" fetch sizes,
89
; and -gen-extract-word already knows how to find what
90
; it needs if we give it too much.
91
; Subroutine of gen-define-ifmt-ifields and gen-extract-ifmt-ifields to
92
; insert the subfields of any multi-ifields present into IFLDS.
93
; Subfields are inserted before their corresponding multi-ifield as they
94
; are initialized in order.
95
; There's no real need to reverse the subfields here
96
; other than to keep them in order.
97
; Return C code to define local vars to contain IFIELDS.
98
; All insns using the result have the same TOTAL-LENGTH (in bits).
99
; INDENT is a string prepended to each line.
100
; MACRO? is #t if the code is part of a macro (and thus '\\' must be appended
101
; to each line).
102
; Define enough ints to hold the trailing part of the insn,
103
; N bits at a time.
104
; ??? This could be more intelligent of course.  Later.
105
; ??? Making these global to us would allow filling them during
106
; decoding.
107
"/* Contents of trailing part of insn.  */"" \\\n""\n""UINT word_""; \\\n"";\n"""; Return C code to define local vars to contain IFIELDS of <iformat> IFMT.
108
; INDENT is a string prepended to each line.
109
; MACRO? is #t if the code is part of a macro (and thus '\\' must be appended
110
; to each line).
111
; USE-MACRO? is #t if instead of generating the fields, we return the macro
112
; that does that.
113
"EXTRACT_""_VARS"" /*"" "" */\n""  ""#define "" \\\n""/* Instruction fields.  */\n""unsigned int length;"; The last line doesn't have a trailing '\\'.
114
"\n"; Subroutine of gen-extract-ifields to fetch one value into VAR-NAME.
115
"  "" = ""pc"";"" \\\n""\n"; Subroutine of gen-extract-ifields to compute the var-list arg to
116
 
117
; The result is a list of `(name start length)' elements describing the
118
; variables holding the parts of the insn.
119
 
120
; ??? lsb0? support ok?
121
"insn"; Return C code to extract IFIELDS.
122
; All insns using the result have the same TOTAL-LENGTH (in bits).
123
; MACRO? is #t if the code is part of a macro (and thus '\\' must be appended
124
; to each line).
125
;
126
; Here is where we handle integral-insn vs non-integeral-insn architectures.
127
;
128
; Examples of architectures that can be handled as integral-insns are:
129
; sparc, m32r, mips, etc.
130
;
131
; Examples of architectures that can't be handled as integral insns are:
132
; arc, i960, fr30, i386, m68k.
133
; [i386,m68k are only mentioned for completeness.  cgen ports of these
134
; would be great, but more thought is needed first]
135
;
136
; C variable `insn' is assumed to contain the base part of the insn
137
; (max base-insn-bitsize insn-bitsize).  In the m32r case insn-bitsize
138
; can be less than base-insn-bitsize.
139
;
140
; ??? Need to see how well gcc optimizes this.
141
;
142
; ??? Another way to do this is to put this code in an inline function that
143
; gets passed pointers to each ifield variable.  GCC is smart enough to
144
; produce optimal code for this, but other compilers may not have inlining
145
; or the indirection removal.  I think the slowdown for a non-scache simulator
146
; would be phenomenal and while one can say "too bad, use gcc", I'm defering
147
; doing this for now.
148
; If the insn has a trailing part, fetch it.
149
; ??? Could have more intelligence here.  Later.
150
 
151
; ??? Written this way to pass through Hobbit, doesn't handle
152
; ((if foo a b) (arg1 arg2)).
153
"insn""word_""insn""word_"; Return C code to extract the fields of <iformat> IFMT.
154
; MACRO? is #t if the code is part of a macro (and thus '\\' must be appended
155
; to each line).
156
; USE-MACRO? is #t if instead of generating the fields, we return the macro
157
; that does that.
158
"EXTRACT_""_CODE""\n""  ""#define "" \\\n""""length = "";"" \\\n""\n"; The last line doesn't have a trailing '\\'.
159
"\n"; Instruction format utilities.
160
"@prefix@_sfmt_type""semantic formats in cpu family @cpu@""@PREFIX@_"

powered by: WebSVN 2.1.0

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