Fastcall optimization for 2nd and 3rd level calls
This commit is contained in:
parent
b43edb2b4c
commit
6fe9a4f167
|
@ -1406,7 +1406,7 @@ void ByteCodeBasicBlock::LoadConstant(InterCodeProcedure* proc, const InterInstr
|
|||
bins.mValue = ins->mConst.mIntConst + ins->mConst.mVarIndex + proc->mLocalSize + 2;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mConst.mMemory == IM_FPARAM)
|
||||
else if (ins->mConst.mMemory == IM_FPARAM || ins->mConst.mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction bins(BC_LEA_ABS);
|
||||
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mDst.mTemp];
|
||||
|
@ -1509,7 +1509,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegister = BC_REG_ACCU;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction bins(BC_STORE_REG_32);
|
||||
bins.mRegister = BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst;
|
||||
|
@ -1571,7 +1571,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_32);
|
||||
ains.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||
|
@ -1707,7 +1707,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegister = BC_REG_ACCU;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction bins(BC_STORE_REG_16);
|
||||
bins.mRegister = BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst;
|
||||
|
@ -1767,7 +1767,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegisterFinal = ins->mSrc[0].mFinal;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_16);
|
||||
ains.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||
|
@ -1909,7 +1909,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegister = BC_REG_ACCU;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction bins(BC_STORE_REG_8);
|
||||
bins.mRegister = BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst;
|
||||
|
@ -1968,7 +1968,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegister = BC_REG_ACCU;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction bins(BC_STORE_REG_16);
|
||||
bins.mRegister = BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst;
|
||||
|
@ -2027,7 +2027,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegister = BC_REG_ACCU;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction bins(BC_STORE_REG_32);
|
||||
bins.mRegister = BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst;
|
||||
|
@ -2091,7 +2091,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegisterFinal = ins->mSrc[0].mFinal;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_8);
|
||||
ains.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||
|
@ -2160,7 +2160,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegisterFinal = ins->mSrc[0].mFinal;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_16);
|
||||
ains.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||
|
@ -2229,7 +2229,7 @@ void ByteCodeBasicBlock::StoreDirectValue(InterCodeProcedure* proc, const InterI
|
|||
bins.mRegisterFinal = ins->mSrc[0].mFinal;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_32);
|
||||
ains.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp];
|
||||
|
@ -2406,7 +2406,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
|
|||
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mDst.mTemp];
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM || ins->mSrc[0].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_32);
|
||||
ains.mRegister = BC_REG_FPARAMS + ins->mSrc[0].mIntConst + ins->mSrc[0].mVarIndex;
|
||||
|
@ -2493,7 +2493,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
|
|||
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mDst.mTemp];
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM || ins->mSrc[0].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_16);
|
||||
ains.mRegister = BC_REG_FPARAMS + ins->mSrc[0].mIntConst + ins->mSrc[0].mVarIndex;
|
||||
|
@ -2582,7 +2582,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
|
|||
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mDst.mTemp];
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM || ins->mSrc[0].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_8);
|
||||
ains.mRegister = BC_REG_FPARAMS + ins->mSrc[0].mIntConst + ins->mSrc[0].mVarIndex;
|
||||
|
@ -2638,7 +2638,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
|
|||
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mDst.mTemp];
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM || ins->mSrc[0].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_16);
|
||||
ains.mRegister = BC_REG_FPARAMS + ins->mSrc[0].mIntConst + ins->mSrc[0].mVarIndex;
|
||||
|
@ -2694,7 +2694,7 @@ void ByteCodeBasicBlock::LoadDirectValue(InterCodeProcedure* proc, const InterIn
|
|||
bins.mRegister = BC_REG_TMP + proc->mTempOffset[ins->mDst.mTemp];
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[0].mMemory == IM_FPARAM || ins->mSrc[0].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction ains(BC_LOAD_REG_32);
|
||||
ains.mRegister = BC_REG_FPARAMS + ins->mSrc[0].mIntConst + ins->mSrc[0].mVarIndex;
|
||||
|
@ -2887,7 +2887,7 @@ void ByteCodeBasicBlock::LoadEffectiveAddress(InterCodeProcedure* proc, const In
|
|||
bins.mValue = ins->mSrc[1].mIntConst;
|
||||
mIns.Push(bins);
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
ByteCodeInstruction bins(BC_CONST_16);
|
||||
bins.mRegister = BC_REG_ACCU;
|
||||
|
@ -2967,7 +2967,7 @@ void ByteCodeBasicBlock::CallAssembler(InterCodeProcedure* proc, const InterInst
|
|||
{
|
||||
if (ins->mSrc[i].mTemp < 0)
|
||||
{
|
||||
if (ins->mSrc[i].mMemory == IM_FPARAM)
|
||||
if (ins->mSrc[i].mMemory == IM_FPARAM || ins->mSrc[i].mMemory == IM_FFRAME)
|
||||
ins->mSrc[0].mLinkerObject->mTemporaries[i - 1] = BC_REG_FPARAMS + ins->mSrc[i].mVarIndex + ins->mSrc[i].mIntConst;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -61,6 +61,8 @@ bool Compiler::ParseSource(void)
|
|||
|
||||
Parser* parser = new Parser(mErrors, scanner, mCompilationUnits);
|
||||
|
||||
parser->mCompilerOptions = mCompilerOptions;
|
||||
|
||||
parser->Parse();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -484,7 +484,7 @@ Expression* Expression::ConstantFold(Errors * errors)
|
|||
Declaration::Declaration(const Location& loc, DecType type)
|
||||
: mLocation(loc), mType(type), mScope(nullptr), mData(nullptr), mIdent(nullptr), mSize(0), mOffset(0), mFlags(0), mComplexity(0), mLocalSize(0),
|
||||
mBase(nullptr), mParams(nullptr), mValue(nullptr), mNext(nullptr), mVarIndex(-1), mLinkerObject(nullptr), mCallers(nullptr), mCalled(nullptr), mAlignment(1),
|
||||
mInteger(0), mNumber(0), mMinValue(-0x80000000LL), mMaxValue(0x7fffffffLL)
|
||||
mInteger(0), mNumber(0), mMinValue(-0x80000000LL), mMaxValue(0x7fffffffLL), mFastCallBase(0), mFastCallSize(0)
|
||||
{}
|
||||
|
||||
Declaration::~Declaration(void)
|
||||
|
|
|
@ -70,6 +70,7 @@ static const uint64 DTF_REQUEST_INLINE = (1ULL << 17);
|
|||
static const uint64 DTF_INTERRUPT = (1ULL << 18);
|
||||
static const uint64 DTF_EXPORT = (1ULL << 19);
|
||||
static const uint64 DTF_HWINTERRUPT = (1ULL << 20);
|
||||
static const uint64 DTF_STACKCALL = (1ULL << 21);
|
||||
|
||||
static const uint64 DTF_FUNC_VARIABLE = (1ULL << 32);
|
||||
static const uint64 DTF_FUNC_ASSEMBLER = (1ULL << 33);
|
||||
|
@ -175,7 +176,7 @@ public:
|
|||
Declaration* mBase, *mParams, * mNext;
|
||||
Expression* mValue;
|
||||
DeclarationScope* mScope;
|
||||
int mOffset, mSize, mVarIndex, mNumVars, mComplexity, mLocalSize, mAlignment;
|
||||
int mOffset, mSize, mVarIndex, mNumVars, mComplexity, mLocalSize, mAlignment, mFastCallBase, mFastCallSize;
|
||||
int64 mInteger, mMinValue, mMaxValue;
|
||||
double mNumber;
|
||||
uint64 mFlags;
|
||||
|
|
|
@ -95,7 +95,7 @@ void GlobalAnalyzer::AutoInline(void)
|
|||
int sk = 0, dk = 0;
|
||||
while (sk < cf->mCalled.Size())
|
||||
{
|
||||
if (cf->mCalled[sk] == f)
|
||||
if (cf->mCalled[sk] == f && ((cf->mFlags & DTF_NATIVE) || !(f->mFlags & DTF_NATIVE)))
|
||||
{
|
||||
cf->mComplexity += cost;
|
||||
for (int m = 0; m < f->mCalled.Size(); m++)
|
||||
|
@ -121,26 +121,59 @@ void GlobalAnalyzer::AutoInline(void)
|
|||
|
||||
for (int i = 0; i < mFunctions.Size(); i++)
|
||||
{
|
||||
Declaration* f = mFunctions[i];
|
||||
if (!(f->mFlags & DTF_INLINE) && !(f->mBase->mFlags & DTF_VARIADIC) && !(f->mFlags & DTF_FUNC_VARIABLE) && f->mCalled.Size() == 0)
|
||||
CheckFastcall(mFunctions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalAnalyzer::CheckFastcall(Declaration* procDec)
|
||||
{
|
||||
if (!(procDec->mBase->mFlags & DTF_FASTCALL) && !(procDec->mBase->mFlags & DTF_STACKCALL))
|
||||
{
|
||||
if (!(procDec->mBase->mFlags & DTF_VARIADIC) && !(procDec->mFlags & DTF_FUNC_VARIABLE) && !(procDec->mFlags & DTF_FUNC_RECURSIVE))
|
||||
{
|
||||
int nbase = 0;
|
||||
for (int i = 0; i < procDec->mCalled.Size(); i++)
|
||||
{
|
||||
Declaration* cf = procDec->mCalled[i];
|
||||
|
||||
CheckFastcall(cf);
|
||||
|
||||
cf = cf->mBase;
|
||||
if (cf->mFlags & DTF_FASTCALL)
|
||||
{
|
||||
int n = cf->mFastCallBase + cf->mFastCallSize;
|
||||
if (n > nbase)
|
||||
nbase = n;
|
||||
}
|
||||
else
|
||||
nbase = 1000;
|
||||
}
|
||||
|
||||
int nparams = 0;
|
||||
Declaration* dec = f->mBase->mParams;
|
||||
Declaration* dec = procDec->mBase->mParams;
|
||||
while (dec)
|
||||
{
|
||||
{
|
||||
nparams += dec->mBase->mSize;
|
||||
dec = dec->mNext;
|
||||
}
|
||||
|
||||
if (nparams <= BC_REG_FPARAMS_END - BC_REG_FPARAMS)
|
||||
if (nbase + nparams <= BC_REG_FPARAMS_END - BC_REG_FPARAMS)
|
||||
{
|
||||
f->mBase->mFlags |= DTF_FASTCALL;
|
||||
procDec->mFastCallBase = nbase;
|
||||
procDec->mFastCallSize = nparams;
|
||||
procDec->mBase->mFastCallBase = nbase;
|
||||
procDec->mBase->mFastCallSize = nparams;
|
||||
|
||||
procDec->mBase->mFlags |= DTF_FASTCALL;
|
||||
#if 0
|
||||
printf("FASTCALL %s\n", f->mIdent->mString);
|
||||
#endif
|
||||
}
|
||||
|
||||
else
|
||||
procDec->mBase->mFlags |= DTF_STACKCALL;
|
||||
}
|
||||
else
|
||||
procDec->mBase->mFlags |= DTF_STACKCALL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ public:
|
|||
|
||||
void DumpCallGraph(void);
|
||||
void AutoInline(void);
|
||||
void CheckFastcall(Declaration* procDec);
|
||||
|
||||
void AnalyzeProcedure(Expression* exp, Declaration* procDec);
|
||||
void AnalyzeAssembler(Expression* exp, Declaration* procDec);
|
||||
|
|
|
@ -6781,7 +6781,7 @@ static bool CanBypassStore(const InterInstruction * sins, const InterInstruction
|
|||
else
|
||||
return false;
|
||||
}
|
||||
else if (sm == IM_FRAME)
|
||||
else if (sm == IM_FRAME || sm == IM_FFRAME)
|
||||
;
|
||||
else if (sm == IM_FPARAM)
|
||||
{
|
||||
|
|
|
@ -64,6 +64,7 @@ enum InterMemory
|
|||
IM_TEMPORARY,
|
||||
IM_ABSOLUTE,
|
||||
IM_FPARAM,
|
||||
IM_FFRAME,
|
||||
};
|
||||
|
||||
enum InterOperator
|
||||
|
|
|
@ -925,7 +925,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
ins->mConst.mVarIndex = inlineMapper->mParams[dec->mVarIndex];
|
||||
}
|
||||
else if (procType->mFlags & DTF_FASTCALL)
|
||||
{
|
||||
ins->mConst.mMemory = IM_FPARAM;
|
||||
ins->mConst.mVarIndex += procType->mFastCallBase;
|
||||
}
|
||||
else
|
||||
ins->mConst.mMemory = IM_PARAM;
|
||||
if (dec->mBase->mType == DT_TYPE_ARRAY)
|
||||
|
@ -2244,8 +2247,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
ains->mConst.mVarIndex = 0;
|
||||
ains->mConst.mIntConst = 0;
|
||||
ains->mConst.mOperandSize = 2;
|
||||
if (ftype->mFlags & DTF_FASTCALL)
|
||||
ains->mConst.mMemory = IM_FPARAM;
|
||||
if (ftype->mFlags & DTF_FASTCALL)
|
||||
{
|
||||
ains->mConst.mMemory = IM_FFRAME;
|
||||
ains->mConst.mVarIndex += ftype->mFastCallBase;
|
||||
}
|
||||
else
|
||||
ains->mConst.mMemory = IM_FRAME;
|
||||
block->Append(ains);
|
||||
|
@ -2300,8 +2306,9 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
|
||||
if (ftype->mFlags & DTF_FASTCALL)
|
||||
{
|
||||
ains->mConst.mMemory = IM_FPARAM;
|
||||
ains->mConst.mMemory = IM_FFRAME;
|
||||
ains->mConst.mIntConst = 0;
|
||||
ains->mConst.mVarIndex += ftype->mFastCallBase;
|
||||
}
|
||||
else
|
||||
ains->mConst.mMemory = IM_FRAME;
|
||||
|
@ -2504,7 +2511,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
vins->mConst.mVarIndex = inlineMapper->mParams[vdec->mVarIndex];
|
||||
}
|
||||
else if (procType->mFlags & DTF_FASTCALL)
|
||||
{
|
||||
vins->mConst.mMemory = IM_FPARAM;
|
||||
vins->mConst.mVarIndex += procType->mFastCallBase;
|
||||
}
|
||||
else
|
||||
vins->mConst.mMemory = IM_PARAM;
|
||||
vins->mConst.mOperandSize = vdec->mSize;
|
||||
|
@ -2584,7 +2594,10 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
pins->mConst.mIntConst = 0;
|
||||
pins->mConst.mOperandSize = 2;
|
||||
if (procType->mFlags & DTF_FASTCALL)
|
||||
{
|
||||
pins->mConst.mMemory = IM_FPARAM;
|
||||
pins->mConst.mVarIndex += procType->mFastCallBase;
|
||||
}
|
||||
else
|
||||
pins->mConst.mMemory = IM_PARAM;
|
||||
block->Append(pins);
|
||||
|
@ -3447,9 +3460,6 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
|||
dec->mLinkerObject = proc->mLinkerObject;
|
||||
proc->mNumLocals = dec->mNumVars;
|
||||
|
||||
if (mCompilerOptions & COPT_NATIVE)
|
||||
dec->mFlags |= DTF_NATIVE;
|
||||
|
||||
if (dec->mFlags & DTF_NATIVE)
|
||||
proc->mNativeProcedure = true;
|
||||
|
||||
|
|
|
@ -3165,7 +3165,7 @@ void NativeCodeBasicBlock::LoadConstantToReg(InterCodeProcedure * proc, const In
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins->mConst.mIntConst >> 8) & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg + 1));
|
||||
}
|
||||
else if (ins->mConst.mMemory == IM_FPARAM)
|
||||
else if (ins->mConst.mMemory == IM_FPARAM || ins->mConst.mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, BC_REG_FPARAMS + ins->mConst.mVarIndex + ins->mConst.mIntConst));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, reg));
|
||||
|
@ -3301,7 +3301,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (cc.v >> 24) & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst + 3, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, cc.v & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3387,7 +3387,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, sreg + 3));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst + 3, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, sreg));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3514,7 +3514,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins->mSrc[0].mIntConst >> 8) & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst + 1, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, ins->mSrc[0].mIntConst & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3567,7 +3567,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp] + 1));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst + 1, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp]));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3661,7 +3661,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, ins->mSrc[0].mIntConst & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, ins->mSrc[0].mIntConst & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3706,7 +3706,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins->mSrc[0].mIntConst >> 8) & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst + 1, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, ins->mSrc[0].mIntConst & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3767,7 +3767,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, (ins->mSrc[0].mIntConst >> 24) & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst + 3, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, ins->mSrc[0].mIntConst & 0xff));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3835,7 +3835,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp]));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp]));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3880,7 +3880,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp] + 1));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst + 1, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp]));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -3942,7 +3942,7 @@ void NativeCodeBasicBlock::StoreValue(InterCodeProcedure* proc, const InterInstr
|
|||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp] + 3));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, ins->mSrc[1].mIntConst + 3, nullptr, flags));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp]));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
|
@ -4112,6 +4112,7 @@ void NativeCodeBasicBlock::LoadStoreIndirectValue(InterCodeProcedure* proc, cons
|
|||
rindex = rins->mSrc[0].mIntConst;
|
||||
break;
|
||||
case IM_FPARAM:
|
||||
case IM_FFRAME:
|
||||
rmode = ASMIM_ZERO_PAGE;
|
||||
rareg = BC_REG_FPARAMS + rins->mSrc[0].mVarIndex + rins->mSrc[0].mIntConst;
|
||||
break;
|
||||
|
@ -4152,6 +4153,7 @@ void NativeCodeBasicBlock::LoadStoreIndirectValue(InterCodeProcedure* proc, cons
|
|||
windex = wins->mSrc[1].mIntConst;
|
||||
break;
|
||||
case IM_FPARAM:
|
||||
case IM_FFRAME:
|
||||
wmode = ASMIM_ZERO_PAGE;
|
||||
wareg = BC_REG_FPARAMS + wins->mSrc[1].mVarIndex + wins->mSrc[1].mIntConst;
|
||||
break;
|
||||
|
@ -4264,7 +4266,7 @@ void NativeCodeBasicBlock::LoadStoreValue(InterCodeProcedure* proc, const InterI
|
|||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ABSOLUTE, wins->mSrc[1].mIntConst, nullptr, wflags));
|
||||
}
|
||||
else if (wins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (wins->mSrc[1].mMemory == IM_FPARAM || wins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_FPARAMS + wins->mSrc[1].mVarIndex + wins->mSrc[1].mIntConst));
|
||||
}
|
||||
|
@ -4399,6 +4401,7 @@ bool NativeCodeBasicBlock::LoadUnopStoreIndirectValue(InterCodeProcedure* proc,
|
|||
rindex += rins->mSrc[0].mVarIndex + proc->mLocalSize + 2 + mFrameOffset;
|
||||
break;
|
||||
case IM_FPARAM:
|
||||
case IM_FFRAME:
|
||||
ram = ASMIM_ZERO_PAGE;
|
||||
rareg = BC_REG_FPARAMS + rins->mSrc[0].mVarIndex + rins->mSrc[0].mIntConst;
|
||||
break;
|
||||
|
@ -4421,6 +4424,7 @@ bool NativeCodeBasicBlock::LoadUnopStoreIndirectValue(InterCodeProcedure* proc,
|
|||
windex += wins->mSrc[1].mVarIndex + proc->mLocalSize + 2 + mFrameOffset;
|
||||
break;
|
||||
case IM_FPARAM:
|
||||
case IM_FFRAME:
|
||||
wam = ASMIM_ZERO_PAGE;
|
||||
wareg = BC_REG_FPARAMS + +wins->mSrc[1].mVarIndex + wins->mSrc[1].mIntConst;
|
||||
break;
|
||||
|
@ -4529,6 +4533,7 @@ bool NativeCodeBasicBlock::LoadOpStoreIndirectValue(InterCodeProcedure* proc, co
|
|||
rindex += rins->mSrc[0].mVarIndex + proc->mLocalSize + 2 + mFrameOffset;
|
||||
break;
|
||||
case IM_FPARAM:
|
||||
case IM_FFRAME:
|
||||
ram = ASMIM_ZERO_PAGE;
|
||||
rareg = BC_REG_FPARAMS + rins->mSrc[0].mVarIndex + rins->mSrc[0].mIntConst;
|
||||
break;
|
||||
|
@ -4551,6 +4556,7 @@ bool NativeCodeBasicBlock::LoadOpStoreIndirectValue(InterCodeProcedure* proc, co
|
|||
windex += wins->mSrc[1].mVarIndex + proc->mLocalSize + 2 + mFrameOffset;
|
||||
break;
|
||||
case IM_FPARAM:
|
||||
case IM_FFRAME:
|
||||
wam = ASMIM_ZERO_PAGE;
|
||||
wareg = BC_REG_FPARAMS + +wins->mSrc[1].mVarIndex + wins->mSrc[1].mIntConst;
|
||||
break;
|
||||
|
@ -8469,7 +8475,7 @@ void NativeCodeBasicBlock::LoadEffectiveAddress(InterCodeProcedure* proc, const
|
|||
mIns.Push(NativeCodeInstruction(iop, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ireg] + 1));
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mDst.mTemp] + 1));
|
||||
}
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM)
|
||||
else if (ins->mSrc[1].mMemory == IM_FPARAM || ins->mSrc[1].mMemory == IM_FFRAME)
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, BC_REG_FPARAMS + ins->mSrc[1].mVarIndex + ins->mSrc[1].mIntConst));
|
||||
mIns.Push(NativeCodeInstruction(iop, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ireg]));
|
||||
|
@ -8592,7 +8598,7 @@ void NativeCodeBasicBlock::CallAssembler(InterCodeProcedure* proc, NativeCodePro
|
|||
{
|
||||
if (ins->mSrc[i].mTemp < 0)
|
||||
{
|
||||
if (ins->mSrc[i].mMemory == IM_FPARAM)
|
||||
if (ins->mSrc[i].mMemory == IM_FPARAM || ins->mSrc[i].mMemory == IM_FFRAME)
|
||||
ins->mSrc[0].mLinkerObject->mTemporaries[i - 1] = BC_REG_FPARAMS + ins->mSrc[i].mVarIndex + ins->mSrc[i].mIntConst;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1022,6 +1022,9 @@ Declaration* Parser::ParseDeclaration(bool variable)
|
|||
ndec->mType = DT_CONST_FUNCTION;
|
||||
ndec->mSection = mCodeSection;
|
||||
ndec->mBase->mFlags |= typeFlags;
|
||||
|
||||
if (mCompilerOptions & COPT_NATIVE)
|
||||
ndec->mFlags |= DTF_NATIVE;
|
||||
}
|
||||
|
||||
if (ndec->mIdent)
|
||||
|
|
|
@ -16,6 +16,8 @@ public:
|
|||
|
||||
LinkerSection * mCodeSection, * mDataSection, * mBSSection;
|
||||
|
||||
uint64 mCompilerOptions;
|
||||
|
||||
void Parse(void);
|
||||
protected:
|
||||
bool ConsumeToken(Token token);
|
||||
|
|
Loading…
Reference in New Issue