1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed backend error vreg handling, softer fails, fixed a forcelink issue

This commit is contained in:
Brian Fiete 2019-12-11 16:54:36 -08:00
parent aafefecfa2
commit 8b71f8d49a
4 changed files with 58 additions and 38 deletions

View file

@ -4031,7 +4031,7 @@ bool BeMCContext::CheckForce(BeMCVRegInfo * vregInfo)
if (!vregInfo->mIsRetVal)
{
if (vregInfo->mForceMem && vregInfo->mForceReg)
Fail("vreg forceMem/forceReg collision");
SoftFail("vreg forceMem/forceReg collision");
}
return false;
}
@ -4467,12 +4467,12 @@ void BeMCContext::GenerateLiveness(BeMCBlock* block, BeVTrackingGenContext* genC
if (vregInfo->mDoConservativeLife)
BF_ASSERT(mVRegInitializedContext.IsSet(vregsInitialized, vregIdx, BeTrackKind_Uninitialized));
else
Fail("VReg lifetime error");
SoftFail("VReg lifetime error");
}
}
else
{
Fail("VReg lifetime error");
SoftFail("VReg lifetime error");
}
}
}
@ -5340,7 +5340,7 @@ uint8 BeMCContext::EncodeRegNum(X64CPURegister regNum)
case X64Reg_XMM15_f64:
return 7;
}
Fail("Invalid reg");
SoftFail("Invalid reg");
return -1;
}
@ -5945,7 +5945,7 @@ void BeMCContext::EmitModRM(int rx, BeMCOperand rm, int relocOfs)
}
else
{
Fail("Invalid rm");
SoftFail("Invalid rm");
}
mOut.Write(modRM);
}
@ -6038,12 +6038,12 @@ void BeMCContext::EmitModRM_Addr(BeMCOperand r, BeMCOperand rm)
}
else
{
Fail("Illegal");
SoftFail("Illegal expression in EmitModRM_Addr");
}
}
else
{
Fail("Invalid rm");
SoftFail("Invalid rm in EmitModRM_Addr");
}
mOut.Write(modRM);
}
@ -7789,7 +7789,7 @@ void BeMCContext::DoRegAssignPass()
continue;
if ((vregInfo->mForceReg) && (!vregInfo->mRelTo) && (vregInfo->mReg == X64Reg_None))
{
Fail("Failed to assign register to ForceReg vreg");
SoftFail("Failed to assign register to ForceReg vreg");
}
if (vregInfo->mDisableRAX)
{
@ -8729,7 +8729,7 @@ bool BeMCContext::DoLegalization()
break;
case BeMCInstKind_DefLoad:
{
Fail("DefLoad- DoLoads should have removed these");
SoftFail("DefLoad- DoLoads should have removed these");
}
break;
case BeMCInstKind_Def:
@ -8846,6 +8846,13 @@ bool BeMCContext::DoLegalization()
int disp = 0;
int errorVRegIdx = -1;
bool isValid = GetRMParams(inst->mArg0, regA, regB, bScale, disp, &errorVRegIdx) != BeMCRMMode_Invalid;
if (mDebugging)
{
if ((inst->mArg0.mVRegIdx == 272) || (inst->mArg0.mVRegIdx == 274))
{
NOP;
}
}
if (!isValid)
{
@ -9001,9 +9008,9 @@ bool BeMCContext::DoLegalization()
else
{
// This should be impossible - a previous def for an inner expr should have caught this case
if (vregExprChangeSet.IsEmpty())
if ((vregExprChangeSet.IsEmpty()) && (!hasPendingActualizations))
{
Fail("Error");
SoftFail("Error legalizing vreg expression", NULL);
}
}
}
@ -9377,7 +9384,7 @@ bool BeMCContext::DoLegalization()
// The 3-op form of MUL must be in "reg, r/m64, imm" form
if (!inst->mArg1.IsImmediateInt())
{
Fail("Not supported");
SoftFail("Not supported");
//isFinalRun = false;
break;
}
@ -9508,7 +9515,7 @@ bool BeMCContext::DoLegalization()
{
if (!arg0.IsNativeReg())
{
Fail("xmm reg required");
SoftFail("xmm reg required");
}
}
}
@ -9557,7 +9564,7 @@ bool BeMCContext::DoLegalization()
else if ((checkInst->mKind != BeMCInstKind_Def) && (checkInst->mKind != BeMCInstKind_DbgDecl) &&
(checkInst->mKind != BeMCInstKind_ValueScopeSoftEnd) && (checkInst->mKind != BeMCInstKind_ValueScopeHardEnd))
{
Fail("Malformed");
SoftFail("Malformed");
}
}
break;
@ -9615,7 +9622,7 @@ bool BeMCContext::DoLegalization()
auto vregInfo = mVRegInfo[inst->mArg1.mVRegIdx];
if ((!vregInfo->mIsExpr) && (!vregInfo->mForceMem))
{
Fail("VRegAddr used without ForceMem");
SoftFail("VRegAddr used without ForceMem");
}
}
@ -10066,7 +10073,7 @@ void BeMCContext::DoSanityChecking()
{
// It's possible during legalization to extend the usage of a dynLife value 'upward', and we need
// to ensure we also extend the init flags up as well
Fail("Invalid liveness - from init flag not being set properly?");
SoftFail("Invalid liveness - from init flag not being set properly?");
}
}
}
@ -10732,7 +10739,7 @@ void BeMCContext::DoRegFinalization()
if (inst->mKind == BeMCInstKind_Def)
{
// If we have a Def here, it's because of a legalization that introduced a variable in a non-safe position
Fail("Illegal def");
SoftFail("Illegal def");
}
if (inst->mKind == BeMCInstKind_Mov)
@ -11269,7 +11276,7 @@ void BeMCContext::EmitInst(BeMCInstForm instForm, uint16 codeBytes, BeMCInst* in
case BeMCInstForm_RM64_IMM32:
break;
default:
Fail("Notimpl EmitInst");
SoftFail("Notimpl EmitInst");
}
}
@ -11306,7 +11313,7 @@ void BeMCContext::EmitInst(BeMCInstForm instForm, uint16 codeBytes, uint8 rx, Be
mOut.Write((int64)inst->mArg1.GetImmediateInt());
break;
default:
Fail("Notimpl EmitInst");
SoftFail("Notimpl EmitInst");
}
}
@ -12055,7 +12062,7 @@ void BeMCContext::DoCodeEmission()
}
else if (vregInfo->mRelTo.mKind == BeMCOperandKind_SymbolAddr)
{
Fail("Not supported SymbolAddr");
SoftFail("Not supported SymbolAddr");
//dbgVar->mPrimaryLoc.mKind = BeDbgVariableLoc::Kind_SymbolAddr;
//dbgVar->mPrimaryLoc.mOfs = vregInfo->mRelTo.mSymbolIdx;
}
@ -12473,7 +12480,7 @@ void BeMCContext::DoCodeEmission()
}
else
{
Fail("Error in Mov");
SoftFail("Error in Mov");
}
switch (useTypeCode)
@ -12882,7 +12889,7 @@ void BeMCContext::DoCodeEmission()
Emit(0x0F); Emit(0xB1); EmitModRM(inst->mArg1, inst->mArg0);
break;
default:
Fail("Invalid CmpXChg args");
SoftFail("Invalid CmpXChg args");
}
}
break;
@ -12932,7 +12939,7 @@ void BeMCContext::DoCodeEmission()
Emit(0x0F); Emit(0xC1); EmitModRM(inst->mArg1, inst->mArg0);
break;
default:
Fail("Invalid XAdd args");
SoftFail("Invalid XAdd args");
}
}
break;
@ -14740,10 +14747,8 @@ void BeMCContext::Generate(BeFunction* function)
mDbgPreferredRegs[32] = X64Reg_R8;*/
//mDbgPreferredRegs[8] = X64Reg_RAX;
mDebugging = function->mName ==
//"?TestPrimitives@Nullable@Tests@bf@@SAXXZ"
"?Hey@Blurg@bf@@SAHXZ";
//mDebugging = function->mName ==
//"?ColorizeCodeString@IDEUtils@IDE@bf@@SAXPEAVString@System@3@W4CodeKind@123@@Z";
//"?Main@Program@bf@@CAHPEAV?$Array1@PEAVString@System@bf@@@System@2@@Z";
//"?Hey@Blurg@bf@@SAXXZ";
@ -15669,7 +15674,7 @@ void BeMCContext::Generate(BeFunction* function)
}
else
Fail("Invalid GEP");
SoftFail("Invalid GEP");
}
else
{

View file

@ -1265,7 +1265,7 @@ public:
public:
void NotImpl();
void Fail(const StringImpl& str);
void SoftFail(const StringImpl& str, BeDbgLoc* dbgLoc);
void SoftFail(const StringImpl& str, BeDbgLoc* dbgLoc = NULL);
void ToString(BeMCInst* inst, String& str, bool showVRegFlags, bool showVRegDetails);
String ToString(const BeMCOperand& operand);
String ToString(bool showVRegFlags = true, bool showVRegDetails = false);

View file

@ -1097,7 +1097,7 @@ void BfModule::EnsureIRBuilder(bool dbgVerifyCodeGen)
// code as we walk the AST
//mBfIRBuilder->mDbgVerifyCodeGen = true;
if (
(mModuleName == "Blurg")
(mModuleName == "-")
//|| (mModuleName == "System_Internal")
//|| (mModuleName == "vdata")
//|| (mModuleName == "Hey_Dude_Bro_TestClass")
@ -3747,7 +3747,7 @@ void BfModule::CreateFakeCallerMethod(const String& funcName)
auto paramType = mCurMethodInstance->GetParamType(paramIdx);
if (paramType->IsValuelessType())
continue;
exprEvaluator.PushArg(GetDefaultTypedValue(paramType, true), args);
exprEvaluator.PushArg(GetDefaultTypedValue(paramType, true, paramType->IsComposite() ? BfDefaultValueKind_Addr : BfDefaultValueKind_Const), args);
}
mBfIRBuilder->CreateCall(mCurMethodInstance->mIRFunction, args);

View file

@ -989,7 +989,17 @@ bool DbgType::Equals(DbgType* dbgType)
if (dbgType == NULL)
return false;
if (mTypeCode != dbgType->mTypeCode)
return false;
{
if ((mTypeCode == DbgType_Enum) || (dbgType->mTypeCode == DbgType_Enum))
{
// These may change mTypeCode, so redo the check afterward
GetPrimaryType();
dbgType->GetPrimaryType();
}
if (mTypeCode != dbgType->mTypeCode)
return false;
}
if ((mName == NULL) != (dbgType->mName == NULL))
return false;
if (mName != NULL)
@ -1212,11 +1222,16 @@ void DbgType::FixName()
if ((c == ':') && (inPtr[0] == ':'))
{
modified = true;
inPtr++;
*(outPtr++) = '.';
if (depthCount == 0)
typeNamePtr = outPtr;
if (mLanguage == DbgLanguage_Beef)
{
modified = true;
inPtr++;
*(outPtr++) = '.';
if (depthCount == 0)
typeNamePtr = outPtr;
}
else if (depthCount == 0)
mTypeName = inPtr + 1;
}
else if (modified)
*(outPtr++) = c;
@ -1658,7 +1673,7 @@ void DbgType::ToString(StringImpl& str, DbgLanguage language, bool allowDirectBf
nameP = combName.c_str();
}*/
if ((!mFixedName) && (language == DbgLanguage_Beef))
if ((!mFixedName) /*&& (language == DbgLanguage_Beef)*/)
{
FixName();
}