Add missing mac include
This commit is contained in:
parent
22dc083283
commit
bc4aea064a
|
@ -192,7 +192,7 @@ bool Compiler::GenerateCode(void)
|
|||
{
|
||||
InterCodeProcedure* proc = mInterCodeModule->mProcedures[i];
|
||||
|
||||
proc->ReduceTemporaries();
|
||||
// proc->ReduceTemporaries();
|
||||
|
||||
#if _DEBUG
|
||||
proc->Disassemble("final");
|
||||
|
|
|
@ -3577,11 +3577,12 @@ InterCodeProcedure::InterCodeProcedure(InterCodeModule * mod, const Location & l
|
|||
mRenameTable(-1), mRenameUnionTable(-1), mGlobalRenameTable(-1),
|
||||
mValueForwardingTable(nullptr), mLocalVars(nullptr), mModule(mod),
|
||||
mIdent(ident), mLinkerObject(linkerObject),
|
||||
mNativeProcedure(false), mLeafProcedure(false)
|
||||
mNativeProcedure(false), mLeafProcedure(false), mCallsFunctionPointer(false), mCalledFunctions(nullptr)
|
||||
{
|
||||
mID = mModule->mProcedures.Size();
|
||||
mModule->mProcedures.Push(this);
|
||||
mLinkerObject->mProc = this;
|
||||
mCallerSavedTemps = 16;
|
||||
}
|
||||
|
||||
InterCodeProcedure::~InterCodeProcedure(void)
|
||||
|
@ -4024,6 +4025,20 @@ void InterCodeProcedure::Close(void)
|
|||
MapVariables();
|
||||
|
||||
DisassembleDebug("mapped variabled");
|
||||
|
||||
ReduceTemporaries();
|
||||
|
||||
DisassembleDebug("Reduced Temporaries");
|
||||
}
|
||||
|
||||
void InterCodeProcedure::AddCalledFunction(InterCodeProcedure* proc)
|
||||
{
|
||||
mCalledFunctions.Push(proc);
|
||||
}
|
||||
|
||||
void InterCodeProcedure::CallsFunctionPointer(void)
|
||||
{
|
||||
mCallsFunctionPointer = true;
|
||||
}
|
||||
|
||||
void InterCodeProcedure::MapVariables(void)
|
||||
|
@ -4145,7 +4160,21 @@ void InterCodeProcedure::ReduceTemporaries(void)
|
|||
ResetVisited();
|
||||
mEntryBlock->BuildCallerSaveTempSet(callerSaved);
|
||||
|
||||
int callerSavedTemps = 0, calleeSavedTemps = 16;
|
||||
int callerSavedTemps = 0, calleeSavedTemps = 16, freeCallerSavedTemps = 0, freeTemps = 0;
|
||||
|
||||
if (mCallsFunctionPointer)
|
||||
freeCallerSavedTemps = 16;
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < mCalledFunctions.Size(); i++)
|
||||
{
|
||||
InterCodeProcedure* proc = mCalledFunctions[i];
|
||||
if (proc->mCallerSavedTemps > freeCallerSavedTemps)
|
||||
freeCallerSavedTemps = proc->mCallerSavedTemps;
|
||||
}
|
||||
}
|
||||
|
||||
callerSavedTemps = freeCallerSavedTemps;
|
||||
|
||||
mTempOffset.SetSize(0);
|
||||
|
||||
|
@ -4153,7 +4182,13 @@ void InterCodeProcedure::ReduceTemporaries(void)
|
|||
{
|
||||
int size = InterTypeSize[mTemporaries[i]];
|
||||
|
||||
if (callerSavedTemps + size <= 16 && !callerSaved[i])
|
||||
if (freeTemps + size <= freeCallerSavedTemps && !callerSaved[i])
|
||||
{
|
||||
mTempOffset.Push(freeTemps);
|
||||
mTempSizes.Push(size);
|
||||
freeTemps += size;
|
||||
}
|
||||
else if (callerSavedTemps + size <= 16)
|
||||
{
|
||||
mTempOffset.Push(callerSavedTemps);
|
||||
mTempSizes.Push(size);
|
||||
|
@ -4167,6 +4202,7 @@ void InterCodeProcedure::ReduceTemporaries(void)
|
|||
}
|
||||
}
|
||||
mTempSize = calleeSavedTemps;
|
||||
mCallerSavedTemps = callerSavedTemps;
|
||||
}
|
||||
|
||||
void InterCodeProcedure::Disassemble(const char* name, bool dumpSets)
|
||||
|
|
|
@ -486,8 +486,9 @@ public:
|
|||
GrowingInterCodeBasicBlockPtrArray mBlocks;
|
||||
GrowingTypeArray mTemporaries;
|
||||
GrowingIntArray mTempOffset, mTempSizes;
|
||||
int mTempSize, mCommonFrameSize;
|
||||
bool mLeafProcedure, mNativeProcedure;
|
||||
int mTempSize, mCommonFrameSize, mCallerSavedTemps;
|
||||
bool mLeafProcedure, mNativeProcedure, mCallsFunctionPointer;
|
||||
GrowingInterCodeProcedurePtrArray mCalledFunctions;
|
||||
|
||||
InterCodeModule * mModule;
|
||||
int mID;
|
||||
|
@ -510,6 +511,9 @@ public:
|
|||
|
||||
// void Set(InterCodeIDMapper* mapper, BitVector localStructure, Scanner scanner, bool debug);
|
||||
|
||||
void AddCalledFunction(InterCodeProcedure* proc);
|
||||
void CallsFunctionPointer(void);
|
||||
|
||||
void MapVariables(void);
|
||||
void ReduceTemporaries(void);
|
||||
void Disassemble(const char* name, bool dumpSets = false);
|
||||
|
|
|
@ -296,7 +296,6 @@ void InterCodeGenerator::TranslateAssembler(InterCodeModule* mod, Expression * e
|
|||
if (!aexp->mBase->mLinkerObject)
|
||||
{
|
||||
InterCodeProcedure* cproc = this->TranslateProcedure(mod, aexp->mBase->mValue, aexp->mBase);
|
||||
cproc->ReduceTemporaries();
|
||||
}
|
||||
|
||||
LinkerReference ref;
|
||||
|
@ -432,7 +431,6 @@ void InterCodeGenerator::TranslateAssembler(InterCodeModule* mod, Expression * e
|
|||
if (!aexp->mLinkerObject)
|
||||
{
|
||||
InterCodeProcedure* cproc = this->TranslateProcedure(mod, aexp->mValue, aexp);
|
||||
cproc->ReduceTemporaries();
|
||||
}
|
||||
|
||||
LinkerReference ref;
|
||||
|
@ -450,7 +448,6 @@ void InterCodeGenerator::TranslateAssembler(InterCodeModule* mod, Expression * e
|
|||
if (!aexp->mBase->mLinkerObject)
|
||||
{
|
||||
InterCodeProcedure* cproc = this->TranslateProcedure(mod, aexp->mBase->mValue, aexp->mBase);
|
||||
cproc->ReduceTemporaries();
|
||||
}
|
||||
|
||||
LinkerReference ref;
|
||||
|
@ -571,7 +568,6 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
if (!dec->mLinkerObject)
|
||||
{
|
||||
InterCodeProcedure* cproc = this->TranslateProcedure(proc->mModule, dec->mValue, dec);
|
||||
cproc->ReduceTemporaries();
|
||||
}
|
||||
|
||||
InterInstruction * ins = new InterInstruction();
|
||||
|
@ -1461,6 +1457,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
if (ftype->mType == DT_TYPE_POINTER)
|
||||
ftype = ftype->mBase;
|
||||
|
||||
if (exp->mLeft->mDecValue->mType == DT_CONST_FUNCTION)
|
||||
proc->AddCalledFunction(proc->mModule->mProcedures[exp->mLeft->mDecValue->mVarIndex]);
|
||||
else
|
||||
proc->CallsFunctionPointer();
|
||||
|
||||
Declaration* pdec = ftype->mParams;
|
||||
Expression* pex = exp->mRight;
|
||||
while (pex)
|
||||
|
@ -2185,7 +2186,6 @@ void InterCodeGenerator::BuildInitializer(InterCodeModule * mod, uint8* dp, int
|
|||
if (!data->mLinkerObject)
|
||||
{
|
||||
InterCodeProcedure* cproc = this->TranslateProcedure(mod, data->mValue, data);
|
||||
cproc->ReduceTemporaries();
|
||||
}
|
||||
|
||||
LinkerReference ref;
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
#include "Compiler.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
Loading…
Reference in New Issue