diff options
Diffstat (limited to 'source/compiler/aslcompiler.y')
| -rw-r--r-- | source/compiler/aslcompiler.y | 146 | 
1 files changed, 77 insertions, 69 deletions
diff --git a/source/compiler/aslcompiler.y b/source/compiler/aslcompiler.y index 7df36a841e95..92ae9409cfff 100644 --- a/source/compiler/aslcompiler.y +++ b/source/compiler/aslcompiler.y @@ -560,7 +560,7 @@ void *                      AslLocalAllocate (unsigned int Size);  %type <n> SwitchTerm  %type <n> UnloadTerm  %type <n> WhileTerm -//%type <n> CaseTermList +/* %type <n> CaseTermList */  /* Type 2 opcodes */ @@ -2507,30 +2507,38 @@ ConstExprTerm      | PARSEOP___PATH__              {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);}      ; +/* + * The NODE_COMPILE_TIME_CONST flag in the following constant expressions + * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes + * to simple integers. It is an error if these types of expressions cannot be + * reduced, since the AML grammar for ****ConstExpr requires a simple constant. + * Note: The required byte length of the constant is passed through to the + * constant folding code in the node AmlLength field. + */  ByteConstExpr -    : Type3Opcode                   {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} -    | Type2IntegerOpcode            {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);} +    : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);} +    | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);}      | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}      | ByteConst                     {}      ;  WordConstExpr -    : Type3Opcode                   {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} -    | Type2IntegerOpcode            {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);} +    : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);} +    | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);}      | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}      | WordConst                     {}      ;  DWordConstExpr -    : Type3Opcode                   {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} -    | Type2IntegerOpcode            {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);} +    : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);} +    | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);}      | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}      | DWordConst                    {}      ;  QWordConstExpr -    : Type3Opcode                   {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} -    | Type2IntegerOpcode            {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);} +    : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);} +    | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);}      | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}      | QWordConst                    {}      ; @@ -2839,10 +2847,10 @@ ExtendedSpaceTerm  FixedDmaTerm      : PARSEOP_FIXEDDMA '('          {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);} -        WordConstExpr               // 04: DMA RequestLines -        ',' WordConstExpr           // 06: DMA Channels -        OptionalXferSize            // 07: DMA TransferSize -        OptionalNameString          // 08: DescriptorName +        WordConstExpr               /* 04: DMA RequestLines */ +        ',' WordConstExpr           /* 06: DMA Channels */ +        OptionalXferSize            /* 07: DMA TransferSize */ +        OptionalNameString          /* 08: DescriptorName */          ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$6,$7,$8);}      | PARSEOP_FIXEDDMA '('          error ')'                   {$$ = AslDoError(); yyclearin;} @@ -2860,16 +2868,16 @@ FixedIOTerm  GpioIntTerm      : PARSEOP_GPIO_INT '('          {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_INT);} -        InterruptTypeKeyword        // 04: InterruptType -        ',' InterruptLevel          // 06: InterruptLevel -        OptionalShareType           // 07: SharedType -        ',' PinConfigByte           // 09: PinConfig -        OptionalWordConstExpr       // 10: DebounceTimeout -        ',' StringData              // 12: ResourceSource -        OptionalByteConstExpr       // 13: ResourceSourceIndex -        OptionalResourceType        // 14: ResourceType -        OptionalNameString          // 15: DescriptorName -        OptionalBuffer_Last         // 16: VendorData +        InterruptTypeKeyword        /* 04: InterruptType */ +        ',' InterruptLevel          /* 06: InterruptLevel */ +        OptionalShareType           /* 07: SharedType */ +        ',' PinConfigByte           /* 09: PinConfig */ +        OptionalWordConstExpr       /* 10: DebounceTimeout */ +        ',' StringData              /* 12: ResourceSource */ +        OptionalByteConstExpr       /* 13: ResourceSourceIndex */ +        OptionalResourceType        /* 14: ResourceType */ +        OptionalNameString          /* 15: DescriptorName */ +        OptionalBuffer_Last         /* 16: VendorData */          ')' '{'              DWordConstExpr '}'      {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);}      | PARSEOP_GPIO_INT '(' @@ -2878,16 +2886,16 @@ GpioIntTerm  GpioIoTerm      : PARSEOP_GPIO_IO '('           {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_IO);} -        OptionalShareType_First     // 04: SharedType -        ',' PinConfigByte           // 06: PinConfig -        OptionalWordConstExpr       // 07: DebounceTimeout -        OptionalWordConstExpr       // 08: DriveStrength -        OptionalIoRestriction       // 09: IoRestriction -        ',' StringData              // 11: ResourceSource -        OptionalByteConstExpr       // 12: ResourceSourceIndex -        OptionalResourceType        // 13: ResourceType -        OptionalNameString          // 14: DescriptorName -        OptionalBuffer_Last         // 15: VendorData +        OptionalShareType_First     /* 04: SharedType */ +        ',' PinConfigByte           /* 06: PinConfig */ +        OptionalWordConstExpr       /* 07: DebounceTimeout */ +        OptionalWordConstExpr       /* 08: DriveStrength */ +        OptionalIoRestriction       /* 09: IoRestriction */ +        ',' StringData              /* 11: ResourceSource */ +        OptionalByteConstExpr       /* 12: ResourceSourceIndex */ +        OptionalResourceType        /* 13: ResourceType */ +        OptionalNameString          /* 14: DescriptorName */ +        OptionalBuffer_Last         /* 15: VendorData */          ')' '{'              DWordList '}'           {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);}      | PARSEOP_GPIO_IO '(' @@ -2896,15 +2904,15 @@ GpioIoTerm  I2cSerialBusTerm      : PARSEOP_I2C_SERIALBUS '('     {$<n>$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);} -        WordConstExpr               // 04: SlaveAddress -        OptionalSlaveMode           // 05: SlaveMode -        ',' DWordConstExpr          // 07: ConnectionSpeed -        OptionalAddressingMode      // 08: AddressingMode -        ',' StringData              // 10: ResourceSource -        OptionalByteConstExpr       // 11: ResourceSourceIndex -        OptionalResourceType        // 12: ResourceType -        OptionalNameString          // 13: DescriptorName -        OptionalBuffer_Last         // 14: VendorData +        WordConstExpr               /* 04: SlaveAddress */ +        OptionalSlaveMode           /* 05: SlaveMode */ +        ',' DWordConstExpr          /* 07: ConnectionSpeed */ +        OptionalAddressingMode      /* 08: AddressingMode */ +        ',' StringData              /* 10: ResourceSource */ +        OptionalByteConstExpr       /* 11: ResourceSourceIndex */ +        OptionalResourceType        /* 12: ResourceType */ +        OptionalNameString          /* 13: DescriptorName */ +        OptionalBuffer_Last         /* 14: VendorData */          ')'                         {$$ = TrLinkChildren ($<n>3,9,$4,$5,$7,$8,$10,$11,$12,$13,$14);}      | PARSEOP_I2C_SERIALBUS '('          error ')'                   {$$ = AslDoError(); yyclearin;} @@ -3077,19 +3085,19 @@ RegisterTerm  SpiSerialBusTerm      : PARSEOP_SPI_SERIALBUS '('     {$<n>$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);} -        WordConstExpr               // 04: DeviceSelection -        OptionalDevicePolarity      // 05: DevicePolarity -        OptionalWireMode            // 06: WireMode -        ',' ByteConstExpr           // 08: DataBitLength -        OptionalSlaveMode           // 09: SlaveMode -        ',' DWordConstExpr          // 11: ConnectionSpeed -        ',' ClockPolarityKeyword    // 13: ClockPolarity -        ',' ClockPhaseKeyword       // 15: ClockPhase -        ',' StringData              // 17: ResourceSource -        OptionalByteConstExpr       // 18: ResourceSourceIndex -        OptionalResourceType        // 19: ResourceType -        OptionalNameString          // 20: DescriptorName -        OptionalBuffer_Last         // 21: VendorData +        WordConstExpr               /* 04: DeviceSelection */ +        OptionalDevicePolarity      /* 05: DevicePolarity */ +        OptionalWireMode            /* 06: WireMode */ +        ',' ByteConstExpr           /* 08: DataBitLength */ +        OptionalSlaveMode           /* 09: SlaveMode */ +        ',' DWordConstExpr          /* 11: ConnectionSpeed */ +        ',' ClockPolarityKeyword    /* 13: ClockPolarity */ +        ',' ClockPhaseKeyword       /* 15: ClockPhase */ +        ',' StringData              /* 17: ResourceSource */ +        OptionalByteConstExpr       /* 18: ResourceSourceIndex */ +        OptionalResourceType        /* 19: ResourceType */ +        OptionalNameString          /* 20: DescriptorName */ +        OptionalBuffer_Last         /* 21: VendorData */          ')'                         {$$ = TrLinkChildren ($<n>3,13,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20,$21);}      | PARSEOP_SPI_SERIALBUS '('          error ')'                   {$$ = AslDoError(); yyclearin;} @@ -3115,20 +3123,20 @@ StartDependentFnTerm  UartSerialBusTerm      : PARSEOP_UART_SERIALBUS '('    {$<n>$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);} -        DWordConstExpr              // 04: ConnectionSpeed -        OptionalBitsPerByte         // 05: BitsPerByte -        OptionalStopBits            // 06: StopBits -        ',' ByteConstExpr           // 08: LinesInUse -        OptionalEndian              // 09: Endianess -        OptionalParityType          // 10: Parity -        OptionalFlowControl         // 11: FlowControl -        ',' WordConstExpr           // 13: Rx BufferSize -        ',' WordConstExpr           // 15: Tx BufferSize -        ',' StringData              // 17: ResourceSource -        OptionalByteConstExpr       // 18: ResourceSourceIndex -        OptionalResourceType        // 19: ResourceType -        OptionalNameString          // 20: DescriptorName -        OptionalBuffer_Last         // 21: VendorData +        DWordConstExpr              /* 04: ConnectionSpeed */ +        OptionalBitsPerByte         /* 05: BitsPerByte */ +        OptionalStopBits            /* 06: StopBits */ +        ',' ByteConstExpr           /* 08: LinesInUse */ +        OptionalEndian              /* 09: Endianess */ +        OptionalParityType          /* 10: Parity */ +        OptionalFlowControl         /* 11: FlowControl */ +        ',' WordConstExpr           /* 13: Rx BufferSize */ +        ',' WordConstExpr           /* 15: Tx BufferSize */ +        ',' StringData              /* 17: ResourceSource */ +        OptionalByteConstExpr       /* 18: ResourceSourceIndex */ +        OptionalResourceType        /* 19: ResourceType */ +        OptionalNameString          /* 20: DescriptorName */ +        OptionalBuffer_Last         /* 21: VendorData */          ')'                         {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20,$21);}      | PARSEOP_UART_SERIALBUS '('          error ')'                   {$$ = AslDoError(); yyclearin;}  | 
