2 /******************************************************************************
4 * Module Name: aslcstyle.y - Production rules for symbolic operators
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2016, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
47 /*******************************************************************************
49 * Production rules for the symbolic (c-style) operators
51 ******************************************************************************/
54 * ASL Extensions: C-style math/logical operators and expressions.
55 * The implementation transforms these operators into the standard
56 * AML opcodes and syntax.
58 * Supported operators and precedence rules (high-to-low)
60 * NOTE: The operator precedence and associativity rules are
61 * implemented by the tokens in asltokens.y
64 * 1) ( ) expr++ expr--
82 * 13) = += -= *= /= %= <<= >>= &= ^= |=
86 /*******************************************************************************
88 * Basic operations for math and logical expressions.
90 ******************************************************************************/
96 : PARSEOP_EXP_LOGICAL_NOT
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LNOT
);}
97 TermArg
{$$
= TrLinkChildren
($
<n
>2,1,$3);}
98 | PARSEOP_EXP_NOT
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_NOT
);}
99 TermArg
{$$
= TrLinkChildren
($
<n
>2,2,$3,TrCreateNullTarget
());}
101 | SuperName PARSEOP_EXP_INCREMENT
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_INCREMENT
);}
102 {$$
= TrLinkChildren
($
<n
>3,1,$1);}
103 | SuperName PARSEOP_EXP_DECREMENT
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_DECREMENT
);}
104 {$$
= TrLinkChildren
($
<n
>3,1,$1);}
106 /* Binary operators: math and logical */
108 | TermArg PARSEOP_EXP_ADD
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_ADD
);}
109 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
110 | TermArg PARSEOP_EXP_DIVIDE
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_DIVIDE
);}
111 TermArg
{$$
= TrLinkChildren
($
<n
>3,4,$1,$4,TrCreateNullTarget
(),
112 TrCreateNullTarget
());}
113 | TermArg PARSEOP_EXP_MODULO
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_MOD
);}
114 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
115 | TermArg PARSEOP_EXP_MULTIPLY
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_MULTIPLY
);}
116 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
117 | TermArg PARSEOP_EXP_SHIFT_LEFT
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_SHIFTLEFT
);}
118 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
119 | TermArg PARSEOP_EXP_SHIFT_RIGHT
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_SHIFTRIGHT
);}
120 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
121 | TermArg PARSEOP_EXP_SUBTRACT
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_SUBTRACT
);}
122 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
124 | TermArg PARSEOP_EXP_AND
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_AND
);}
125 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
126 | TermArg PARSEOP_EXP_OR
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_OR
);}
127 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
128 | TermArg PARSEOP_EXP_XOR
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_XOR
);}
129 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,TrCreateNullTarget
());}
131 | TermArg PARSEOP_EXP_GREATER
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LGREATER
);}
132 TermArg
{$$
= TrLinkChildren
($
<n
>3,2,$1,$4);}
133 | TermArg PARSEOP_EXP_GREATER_EQUAL
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LGREATEREQUAL
);}
134 TermArg
{$$
= TrLinkChildren
($
<n
>3,2,$1,$4);}
135 | TermArg PARSEOP_EXP_LESS
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LLESS
);}
136 TermArg
{$$
= TrLinkChildren
($
<n
>3,2,$1,$4);}
137 | TermArg PARSEOP_EXP_LESS_EQUAL
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LLESSEQUAL
);}
138 TermArg
{$$
= TrLinkChildren
($
<n
>3,2,$1,$4);}
140 | TermArg PARSEOP_EXP_EQUAL
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LEQUAL
);}
141 TermArg
{$$
= TrLinkChildren
($
<n
>3,2,$1,$4);}
142 | TermArg PARSEOP_EXP_NOT_EQUAL
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LNOTEQUAL
);}
143 TermArg
{$$
= TrLinkChildren
($
<n
>3,2,$1,$4);}
145 | TermArg PARSEOP_EXP_LOGICAL_AND
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LAND
);}
146 TermArg
{$$
= TrLinkChildren
($
<n
>3,2,$1,$4);}
147 | TermArg PARSEOP_EXP_LOGICAL_OR
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_LOR
);}
148 TermArg
{$$
= TrLinkChildren
($
<n
>3,2,$1,$4);}
154 PARSEOP_CLOSE_PAREN
{$$
= $2;}
156 /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */
162 * Index term -- "BUF1[5] = " or " = BUF1[5] on either the left side
163 * of an equals (target) or the right side (source)
164 * Currently used in these terms:
173 PARSEOP_EXP_INDEX_LEFT
175 PARSEOP_EXP_INDEX_RIGHT
{$$
= TrCreateLeafNode
(PARSEOP_INDEX
);
176 TrLinkChildren
($$
,3,$1,$3,TrCreateNullTarget
());}
180 /*******************************************************************************
182 * All assignment-type operations -- math and logical. Includes simple
183 * assignment and compound assignments.
185 ******************************************************************************/
189 /* Allow parens anywhere */
193 PARSEOP_CLOSE_PAREN
{$$
= $2;}
195 /* Simple Store() operation */
199 TermArg
{$$
= TrCreateAssignmentNode
($1, $3);}
201 /* Chained equals: (a=RefOf)=b, a=b=c=d etc. */
207 TermArg
{$$
= TrCreateAssignmentNode
($2, $5);}
209 /* Compound assignments -- Add (operand, operand, target) */
211 | TermArg PARSEOP_EXP_ADD_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_ADD
);}
212 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
213 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
215 | TermArg PARSEOP_EXP_DIV_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_DIVIDE
);}
216 TermArg
{$$
= TrLinkChildren
($
<n
>3,4,$1,$4,TrCreateNullTarget
(),
217 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
219 | TermArg PARSEOP_EXP_MOD_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_MOD
);}
220 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
221 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
223 | TermArg PARSEOP_EXP_MUL_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_MULTIPLY
);}
224 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
225 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
227 | TermArg PARSEOP_EXP_SHL_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_SHIFTLEFT
);}
228 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
229 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
231 | TermArg PARSEOP_EXP_SHR_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_SHIFTRIGHT
);}
232 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
233 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
235 | TermArg PARSEOP_EXP_SUB_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_SUBTRACT
);}
236 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
237 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
239 | TermArg PARSEOP_EXP_AND_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_AND
);}
240 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
241 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
243 | TermArg PARSEOP_EXP_OR_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_OR
);}
244 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
245 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}
247 | TermArg PARSEOP_EXP_XOR_EQ
{$
<n
>$
= TrCreateLeafNode
(PARSEOP_XOR
);}
248 TermArg
{$$
= TrLinkChildren
($
<n
>3,3,$1,$4,
249 TrSetNodeFlags
(TrCreateTargetOperand
($1, NULL
), NODE_IS_TARGET
));}