1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 /************************************************************************/
6 /* Overall emitter control (including startup and shutdown) */
7 /************************************************************************/
9 static void emitInit();
10 static void emitDone();
12 void emitBegCG(Compiler* comp, COMP_HANDLE cmpHandle);
15 void emitBegFN(bool hasFramePtr
23 #endif // LEGACY_BACKEND
29 void emitComputeCodeSizes();
31 unsigned emitEndCodeGen(Compiler* comp,
43 /************************************************************************/
44 /* Method prolog and epilog */
45 /************************************************************************/
47 unsigned emitGetEpilogCnt();
49 template <typename Callback>
50 bool emitGenNoGCLst(Callback& cb);
53 unsigned emitGetPrologOffsetEstimate();
54 void emitMarkPrologEnd();
57 void emitCreatePlaceholderIG(insGroupPlaceholderType igType,
59 VARSET_VALARG_TP GCvars,
64 void emitGeneratePrologEpilog();
65 void emitStartPrologEpilogGeneration();
66 void emitFinishPrologEpilogGeneration();
68 /************************************************************************/
69 /* Record a code position and later convert it to offset */
70 /************************************************************************/
73 unsigned emitCurOffset();
75 UNATIVE_OFFSET emitCodeOffset(void* blockPtr, unsigned codeOffs);
78 const char* emitOffsetToLabel(unsigned offs);
81 /************************************************************************/
82 /* Output target-independent instructions */
83 /************************************************************************/
85 void emitIns_J(instruction ins, BasicBlock* dst, int instrCount = 0);
87 /************************************************************************/
88 /* Emit initialized data sections */
89 /************************************************************************/
91 UNATIVE_OFFSET emitDataGenBeg(UNATIVE_OFFSET size, bool dblAlign, bool codeLtab);
93 UNATIVE_OFFSET emitBBTableDataGenBeg(unsigned numEntries, bool relativeAddr);
95 void emitDataGenData(unsigned offs, const void* data, size_t size);
97 void emitDataGenData(unsigned offs, BasicBlock* label);
99 void emitDataGenEnd();
101 UNATIVE_OFFSET emitDataConst(const void* cnsAddr, unsigned cnsSize, bool dblAlign);
103 UNATIVE_OFFSET emitDataSize();
105 /************************************************************************/
106 /* Instruction information */
107 /************************************************************************/
109 #ifdef _TARGET_XARCH_
110 static bool instrIs3opImul(instruction ins);
111 static bool instrIsExtendedReg3opImul(instruction ins);
112 static bool instrHasImplicitRegPairDest(instruction ins);
113 static void check3opImulValues();
114 static regNumber inst3opImulReg(instruction ins);
115 static instruction inst3opImulForReg(regNumber reg);
118 /************************************************************************/
119 /* Emit PDB offset translation information */
120 /************************************************************************/
124 static void SetILBaseOfCode(BYTE* pTextBase);
125 static void SetILMethodBase(BYTE* pMethodEntry);
126 static void SetILMethodStart(BYTE* pMethodCode);
127 static void SetImgBaseOfCode(BYTE* pTextBase);
129 void SetIDBaseToProlog();
130 void SetIDBaseToOffset(int methodOffset);
132 static void DisablePDBTranslation();
133 static bool IsPDBEnabled();
135 static void InitTranslationMaps(int ilCodeSize);
136 static void DeleteTranslationMaps();
137 static void InitTranslator(PDBRewriter* pPDB, int* rgSecMap, IMAGE_SECTION_HEADER** rgpHeader, int numSections);
140 /************************************************************************/
141 /* Interface for generating unwind information */
142 /************************************************************************/
144 #ifdef _TARGET_ARMARCH_
146 bool emitIsFuncEnd(emitLocation* emitLoc, emitLocation* emitLocNextFragment = NULL);
148 void emitSplit(emitLocation* startLoc,
149 emitLocation* endLoc,
150 UNATIVE_OFFSET maxSplitSize,
152 emitSplitCallbackType callbackFunc);
154 void emitUnwindNopPadding(emitLocation* locFrom, Compiler* comp);
156 #endif // _TARGET_ARMARCH_
158 #if defined(_TARGET_ARM_)
160 unsigned emitGetInstructionSize(emitLocation* emitLoc);
162 #endif // defined(_TARGET_ARM_)