r=db48x sr=blake a=asa git-svn-id: svn://10.0.0.236/trunk@116832 18797224-902f-48f8-a5cc-f745e15eee43
411 lines
12 KiB
Plaintext
411 lines
12 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):
|
|
*/
|
|
%
|
|
|
|
Vptr <- Vint()
|
|
Vint <- Vptr()
|
|
|
|
Vint <- poConst_I() cost(1)
|
|
%{
|
|
genPrimConst_32(thisPrimitive);
|
|
%}
|
|
|
|
Vptr <- poConst_A() cost(1)
|
|
%{
|
|
genPrimConst_32(thisPrimitive);
|
|
%}
|
|
|
|
Vfloat <- poConst_F() cost(1)
|
|
%{
|
|
Flt32 constant = (*static_cast<const PrimConst *>(&thisPrimitive)).value.f;
|
|
|
|
Uint16 offset;
|
|
mAccumulatorTOC.addData(&constant, sizeof(constant), offset);
|
|
|
|
Instruction& ldConstant = *new(mPool) LdD_RTOC(&thisPrimitive, mPool, dfLfs, offset);
|
|
defineProducer(thisPrimitive, ldConstant, 0, vrcFloatingPoint);
|
|
%}
|
|
|
|
Result <- poResult_I(Vint inResult) cost(1)
|
|
%{
|
|
genPrimResult_32(thisPrimitive, inResult);
|
|
%}
|
|
|
|
Result <- poResult_A(Vptr inResult) cost(1)
|
|
%{
|
|
genPrimResult_32(thisPrimitive, inResult);
|
|
%}
|
|
|
|
Result <- poResult_F(Vfloat inResult) cost(1)
|
|
%{
|
|
VirtualRegister* returnVr;
|
|
|
|
// generate: fmr fp0, fpResultRegister
|
|
|
|
// create a buffer copy instruction between the result
|
|
// and the precolored register
|
|
XInBOnly& copyInsn = *new(mPool) XInBOnly(&thisPrimitive, mPool, xfFmr, pfNil);
|
|
|
|
useProducer(inResult, copyInsn, 0, vrcFloatingPoint);
|
|
returnVr = &defineTemporary(copyInsn, 0, vrcFloatingPoint);
|
|
|
|
// floating point results go somewhere FIX-ME
|
|
returnVr->preColorRegister(1);
|
|
|
|
// create a special instruction for the RegisterAllocator which says this result
|
|
// is used elsewhere (but not in this body of code).
|
|
InsnExternalUse& externalUse = *new(mPool) InsnExternalUse(&thisPrimitive, mPool, 1);
|
|
useTemporaryVR(externalUse, *returnVr, 0, vrcFloatingPoint);
|
|
thisPrimitive.setInstructionRoot(&externalUse);
|
|
%}
|
|
|
|
#define IF_CONTROL(inPrimOp, inCondition) \
|
|
Control <- inPrimOp(Vcond) cost(1) \
|
|
%{ \
|
|
genBranch(thisPrimitive, inCondition); \
|
|
%}
|
|
|
|
IF_CONTROL(poIfLt, condLt)
|
|
IF_CONTROL(poIfNe, condNe)
|
|
IF_CONTROL(poIfEq, condEq)
|
|
IF_CONTROL(poIfLe, condLe)
|
|
IF_CONTROL(poIfGt, condGt)
|
|
IF_CONTROL(poIfLgt, condLgt)
|
|
IF_CONTROL(poIfGe, condGe)
|
|
|
|
Vint <- poAnd_I(Vint inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfAnd, inA, inB);
|
|
%}
|
|
|
|
Vint <- poOr_I(Vint inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfOr, inA, inB);
|
|
%}
|
|
|
|
Vint <- poXor_I(Vint inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfXor, inA, inB);
|
|
%}
|
|
|
|
Vint <- poAnd_I(Vint inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfAnd, inA, inB);
|
|
%}
|
|
|
|
Vint <- poAdd_I(Vint inA, coConstS16 inConstant) cost(1)
|
|
%{
|
|
genArithD_32(thisPrimitive, dfAddi, inA, PrimConst::cast(inConstant).value.i);
|
|
%}
|
|
|
|
Vint <- poAdd_I(coConstS16 inConstant, Vint inB) cost(1)
|
|
%{
|
|
genArithD_32(thisPrimitive, dfAddi, inB, PrimConst::cast(inConstant).value.i);
|
|
%}
|
|
|
|
Vint <- poAdd_I(Vptr inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfAdd, inA, inB);
|
|
%}
|
|
|
|
Vptr <- poAddU_A(Vptr inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfAdd, inA, inB);
|
|
%}
|
|
|
|
Vptr <- poAdd_A(Vptr inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfAdd, inA, inB);
|
|
%}
|
|
|
|
Vint <- poSub_I(Vptr inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfSubf, inB, inA);
|
|
%}
|
|
|
|
|
|
Vptr <- poSub_A(Vptr inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfSubf, inB, inA);
|
|
%}
|
|
|
|
Vint <- poMul_I(Vint inA, Vint inB) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfMullw, inA, inB);
|
|
%}
|
|
|
|
Vint <- poDiv_I(Vint inDividend, Vint inDivisor) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfDivw, inDividend, inDivisor);
|
|
%}
|
|
|
|
Vint <- poDivE_I(Vint inDividend, Vint inDivisor) cost(1)
|
|
%{
|
|
// FIX-ME must handle divide by zero system exception
|
|
genArithX_32(thisPrimitive, xfDivw, inDividend, inDivisor);
|
|
%}
|
|
|
|
Vint <- poDivU_I(Vint inDividend, Vint inDivisor) cost(1)
|
|
%{
|
|
genArithX_32(thisPrimitive, xfDivwu, inDividend, inDivisor);
|
|
%}
|
|
|
|
Vint <- poDivUE_I(Vint inDividend, Vint inDivisor) cost(1)
|
|
%{
|
|
// FIX-ME must handle divide by zero system exception
|
|
genArithX_32(thisPrimitive, xfDivwu, inDividend, inDivisor);
|
|
%}
|
|
|
|
|
|
Vint <- poMod_I(Vint inDividend, Vint inDivisor) cost(1)
|
|
%{
|
|
genMod(thisPrimitive, xfDivw, inDividend, inDivisor);
|
|
%}
|
|
|
|
Vint <- poModE_I(Vint inDividend, Vint inDivisor) cost(1)
|
|
%{
|
|
// FIX-ME must handle divide by zero system exception
|
|
genMod(thisPrimitive, xfDivw, inDividend, inDivisor);
|
|
%}
|
|
|
|
|
|
Vint <- poModU_I(Vint inDividend, Vint inDivisor) cost(1)
|
|
%{
|
|
// FIX-ME must handle divide by zero system exception
|
|
genMod(thisPrimitive, xfDivwu, inDividend, inDivisor);
|
|
%}
|
|
|
|
Vint <- poShl_I(Vint inValue, Vint inShiftAmount) cost(1)
|
|
%{
|
|
XOutA& newInsn = *new(mPool) XOutA(&thisPrimitive, mPool, xfSlw, pfNil);
|
|
|
|
useProducer(inValue, newInsn, 0);
|
|
useProducer(inShiftAmount, newInsn, 1);
|
|
defineProducer(thisPrimitive, newInsn, 0);
|
|
%}
|
|
|
|
|
|
Vfloat <- poFAdd_F(Vfloat inA, Vfloat inB) cost(1)
|
|
%{
|
|
genArith_FP(thisPrimitive, afFadd, inA, inB);
|
|
%}
|
|
|
|
Vcond <- poCmp_I(Vint inA, Vint inB) cost(1)
|
|
%{
|
|
CmpIX& newInsn = *new(mPool) CmpIX(&thisPrimitive, mPool, xfCmp, 0);
|
|
|
|
useProducer(inA, newInsn, 0);
|
|
useProducer(inB, newInsn, 1);
|
|
defineProducer(thisPrimitive, newInsn, 0);
|
|
%}
|
|
|
|
Vcond <- poCmpU_I(Vint inA, Vint inB) cost(1)
|
|
%{
|
|
CmpIX& newInsn = *new(mPool) CmpIX(&thisPrimitive, mPool, xfCmpl, 0);
|
|
|
|
useProducer(inA, newInsn, 0);
|
|
useProducer(inB, newInsn, 1);
|
|
defineProducer(thisPrimitive, newInsn, 0);
|
|
%}
|
|
|
|
Exception <- poChkNull(Vptr inTestValue) cost(1)
|
|
%{
|
|
genThrowIfZero(thisPrimitive, inTestValue);
|
|
%}
|
|
|
|
|
|
Exception <- poLimit(Vint inIndex, Vint inBound) cost(1)
|
|
%{
|
|
TrapX& newInsn = *new(mPool) TrapX(&thisPrimitive, mPool, condGe, false, pfNil);
|
|
useProducer(inIndex, newInsn, 0);
|
|
useProducer(inBound, newInsn, 1);
|
|
thisPrimitive.setInstructionRoot(&newInsn);
|
|
%}
|
|
|
|
#define LD_FIXED(inPrimOp, inReturnType, inOpcode) \
|
|
inReturnType <- inPrimOp(Vptr[1] inAddress) cost(1) \
|
|
%{ \
|
|
genLd_Fixed(thisPrimitive, inOpcode, inAddress); \
|
|
%}
|
|
|
|
#define LDE_FIXED(inPrimOp, inReturnType, inOpcode) \
|
|
inReturnType <- inPrimOp(Vptr[1] inAddress) cost(1) \
|
|
%{ \
|
|
genThrowIfZero(thisPrimitive, inAddress); \
|
|
genLd_Fixed(thisPrimitive, inOpcode, inAddress); \
|
|
%}
|
|
|
|
#define LD_SEX(inPrimOp, inLdOpcode, inSexOpcode) \
|
|
Vint <- inPrimOp(Vptr[1] inAddress) cost(1) \
|
|
%{ \
|
|
genLd_Fixed(thisPrimitive, inLdOpcode, inAddress); \
|
|
\
|
|
XInAOnly &ext = *new(mPool) XInAOnly(&thisPrimitive, mPool, inSexOpcode, pfNil, 0); \
|
|
useProducer(thisPrimitive, ext, 0); \
|
|
defineProducer(thisPrimitive, ext, 0); \
|
|
%}
|
|
|
|
#define LDE_SEX(inPrimOp, inLdOpcode, inSexOpcode) \
|
|
Vint <- inPrimOp(Vptr[1] inAddress) cost(1) \
|
|
%{ \
|
|
genThrowIfZero(thisPrimitive, inAddress); \
|
|
genLd_Fixed(thisPrimitive, inLdOpcode, inAddress); \
|
|
\
|
|
XInAOnly &ext = *new(mPool) XInAOnly(&thisPrimitive, mPool, inSexOpcode, pfNil, 0); \
|
|
useProducer(thisPrimitive, ext, 0); \
|
|
defineProducer(thisPrimitive, ext, 0); \
|
|
%}
|
|
|
|
#define LD_FLOATING(inPrimOp, inReturnType, inOpcode) \
|
|
inReturnType <- inPrimOp(Vptr[1] inAddress) cost(1) \
|
|
%{ \
|
|
genLd_FP(thisPrimitive, inOpcode, inAddress); \
|
|
%}
|
|
|
|
|
|
#define LDE_FLOATING(inPrimOp, inReturnType, inOpcode) \
|
|
inReturnType <- inPrimOp(Vptr[1] inAddress) cost(1) \
|
|
%{ \
|
|
genThrowIfZero(thisPrimitive, inAddress); \
|
|
genLd_FP(thisPrimitive, inOpcode, inAddress); \
|
|
%}
|
|
|
|
|
|
LD_FIXED(poLd_I, Vint, dfLwz)
|
|
LD_FIXED(poLd_A, Vptr, dfLwz)
|
|
LD_FLOATING(poLd_F, Vfloat, dfLfs)
|
|
|
|
LDE_FIXED(poLdE_I, Vint, dfLwz)
|
|
LDE_FIXED(poLdE_A, Vptr, dfLwz)
|
|
LDE_FLOATING(poLdE_F, Vfloat, dfLfs)
|
|
|
|
LD_SEX(poLdS_B, dfLbz, xfExtsb)
|
|
LD_SEX(poLdS_H, dfLhz, xfExtsh)
|
|
LDE_SEX(poLdS_B, dfLbz, xfExtsb)
|
|
LDE_SEX(poLdS_H, dfLhz, xfExtsh)
|
|
|
|
LD_FIXED(poLdU_B, Vint, dfLbz)
|
|
LD_FIXED(poLdU_H, Vint, dfLhz)
|
|
LDE_FIXED(poLdUE_B, Vint, dfLbz)
|
|
LDE_FIXED(poLdUE_H, Vint, dfLhz)
|
|
|
|
|
|
Store <- poSt_B(Vptr[1] inAddress, Vint inValue) cost(1)
|
|
%{
|
|
genSt(thisPrimitive, dfStb, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poSt_H(Vptr[1] inAddress, Vint inValue) cost(1)
|
|
%{
|
|
genSt(thisPrimitive, dfSth, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poSt_I(Vptr[1] inAddress, Vint inValue) cost(1)
|
|
%{
|
|
genSt(thisPrimitive, dfStw, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poSt_F(Vptr[1] inAddress, Vfloat inValue) cost(1)
|
|
%{
|
|
genSt(thisPrimitive, dfStfs, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poSt_A(Vptr[1] inAddress, Vptr inValue) cost(1)
|
|
%{
|
|
genSt(thisPrimitive, dfStw, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poStE_B(Vptr[1] inAddress, Vint inValue) cost(1)
|
|
%{
|
|
genThrowIfZero(thisPrimitive, inAddress); // FIX-ME eliminate on AIX
|
|
genSt(thisPrimitive, dfStb, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poStE_H(Vptr[1] inAddress, Vint inValue) cost(1)
|
|
%{
|
|
genThrowIfZero(thisPrimitive, inAddress); // FIX-ME eliminate on AIX
|
|
genSt(thisPrimitive, dfSth, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poStE_I(Vptr[1] inAddress, Vint inValue) cost(1)
|
|
%{
|
|
genThrowIfZero(thisPrimitive, inAddress); // FIX-ME eliminate on AIX
|
|
genSt(thisPrimitive, dfStw, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poStE_F(Vptr[1] inAddress, Vfloat inValue) cost(1)
|
|
%{
|
|
genThrowIfZero(thisPrimitive, inAddress); // FIX-ME eliminate on AIX
|
|
genSt(thisPrimitive, dfStfs, inAddress, inValue);
|
|
%}
|
|
|
|
Store <- poStE_A(Vptr[1] inAddress, Vptr inValue) cost(1)
|
|
%{
|
|
genThrowIfZero(thisPrimitive, inAddress); // FIX-ME eliminate on AIX
|
|
genSt(thisPrimitive, dfStw, inAddress, inValue);
|
|
%}
|
|
|
|
|
|
Tuple <- poSysCall() cost(1)
|
|
%{
|
|
CallS_& newInsn = *new CallS_(&thisPrimitive, mPool, CallS_::numberOfArguments(thisPrimitive), CallS_::hasReturnValue(thisPrimitive), *this, PrimSysCall::cast(thisPrimitive).sysCall.function);
|
|
%}
|
|
|
|
Tuple <- poSysCallE() cost(1)
|
|
%{
|
|
CallS_& newInsn = *new CallS_(&thisPrimitive, mPool, CallS_::numberOfArguments(thisPrimitive), CallS_::hasReturnValue(thisPrimitive), *this, PrimSysCall::cast(thisPrimitive).sysCall.function);
|
|
%}
|
|
|
|
Tuple <- poSysCallC() cost(1)
|
|
%{
|
|
CallS_C& newInsn = *new CallS_C(&thisPrimitive, mPool, CallS_C::numberOfArguments(thisPrimitive), CallS_C::hasReturnValue(thisPrimitive), *this, PrimSysCall::cast(thisPrimitive).sysCall.function);
|
|
%}
|
|
|
|
Tuple <- poSysCallEC() cost(1)
|
|
%{
|
|
CallS_C& newInsn = *new CallS_C(&thisPrimitive, mPool, CallS_C::numberOfArguments(thisPrimitive), CallS_C::hasReturnValue(thisPrimitive), *this, PrimSysCall::cast(thisPrimitive).sysCall.function);
|
|
%}
|
|
|
|
Tuple <- poSysCallV() cost(1)
|
|
%{
|
|
CallS_V& newInsn = *new CallS_V(&thisPrimitive, mPool, CallS_V::numberOfArguments(thisPrimitive), CallS_V::hasReturnValue(thisPrimitive), *this, PrimSysCall::cast(thisPrimitive).sysCall.function);
|
|
%}
|
|
|
|
Tuple <- poSysCallEV() cost(1)
|
|
%{
|
|
CallS_V& newInsn = *new CallS_V(&thisPrimitive, mPool, CallS_V::numberOfArguments(thisPrimitive), CallS_V::hasReturnValue(thisPrimitive), *this, PrimSysCall::cast(thisPrimitive).sysCall.function);
|
|
%}
|
|
|
|
Tuple <- poCall(Vptr) cost(1)
|
|
%{
|
|
// Dynamic call
|
|
CallD_& newInsn = *new CallD_(&thisPrimitive, mPool, CallD_::numberOfArguments(thisPrimitive), CallD_::hasReturnValue(thisPrimitive), *this);
|
|
%}
|
|
|
|
Tuple <- poCall(poConst_A) cost(1)
|
|
%{
|
|
// Static call
|
|
Call_& newInsn = *new Call_(&thisPrimitive, mPool, Call_::numberOfArguments(thisPrimitive), Call_::hasReturnValue(thisPrimitive), *this);
|
|
%}
|
|
|