Home | History | Annotate | Line # | Download | only in compiler
aslcstyle.y revision 1.1
      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  christos Expression
     86  1.1  christos 
     87  1.1  christos     /* Unary operators */
     88  1.1  christos 
     89  1.1  christos     : PARSEOP_EXP_LOGICAL_NOT           {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);}
     90  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>2,1,$3);}
     91  1.1  christos     | PARSEOP_EXP_NOT                   {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);}
     92  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>2,2,$3,TrCreateNullTarget ());}
     93  1.1  christos 
     94  1.1  christos     | SuperName PARSEOP_EXP_INCREMENT   {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);}
     95  1.1  christos                                         {$$ = TrLinkChildren ($<n>3,1,$1);}
     96  1.1  christos     | SuperName PARSEOP_EXP_DECREMENT   {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);}
     97  1.1  christos                                         {$$ = TrLinkChildren ($<n>3,1,$1);}
     98  1.1  christos 
     99  1.1  christos     /* Binary operators: math and logical */
    100  1.1  christos 
    101  1.1  christos     | TermArg PARSEOP_EXP_ADD           {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);}
    102  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    103  1.1  christos     | TermArg PARSEOP_EXP_DIVIDE        {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);}
    104  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (),
    105  1.1  christos                                             TrCreateNullTarget ());}
    106  1.1  christos     | TermArg PARSEOP_EXP_MODULO        {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);}
    107  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    108  1.1  christos     | TermArg PARSEOP_EXP_MULTIPLY      {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);}
    109  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    110  1.1  christos     | TermArg PARSEOP_EXP_SHIFT_LEFT    {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);}
    111  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    112  1.1  christos     | TermArg PARSEOP_EXP_SHIFT_RIGHT   {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);}
    113  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    114  1.1  christos     | TermArg PARSEOP_EXP_SUBTRACT      {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);}
    115  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    116  1.1  christos 
    117  1.1  christos     | TermArg PARSEOP_EXP_AND           {$<n>$ = TrCreateLeafNode (PARSEOP_AND);}
    118  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    119  1.1  christos     | TermArg PARSEOP_EXP_OR            {$<n>$ = TrCreateLeafNode (PARSEOP_OR);}
    120  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    121  1.1  christos     | TermArg PARSEOP_EXP_XOR           {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);}
    122  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,TrCreateNullTarget ());}
    123  1.1  christos 
    124  1.1  christos     | TermArg PARSEOP_EXP_GREATER       {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);}
    125  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
    126  1.1  christos     | TermArg PARSEOP_EXP_GREATER_EQUAL {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATEREQUAL);}
    127  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
    128  1.1  christos     | TermArg PARSEOP_EXP_LESS          {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);}
    129  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
    130  1.1  christos     | TermArg PARSEOP_EXP_LESS_EQUAL    {$<n>$ = TrCreateLeafNode (PARSEOP_LLESSEQUAL);}
    131  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
    132  1.1  christos 
    133  1.1  christos     | TermArg PARSEOP_EXP_EQUAL         {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);}
    134  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
    135  1.1  christos     | TermArg PARSEOP_EXP_NOT_EQUAL     {$<n>$ = TrCreateLeafNode (PARSEOP_LNOTEQUAL);}
    136  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
    137  1.1  christos 
    138  1.1  christos     | TermArg PARSEOP_EXP_LOGICAL_AND   {$<n>$ = TrCreateLeafNode (PARSEOP_LAND);}
    139  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
    140  1.1  christos     | TermArg PARSEOP_EXP_LOGICAL_OR    {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);}
    141  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,2,$1,$4);}
    142  1.1  christos 
    143  1.1  christos         /* Parentheses */
    144  1.1  christos 
    145  1.1  christos     | '(' TermArg ')'                   { $$ = $2;}
    146  1.1  christos 
    147  1.1  christos         /* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */
    148  1.1  christos 
    149  1.1  christos     | SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT
    150  1.1  christos                                         {$$ = TrCreateLeafNode (PARSEOP_INDEX);
    151  1.1  christos                                         TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());}
    152  1.1  christos     ;
    153  1.1  christos 
    154  1.1  christos         /* Index term -- "BUF1[5] = " on left-hand side of an equals (target) */
    155  1.1  christos 
    156  1.1  christos IndexExpTerm
    157  1.1  christos 
    158  1.1  christos     : SuperName PARSEOP_EXP_INDEX_LEFT TermArg PARSEOP_EXP_INDEX_RIGHT
    159  1.1  christos                                         {$$ = TrCreateLeafNode (PARSEOP_INDEX);
    160  1.1  christos                                         TrLinkChildren ($$,3,$1,$3,TrCreateNullTarget ());}
    161  1.1  christos     ;
    162  1.1  christos 
    163  1.1  christos EqualsTerm
    164  1.1  christos 
    165  1.1  christos     /* All assignment-type operations */
    166  1.1  christos 
    167  1.1  christos     : SuperName PARSEOP_EXP_EQUALS
    168  1.1  christos         TermArg                         {$$ = TrCreateAssignmentNode ($1, $3);}
    169  1.1  christos 
    170  1.1  christos     | TermArg PARSEOP_EXP_ADD_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);}
    171  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    172  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    173  1.1  christos 
    174  1.1  christos     | TermArg PARSEOP_EXP_DIV_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);}
    175  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,4,$1,$4,TrCreateNullTarget (),
    176  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    177  1.1  christos 
    178  1.1  christos     | TermArg PARSEOP_EXP_MOD_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);}
    179  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    180  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    181  1.1  christos 
    182  1.1  christos     | TermArg PARSEOP_EXP_MUL_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);}
    183  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    184  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    185  1.1  christos 
    186  1.1  christos     | TermArg PARSEOP_EXP_SHL_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);}
    187  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    188  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    189  1.1  christos 
    190  1.1  christos     | TermArg PARSEOP_EXP_SHR_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);}
    191  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    192  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    193  1.1  christos 
    194  1.1  christos     | TermArg PARSEOP_EXP_SUB_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);}
    195  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    196  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    197  1.1  christos 
    198  1.1  christos     | TermArg PARSEOP_EXP_AND_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_AND);}
    199  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    200  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    201  1.1  christos 
    202  1.1  christos     | TermArg PARSEOP_EXP_OR_EQ         {$<n>$ = TrCreateLeafNode (PARSEOP_OR);}
    203  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    204  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    205  1.1  christos 
    206  1.1  christos     | TermArg PARSEOP_EXP_XOR_EQ        {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);}
    207  1.1  christos         TermArg                         {$$ = TrLinkChildren ($<n>3,3,$1,$4,
    208  1.1  christos                                             TrSetNodeFlags (TrCreateTargetOperand ($1, NULL), NODE_IS_TARGET));}
    209  1.1  christos     ;
    210