mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Bug fixes, installer, [Export]
Fixed a bunch of bugs in aggregate const initializers Fixed ZIP bugs Fixed a compilation case where we change protection while reifying a type Added another project kind - Dynamic Library Added [Export] for DLL method exporting Fixed some issues of things being generated as __NOINLINE incorrectly Fixed an issue with module extensions with not-yet-demanded on-demand methods Started adding Installer
This commit is contained in:
parent
efa22e51fb
commit
09016c8dc0
135 changed files with 3615 additions and 2337 deletions
|
@ -1950,7 +1950,7 @@ void BeCOFFObject::Generate(BeModule* module)
|
|||
InitSect(mDebugTSect, ".debug$T", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_DISCARDABLE | IMAGE_SCN_MEM_READ, true, false);
|
||||
}
|
||||
InitSect(mPDataSect, ".pdata", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ, true, false);
|
||||
|
||||
|
||||
mTextSect.mData.mData.Reserve(4096);
|
||||
|
||||
BfSizedVector<BeMCSymbol*, 32> globalVarSyms;
|
||||
|
@ -2060,8 +2060,21 @@ void BeCOFFObject::Generate(BeModule* module)
|
|||
|
||||
BeMCContext context(this);
|
||||
context.Generate(func);
|
||||
|
||||
if (func->mIsDLLExport)
|
||||
{
|
||||
mDirectives += " ";
|
||||
mDirectives.Append("/EXPORT:");
|
||||
mDirectives.Append(func->mName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mDirectives.IsEmpty())
|
||||
{
|
||||
InitSect(mDirectiveSect, ".drectve", IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE | IMAGE_SCN_ALIGN_1BYTES, true, false);
|
||||
mDirectiveSect.mData.Write((void*)mDirectives.c_str(), (int)mDirectives.length());
|
||||
}
|
||||
|
||||
if (hasDebugInfo)
|
||||
{
|
||||
|
|
|
@ -229,6 +229,7 @@ public:
|
|||
BeCOFFSection mXDataSect;
|
||||
BeCOFFSection mDebugSSect;
|
||||
BeCOFFSection mDebugTSect;
|
||||
BeCOFFSection mDirectiveSect;
|
||||
DynMemStream mStrTable;
|
||||
int mBSSPos;
|
||||
Array<BeCOFFSection*> mUsedSections;
|
||||
|
@ -244,6 +245,7 @@ public:
|
|||
int mCurStringId;
|
||||
int mCurJumpTableIdx;
|
||||
bool mTypesLocked;
|
||||
String mDirectives;
|
||||
|
||||
public:
|
||||
void ToString(BeMDNode* mdNode, String& str);
|
||||
|
|
|
@ -2112,6 +2112,10 @@ void BeIRCodeGen::HandleNextCmd()
|
|||
func->mNoReturn = true;
|
||||
else if (attribute == BFIRAttribute_NoFramePointerElim)
|
||||
func->mNoFramePointerElim = true;
|
||||
else if (attribute == BFIRAttribute_DllExport)
|
||||
func->mIsDLLExport = true;
|
||||
else if (attribute == BFIRAttribute_DllImport)
|
||||
func->mIsDLLImport = true;
|
||||
else
|
||||
BF_FATAL("Unhandled");
|
||||
}
|
||||
|
|
|
@ -11502,6 +11502,10 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src)
|
|||
int curOfs = 0;
|
||||
|
||||
bool allowRep = dataVec.size() >= BF_REP_MOV_LIMIT;
|
||||
if (mDebugging)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
union IntUnion
|
||||
{
|
||||
|
@ -11570,7 +11574,7 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src)
|
|||
}
|
||||
};
|
||||
|
||||
for (; curOfs <= memSize - 8; curOfs += 8)
|
||||
for (; curOfs <= memSize - 8; )
|
||||
{
|
||||
if (allowRep)
|
||||
{
|
||||
|
@ -11588,14 +11592,26 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src)
|
|||
|
||||
if (repSize >= 16)
|
||||
{
|
||||
// mov al, <val>
|
||||
Emit(0xB0); Emit(val);
|
||||
|
||||
bool regSaved = false;
|
||||
if ((regA == X64Reg_RAX) ||
|
||||
(regA == X64Reg_RCX) ||
|
||||
(regA == X64Reg_RDI))
|
||||
{
|
||||
BF_ASSERT(regB == X64Reg_None);
|
||||
// mov R11, regA
|
||||
Emit(0x49); Emit(0x89);
|
||||
EmitModRM(BeMCOperand::FromReg(regA), BeMCOperand::FromReg(X64Reg_R11));
|
||||
regSaved = true;
|
||||
}
|
||||
|
||||
// lea rdi, <dest+curOfs>
|
||||
EmitREX(BeMCOperand::FromReg(X64Reg_RDI), dest, true);
|
||||
Emit(0x8D);
|
||||
EmitModRMRel(EncodeRegNum(X64Reg_RDI), regA, regB, 1, disp + curOfs);
|
||||
|
||||
// mov al, <val>
|
||||
Emit(0xB0); Emit(val);
|
||||
|
||||
// mov edx, <repSize>
|
||||
Emit(0xB9);
|
||||
mOut.Write((int32)repSize);
|
||||
|
@ -11603,6 +11619,13 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src)
|
|||
// rep stosb
|
||||
Emit(0xF3); Emit(0xAA);
|
||||
|
||||
if (regSaved)
|
||||
{
|
||||
// mov regA, R11
|
||||
Emit(0x4C); Emit(0x89);
|
||||
EmitModRM(BeMCOperand::FromReg(X64Reg_R11), BeMCOperand::FromReg(regA));
|
||||
}
|
||||
|
||||
curOfs += repSize;
|
||||
continue;
|
||||
}
|
||||
|
@ -11615,6 +11638,7 @@ void BeMCContext::EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src)
|
|||
EmitREX(BeMCOperand::FromReg(X64Reg_R11), dest, true);
|
||||
Emit(0x89);
|
||||
EmitModRMRel(EncodeRegNum(X64Reg_R11), regA, regB, 1, disp + curOfs);
|
||||
curOfs += 8;
|
||||
}
|
||||
|
||||
for (; curOfs <= memSize - 4; curOfs += 4)
|
||||
|
@ -14738,7 +14762,7 @@ void BeMCContext::Generate(BeFunction* function)
|
|||
mDbgPreferredRegs[32] = X64Reg_R8;*/
|
||||
|
||||
//mDbgPreferredRegs[8] = X64Reg_RAX;
|
||||
mDebugging = function->mName == "??$Add@MW4RMWAtomicOrdering@Interlocked@Threading@System@bf@@$$04@Interlocked@Threading@System@bf@@SAMAEAMMW4RMWAtomicOrdering@Interlocked@Threading@System@bf@@$$04@Z";
|
||||
//mDebugging = function->mName == "?__BfStaticCtor@Blurg@bf@@SAXXZ";
|
||||
//"?Main@Program@bf@@CAHPEAV?$Array1@PEAVString@System@bf@@@System@2@@Z";
|
||||
|
||||
//"?Hey@Blurg@bf@@SAXXZ";
|
||||
|
|
|
@ -1963,6 +1963,8 @@ String BeModule::ToString(BeFunction* wantFunc)
|
|||
str += " noreturn";
|
||||
if (func->mNoFramePointerElim)
|
||||
str += " noframepointerelim";
|
||||
if (func->mIsDLLExport)
|
||||
str += " dllexport";
|
||||
|
||||
if (func->mBlocks.size() == 0)
|
||||
{
|
||||
|
@ -2970,6 +2972,9 @@ BeFunction* BeModule::CreateFunction(BeFunctionType* funcType, BfIRLinkageType l
|
|||
func->mLinkageType = linkageType;
|
||||
func->mParams.Resize(funcType->mParams.size());
|
||||
mFunctions.push_back(func);
|
||||
#ifdef _DEBUG
|
||||
BF_ASSERT(mFunctionMap.TryAdd(name, func));
|
||||
#endif
|
||||
return func;
|
||||
}
|
||||
|
||||
|
|
|
@ -447,6 +447,8 @@ public:
|
|||
bool mNoReturn;
|
||||
bool mDidInlinePass;
|
||||
bool mNoFramePointerElim;
|
||||
bool mIsDLLExport;
|
||||
bool mIsDLLImport;
|
||||
BfIRCallingConv mCallingConv;
|
||||
Array<BeBlock*> mBlocks;
|
||||
Array<BeFunctionParam> mParams;
|
||||
|
@ -467,6 +469,8 @@ public:
|
|||
mUWTable = false;
|
||||
mNoReturn = false;
|
||||
mNoFramePointerElim = false;
|
||||
mIsDLLExport = false;
|
||||
mIsDLLImport = false;
|
||||
mRemapBindVar = NULL;
|
||||
mCurElementId = 0;
|
||||
}
|
||||
|
@ -2056,6 +2060,7 @@ public:
|
|||
BeDbgLoc* mLastDbgLoc;
|
||||
Array<BeArgument*> mArgs;
|
||||
Array<BeFunction*> mFunctions;
|
||||
Dictionary<String, BeFunction*> mFunctionMap;
|
||||
int mCurDbgLocIdx;
|
||||
int mCurLexBlockId;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue