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