aslcstyle.y revision 1.1.1.2 1 1.1 christos NoEcho('
2 1.1 christos /******************************************************************************
3 1.1 christos *
4 1.1 christos * Module Name: aslcstyle.y - Production rules for symbolic operators
5 1.1 christos *
6 1.1 christos *****************************************************************************/
7 1.1 christos
8 1.1 christos /*
9 1.1 christos * Copyright (C) 2000 - 2016, Intel Corp.
10 1.1 christos * All rights reserved.
11 1.1 christos *
12 1.1 christos * Redistribution and use in source and binary forms, with or without
13 1.1 christos * modification, are permitted provided that the following conditions
14 1.1 christos * are met:
15 1.1 christos * 1. Redistributions of source code must retain the above copyright
16 1.1 christos * notice, this list of conditions, and the following disclaimer,
17 1.1 christos * without modification.
18 1.1 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 1.1 christos * substantially similar to the "NO WARRANTY" disclaimer below
20 1.1 christos * ("Disclaimer") and any redistribution must be conditioned upon
21 1.1 christos * including a substantially similar Disclaimer requirement for further
22 1.1 christos * binary redistribution.
23 1.1 christos * 3. Neither the names of the above-listed copyright holders nor the names
24 1.1 christos * of any contributors may be used to endorse or promote products derived
25 1.1 christos * from this software without specific prior written permission.
26 1.1 christos *
27 1.1 christos * Alternatively, this software may be distributed under the terms of the
28 1.1 christos * GNU General Public License ("GPL") version 2 as published by the Free
29 1.1 christos * Software Foundation.
30 1.1 christos *
31 1.1 christos * NO WARRANTY
32 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 1.1 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 1.1 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 1.1 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 1.1 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 1.1 christos * POSSIBILITY OF SUCH DAMAGES.
43 1.1 christos */
44 1.1 christos
45 1.1 christos ')
46 1.1 christos
47 1.1 christos /*******************************************************************************
48 1.1 christos *
49 1.1 christos * Production rules for the symbolic (c-style) operators
50 1.1 christos *
51 1.1 christos ******************************************************************************/
52 1.1 christos
53 1.1 christos /*
54 1.1 christos * ASL Extensions: C-style math/logical operators and expressions.
55 1.1 christos * The implementation transforms these operators into the standard
56 1.1 christos * AML opcodes and syntax.
57 1.1 christos *
58 1.1 christos * Supported operators and precedence rules (high-to-low)
59 1.1 christos *
60 1.1 christos * NOTE: The operator precedence and associativity rules are
61 1.1 christos * implemented by the tokens in asltokens.y
62 1.1 christos *
63 1.1 christos * (left-to-right):
64 1.1 christos * 1) ( ) expr++ expr--
65 1.1 christos *
66 1.1 christos * (right-to-left):
67 1.1 christos * 2) ! ~
68 1.1 christos *
69 1.1 christos * (left-to-right):
70 1.1 christos * 3) * / %
71 1.1 christos * 4) + -
72 1.1 christos * 5) >> <<
73 1.1 christos * 6) < > <= >=
74 1.1 christos * 7) == !=
75 1.1 christos * 8) &
76 1.1 christos * 9) ^
77 1.1 christos * 10) |
78 1.1 christos * 11) &&
79 1.1 christos * 12) ||
80 1.1 christos *
81 1.1 christos * (right-to-left):
82 1.1 christos * 13) = += -= *= /= %= <<= >>= &= ^= |=
83 1.1 christos */
84 1.1 christos
85 1.1.1.2 christos
86 1.1.1.2 christos /*******************************************************************************
87 1.1.1.2 christos *
88 1.1.1.2 christos * Basic operations for math and logical expressions.
89 1.1.1.2 christos *
90 1.1.1.2 christos ******************************************************************************/
91 1.1.1.2 christos
92 1.1 christos Expression
93 1.1 christos
94 1.1 christos /* Unary operators */
95 1.1 christos
96 1.1 christos : PARSEOP_EXP_LOGICAL_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);}
97 1.1 christos TermArg {$$ = TrLinkChildren ($<n>2,1,$3);}
98 1.1 christos | PARSEOP_EXP_NOT {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);}
99 1.1 christos TermArg {$$ = TrLinkChildren ($<n>2,2,$3,TrCreateNullTarget ());}
100 1.1 christos
101 1.1 christos | SuperName PARSEOP_EXP_INCREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);}
102 1.1 christos {$$ = TrLinkChildren ($<n>3,1,$1);}
103 1.1 christos | SuperName PARSEOP_EXP_DECREMENT {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);}
104 1.1 christos {$$ = TrLinkChildren ($<n>3,1,$1);}
105 1.1 christos
106 1.1 christos /* Binary operators: math and logical */
107 1.1 christos
108 1.1 christos | TermArg PARSEOP_EXP_ADD {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);}
109 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
110 1.1 christos | TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);}
111 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (),
112 1.1 christos TrCreateNullTarget ());}
113 1.1 christos | TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);}
114 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
115 1.1 christos | TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);}
116 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
117 1.1 christos | TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);}
118 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
119 1.1 christos | TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);}
120 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
121 1.1 christos | TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);}
122 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
123 1.1 christos
124 1.1 christos | TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafNode (PARSEOP_AND);}
125 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
126 1.1 christos | TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafNode (PARSEOP_OR);}
127 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
128 1.1 christos | TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);}
129 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
130 1.1 christos
131 1.1 christos | TermArg PARSEOP_EXP_GREATER {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);}
132 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
133 1.1 christos | TermArg PARSEOP_EXP_GREATER_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATEREQUAL);}
134 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
135 1.1 christos | TermArg PARSEOP_EXP_LESS {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);}
136 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
137 1.1 christos | TermArg PARSEOP_EXP_LESS_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LLESSEQUAL);}
138 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
139 1.1 christos
140 1.1 christos | TermArg PARSEOP_EXP_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);}
141 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
142 1.1 christos | TermArg PARSEOP_EXP_NOT_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LNOTEQUAL);}
143 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
144 1.1 christos
145 1.1 christos | TermArg PARSEOP_EXP_LOGICAL_AND {$<n>$ = TrCreateLeafNode (PARSEOP_LAND);}
146 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
147 1.1 christos | TermArg PARSEOP_EXP_LOGICAL_OR {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);}
148 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
149 1.1 christos
150 1.1.1.2 christos /* Parentheses */
151 1.1 christos
152 1.1 christos | '(' TermArg ')' { $$ = $2;}
153 1.1 christos
154 1.1.1.2 christos /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */
155 1.1 christos
156 1.1.1.2 christos | SuperName PARSEOP_EXP_INDEX_LEFT
157 1.1.1.2 christos TermArg PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafNode (PARSEOP_INDEX);
158 1.1 christos TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());}
159 1.1 christos ;
160 1.1 christos
161 1.1.1.2 christos /* Index term -- "BUF1[5] = " on left-hand side of an equals (target) */
162 1.1 christos
163 1.1 christos IndexExpTerm
164 1.1 christos
165 1.1.1.2 christos : SuperName PARSEOP_EXP_INDEX_LEFT
166 1.1.1.2 christos TermArg PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafNode (PARSEOP_INDEX);
167 1.1 christos TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());}
168 1.1 christos ;
169 1.1 christos
170 1.1.1.2 christos
171 1.1.1.2 christos /*******************************************************************************
172 1.1.1.2 christos *
173 1.1.1.2 christos * All assignment-type operations -- math and logical. Includes simple
174 1.1.1.2 christos * assignment and compound assignments.
175 1.1.1.2 christos *
176 1.1.1.2 christos ******************************************************************************/
177 1.1.1.2 christos
178 1.1 christos EqualsTerm
179 1.1 christos
180 1.1.1.2 christos /* Simple Store() operation */
181 1.1 christos
182 1.1 christos : SuperName PARSEOP_EXP_EQUALS
183 1.1 christos TermArg {$$ = TrCreateAssignmentNode ($1, $3);}
184 1.1 christos
185 1.1.1.2 christos /* Compound assignments -- Add (operand, operand, target) */
186 1.1.1.2 christos
187 1.1 christos | TermArg PARSEOP_EXP_ADD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);}
188 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
189 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
190 1.1 christos
191 1.1 christos | TermArg PARSEOP_EXP_DIV_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);}
192 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (),
193 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
194 1.1 christos
195 1.1 christos | TermArg PARSEOP_EXP_MOD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);}
196 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
197 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
198 1.1 christos
199 1.1 christos | TermArg PARSEOP_EXP_MUL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);}
200 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
201 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
202 1.1 christos
203 1.1 christos | TermArg PARSEOP_EXP_SHL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);}
204 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
205 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
206 1.1 christos
207 1.1 christos | TermArg PARSEOP_EXP_SHR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);}
208 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
209 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
210 1.1 christos
211 1.1 christos | TermArg PARSEOP_EXP_SUB_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);}
212 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
213 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
214 1.1 christos
215 1.1 christos | TermArg PARSEOP_EXP_AND_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_AND);}
216 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
217 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
218 1.1 christos
219 1.1 christos | TermArg PARSEOP_EXP_OR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_OR);}
220 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
221 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
222 1.1 christos
223 1.1 christos | TermArg PARSEOP_EXP_XOR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);}
224 1.1 christos TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4,
225 1.1 christos TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
226 1.1 christos ;
227