395 lines
13 KiB
Plaintext
395 lines
13 KiB
Plaintext
%top
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
*
|
|
* The contents of this file are subject to the Netscape Public
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.mozilla.org/NPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
* implied. See the License for the specific language governing
|
|
* rights and limitations under the License.
|
|
*
|
|
* The Original Code is mozilla.org code.
|
|
*
|
|
* The Initial Developer of the Original Code is Netscape
|
|
* Communications Corporation. Portions created by Netscape are
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
*/
|
|
#include "Burg.h"
|
|
%
|
|
|
|
%terminals
|
|
%
|
|
|
|
%startsymbols
|
|
Control
|
|
Result
|
|
Exception
|
|
Store
|
|
Vcond
|
|
Vint
|
|
Vlong
|
|
Vfloat
|
|
Vdouble
|
|
Vptr
|
|
Cint
|
|
Clong
|
|
Cfloat
|
|
Cdouble
|
|
Cptr
|
|
Tuple
|
|
%
|
|
|
|
%grammar
|
|
Vint: coReg_I $1 $
|
|
Vlong: coReg_L $1 $
|
|
Vfloat: coReg_F $1 $
|
|
Vdouble: coReg_D $1 $
|
|
Vptr: coReg_A $1 $
|
|
Vcond: coReg_C $1 $
|
|
Store: coReg_M $1 $
|
|
Cint: coReg_I $1 $
|
|
Clong: coReg_L $1 $
|
|
Cfloat: coReg_F $1 $
|
|
Cdouble: coReg_D $1 $
|
|
Cptr: coReg_A $1 $
|
|
|
|
Vint: poConst_I $1 $emConst_I
|
|
Vlong: poConst_L $1 $emConst_L
|
|
Vptr: poConst_A $1 $emConst_A
|
|
|
|
Vfloat: poConst_F $1 $emConst_F
|
|
Vdouble: poConst_D $1 $emConst_D
|
|
// Vcond: poConst_C $1 $emConst_C
|
|
|
|
//-----------------------------------------------------------------
|
|
// Addressing Mode Helpers
|
|
Scale: poShl_I(Vint, poConst_I) $0
|
|
ScaleIndex: poAdd_A(Vptr, Scale) $0
|
|
//ScaleIndex: Vptr $0
|
|
DispScaleIndex: poAdd_A(ScaleIndex, poConst_I) $0
|
|
MemDSI: poLd_I(DispScaleIndex) $0
|
|
|
|
Disp: poAdd_A(Vptr, poConst_I) $0
|
|
MemDisp: poLd_I(Disp) $0
|
|
|
|
//-----------------------------------------------------------------
|
|
Store: poBreak(Store) $1 $emBreak
|
|
|
|
Vint: poArg_I $1 $
|
|
Vlong: poArg_L $1 $
|
|
Vfloat: poArg_F $1 $
|
|
Vdouble: poArg_D $1 $
|
|
Vptr: poArg_A $1 $
|
|
Store: poArg_M $1 $
|
|
|
|
Result: poResult_I(Vint) $1 $emResult_I
|
|
Result: poResult_A(Vptr) $1 $emResult_A
|
|
Result: poResult_L(Vlong) $1 $emResult_L
|
|
|
|
Result: poResult_F(Vfloat) $1 $emResult_F
|
|
Result: poResult_D(Vdouble) $1 $emResult_D
|
|
// Result: poResult_C(Acond) $1 $emResult_C
|
|
Result: poResult_M(Store) $1 $
|
|
|
|
|
|
//-----------------------------------------------------------------
|
|
// Conditional Branches
|
|
Control: poIfLt(Vcond) $1 $emIfLt
|
|
Control: poIfEq(Vcond) $1 $emIfEq
|
|
Control: poIfLe(Vcond) $1 $emIfLe
|
|
Control: poIfGt(Vcond) $1 $emIfGt
|
|
Control: poIfLgt(Vcond) $1 $emIfLgt
|
|
Control: poIfGe(Vcond) $1 $emIfGe
|
|
|
|
Control: poIfULt(Vcond) $1 $emIfULt
|
|
Control: poIfUEq(Vcond) $1 $emIfUEq
|
|
Control: poIfULe(Vcond) $1 $emIfULe
|
|
Control: poIfUGt(Vcond) $1 $emIfUGt
|
|
Control: poIfNe(Vcond) $1 $emIfNe
|
|
Control: poIfUGe(Vcond) $1 $emIfUGe
|
|
|
|
//-----------------------------------------------------------------
|
|
// Booleans
|
|
Vint: poLt_I(Vcond) $1 $emLt_I
|
|
Vint: poEq_I(Vcond) $1 $emEq_I
|
|
Vint: poLe_I(Vcond) $1 $emLe_I
|
|
Vint: poGt_I(Vcond) $1 $emGt_I
|
|
Vint: poLgt_I(Vcond) $1 $emLgt_I
|
|
Vint: poGe_I(Vcond) $1 $emGe_I
|
|
|
|
Vint: poULt_I(Vcond) $1 $emULt_I
|
|
Vint: poUEq_I(Vcond) $1 $emUEq_I
|
|
Vint: poULe_I(Vcond) $1 $emULe_I
|
|
Vint: poUGt_I(Vcond) $1 $emUGt_I
|
|
Vint: poNe_I(Vcond) $1 $emNe_I
|
|
Vint: poUGe_I(Vcond) $1 $emUGe_I
|
|
|
|
//-----------------------------------------------------------------
|
|
// switch
|
|
Control: poSwitch(Vint) $1 $emSwitch
|
|
|
|
//-----------------------------------------------------------------
|
|
// And
|
|
Vint: poAnd_I(Vint, Vint) $1 $emAnd_I
|
|
Vint: poAnd_I(Vint, poConst_I) $1 $emAndI_I
|
|
Vlong: poAnd_L(Vlong, Vlong) $1 $emAnd_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Or
|
|
Vint: poOr_I(Vint, Vint) $1 $emOr_I
|
|
Vint: poOr_I(Vint, poConst_I) $1 $emOrI_I
|
|
Vlong: poOr_L(Vlong, Vlong) $1 $emOr_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Xor
|
|
Vint: poXor_I(Vint, Vint) $1 $emXor_I
|
|
Vint: poXor_I(Vint, poConst_I) $1 $emXorI_I
|
|
Vlong: poXor_L(Vlong, Vlong) $1 $emXor_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Add
|
|
Vint: poAdd_I(Vint, Vint) $1 $emAdd_I
|
|
Vptr: poAdd_A(Vptr, Vint) $1 $emAdd_A
|
|
Vint: poAdd_I(Vint, poConst_I) $1 $emAddI_I
|
|
Vptr: poAdd_A(Vptr, poConst_I) $1 $emAddI_A
|
|
Vlong: poAdd_L(Vlong, Vlong) $1 $emAdd_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Sub
|
|
Vint: poSub_I(poConst_I, Vint) $1 $emSubR_I
|
|
Vint: poSub_I(Vint, Vint) $1 $emSub_I
|
|
Vptr: poSub_A(Vptr, Vint) $1 $emSub_A
|
|
Vlong: poSub_L(Vlong, Vlong) $1 $emSub_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Mul
|
|
Vint: poMul_I(Vint, Vint) $1 $emMul_I
|
|
Vlong: poMul_L(Vlong, Vlong) $1 $emMul_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Div
|
|
Vint: poDiv_I(Vint, Vint) $1 $emDiv_I
|
|
Vint: poDivE_I(Vint, Vint) $1 $emDivE_I
|
|
|
|
Vint: poDivU_I(Vint, Vint) $1 $emDivU_I
|
|
Vint: poDivUE_I(Vint, Vint) $1 $emDivUE_I
|
|
|
|
Vint: poDiv_I(Vint, MemDSI) $1 $emDiv_I_MemDSI
|
|
Vint: poDivE_I(Vint, MemDSI) $1 $emDivE_I_MemDSI
|
|
Vint: poDiv_I(Vint, MemDSI) $1 $emDivU_I_MemDSI
|
|
Vint: poDivE_I(Vint, MemDSI) $1 $emDivUE_I_MemDSI
|
|
|
|
Vlong: poDiv_L(Vlong, Vlong) $1 $emDiv_L
|
|
Vlong: poDivE_L(Vlong, Vlong) $1 $emDivE_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Mod
|
|
Vint: poMod_I(Vint, Vint) $1 $emMod_I
|
|
Vint: poModE_I(Vint, Vint) $1 $emModE_I
|
|
|
|
Vint: poModU_I(Vint, Vint) $1 $emModU_I
|
|
Vint: poModUE_I(Vint, Vint) $1 $emModUE_I
|
|
|
|
Vint: poMod_I(Vint, MemDSI) $1 $emMod_I_MemDSI
|
|
Vint: poModE_I(Vint, MemDSI) $1 $emModE_I_MemDSI
|
|
Vint: poMod_I(Vint, MemDSI) $1 $emModU_I_MemDSI
|
|
Vint: poModE_I(Vint, MemDSI) $1 $emModUE_I_MemDSI
|
|
|
|
Vlong: poMod_L(Vlong, Vlong) $1 $emMod_L
|
|
Vlong: poModE_L(Vlong, Vlong) $1 $emModE_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Shl
|
|
Vint: poShl_I(Vint, Vint) $1 $emShl_I
|
|
Vint: poShl_I(Vint, poConst_I) $1 $emShlI_I
|
|
Vlong: poShl_L(Vlong, Vint) $1 $emShl_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Shr
|
|
Vint: poShr_I(Vint, Vint) $1 $emShr_I
|
|
Vint: poShr_I(Vint, poConst_I) $1 $emShrI_I
|
|
Vlong: poShr_L(Vlong, Vint) $1 $emShr_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Shru
|
|
Vint: poShrU_I(Vint, Vint) $1 $emShrU_I
|
|
Vint: poShrU_I(Vint, poConst_I) $1 $emShrUI_I
|
|
Vlong: poShrU_L(Vlong, Vint) $1 $emShrU_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// sign extend
|
|
Vint: poExt_I(Vint, poConst_I) $1 $emExt_I
|
|
Vlong: poExt_L(Vlong, poConst_I) $1 $emExt_L
|
|
|
|
//-----------------------------------------------------------------
|
|
// Floating Point
|
|
|
|
Vfloat: poFAdd_F(Vfloat, Vfloat) $1 $emFAdd_F
|
|
Vdouble: poFAdd_D(Vdouble, Vdouble) $1 $emFAdd_D
|
|
|
|
Vfloat: poFSub_F(Vfloat, Vfloat) $1 $emFSub_F
|
|
Vdouble: poFSub_D(Vdouble, Vdouble) $1 $emFSub_D
|
|
|
|
Vfloat: poFMul_F(Vfloat, Vfloat) $1 $emFMul_F
|
|
Vdouble: poFMul_D(Vdouble, Vdouble) $1 $emFMul_D
|
|
|
|
Vfloat: poFDiv_F(Vfloat, Vfloat) $1 $emFDiv_F
|
|
Vdouble: poFDiv_D(Vdouble, Vdouble) $1 $emFDiv_D
|
|
|
|
Vfloat: poFRem_F(Vfloat, Vfloat) $1 $emFRem_F
|
|
Vdouble: poFRem_D(Vdouble, Vdouble) $1 $emFRem_D
|
|
|
|
//-----------------------------------------------------------------
|
|
// Convert
|
|
Vint: poConvI_L(Vlong) $1 $emConvI_L
|
|
Vlong: poConvL_I(Vint) $1 $emConvL_I
|
|
|
|
Vint: poFConvI_F(Vfloat) $1 $emFConvI_F
|
|
Vint: poFConvI_D(Vdouble) $1 $emFConvI_D
|
|
Vlong: poFConvL_F(Vfloat) $1 $emFConvL_F
|
|
Vlong: poFConvL_D(Vdouble) $1 $emFConvL_D
|
|
Vfloat: poFConvF_I(Vint) $1 $emFConvF_I
|
|
Vfloat: poFConvF_L(Vlong) $1 $emFConvF_L
|
|
Vfloat: poFConvF_D(Vdouble) $1 $emFConvF_D
|
|
Vdouble: poFConvD_I(Vint) $1 $emFConvD_I
|
|
Vdouble: poFConvD_L(Vlong) $1 $emFConvD_L
|
|
Vdouble: poFConvD_F(Vfloat) $1 $emFConvD_F
|
|
|
|
//-----------------------------------------------------------------
|
|
// Compare
|
|
Vcond: poCmp_I(Vint, Vint) $1 $emCmp_I
|
|
Vcond: poCmpU_I(Vint, Vint) $1 $emCmpU_I
|
|
Vcond: poCmpU_A(Vptr, Vptr) $1 $emCmpU_A
|
|
|
|
Vcond: poCmp_I(Vint, poConst_I) $1 $emCmpI_I
|
|
Vcond: poCmpU_I(Vint, poConst_I) $1 $emCmpUI_I
|
|
|
|
Vint: poCatL_I(poCmp_L(Vlong, Vlong)) $1 $em3wayCmpL_L
|
|
Vint: poCatCL_I(poCmp_L(Vlong, Vlong)) $1 $em3wayCmpCL_L
|
|
|
|
Vint: poCatL_I(poFCmp_F(Vfloat, Vfloat)) $1 $em3wayCmpF_L
|
|
Vint: poCatG_I(poFCmp_F(Vfloat, Vfloat)) $1 $em3wayCmpF_G
|
|
Vint: poCatL_I(poFCmp_D(Vdouble, Vdouble)) $1 $em3wayCmpD_L
|
|
Vint: poCatG_I(poFCmp_D(Vdouble, Vdouble)) $1 $em3wayCmpD_G
|
|
|
|
Vint: poCatCL_I(poFCmp_F(Vfloat, Vfloat)) $1 $em3wayCmpCF_L
|
|
Vint: poCatCG_I(poFCmp_F(Vfloat, Vfloat)) $1 $em3wayCmpCF_G
|
|
Vint: poCatCL_I(poFCmp_D(Vdouble, Vdouble)) $1 $em3wayCmpCD_L
|
|
Vint: poCatCG_I(poFCmp_D(Vdouble, Vdouble)) $1 $em3wayCmpCD_G
|
|
|
|
Vcond: poCmp_I(MemDSI, poConst_I) $1 $emCmpI_I_MemDSI
|
|
Vcond: poCmp_I(MemDSI, Vint) $1 $emCmp_I_MemDSI
|
|
|
|
//-----------------------------------------------------------------
|
|
// CheckNull
|
|
Exception: poChkNull(Vptr) $1 $emChkNull
|
|
|
|
//-----------------------------------------------------------------
|
|
// Limit
|
|
Exception: poLimit(Vint, Vint) $1 $emLimit
|
|
Exception: poLimit(poConst_I, Vint) $1 $emLimitR
|
|
Exception: poLimit(poConst_I, MemDisp) $1 $emLimitR_MemDisp
|
|
Exception: poLimit(Vint, MemDisp) $1 $emLimit_MemDisp
|
|
|
|
//-----------------------------------------------------------------
|
|
// Check/Limit Cast
|
|
Exception: poChkCast_A(Vptr, poConst_A) $1 $emChkCastI_A
|
|
Exception: poChkCast_A(Vptr, Vptr) $1 $emChkCast_A
|
|
|
|
Exception: poChkCast_I(Vint, Vint) $1 $emChkCast_I
|
|
|
|
Exception: poLimCast(Vint) $1 $emLimCast
|
|
|
|
//-----------------------------------------------------------------
|
|
// Load
|
|
Vint: poLd_I(Vptr) $1 $emLd_I
|
|
Vptr: poLd_A(Vptr) $1 $emLd_A
|
|
Vlong: poLd_L(Vptr) $1 $emLd_L
|
|
Vfloat: poLd_F(Vptr) $1 $emLd_F
|
|
Vdouble: poLd_D(Vptr) $1 $emLd_D
|
|
|
|
Vint: poLdS_B(Vptr) $1 $emLdS_B
|
|
Vint: poLdU_B(Vptr) $1 $emLdU_B
|
|
|
|
Vint: poLdS_H(Vptr) $1 $emLdS_H
|
|
Vint: poLdU_H(Vptr) $1 $emLdU_H
|
|
|
|
Vint: MemDisp $1 $emLd_I_MemDisp
|
|
Vint: MemDSI $1 $emLd_I_MemDSI
|
|
|
|
// FIXME - Add these patterns for performance
|
|
// Vfloat: poLd_F(Disp) $1 $emLd_F_MemDisp
|
|
// Vfloat: poLd_F(DispScaleIndex) $1 $emLd_F_MemDSI
|
|
// Vdouble: poLd_D(Disp) $1 $emLd_D_MemDisp
|
|
// Vdouble: poLd_D(DispScaleIndex) $1 $emLd_D_MemDSI
|
|
|
|
//-----------------------------------------------------------------
|
|
// Store
|
|
Store: poSt_I(Vptr, Vint) $1 $emSt_I
|
|
Store: poSt_I(Vptr, poConst_I) $1 $emStI_I
|
|
Store: poSt_A(Vptr, Vptr) $1 $emSt_A
|
|
Store: poSt_L(Vptr, Vlong) $1 $emSt_L
|
|
|
|
Store: poSt_B(Vptr, Vint) $1 $emSt_B
|
|
Store: poSt_H(Vptr, Vint) $1 $emSt_H
|
|
|
|
Store: poSt_I(Disp, poConst_I) $1 $emStI_I_MemDisp
|
|
Store: poSt_I(Disp, Vint) $1 $emSt_I_MemDisp
|
|
Store: poSt_I(DispScaleIndex, Vint) $1 $emSt_I_MemDSI
|
|
|
|
Store: poSt_F(Vptr, Vfloat) $1 $emSt_F
|
|
Store: poSt_D(Vptr, Vdouble) $1 $emSt_D
|
|
|
|
// FIXME - Add below patterns for performance
|
|
//Store: poSt_F(Disp, poConst_I) $1 $emStI_F_MemDisp
|
|
//Store: poSt_F(Disp, Vint) $1 $emSt_F_MemDisp
|
|
//Store: poSt_F(DispScaleIndex, Vint) $1 $emSt_F_MemDSI
|
|
|
|
//Store: poSt_D(Disp, poConst_I) $1 $emStI_D_MemDisp
|
|
//Store: poSt_D(Disp, Vint) $1 $emSt_D_MemDisp
|
|
//Store: poSt_D(DispScaleIndex, Vint) $1 $emSt_D_MemDSI
|
|
|
|
//-----------------------------------------------------------------
|
|
// Monitor
|
|
//Store: poMEnter_A(Vptr) $1 $emMEnter_A
|
|
//Store: poMExit_A(Vptr) $1 $emMExit_A
|
|
|
|
//-----------------------------------------------------------------
|
|
// Monitor
|
|
Store: poMEnter(Store, Vptr) $1 $emMEnter
|
|
Store: poMExit(Store, Vptr) $1 $emMExit
|
|
|
|
//-----------------------------------------------------------------
|
|
// Projections
|
|
Store: poProj_M $1 $
|
|
Vint: poProj_I $1 $
|
|
Vptr: poProj_A $1 $
|
|
Vlong: poProj_L $1 $
|
|
Vfloat: poProj_F $1 $
|
|
Vdouble: poProj_D $1 $
|
|
|
|
//-----------------------------------------------------------------
|
|
// Syscalls
|
|
Tuple: poSysCall $1 $emSysCall
|
|
Tuple: poSysCallE $1 $emSysCallE
|
|
Tuple: poSysCallC $1 $emSysCallC
|
|
Tuple: poSysCallEC $1 $emSysCallEC
|
|
Tuple: poSysCallV $1 $emSysCallV
|
|
Tuple: poSysCallEV $1 $emSysCallEV
|
|
|
|
//-----------------------------------------------------------------
|
|
// Calls
|
|
Tuple: poCall(Vptr) $1 $emDynamicCall
|
|
Tuple: poCall(poConst_A) $1 $emStaticCall
|
|
|
|
//-----------------------------------------------------------------
|
|
// Catch
|
|
Vptr: poCatch $1 $emCatch
|
|
%
|