1 NoEcho(' 2 /****************************************************************************** 3 * 4 * Module Name: aslcstyle.y - Production rules for symbolic operators 5 * 6 *****************************************************************************/ 7 8 /* 9 * Copyright (C) 2000 - 2016, Intel Corp. 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 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. 26 * 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. 30 * 31 * NO WARRANTY 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. 43 */ 44 45 ') 46 47 /******************************************************************************* 48 * 49 * Production rules for the symbolic (c-style) operators 50 * 51 ******************************************************************************/ 52 53 /* 54 * ASL Extensions: C-style math/logical operators and expressions. 55 * The implementation transforms these operators into the standard 56 * AML opcodes and syntax. 57 * 58 * Supported operators and precedence rules (high-to-low) 59 * 60 * NOTE: The operator precedence and associativity rules are 61 * implemented by the tokens in asltokens.y 62 * 63 * (left-to-right): 64 * 1) ( ) expr++ expr-- 65 * 66 * (right-to-left): 67 * 2) ! ~ 68 * 69 * (left-to-right): 70 * 3) * / % 71 * 4) + - 72 * 5) >> << 73 * 6) < > <= >= 74 * 7) == != 75 * 8) & 76 * 9) ^ 77 * 10) | 78 * 11) && 79 * 12) || 80 * 81 * (right-to-left): 82 * 13) = += -= *= /= %= <<= >>= &= ^= |= 83 */ 84 85 86 /******************************************************************************* 87 * 88 * Basic operations for math and logical expressions. 89 * 90 ******************************************************************************/ 91 92 Expression 93 94 /* Unary operators */ 95 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 ());} 100 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);} 105 106 /* Binary operators: math and logical */ 107 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 ());} 123 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 ());} 130 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);} 139 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);} 144 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);} 149 150 /* Parentheses */ 151 152 | '(' TermArg ')' { $$ = $2;} 153 154 /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */ 155 156 | SuperName PARSEOP_EXP_INDEX_LEFT 157 TermArg PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafNode (PARSEOP_INDEX); 158 TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} 159 ; 160 161 /* Index term -- "BUF1[5] = " on left-hand side of an equals (target) */ 162 163 IndexExpTerm 164 165 : SuperName PARSEOP_EXP_INDEX_LEFT 166 TermArg PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafNode (PARSEOP_INDEX); 167 TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());} 168 ; 169 170 171 /******************************************************************************* 172 * 173 * All assignment-type operations -- math and logical. Includes simple 174 * assignment and compound assignments. 175 * 176 ******************************************************************************/ 177 178 EqualsTerm 179 180 /* Simple Store() operation */ 181 182 : SuperName PARSEOP_EXP_EQUALS 183 TermArg {$$ = TrCreateAssignmentNode ($1, $3);} 184 185 /* Compound assignments -- Add (operand, operand, target) */ 186 187 | TermArg PARSEOP_EXP_ADD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);} 188 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 189 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 190 191 | TermArg PARSEOP_EXP_DIV_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);} 192 TermArg {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (), 193 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 194 195 | TermArg PARSEOP_EXP_MOD_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);} 196 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 197 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 198 199 | TermArg PARSEOP_EXP_MUL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);} 200 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 201 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 202 203 | TermArg PARSEOP_EXP_SHL_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);} 204 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 205 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 206 207 | TermArg PARSEOP_EXP_SHR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);} 208 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 209 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 210 211 | TermArg PARSEOP_EXP_SUB_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);} 212 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 213 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 214 215 | TermArg PARSEOP_EXP_AND_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_AND);} 216 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 217 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 218 219 | TermArg PARSEOP_EXP_OR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_OR);} 220 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 221 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 222 223 | TermArg PARSEOP_EXP_XOR_EQ {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);} 224 TermArg {$$ = TrLinkChildren ($<n>3,3,$1,$4, 225 TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));} 226 ; 227