1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 14:24:10 +02:00

More Fail info, better fail on OperandToAddr

This commit is contained in:
Brian Fiete 2020-08-03 10:00:32 -07:00
parent 99c7a9fe1f
commit 7e843bb402
2 changed files with 5783 additions and 5768 deletions

File diff suppressed because it is too large Load diff

View file

@ -18,17 +18,17 @@ public:
}; };
struct BeVTrackingBits struct BeVTrackingBits
{ {
// Memory is allocated by BeVTrackingContext // Memory is allocated by BeVTrackingContext
bool IsSet(int idx); bool IsSet(int idx);
void Set(int idx); void Set(int idx);
void Clear(int idx); void Clear(int idx);
}; };
struct BeVTrackingValue struct BeVTrackingValue
{ {
public: public:
BeVTrackingBits* mEntry; BeVTrackingBits* mEntry;
int mNumEntries; int mNumEntries;
BeVTrackingValue(int maxSize) BeVTrackingValue(int maxSize)
@ -41,7 +41,7 @@ public:
~BeVTrackingValue() ~BeVTrackingValue()
{ {
delete[](int32*)mEntry; delete[](int32*)mEntry;
} }
void Clear() void Clear()
{ {
@ -60,13 +60,13 @@ public:
{ {
public: public:
BeVTrackingList* mList; BeVTrackingList* mList;
int mIdx; int mIdx;
public: public:
Iterator(BeVTrackingList* list) Iterator(BeVTrackingList* list)
{ {
mList = list; mList = list;
mIdx = 0; mIdx = 0;
} }
Iterator& operator++() Iterator& operator++()
@ -147,7 +147,7 @@ struct BeMemSetInfo
{ {
public: public:
int32 mSize; int32 mSize;
int8 mAlign; int8 mAlign;
uint8 mValue; uint8 mValue;
}; };
@ -155,7 +155,7 @@ struct BeMemCpyInfo
{ {
public: public:
int32 mSize; int32 mSize;
int8 mAlign; int8 mAlign;
}; };
struct BeVRegPair struct BeVRegPair
@ -166,14 +166,14 @@ struct BeVRegPair
}; };
struct BeCmpResult struct BeCmpResult
{ {
BeCmpKind mCmpKind; BeCmpKind mCmpKind;
int mResultVRegIdx; int mResultVRegIdx;
BeCmpResult() BeCmpResult()
{ {
mCmpKind = BeCmpKind_None; mCmpKind = BeCmpKind_None;
mResultVRegIdx = -1; mResultVRegIdx = -1;
} }
}; };
@ -182,7 +182,7 @@ struct BeNotResult;
enum BeMCOperandKind enum BeMCOperandKind
{ {
BeMCOperandKind_None, BeMCOperandKind_None,
BeMCOperandKind_NativeReg, BeMCOperandKind_NativeReg,
BeMCOperandKind_VReg, BeMCOperandKind_VReg,
BeMCOperandKind_VRegAddr, BeMCOperandKind_VRegAddr,
BeMCOperandKind_VRegLoad, BeMCOperandKind_VRegLoad,
@ -199,7 +199,7 @@ enum BeMCOperandKind
BeMCOperandKind_Immediate_f64_Packed128, BeMCOperandKind_Immediate_f64_Packed128,
BeMCOperandKind_ConstAgg, BeMCOperandKind_ConstAgg,
BeMCOperandKind_Block, BeMCOperandKind_Block,
BeMCOperandKind_Label, BeMCOperandKind_Label,
BeMCOperandKind_CmpKind, BeMCOperandKind_CmpKind,
BeMCOperandKind_CmpResult, BeMCOperandKind_CmpResult,
BeMCOperandKind_NotResult, BeMCOperandKind_NotResult,
@ -218,7 +218,7 @@ enum BeMCPreserveFlag
class BeMCOperand class BeMCOperand
{ {
public: public:
enum EncodeFlag enum EncodeFlag
{ {
EncodeFlag_Addr = 0x80000000, EncodeFlag_Addr = 0x80000000,
@ -226,7 +226,7 @@ public:
EncodeFlag_IdxMask = 0x0FFFFFFF EncodeFlag_IdxMask = 0x0FFFFFFF
}; };
BeMCOperandKind mKind; BeMCOperandKind mKind;
union union
{ {
X64CPURegister mReg; X64CPURegister mReg;
@ -242,25 +242,25 @@ public:
BeConstant* mConstant; BeConstant* mConstant;
int mLabelIdx; int mLabelIdx;
int mSymbolIdx; int mSymbolIdx;
BeCmpKind mCmpKind; BeCmpKind mCmpKind;
int mCmpResultIdx; int mCmpResultIdx;
BeMemSetInfo mMemSetInfo; BeMemSetInfo mMemSetInfo;
BeMemCpyInfo mMemCpyInfo; BeMemCpyInfo mMemCpyInfo;
BeVRegPair mVRegPair; BeVRegPair mVRegPair;
BeMCPreserveFlag mPreserveFlag; BeMCPreserveFlag mPreserveFlag;
}; };
public: public:
BeMCOperand() BeMCOperand()
{ {
mKind = BeMCOperandKind_None; mKind = BeMCOperandKind_None;
} }
operator bool() const operator bool() const
{ {
return mKind != BeMCOperandKind_None; return mKind != BeMCOperandKind_None;
} }
bool IsVReg() const bool IsVReg() const
{ {
return (mKind == BeMCOperandKind_VReg); return (mKind == BeMCOperandKind_VReg);
@ -270,7 +270,7 @@ public:
{ {
return (mKind == BeMCOperandKind_VReg) || (mKind == BeMCOperandKind_VRegAddr) || (mKind == BeMCOperandKind_VRegLoad); return (mKind == BeMCOperandKind_VReg) || (mKind == BeMCOperandKind_VRegAddr) || (mKind == BeMCOperandKind_VRegLoad);
} }
bool MayBeMemory() bool MayBeMemory()
{ {
return (mKind >= BeMCOperandKind_VReg) && (mKind <= BeMCOperandKind_SymbolAddr); return (mKind >= BeMCOperandKind_VReg) && (mKind <= BeMCOperandKind_SymbolAddr);
@ -300,7 +300,7 @@ public:
{ {
return (mKind == BeMCOperandKind_Symbol) || (mKind == BeMCOperandKind_SymbolAddr); return (mKind == BeMCOperandKind_Symbol) || (mKind == BeMCOperandKind_SymbolAddr);
} }
bool operator==(const BeMCOperand& other) const bool operator==(const BeMCOperand& other) const
{ {
if (mKind != other.mKind) if (mKind != other.mKind)
@ -351,7 +351,7 @@ public:
return mImmF64; return mImmF64;
return 0; return 0;
} }
static BeMCOperand FromEncoded(int vregIdx) static BeMCOperand FromEncoded(int vregIdx)
{ {
BeMCOperand operand; BeMCOperand operand;
@ -370,9 +370,9 @@ public:
else else
operand.mKind = BeMCOperandKind_VReg; operand.mKind = BeMCOperandKind_VReg;
} }
return operand; return operand;
} }
static BeMCOperand ToLoad(const BeMCOperand& operand) static BeMCOperand ToLoad(const BeMCOperand& operand)
{ {
@ -388,20 +388,6 @@ public:
return loadedOperand; return loadedOperand;
} }
static BeMCOperand ToAddr(const BeMCOperand& operand)
{
BeMCOperand loadedOperand = operand;
if (loadedOperand.mKind == BeMCOperandKind_VRegLoad)
loadedOperand.mKind = BeMCOperandKind_VReg;
else if (loadedOperand.mKind == BeMCOperandKind_VReg)
loadedOperand.mKind = BeMCOperandKind_VRegAddr;
else if (loadedOperand.mKind == BeMCOperandKind_Symbol)
loadedOperand.mKind = BeMCOperandKind_SymbolAddr;
else
BF_FATAL("Bad");
return loadedOperand;
}
static BeMCOperand FromVReg(int vregIdx) static BeMCOperand FromVReg(int vregIdx)
{ {
BeMCOperand operand; BeMCOperand operand;
@ -464,7 +450,7 @@ public:
operand.mKind = BeMCOperandKind_Symbol; operand.mKind = BeMCOperandKind_Symbol;
operand.mSymbolIdx = symIdx; operand.mSymbolIdx = symIdx;
return operand; return operand;
} }
static BeMCOperand FromSymbolAddr(int symIdx) static BeMCOperand FromSymbolAddr(int symIdx)
{ {
@ -472,7 +458,7 @@ public:
operand.mKind = BeMCOperandKind_SymbolAddr; operand.mKind = BeMCOperandKind_SymbolAddr;
operand.mSymbolIdx = symIdx; operand.mSymbolIdx = symIdx;
return operand; return operand;
} }
static BeMCOperand FromPreserveFlag(BeMCPreserveFlag preserveFlag) static BeMCOperand FromPreserveFlag(BeMCPreserveFlag preserveFlag)
{ {
@ -499,11 +485,11 @@ enum BeMCInstKind
BeMCInstKind_DbgRangeStart, BeMCInstKind_DbgRangeStart,
BeMCInstKind_DbgRangeEnd, // Extends life of local variables/arguments to their lexical scope end BeMCInstKind_DbgRangeEnd, // Extends life of local variables/arguments to their lexical scope end
BeMCInstKind_LifetimeExtend, BeMCInstKind_LifetimeExtend,
BeMCInstKind_LifetimeStart, BeMCInstKind_LifetimeStart,
BeMCInstKind_LifetimeEnd, BeMCInstKind_LifetimeEnd,
BeMCInstKind_ValueScopeSoftEnd, BeMCInstKind_ValueScopeSoftEnd,
BeMCInstKind_ValueScopeHardEnd, BeMCInstKind_ValueScopeHardEnd,
BeMCInstKind_Label, BeMCInstKind_Label,
BeMCInstKind_CmpToBool, BeMCInstKind_CmpToBool,
BeMCInstKind_MemSet, BeMCInstKind_MemSet,
BeMCInstKind_MemCpy, BeMCInstKind_MemCpy,
@ -514,9 +500,9 @@ enum BeMCInstKind
BeMCInstKind_Unwind_PushReg, BeMCInstKind_Unwind_PushReg,
BeMCInstKind_Unwind_SaveXMM, BeMCInstKind_Unwind_SaveXMM,
BeMCInstKind_Unwind_Alloc, BeMCInstKind_Unwind_Alloc,
BeMCInstKind_Unwind_SetBP, BeMCInstKind_Unwind_SetBP,
BeMCInstKind_Rem, BeMCInstKind_Rem,
BeMCInstKind_IRem, BeMCInstKind_IRem,
// Legal instructions // Legal instructions
BeMCInstKind_Nop, BeMCInstKind_Nop,
@ -524,9 +510,9 @@ enum BeMCInstKind
BeMCInstKind_EnsureInstructionAt, BeMCInstKind_EnsureInstructionAt,
BeMCInstKind_DbgBreak, BeMCInstKind_DbgBreak,
BeMCInstKind_MFence, BeMCInstKind_MFence,
BeMCInstKind_Mov, BeMCInstKind_Mov,
BeMCInstKind_MovRaw, BeMCInstKind_MovRaw,
BeMCInstKind_MovSX, BeMCInstKind_MovSX,
BeMCInstKind_XChg, BeMCInstKind_XChg,
BeMCInstKind_XAdd, BeMCInstKind_XAdd,
BeMCInstKind_CmpXChg, BeMCInstKind_CmpXChg,
@ -536,13 +522,13 @@ enum BeMCInstKind
BeMCInstKind_Pop, BeMCInstKind_Pop,
BeMCInstKind_Neg, BeMCInstKind_Neg,
BeMCInstKind_Not, BeMCInstKind_Not,
BeMCInstKind_Add, BeMCInstKind_Add,
BeMCInstKind_Sub, BeMCInstKind_Sub,
BeMCInstKind_Mul, BeMCInstKind_Mul,
BeMCInstKind_IMul, BeMCInstKind_IMul,
BeMCInstKind_Div, BeMCInstKind_Div,
BeMCInstKind_IDiv, BeMCInstKind_IDiv,
BeMCInstKind_Cmp, BeMCInstKind_Cmp,
BeMCInstKind_And, BeMCInstKind_And,
BeMCInstKind_Or, BeMCInstKind_Or,
BeMCInstKind_Xor, BeMCInstKind_Xor,
@ -575,17 +561,17 @@ struct BeVRegLastUseRecord
class BeMCInst class BeMCInst
{ {
public: public:
BeMCInstKind mKind; BeMCInstKind mKind;
BeMCOperand mResult; BeMCOperand mResult;
BeMCOperand mArg0; BeMCOperand mArg0;
BeMCOperand mArg1; BeMCOperand mArg1;
BeVTrackingList* mLiveness; BeVTrackingList* mLiveness;
BeVTrackingList* mVRegsInitialized; BeVTrackingList* mVRegsInitialized;
BeVRegLastUseRecord* mVRegLastUseRecord; BeVRegLastUseRecord* mVRegLastUseRecord;
BeDbgLoc* mDbgLoc; BeDbgLoc* mDbgLoc;
bool IsDef() bool IsDef()
{ {
return (mKind == BeMCInstKind_Def) || (mKind == BeMCInstKind_DefLoad); return (mKind == BeMCInstKind_Def) || (mKind == BeMCInstKind_DefLoad);
@ -624,8 +610,8 @@ public:
bool IsPsuedo() bool IsPsuedo()
{ {
return (mKind <= BeMCInstKind_Unwind_SetBP); return (mKind <= BeMCInstKind_Unwind_SetBP);
} }
BeMCOperand* GetDest() BeMCOperand* GetDest()
{ {
if (mResult) if (mResult)
@ -650,15 +636,15 @@ public:
case BeMCInstKind_IDiv: case BeMCInstKind_IDiv:
case BeMCInstKind_And: case BeMCInstKind_And:
case BeMCInstKind_Or: case BeMCInstKind_Or:
case BeMCInstKind_Xor: case BeMCInstKind_Xor:
case BeMCInstKind_Shl: case BeMCInstKind_Shl:
case BeMCInstKind_Shr: case BeMCInstKind_Shr:
case BeMCInstKind_Sar: case BeMCInstKind_Sar:
return &mArg0; return &mArg0;
} }
return NULL; return NULL;
} }
}; };
class BeMCBlock class BeMCBlock
@ -683,15 +669,15 @@ public:
BeMCBlock() BeMCBlock()
{ {
mLabelIdx = -1; mLabelIdx = -1;
mIsLooped = false; mIsLooped = false;
mBlockIdx = -1; mBlockIdx = -1;
mMaxDeclBlockId = -1; mMaxDeclBlockId = -1;
mSuccLiveness = NULL; mSuccLiveness = NULL;
mSuccVRegsInitialized = NULL; mSuccVRegsInitialized = NULL;
mPredVRegsInitialized = NULL; mPredVRegsInitialized = NULL;
} }
void AddPred(BeMCBlock* pred); void AddPred(BeMCBlock* pred);
int FindLabelInstIdx(int labelIdx); int FindLabelInstIdx(int labelIdx);
}; };
@ -725,7 +711,7 @@ public:
} }
void Next(); void Next();
bool HasMore() bool HasMore()
{ {
return mReadIdx < mBlock->mInstructions.mSize; return mReadIdx < mBlock->mInstructions.mSize;
@ -746,14 +732,14 @@ class BeMCPhiValue
{ {
public: public:
BeMCBlock* mBlockFrom; BeMCBlock* mBlockFrom;
BeMCOperand mValue; BeMCOperand mValue;
int mLandingLabel; int mLandingLabel;
}; };
class BeMCPhi class BeMCPhi
{ {
public: public:
BeMCBlock* mBlock; BeMCBlock* mBlock;
Array<BeMCPhiValue> mValues; Array<BeMCPhiValue> mValues;
int mIdx; int mIdx;
@ -765,7 +751,7 @@ enum BeMCRMMode
{ {
BeMCRMMode_Invalid, BeMCRMMode_Invalid,
BeMCRMMode_Direct, BeMCRMMode_Direct,
BeMCRMMode_Deref BeMCRMMode_Deref
}; };
enum BeMCValueScopeRetainKind : uint8 enum BeMCValueScopeRetainKind : uint8
@ -795,7 +781,7 @@ public:
bool mSpilled; bool mSpilled;
BeMCValueScopeRetainKind mValueScopeRetainedKind; BeMCValueScopeRetainKind mValueScopeRetainedKind;
bool mAwaitingDbgStart; bool mAwaitingDbgStart;
bool mHasAmbiguousInitialization; bool mHasAmbiguousInitialization;
bool mIsRetVal; bool mIsRetVal;
bool mForceMerge; // Original param, not the 'debug holder' bool mForceMerge; // Original param, not the 'debug holder'
bool mDefOnFirstUse; bool mDefOnFirstUse;
@ -807,25 +793,25 @@ public:
bool mDisableEx; // Disable any registers that require a REX bool mDisableEx; // Disable any registers that require a REX
int mVRegAffinity; // Try to match the mReg of this vreg int mVRegAffinity; // Try to match the mReg of this vreg
BeMCOperand mRelTo; BeMCOperand mRelTo;
int mRelOffsetScale; int mRelOffsetScale;
BeMCOperand mRelOffset; BeMCOperand mRelOffset;
int mVolatileVRegSave; int mVolatileVRegSave;
BeDbgVariable* mDbgVariable; BeDbgVariable* mDbgVariable;
bool mFoundLastUse; bool mFoundLastUse;
bool mMustExist; // Regs we must be able to debug bool mMustExist; // Regs we must be able to debug
// Must be refreshed with RefreshRefCounts // Must be refreshed with RefreshRefCounts
int mRefCount; int mRefCount;
int mAssignCount; int mAssignCount;
public: public:
BeMCVRegInfo() BeMCVRegInfo()
{ {
mAlign = -1; mAlign = -1;
mRegNumPinned = false; mRegNumPinned = false;
mReg = X64Reg_None; mReg = X64Reg_None;
mNaturalReg = X64Reg_None; mNaturalReg = X64Reg_None;
mType = NULL; mType = NULL;
mIsExpr = false; mIsExpr = false;
mWantsExprActualize = false; mWantsExprActualize = false;
mWantsExprOffsetActualize = false; mWantsExprOffsetActualize = false;
@ -853,7 +839,7 @@ public:
mRefCount = -1; mRefCount = -1;
mAssignCount = -1; mAssignCount = -1;
mVolatileVRegSave = -1; mVolatileVRegSave = -1;
mMustExist = false; mMustExist = false;
mIsRetVal = false; mIsRetVal = false;
mFoundLastUse = false; mFoundLastUse = false;
} }
@ -874,14 +860,14 @@ public:
bool IsDirectRelTo() bool IsDirectRelTo()
{ {
return ((mRelTo.mKind == BeMCOperandKind_VReg) || (mRelTo.mKind == BeMCOperandKind_NativeReg)) && return ((mRelTo.mKind == BeMCOperandKind_VReg) || (mRelTo.mKind == BeMCOperandKind_NativeReg)) &&
(mRelOffset.IsZero()) && (mRelOffsetScale == 1); (mRelOffset.IsZero()) && (mRelOffsetScale == 1);
} }
bool IsDirectRelToAny() bool IsDirectRelToAny()
{ {
return (mRelTo) && (mRelOffset.IsZero()) && (mRelOffsetScale == 1); return (mRelTo) && (mRelOffset.IsZero()) && (mRelOffsetScale == 1);
} }
void SetRetVal() void SetRetVal()
{ {
//BF_ASSERT(!mForceMem); //BF_ASSERT(!mForceMem);
@ -896,45 +882,45 @@ enum BeMCInstForm
BeMCInstForm_R8_RM8, BeMCInstForm_R8_RM8,
BeMCInstForm_R16_RM16, BeMCInstForm_R16_RM16,
BeMCInstForm_R32_RM32, BeMCInstForm_R32_RM32,
BeMCInstForm_R64_RM64, BeMCInstForm_R64_RM64,
BeMCInstForm_R8_RM64_ADDR, BeMCInstForm_R8_RM64_ADDR,
BeMCInstForm_R16_RM64_ADDR, BeMCInstForm_R16_RM64_ADDR,
BeMCInstForm_R32_RM64_ADDR, BeMCInstForm_R32_RM64_ADDR,
BeMCInstForm_R64_RM64_ADDR, BeMCInstForm_R64_RM64_ADDR,
BeMCInstForm_RM8_R8, BeMCInstForm_RM8_R8,
BeMCInstForm_RM16_R16, BeMCInstForm_RM16_R16,
BeMCInstForm_RM32_R32, BeMCInstForm_RM32_R32,
BeMCInstForm_RM64_R64, BeMCInstForm_RM64_R64,
BeMCInstForm_RM64_R8_ADDR, BeMCInstForm_RM64_R8_ADDR,
BeMCInstForm_RM64_R16_ADDR, BeMCInstForm_RM64_R16_ADDR,
BeMCInstForm_RM64_R32_ADDR, BeMCInstForm_RM64_R32_ADDR,
BeMCInstForm_RM64_R64_ADDR, BeMCInstForm_RM64_R64_ADDR,
BeMCInstForm_RM8_IMM8, BeMCInstForm_RM8_IMM8,
BeMCInstForm_RM16_IMM8, BeMCInstForm_RM16_IMM8,
BeMCInstForm_RM32_IMM8, BeMCInstForm_RM32_IMM8,
BeMCInstForm_RM64_IMM8, BeMCInstForm_RM64_IMM8,
BeMCInstForm_RM16_IMM16, BeMCInstForm_RM16_IMM16,
BeMCInstForm_RM32_IMM16, BeMCInstForm_RM32_IMM16,
BeMCInstForm_RM64_IMM16, BeMCInstForm_RM64_IMM16,
BeMCInstForm_RM32_IMM32, BeMCInstForm_RM32_IMM32,
BeMCInstForm_RM64_IMM32, BeMCInstForm_RM64_IMM32,
BeMCInstForm_RM64_IMM64, BeMCInstForm_RM64_IMM64,
BeMCInstForm_RM8, BeMCInstForm_RM8,
BeMCInstForm_RM16, BeMCInstForm_RM16,
BeMCInstForm_RM32, BeMCInstForm_RM32,
BeMCInstForm_RM64, BeMCInstForm_RM64,
BeMCInstForm_IMM32, BeMCInstForm_IMM32,
BeMCInstForm_R8, BeMCInstForm_R8,
BeMCInstForm_R16, BeMCInstForm_R16,
BeMCInstForm_R32, BeMCInstForm_R32,
BeMCInstForm_R64, BeMCInstForm_R64,
BeMCInstForm_XMM32_IMM, BeMCInstForm_XMM32_IMM,
BeMCInstForm_XMM64_IMM, BeMCInstForm_XMM64_IMM,
BeMCInstForm_XMM32_FRM32, BeMCInstForm_XMM32_FRM32,
BeMCInstForm_XMM64_FRM32, BeMCInstForm_XMM64_FRM32,
BeMCInstForm_XMM32_FRM64, BeMCInstForm_XMM32_FRM64,
BeMCInstForm_XMM64_FRM64, BeMCInstForm_XMM64_FRM64,
BeMCInstForm_FRM32_XMM32, BeMCInstForm_FRM32_XMM32,
BeMCInstForm_FRM64_XMM32, BeMCInstForm_FRM64_XMM32,
BeMCInstForm_FRM32_XMM64, BeMCInstForm_FRM32_XMM64,
@ -943,7 +929,7 @@ enum BeMCInstForm
BeMCInstForm_XMM64_RM32, BeMCInstForm_XMM64_RM32,
BeMCInstForm_XMM32_RM64, BeMCInstForm_XMM32_RM64,
BeMCInstForm_XMM64_RM64, BeMCInstForm_XMM64_RM64,
BeMCInstForm_R32_F32, BeMCInstForm_R32_F32,
BeMCInstForm_R64_F32, BeMCInstForm_R64_F32,
BeMCInstForm_R32_F64, BeMCInstForm_R32_F64,
BeMCInstForm_R64_F64, BeMCInstForm_R64_F64,
@ -960,7 +946,7 @@ enum BeTrackKind
BetTrackKind_Default = 0, BetTrackKind_Default = 0,
// Liveness // Liveness
BeTrackKind_Exists = 0, BeTrackKind_Exists = 0,
// Initialized // Initialized
BeTrackKind_Initialized = 0, BeTrackKind_Initialized = 0,
@ -1000,11 +986,11 @@ public:
public: public:
BeVTrackingContext(BeMCContext* mcContext); BeVTrackingContext(BeMCContext* mcContext);
void Init(int numItems); void Init(int numItems);
void Clear(); void Clear();
int GetBitsBytes(); int GetBitsBytes();
int GetIdx(int baseIdx, BeTrackKind trackKind); int GetIdx(int baseIdx, BeTrackKind trackKind);
void Print(BeVTrackingList* list); void Print(BeVTrackingList* list);
BeVTrackingList* AllocEmptyList(); BeVTrackingList* AllocEmptyList();
@ -1019,8 +1005,8 @@ public:
bool IsSet(BeVTrackingList* entry, int idx, BeTrackKind trackKind); bool IsSet(BeVTrackingList* entry, int idx, BeTrackKind trackKind);
BeVTrackingList* Clear(BeVTrackingList* list, const SizedArrayImpl<int>& indices); BeVTrackingList* Clear(BeVTrackingList* list, const SizedArrayImpl<int>& indices);
bool IsEmpty(BeVTrackingList* list); bool IsEmpty(BeVTrackingList* list);
BeVTrackingList* Merge(BeVTrackingList* prevDestEntry, BeVTrackingList* mergeFrom); BeVTrackingList* Merge(BeVTrackingList* prevDestEntry, BeVTrackingList* mergeFrom);
BeVTrackingList* MergeChanges(BeVTrackingList* prevDestEntry, BeVTrackingList* mergeFrom); BeVTrackingList* MergeChanges(BeVTrackingList* prevDestEntry, BeVTrackingList* mergeFrom);
BeVTrackingList* SetChanges(BeVTrackingList* prevDestEntry, BeVTrackingList* mergeFrom); BeVTrackingList* SetChanges(BeVTrackingList* prevDestEntry, BeVTrackingList* mergeFrom);
BeVTrackingList* RemoveChange(BeVTrackingList* prevDestEntry, int idx); BeVTrackingList* RemoveChange(BeVTrackingList* prevDestEntry, int idx);
}; };
@ -1056,7 +1042,7 @@ public:
class BeMCColorizer class BeMCColorizer
{ {
public: public:
struct Node struct Node
{ {
HashSet<int> mEdges; HashSet<int> mEdges;
@ -1100,11 +1086,11 @@ public:
struct BlockInfo struct BlockInfo
{ {
HashSet<X64CPURegister> mSuccLiveRegs; HashSet<X64CPURegister> mSuccLiveRegs;
bool mEntryCount; bool mEntryCount;
BlockInfo() BlockInfo()
{ {
mEntryCount = 0; mEntryCount = 0;
} }
}; };
@ -1116,14 +1102,14 @@ public:
Array<BlockInfo> mBlockInfo; Array<BlockInfo> mBlockInfo;
Array<Node> mNodes; Array<Node> mNodes;
BeMCContext* mContext; BeMCContext* mContext;
bool mReserveParamRegs; bool mReserveParamRegs;
public: public:
BeMCColorizer(BeMCContext* mcContext); BeMCColorizer(BeMCContext* mcContext);
void Prepare(); void Prepare();
void AddEdge(int vreg0, int vreg1); void AddEdge(int vreg0, int vreg1);
void PropogateMemCost(const BeMCOperand& operand, int memCost); void PropogateMemCost(const BeMCOperand& operand, int memCost);
void GenerateRegCosts(); void GenerateRegCosts();
void AssignRegs(RegKind regKind); // Returns false if we had spills - we need to rerun void AssignRegs(RegKind regKind); // Returns false if we had spills - we need to rerun
@ -1189,7 +1175,7 @@ public:
toNode->mFrom = from; toNode->mFrom = from;
fromNode->mTo = to; fromNode->mTo = to;
return; return;
} }
} }
int GetHead(int idx) int GetHead(int idx)
@ -1253,7 +1239,7 @@ public:
int mGenerateCount; int mGenerateCount;
Entry() Entry()
{ {
mGenerateQueued = false; mGenerateQueued = false;
mGenerateCount = 0; mGenerateCount = 0;
} }
@ -1271,7 +1257,7 @@ public:
{ {
mCalls = 0; mCalls = 0;
mHandledCalls = 0; mHandledCalls = 0;
mInstructions = 0; mInstructions = 0;
mEmptyList = NULL; mEmptyList = NULL;
} }
}; };
@ -1283,7 +1269,7 @@ struct BeRMParamsInfo
int mBScale; int mBScale;
int mDisp; int mDisp;
BeMCRMMode mMode; BeMCRMMode mMode;
int mErrorVReg; int mErrorVReg;
int mVRegWithScaledOffset; int mVRegWithScaledOffset;
@ -1291,8 +1277,8 @@ struct BeRMParamsInfo
{ {
mRegA = X64Reg_None; mRegA = X64Reg_None;
mRegB = X64Reg_None; mRegB = X64Reg_None;
mBScale = 1; mBScale = 1;
mDisp = 0; mDisp = 0;
mMode = BeMCRMMode_Invalid; mMode = BeMCRMMode_Invalid;
mErrorVReg = -1; mErrorVReg = -1;
@ -1305,10 +1291,10 @@ class BeMCContext
{ {
public: public:
BeCOFFObject* mCOFFObject; BeCOFFObject* mCOFFObject;
DynMemStream& mOut; DynMemStream& mOut;
bool mDebugging; bool mDebugging;
bool mFailed; bool mFailed;
int mDetectLoopIdx; int mDetectLoopIdx;
BeVTrackingContext mLivenessContext; BeVTrackingContext mLivenessContext;
BeVTrackingContext mVRegInitializedContext; BeVTrackingContext mVRegInitializedContext;
@ -1322,58 +1308,59 @@ public:
BeType* mNativeIntType; BeType* mNativeIntType;
BeModule* mModule; BeModule* mModule;
BeMCBlock* mActiveBlock; BeMCBlock* mActiveBlock;
BeMCInst* mActiveInst;
int* mInsertInstIdxRef; int* mInsertInstIdxRef;
BeBlock* mActiveBeBlock; BeBlock* mActiveBeBlock;
BeFunction* mBeFunction; BeFunction* mBeFunction;
BeDbgFunction* mDbgFunction; BeDbgFunction* mDbgFunction;
Array<BeMCVRegInfo*> mVRegInfo; Array<BeMCVRegInfo*> mVRegInfo;
Array<BeCmpResult> mCmpResults; Array<BeCmpResult> mCmpResults;
int mCompositeRetVRegIdx; int mCompositeRetVRegIdx;
int mTLSVRegIdx; int mTLSVRegIdx;
int mLegalizationIterations; int mLegalizationIterations;
Array<int> mCallArgVRegs[BeMCNativeTypeCode_COUNT]; Array<int> mCallArgVRegs[BeMCNativeTypeCode_COUNT];
int mStackSize; int mStackSize;
bool mUseBP; bool mUseBP;
int mCurLabelIdx; int mCurLabelIdx;
int mCurPhiIdx; int mCurPhiIdx;
int mMaxCallParamCount; // -1 if we have no calls int mMaxCallParamCount; // -1 if we have no calls
Array<X64CPURegister> mParamsUsedRegs; Array<X64CPURegister> mParamsUsedRegs;
HashSet<X64CPURegister> mUsedRegs; HashSet<X64CPURegister> mUsedRegs;
BeDbgLoc* mCurDbgLoc; BeDbgLoc* mCurDbgLoc;
BeVTrackingList* mCurVRegsInit; BeVTrackingList* mCurVRegsInit;
BeVTrackingList* mCurVRegsLive; BeVTrackingList* mCurVRegsLive;
Array<int> mTextRelocs; Array<int> mTextRelocs;
Array<BeMCSwitchEntry> mSwitchEntries; Array<BeMCSwitchEntry> mSwitchEntries;
Dictionary<int, X64CPURegister> mDbgPreferredRegs; Dictionary<int, X64CPURegister> mDbgPreferredRegs;
public: public:
void NotImpl(); void NotImpl();
void Fail(const StringImpl& str); void Fail(const StringImpl& str);
void SoftFail(const StringImpl& str, BeDbgLoc* dbgLoc = NULL); void SoftFail(const StringImpl& str, BeDbgLoc* dbgLoc = NULL);
void ToString(BeMCInst* inst, String& str, bool showVRegFlags, bool showVRegDetails); void ToString(BeMCInst* inst, String& str, bool showVRegFlags, bool showVRegDetails);
String ToString(const BeMCOperand& operand); String ToString(const BeMCOperand& operand);
String ToString(bool showVRegFlags = true, bool showVRegDetails = false); String ToString(bool showVRegFlags = true, bool showVRegDetails = false);
void Print(bool showVRegFlags, bool showVRegDetails); void Print(bool showVRegFlags, bool showVRegDetails);
void Print(); void Print();
BeMCOperand GetOperand(BeValue* value, bool allowMetaResult = false, bool allowFail = false); // Meta results are PHIs or CmpResults BeMCOperand GetOperand(BeValue* value, bool allowMetaResult = false, bool allowFail = false); // Meta results are PHIs or CmpResults
BeMCOperand CreateNot(const BeMCOperand& operand); BeMCOperand CreateNot(const BeMCOperand& operand);
BeType* GetType(const BeMCOperand& operand); BeType* GetType(const BeMCOperand& operand);
bool AreTypesEquivalent(BeType* type0, BeType* type1); bool AreTypesEquivalent(BeType* type0, BeType* type1);
void AddRelRefs(BeMCOperand& operand, int refCount); void AddRelRefs(BeMCOperand& operand, int refCount);
int FindSafeInstInsertPos(int instIdx, bool forceSafeCheck = false); int FindSafeInstInsertPos(int instIdx, bool forceSafeCheck = false);
BeMCInst* AllocInst(int insertIdx = -1); BeMCInst* AllocInst(int insertIdx = -1);
BeMCInst* AllocInst(BeMCInstKind instKind, int insertIdx = -1); BeMCInst* AllocInst(BeMCInstKind instKind, int insertIdx = -1);
BeMCInst* AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0, int insertIdx = -1); BeMCInst* AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0, int insertIdx = -1);
BeMCInst* AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0, const BeMCOperand& arg1, int insertIdx = -1); BeMCInst* AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0, const BeMCOperand& arg1, int insertIdx = -1);
void MergeInstFlags(BeMCInst* prevInst, BeMCInst* inst, BeMCInst* nextInst); void MergeInstFlags(BeMCInst* prevInst, BeMCInst* inst, BeMCInst* nextInst);
void RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerged = true, bool removeFromList = true); void RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerged = true, bool removeFromList = true);
BeMCOperand AllocBinaryOp(BeMCInstKind instKind, const BeMCOperand & lhs, const BeMCOperand & rhs, BeMCBinIdentityKind identityKind); BeMCOperand AllocBinaryOp(BeMCInstKind instKind, const BeMCOperand & lhs, const BeMCOperand & rhs, BeMCBinIdentityKind identityKind);
BeMCOperand GetCallArgVReg(int argIdx, BeTypeCode typeCode); BeMCOperand GetCallArgVReg(int argIdx, BeTypeCode typeCode);
BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeMCOperand>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, bool isVarArg = false); BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeMCOperand>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, bool isVarArg = false);
BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeValue*>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, bool isVarArg = false); BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeValue*>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, bool isVarArg = false);
BeMCOperand CreateLoad(const BeMCOperand& mcTarget); BeMCOperand CreateLoad(const BeMCOperand& mcTarget);
void CreateStore(BeMCInstKind instKind, const BeMCOperand& val, const BeMCOperand& ptr); void CreateStore(BeMCInstKind instKind, const BeMCOperand& val, const BeMCOperand& ptr);
void CreateMemSet(const BeMCOperand& addr, uint8 val, int size, int align); void CreateMemSet(const BeMCOperand& addr, uint8 val, int size, int align);
@ -1381,8 +1368,9 @@ public:
void CreateTableSwitchSection(BeSwitchInst* switchInst, int startIdx, int endIdx); void CreateTableSwitchSection(BeSwitchInst* switchInst, int startIdx, int endIdx);
void CreateBinarySwitchSection(BeSwitchInst* switchInst, int startIdx, int endIdx); void CreateBinarySwitchSection(BeSwitchInst* switchInst, int startIdx, int endIdx);
void CreateCondBr(BeMCBlock* mcBlock, BeMCOperand& testVal, const BeMCOperand& trueBlock, const BeMCOperand& falseBlock); void CreateCondBr(BeMCBlock* mcBlock, BeMCOperand& testVal, const BeMCOperand& trueBlock, const BeMCOperand& falseBlock);
void CreatePhiAssign(BeMCBlock* mcBlock, const BeMCOperand& testVal, const BeMCOperand& result, const BeMCOperand& doneLabel); void CreatePhiAssign(BeMCBlock* mcBlock, const BeMCOperand& testVal, const BeMCOperand& result, const BeMCOperand& doneLabel);
BeMCOperand GetImmediate(int64 val); BeMCOperand GetImmediate(int64 val);
BeMCOperand OperandToAddr(const BeMCOperand& operand);
BeMCOperand GetVReg(int regNum); BeMCOperand GetVReg(int regNum);
BeMCOperand AllocVirtualReg(BeType* type, int refCount = -1, bool mustBeReg = false); BeMCOperand AllocVirtualReg(BeType* type, int refCount = -1, bool mustBeReg = false);
int GetUnderlyingVReg(int vregIdx); int GetUnderlyingVReg(int vregIdx);
@ -1392,23 +1380,23 @@ public:
BeMCInst* CreateDefineVReg(const BeMCOperand& vreg, int insertIdx = -1); BeMCInst* CreateDefineVReg(const BeMCOperand& vreg, int insertIdx = -1);
int CreateLabel(int insertIdx = -1, int labelIdx = -1); int CreateLabel(int insertIdx = -1, int labelIdx = -1);
bool FindTarget(const BeMCOperand& loc, BeMCBlock*& outBlock, int& outInstIdx); bool FindTarget(const BeMCOperand& loc, BeMCBlock*& outBlock, int& outInstIdx);
BeMCOperand AllocRelativeVirtualReg(BeType* type, const BeMCOperand& relTo, const BeMCOperand& relOffset, int relScale); BeMCOperand AllocRelativeVirtualReg(BeType* type, const BeMCOperand& relTo, const BeMCOperand& relOffset, int relScale);
BeMCVRegInfo* GetVRegInfo(const BeMCOperand& operand); BeMCVRegInfo* GetVRegInfo(const BeMCOperand& operand);
bool HasSymbolAddr(const BeMCOperand& operand); bool HasSymbolAddr(const BeMCOperand& operand);
BeMCOperand ReplaceWithNewVReg(BeMCOperand& operand, int& instIdx, bool isInput, bool mustBeReg = true, bool preserveDeref = false); BeMCOperand ReplaceWithNewVReg(BeMCOperand& operand, int& instIdx, bool isInput, bool mustBeReg = true, bool preserveDeref = false);
BeMCOperand RemapOperand(BeMCOperand& operand, BeMCRemapper& regRemaps); BeMCOperand RemapOperand(BeMCOperand& operand, BeMCRemapper& regRemaps);
bool IsLive(BeVTrackingList* liveRegs, int vregIdx, BeMCRemapper& regRemaps); bool IsLive(BeVTrackingList* liveRegs, int vregIdx, BeMCRemapper& regRemaps);
void AddRegRemap(int from, int to, BeMCRemapper& regRemaps, bool allowRemapToDbgVar = false); void AddRegRemap(int from, int to, BeMCRemapper& regRemaps, bool allowRemapToDbgVar = false);
bool GetEncodedOperand(const BeMCOperand& operand, int& vregAddrIdx); bool GetEncodedOperand(const BeMCOperand& operand, int& vregAddrIdx);
bool HasPointerDeref(const BeMCOperand& operand); bool HasPointerDeref(const BeMCOperand& operand);
bool AreOperandsEquivalent(const BeMCOperand& op1, const BeMCOperand& op2, BeMCRemapper& regRemaps); bool AreOperandsEquivalent(const BeMCOperand& op1, const BeMCOperand& op2, BeMCRemapper& regRemaps);
bool CouldBeReg(const BeMCOperand& operand); bool CouldBeReg(const BeMCOperand& operand);
bool CheckForce(BeMCVRegInfo* vregInfo); bool CheckForce(BeMCVRegInfo* vregInfo);
void MarkLive(BeVTrackingList* liveRegs, SizedArrayImpl<int>& newRegs, BeVTrackingList*& initRegs, const BeMCOperand& operand); void MarkLive(BeVTrackingList* liveRegs, SizedArrayImpl<int>& newRegs, BeVTrackingList*& initRegs, const BeMCOperand& operand);
BeVTrackingList* MergeLiveRegs(BeVTrackingList* prevDestEntry, BeVTrackingList* mergeFrom); BeVTrackingList* MergeLiveRegs(BeVTrackingList* prevDestEntry, BeVTrackingList* mergeFrom);
void GenerateLiveness(BeMCBlock* block, BeVTrackingGenContext* genCtx, bool& modifiedBlockBefore, bool& modifiedBlockAfter); void GenerateLiveness(BeMCBlock* block, BeVTrackingGenContext* genCtx, bool& modifiedBlockBefore, bool& modifiedBlockAfter);
void GenerateLiveness(); void GenerateLiveness();
void IntroduceVRegs(const BeMCOperand& newVReg, BeMCBlock* block, int startInstIdx, int lastInstIdx); void IntroduceVRegs(const BeMCOperand& newVReg, BeMCBlock* block, int startInstIdx, int lastInstIdx);
void VRegSetInitialized(BeMCBlock* mcBlock, BeMCInst* inst, const BeMCOperand& operand, SizedArrayImpl<int>& addVec, SizedArrayImpl<int>& removeVec, bool deepSet, bool doSet); void VRegSetInitialized(BeMCBlock* mcBlock, BeMCInst* inst, const BeMCOperand& operand, SizedArrayImpl<int>& addVec, SizedArrayImpl<int>& removeVec, bool deepSet, bool doSet);
bool CheckVRegEqualityRange(BeMCBlock * mcBlock, int instIdx, const BeMCOperand & vreg0, const BeMCOperand & vreg1, BeMCRemapper& regRemaps, bool onlyCheckFirstLifetime = false); bool CheckVRegEqualityRange(BeMCBlock * mcBlock, int instIdx, const BeMCOperand & vreg0, const BeMCOperand & vreg1, BeMCRemapper& regRemaps, bool onlyCheckFirstLifetime = false);
@ -1420,7 +1408,7 @@ public:
void DoInitInjectionPass(); void DoInitInjectionPass();
void ReplaceVRegsInit(BeMCBlock* mcBlock, int instIdx, BeVTrackingList* prevList, BeVTrackingList* newList); void ReplaceVRegsInit(BeMCBlock* mcBlock, int instIdx, BeVTrackingList* prevList, BeVTrackingList* newList);
void FixVRegInitFlags(BeMCInst* inst, const BeMCOperand& operand); void FixVRegInitFlags(BeMCInst* inst, const BeMCOperand& operand);
void SetVTrackingValue(BeMCOperand& operand, BeVTrackingValue& vTrackingValue); void SetVTrackingValue(BeMCOperand& operand, BeVTrackingValue& vTrackingValue);
bool IsVolatileReg(X64CPURegister reg); bool IsVolatileReg(X64CPURegister reg);
bool IsXMMReg(X64CPURegister reg); bool IsXMMReg(X64CPURegister reg);
@ -1428,28 +1416,28 @@ public:
bool IsAddress(BeMCOperand& operand); bool IsAddress(BeMCOperand& operand);
bool IsAddressable(BeMCOperand& operand); bool IsAddressable(BeMCOperand& operand);
bool IsVRegExpr(BeMCOperand& operand); bool IsVRegExpr(BeMCOperand& operand);
void FixOperand(BeMCOperand& operand); void FixOperand(BeMCOperand& operand);
BeMCOperand GetFixedOperand(const BeMCOperand& operand); BeMCOperand GetFixedOperand(const BeMCOperand& operand);
uint8 GetREX(const BeMCOperand& op0, const BeMCOperand& op1, bool is64Bit); uint8 GetREX(const BeMCOperand& op0, const BeMCOperand& op1, bool is64Bit);
void EmitREX(const BeMCOperand& op0, const BeMCOperand& op1, bool is64Bit); void EmitREX(const BeMCOperand& op0, const BeMCOperand& op1, bool is64Bit);
uint8 EncodeRegNum(X64CPURegister regNum); uint8 EncodeRegNum(X64CPURegister regNum);
int GetRegSize(int regNum); int GetRegSize(int regNum);
void ValidateRMResult(const BeMCOperand& operand, BeRMParamsInfo& rmInfo, bool doValidate = true); void ValidateRMResult(const BeMCOperand& operand, BeRMParamsInfo& rmInfo, bool doValidate = true);
void GetRMParams(const BeMCOperand& operand, BeRMParamsInfo& rmInfo, bool doValidate = true); void GetRMParams(const BeMCOperand& operand, BeRMParamsInfo& rmInfo, bool doValidate = true);
void DisableRegister(const BeMCOperand& operand, X64CPURegister reg); void DisableRegister(const BeMCOperand& operand, X64CPURegister reg);
void MarkInvalidRMRegs(const BeMCOperand& operand); void MarkInvalidRMRegs(const BeMCOperand& operand);
void GetUsedRegs(const BeMCOperand& operand, X64CPURegister& regA, X64CPURegister& regB); // Expands regs void GetUsedRegs(const BeMCOperand& operand, X64CPURegister& regA, X64CPURegister& regB); // Expands regs
BeMCRMMode GetRMForm(const BeMCOperand& operand, bool& isMulti); BeMCRMMode GetRMForm(const BeMCOperand& operand, bool& isMulti);
void GetValAddr(const BeMCOperand& operand, X64CPURegister& reg, int& offset); void GetValAddr(const BeMCOperand& operand, X64CPURegister& reg, int& offset);
int GetHighestVRegRef(const BeMCOperand& operand); int GetHighestVRegRef(const BeMCOperand& operand);
BeMCInstForm GetInstForm(BeMCInst* inst); BeMCInstForm GetInstForm(BeMCInst* inst);
BeMCInstForm ToIMM16(BeMCInstForm instForm); BeMCInstForm ToIMM16(BeMCInstForm instForm);
BeMCInstForm ToIMM32OrSmaller(BeMCInstForm instForm); BeMCInstForm ToIMM32OrSmaller(BeMCInstForm instForm);
void SetCurrentInst(BeMCInst* mcInst); void SetCurrentInst(BeMCInst* mcInst);
int FindPreserveVolatiles(BeMCBlock* mcBlock, int instIdx); int FindPreserveVolatiles(BeMCBlock* mcBlock, int instIdx);
int FindRestoreVolatiles(BeMCBlock* mcBlock, int instIdx); int FindRestoreVolatiles(BeMCBlock* mcBlock, int instIdx);
uint8 GetJumpOpCode(BeCmpKind cmpKind, bool isLong); uint8 GetJumpOpCode(BeCmpKind cmpKind, bool isLong);
void Emit(uint8 val); void Emit(uint8 val);
void EmitModRM(int mod, int reg, int rm); void EmitModRM(int mod, int reg, int rm);
@ -1457,16 +1445,16 @@ public:
void EmitModRMRel(int rx, X64CPURegister regA, X64CPURegister regB, int bScale, int relOffset); void EmitModRMRel(int rx, X64CPURegister regA, X64CPURegister regB, int bScale, int relOffset);
void EmitModRM(int rx, BeMCOperand rm, int relocOfs = 0); void EmitModRM(int rx, BeMCOperand rm, int relocOfs = 0);
void EmitModRM(BeMCOperand r, BeMCOperand rm, int relocOfs = 0); void EmitModRM(BeMCOperand r, BeMCOperand rm, int relocOfs = 0);
void EmitModRM_Addr(BeMCOperand r, BeMCOperand rm); void EmitModRM_Addr(BeMCOperand r, BeMCOperand rm);
void EmitModRM_XMM_IMM(int rx, BeMCOperand& imm); void EmitModRM_XMM_IMM(int rx, BeMCOperand& imm);
void EmitInstPrefix(BeMCInstForm instForm, BeMCInst* inst); void EmitInstPrefix(BeMCInstForm instForm, BeMCInst* inst);
void EmitInst(BeMCInstForm instForm, uint16 codeBytes, BeMCInst* inst); void EmitInst(BeMCInstForm instForm, uint16 codeBytes, BeMCInst* inst);
void EmitInst(BeMCInstForm instForm, uint16 codeBytes, uint8 rx, BeMCInst* inst); void EmitInst(BeMCInstForm instForm, uint16 codeBytes, uint8 rx, BeMCInst* inst);
void EmitStdInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode_rm_r, uint8 opcode_r_rm, uint8 opcode_rm_imm, uint8 opcode_rm_imm_rx); void EmitStdInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode_rm_r, uint8 opcode_r_rm, uint8 opcode_rm_imm, uint8 opcode_rm_imm_rx);
void EmitStdInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode_rm_r, uint8 opcode_r_rm, uint8 opcode_rm_imm, uint8 opcode_rm_imm_rx, uint8 opcode_rm_imm8, uint8 opcode_rm_imm8_rx); void EmitStdInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode_rm_r, uint8 opcode_r_rm, uint8 opcode_rm_imm, uint8 opcode_rm_imm_rx, uint8 opcode_rm_imm8, uint8 opcode_rm_imm8_rx);
bool EmitStdXMMInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode); bool EmitStdXMMInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode);
bool EmitStdXMMInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode, uint8 opcode_dest_frm); bool EmitStdXMMInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode, uint8 opcode_dest_frm);
bool EmitPackedXMMInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode); bool EmitPackedXMMInst(BeMCInstForm instForm, BeMCInst* inst, uint8 opcode);
void EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src); void EmitAggMov(const BeMCOperand& dest, const BeMCOperand& src);
void DoTLSSetup(); void DoTLSSetup();
@ -1474,8 +1462,8 @@ public:
void DoSplitLargeBlocks(); void DoSplitLargeBlocks();
void DetectLoops(); void DetectLoops();
void DoLastUsePass(); void DoLastUsePass();
bool DoInitializedPass(); bool DoInitializedPass();
void RefreshRefCounts(); void RefreshRefCounts();
void DoInstCombinePass(); void DoInstCombinePass();
void DoRegAssignPass(); void DoRegAssignPass();
void DoFrameObjPass(); void DoFrameObjPass();
@ -1486,9 +1474,9 @@ public:
void DoBlockCombine(); void DoBlockCombine();
bool DoJumpRemovePass(); bool DoJumpRemovePass();
void DoRegFinalization(); void DoRegFinalization();
void DoCodeEmission(); void DoCodeEmission();
void HandleParams(); void HandleParams();
public: public:
BeMCContext(BeCOFFObject* coffObject); BeMCContext(BeCOFFObject* coffObject);