MCPcopy Create free account
hub / github.com/beefytech/Beef / DoCodeEmission

Method DoCodeEmission

IDEHelper/Backend/BeMCContext.cpp:12903–15741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12901}
12902
12903void BeMCContext::DoCodeEmission()
12904{
12905 BP_ZONE("BeMCContext::DoCodeEmission");
12906
12907 struct BeMCJump
12908 {
12909 public:
12910 int mCodeOffset;
12911 int mLabelIdx;
12912 int mJumpKind; // 0 = rel8, 1 = rel16 (not valid in x64), 2 = rel32
12913 BeCmpKind mCmpKind;
12914
12915 public:
12916 BeMCJump()
12917 {
12918 mCmpKind = BeCmpKind_None;
12919 mCodeOffset = -1;
12920 mLabelIdx = -1;
12921 mJumpKind = -1;
12922 }
12923 };
12924
12925 SizedArray<int, 64> labelPositions;
12926 labelPositions.resize(mCurLabelIdx);
12927 for (int labelIdx = 0; labelIdx < mCurLabelIdx; labelIdx++)
12928 labelPositions[labelIdx] = -1;
12929 SizedArray<BeMCJump, 64> deferredJumps;
12930
12931 auto& xdata = mCOFFObject->mXDataSect.mData;
12932 int xdataStartPos = xdata.GetPos();
12933
12934 int textSectStartPos = mOut.GetPos();
12935 int lastLabelIdx = -1;
12936
12937 bool hasPData = mStackSize != 0;
12938 if (hasPData)
12939 {
12940 // xdata must be DWORD aligned
12941 while ((xdataStartPos & 3) != 0)
12942 {
12943 xdata.Write((uint8)0);
12944 xdataStartPos++;
12945 }
12946
12947 // pdata starting loc
12948 BeMCRelocation reloc;
12949 reloc.mKind = BeMCRelocationKind_ADDR32NB;
12950 reloc.mOffset = mCOFFObject->mPDataSect.mData.GetPos();
12951 reloc.mSymTableIdx = mCOFFObject->GetSymbol(mBeFunction)->mIdx;
12952 mCOFFObject->mPDataSect.mRelocs.push_back(reloc);
12953 mCOFFObject->mPDataSect.mData.Write((int32)0);
12954
12955 xdata.Write((uint8)1); // version
12956 xdata.Write((uint8)0); // prolog size (placeholder)
12957 xdata.Write((uint8)0); // num unwind codes (placeholder)
12958 if (mUseBP)
12959 {
12960 int frameReg = 5;

Callers

nothing calls this directly

Calls 15

BeMCOperandClass · 0.85
IsPowerOfTwoFunction · 0.85
AllocEmptyListMethod · 0.80
GetDbgFileMethod · 0.80
GetChangeMethod · 0.80
IsDirectRelToMethod · 0.80
IsNativeRegMethod · 0.80
IsNonVectorCompositeMethod · 0.80
IsImmediateIntMethod · 0.80
GetSymbolRefMethod · 0.80
IsVRegAnyMethod · 0.80
IsVectorMethod · 0.80

Tested by

no test coverage detected