Home | History | Annotate | Line # | Download | only in compiler
aslcstyle.y revision 1.1.1.4
      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.1.3  christos  * Copyright (C) 2000 - 2017, 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.1.4  christos     : PARSEOP_EXP_LOGICAL_NOT           {$<n>$ = TrCreateLeafOp (PARSEOP_LNOT);}
     97  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>2,1,$3);}
     98  1.1.1.4  christos     | PARSEOP_EXP_NOT                   {$<n>$ = TrCreateLeafOp (PARSEOP_NOT);}
     99  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>2,2,$3,TrCreateNullTargetOp ());}
    100  1.1.1.4  christos 
    101  1.1.1.4  christos     | SuperName PARSEOP_EXP_INCREMENT   {$<n>$ = TrCreateLeafOp (PARSEOP_INCREMENT);}
    102  1.1.1.4  christos                                         {$$ = TrLinkOpChildren ($<n>3,1,$1);}
    103  1.1.1.4  christos     | SuperName PARSEOP_EXP_DECREMENT   {$<n>$ = TrCreateLeafOp (PARSEOP_DECREMENT);}
    104  1.1.1.4  christos                                         {$$ = TrLinkOpChildren ($<n>3,1,$1);}
    105      1.1  christos 
    106      1.1  christos     /* Binary operators: math and logical */
    107      1.1  christos 
    108  1.1.1.4  christos     | TermArg PARSEOP_EXP_ADD           {$<n>$ = TrCreateLeafOp (PARSEOP_ADD);}
    109  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    110  1.1.1.4  christos     | TermArg PARSEOP_EXP_DIVIDE        {$<n>$ = TrCreateLeafOp (PARSEOP_DIVIDE);}
    111  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,4,$1,$4,TrCreateNullTargetOp (),
    112  1.1.1.4  christos                                             TrCreateNullTargetOp ());}
    113  1.1.1.4  christos     | TermArg PARSEOP_EXP_MODULO        {$<n>$ = TrCreateLeafOp (PARSEOP_MOD);}
    114  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    115  1.1.1.4  christos     | TermArg PARSEOP_EXP_MULTIPLY      {$<n>$ = TrCreateLeafOp (PARSEOP_MULTIPLY);}
    116  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    117  1.1.1.4  christos     | TermArg PARSEOP_EXP_SHIFT_LEFT    {$<n>$ = TrCreateLeafOp (PARSEOP_SHIFTLEFT);}
    118  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    119  1.1.1.4  christos     | TermArg PARSEOP_EXP_SHIFT_RIGHT   {$<n>$ = TrCreateLeafOp (PARSEOP_SHIFTRIGHT);}
    120  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    121  1.1.1.4  christos     | TermArg PARSEOP_EXP_SUBTRACT      {$<n>$ = TrCreateLeafOp (PARSEOP_SUBTRACT);}
    122  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    123  1.1.1.4  christos 
    124  1.1.1.4  christos     | TermArg PARSEOP_EXP_AND           {$<n>$ = TrCreateLeafOp (PARSEOP_AND);}
    125  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    126  1.1.1.4  christos     | TermArg PARSEOP_EXP_OR            {$<n>$ = TrCreateLeafOp (PARSEOP_OR);}
    127  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    128  1.1.1.4  christos     | TermArg PARSEOP_EXP_XOR           {$<n>$ = TrCreateLeafOp (PARSEOP_XOR);}
    129  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
    130  1.1.1.4  christos 
    131  1.1.1.4  christos     | TermArg PARSEOP_EXP_GREATER       {$<n>$ = TrCreateLeafOp (PARSEOP_LGREATER);}
    132  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
    133  1.1.1.4  christos     | TermArg PARSEOP_EXP_GREATER_EQUAL {$<n>$ = TrCreateLeafOp (PARSEOP_LGREATEREQUAL);}
    134  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
    135  1.1.1.4  christos     | TermArg PARSEOP_EXP_LESS          {$<n>$ = TrCreateLeafOp (PARSEOP_LLESS);}
    136  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
    137  1.1.1.4  christos     | TermArg PARSEOP_EXP_LESS_EQUAL    {$<n>$ = TrCreateLeafOp (PARSEOP_LLESSEQUAL);}
    138  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
    139  1.1.1.4  christos 
    140  1.1.1.4  christos     | TermArg PARSEOP_EXP_EQUAL         {$<n>$ = TrCreateLeafOp (PARSEOP_LEQUAL);}
    141  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
    142  1.1.1.4  christos     | TermArg PARSEOP_EXP_NOT_EQUAL     {$<n>$ = TrCreateLeafOp (PARSEOP_LNOTEQUAL);}
    143  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
    144  1.1.1.4  christos 
    145  1.1.1.4  christos     | TermArg PARSEOP_EXP_LOGICAL_AND   {$<n>$ = TrCreateLeafOp (PARSEOP_LAND);}
    146  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
    147  1.1.1.4  christos     | TermArg PARSEOP_EXP_LOGICAL_OR    {$<n>$ = TrCreateLeafOp (PARSEOP_LOR);}
    148  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
    149      1.1  christos 
    150  1.1.1.2  christos     /* Parentheses */
    151      1.1  christos 
    152  1.1.1.3  christos     | PARSEOP_OPEN_PAREN
    153  1.1.1.3  christos         Expression
    154  1.1.1.3  christos         PARSEOP_CLOSE_PAREN             {$$ = $2;}
    155      1.1  christos 
    156  1.1.1.2  christos     /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */
    157      1.1  christos 
    158  1.1.1.3  christos     | IndexExpTerm
    159      1.1  christos     ;
    160      1.1  christos 
    161  1.1.1.3  christos     /*
    162  1.1.1.3  christos      * Index term -- "BUF1[5] = " or " = BUF1[5] on either the left side
    163  1.1.1.3  christos      * of an equals (target) or the right side (source)
    164  1.1.1.3  christos      * Currently used in these terms:
    165  1.1.1.3  christos      *      Expression
    166  1.1.1.3  christos      *      ObjectTypeSource
    167  1.1.1.3  christos      *      DerefOfSource
    168  1.1.1.3  christos      *      Type6Opcode
    169  1.1.1.3  christos      */
    170      1.1  christos IndexExpTerm
    171      1.1  christos 
    172  1.1.1.3  christos     : SuperName
    173  1.1.1.3  christos         PARSEOP_EXP_INDEX_LEFT
    174  1.1.1.3  christos         TermArg
    175  1.1.1.4  christos         PARSEOP_EXP_INDEX_RIGHT         {$$ = TrCreateLeafOp (PARSEOP_INDEX);
    176  1.1.1.4  christos                                         TrLinkOpChildren ($$,3,$1,$3,TrCreateNullTargetOp ());}
    177      1.1  christos     ;
    178      1.1  christos 
    179  1.1.1.2  christos 
    180  1.1.1.2  christos /*******************************************************************************
    181  1.1.1.2  christos  *
    182  1.1.1.2  christos  * All assignment-type operations -- math and logical. Includes simple
    183  1.1.1.2  christos  * assignment and compound assignments.
    184  1.1.1.2  christos  *
    185  1.1.1.2  christos  ******************************************************************************/
    186  1.1.1.2  christos 
    187      1.1  christos EqualsTerm
    188      1.1  christos 
    189  1.1.1.3  christos     /* Allow parens anywhere */
    190  1.1.1.3  christos 
    191  1.1.1.3  christos     : PARSEOP_OPEN_PAREN
    192  1.1.1.3  christos         EqualsTerm
    193  1.1.1.3  christos         PARSEOP_CLOSE_PAREN             {$$ = $2;}
    194  1.1.1.3  christos 
    195  1.1.1.2  christos     /* Simple Store() operation */
    196      1.1  christos 
    197  1.1.1.3  christos     | SuperName
    198  1.1.1.3  christos         PARSEOP_EXP_EQUALS
    199  1.1.1.4  christos         TermArg                         {$$ = TrCreateAssignmentOp ($1, $3);}
    200      1.1  christos 
    201  1.1.1.3  christos     /* Chained equals: (a=RefOf)=b, a=b=c=d etc. */
    202  1.1.1.3  christos 
    203  1.1.1.3  christos     | PARSEOP_OPEN_PAREN
    204  1.1.1.3  christos         EqualsTerm
    205  1.1.1.3  christos         PARSEOP_CLOSE_PAREN
    206  1.1.1.3  christos         PARSEOP_EXP_EQUALS
    207  1.1.1.4  christos         TermArg                         {$$ = TrCreateAssignmentOp ($2, $5);}
    208  1.1.1.3  christos 
    209  1.1.1.2  christos     /* Compound assignments -- Add (operand, operand, target) */
    210  1.1.1.2  christos 
    211  1.1.1.4  christos     | TermArg PARSEOP_EXP_ADD_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_ADD);}
    212  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    213  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    214  1.1.1.4  christos 
    215  1.1.1.4  christos     | TermArg PARSEOP_EXP_DIV_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_DIVIDE);}
    216  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,4,$1,$4,TrCreateNullTargetOp (),
    217  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    218  1.1.1.4  christos 
    219  1.1.1.4  christos     | TermArg PARSEOP_EXP_MOD_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_MOD);}
    220  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    221  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    222  1.1.1.4  christos 
    223  1.1.1.4  christos     | TermArg PARSEOP_EXP_MUL_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_MULTIPLY);}
    224  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    225  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    226  1.1.1.4  christos 
    227  1.1.1.4  christos     | TermArg PARSEOP_EXP_SHL_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_SHIFTLEFT);}
    228  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    229  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    230  1.1.1.4  christos 
    231  1.1.1.4  christos     | TermArg PARSEOP_EXP_SHR_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_SHIFTRIGHT);}
    232  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    233  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    234  1.1.1.4  christos 
    235  1.1.1.4  christos     | TermArg PARSEOP_EXP_SUB_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_SUBTRACT);}
    236  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    237  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    238  1.1.1.4  christos 
    239  1.1.1.4  christos     | TermArg PARSEOP_EXP_AND_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_AND);}
    240  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    241  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    242  1.1.1.4  christos 
    243  1.1.1.4  christos     | TermArg PARSEOP_EXP_OR_EQ         {$<n>$ = TrCreateLeafOp (PARSEOP_OR);}
    244  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    245  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    246  1.1.1.4  christos 
    247  1.1.1.4  christos     | TermArg PARSEOP_EXP_XOR_EQ        {$<n>$ = TrCreateLeafOp (PARSEOP_XOR);}
    248  1.1.1.4  christos         TermArg                         {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
    249  1.1.1.4  christos                                             TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
    250      1.1  christos     ;
    251