LowerMDShared.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. class Lowerer;
  7. enum LegalForms : uint
  8. {
  9. L_None = 0x0,
  10. L_Reg = 0x1,
  11. L_Mem = 0x2,
  12. L_Imm32 = 0x4, // supports 8-bit, 16-bit, and 32-bit immediate values
  13. L_Ptr = 0x8 // supports 8-bit, 16-bit, 32-bit, and 64-bit immediate values on 64-bit architectures
  14. };
  15. #include "LowererMDArch.h"
  16. ///---------------------------------------------------------------------------
  17. ///
  18. /// class LowererMD
  19. ///
  20. ///---------------------------------------------------------------------------
  21. class LowererMD
  22. {
  23. public:
  24. LowererMD(Func *func) :
  25. m_func(func),
  26. lowererMDArch(func),
  27. floatTmpMap(nullptr),
  28. bvFloatTmpInits(nullptr),
  29. m_simd128OpCodesMap(nullptr)
  30. {
  31. }
  32. friend class LowererMDArch;
  33. static bool IsAssign(IR::Instr *instr);
  34. static bool IsCall(IR::Instr *instr);
  35. static bool IsUnconditionalBranch(const IR::Instr *instr);
  36. static void InvertBranch(IR::BranchInstr *instr);
  37. static void ReverseBranch(IR::BranchInstr *branchInstr);
  38. static Js::OpCode MDBranchOpcode(Js::OpCode opcode);
  39. static Js::OpCode MDUnsignedBranchOpcode(Js::OpCode opcode);
  40. static Js::OpCode MDCompareWithZeroBranchOpcode(Js::OpCode opcode);
  41. static Js::OpCode MDConvertFloat64ToInt32Opcode(const RoundMode roundMode);
  42. static void ChangeToAdd(IR::Instr *const instr, const bool needFlags);
  43. static void ChangeToSub(IR::Instr *const instr, const bool needFlags);
  44. static void ChangeToShift(IR::Instr *const instr, const bool needFlags);
  45. static void ChangeToMul(IR::Instr *const instr, const bool hasOverflowCheck = false);
  46. static const uint16 GetFormalParamOffset();
  47. static const Js::OpCode MDUncondBranchOpcode;
  48. static const Js::OpCode MDExtend32Opcode;
  49. static const Js::OpCode MDTestOpcode;
  50. static const Js::OpCode MDOrOpcode;
  51. static const Js::OpCode MDOverflowBranchOpcode;
  52. static const Js::OpCode MDNotOverflowBranchOpcode;
  53. static const Js::OpCode MDConvertFloat32ToFloat64Opcode;
  54. static const Js::OpCode MDConvertFloat64ToFloat32Opcode;
  55. static const Js::OpCode MDCallOpcode;
  56. static const Js::OpCode MDImulOpcode;
  57. UINT FloatPrefThreshold;
  58. public:
  59. void Init(Lowerer *lowerer);
  60. IR::Opnd * GenerateMemRef(void *addr, IRType type, IR::Instr *instr, bool dontEncode = false);
  61. IR::Instr * ChangeToHelperCall(IR::Instr * instr, IR::JnHelperMethod helperMethod, IR::LabelInstr *labelBailOut = nullptr,
  62. IR::Opnd *opndInstance = nullptr, IR::PropertySymOpnd * propSymOpnd = nullptr, bool isHelperContinuation = false);
  63. void FinalLower();
  64. #ifdef _M_X64
  65. void FlipHelperCallArgsOrder()
  66. {
  67. lowererMDArch.FlipHelperCallArgsOrder();
  68. }
  69. #endif
  70. IR::Instr * ChangeToHelperCallMem(IR::Instr * instr, IR::JnHelperMethod helperMethod);
  71. static IR::Instr * CreateAssign(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsertPt);
  72. static IR::Instr * ChangeToAssign(IR::Instr * instr);
  73. static IR::Instr * ChangeToAssign(IR::Instr * instr, IRType type);
  74. static IR::Instr * ChangeToLea(IR::Instr *const instr);
  75. static void ImmedSrcToReg(IR::Instr * instr, IR::Opnd * newOpnd, int srcNum);
  76. IR::Instr * LoadInputParamCount(IR::Instr * instr, int adjust = 0, bool needFlags = false);
  77. IR::Instr * LoadStackArgPtr(IR::Instr * instr);
  78. IR::Opnd * CreateStackArgumentsSlotOpnd();
  79. IR::Instr * LoadArgumentsFromFrame(IR::Instr * instr);
  80. IR::Instr * LoadArgumentCount(IR::Instr * instr);
  81. IR::Instr * LoadHeapArguments(IR::Instr * instr, bool force = false, IR::Opnd* opndInputParamCount = nullptr);
  82. IR::Instr * LoadHeapArgsCached(IR::Instr * instr);
  83. IR::Instr * LoadFuncExpression(IR::Instr * instr);
  84. IR::Instr * LowerRet(IR::Instr * instr);
  85. IR::Instr * LowerUncondBranch(IR::Instr * instr);
  86. IR::Instr * LowerMultiBranch(IR::Instr * instr);
  87. IR::Instr * LowerCondBranch(IR::Instr * instr);
  88. IR::Instr * LoadFunctionObjectOpnd(IR::Instr *instr, IR::Opnd *&functionObjOpnd);
  89. IR::Instr * LowerLdSuper(IR::Instr *instr, IR::JnHelperMethod helperOpCode);
  90. IR::Instr * LowerNewScObject(IR::Instr *newObjInstr);
  91. void ForceDstToReg(IR::Instr *instr);
  92. public:
  93. template <bool verify = false>
  94. static void Legalize(IR::Instr *const instr, bool fPostRegAlloc = false);
  95. private:
  96. template <bool verify>
  97. static void LegalizeOpnds(IR::Instr *const instr, const uint dstForms, const uint src1Forms, uint src2Forms);
  98. template <bool verify>
  99. static void LegalizeDst(IR::Instr *const instr, const uint forms);
  100. template <bool verify>
  101. static void LegalizeSrc(IR::Instr *const instr, IR::Opnd *src, const uint forms);
  102. template <bool verify = false>
  103. static void MakeDstEquSrc1(IR::Instr *const instr);
  104. public:
  105. IR::Instr * GenerateSmIntPairTest(IR::Instr * instrInsert, IR::Opnd * opndSrc1, IR::Opnd * opndSrc2, IR::LabelInstr * labelFail);
  106. void GenerateSmIntTest(IR::Opnd *opndSrc, IR::Instr *instrInsert, IR::LabelInstr *labelHelper, IR::Instr **instrFirst = nullptr, bool fContinueLabel = false);
  107. void GenerateTaggedZeroTest( IR::Opnd * opndSrc, IR::Instr * instrInsert, IR::LabelInstr * labelHelper = nullptr);
  108. bool GenerateObjectTest(IR::Opnd * opndSrc, IR::Instr * insertInstr, IR::LabelInstr * labelInstr, bool fContinueLabel = false);
  109. bool GenerateJSBooleanTest(IR::RegOpnd * regSrc, IR::Instr * insertInstr, IR::LabelInstr * labelTarget, bool fContinueLabel = false);
  110. void GenerateBooleanTest(IR::Opnd * regSrc, IR::Instr * insertInstr, IR::LabelInstr * labelTarget, bool fContinueLabel = false);
  111. void GenerateInt32ToVarConversion( IR::Opnd * opndSrc, IR::Instr * insertInstr );
  112. void GenerateFloatTest( IR::RegOpnd * opndSrc, IR::Instr * insertInstr, IR::LabelInstr* labelHelper, const bool checkForNullInLoopBody = false);
  113. void GenerateIsDynamicObject(IR::RegOpnd *regOpnd, IR::Instr *insertInstr, IR::LabelInstr *labelHelper, bool fContinueLabel = false);
  114. void GenerateIsRecyclableObject(IR::RegOpnd *regOpnd, IR::Instr *insertInstr, IR::LabelInstr *labelhelper, bool checkObjectAndDynamicObject = true);
  115. #if FLOATVAR
  116. IR::RegOpnd* CheckFloatAndUntag(IR::RegOpnd * opndSrc, IR::Instr * insertInstr, IR::LabelInstr* labelHelper);
  117. #endif
  118. bool GenerateFastBrString(IR::BranchInstr* instr);
  119. bool GenerateFastCmSrEqConst(IR::Instr *instr);
  120. bool GenerateFastCmXxTaggedInt(IR::Instr *instr);
  121. void GenerateFastCmXxI4(IR::Instr *instr);
  122. void GenerateFastCmXxR8(IR::Instr *instr);
  123. void GenerateFastCmXx(IR::Instr *instr);
  124. IR::Instr * GenerateConvBool(IR::Instr *instr);
  125. void GenerateFastDivByPow2(IR::Instr *instr);
  126. bool GenerateFastAdd(IR::Instr * instrAdd);
  127. #if DBG
  128. static void GenerateDebugBreak( IR::Instr * insertInstr );
  129. #endif
  130. bool GenerateFastSub(IR::Instr * instrSub);
  131. bool GenerateFastMul(IR::Instr * instrMul);
  132. bool GenerateFastAnd(IR::Instr * instrAnd);
  133. bool GenerateFastXor(IR::Instr * instrXor);
  134. bool GenerateFastOr(IR::Instr * instrOr);
  135. bool GenerateFastNot(IR::Instr * instrNot);
  136. bool GenerateFastShiftLeft(IR::Instr * instrShift);
  137. bool GenerateFastShiftRight(IR::Instr * instrShift);
  138. bool GenerateFastNeg(IR::Instr * instrNeg);
  139. void GenerateFastBrS(IR::BranchInstr *brInstr);
  140. IR::IndirOpnd* GetArgsIndirOpndForTopFunction(IR::Instr* ldElem, IR::Opnd* valueOpnd);
  141. IR::IndirOpnd* GetArgsIndirOpndForInlinee(IR::Instr* ldElem, IR::Opnd* valueOpnd);
  142. void GenerateCheckForArgumentsLength(IR::Instr* ldElem, IR::LabelInstr* labelCreateHeapArgs, IR::Opnd* actualParamOpnd, IR::Opnd* valueOpnd, Js::OpCode);
  143. IR::RegOpnd * LoadNonnegativeIndex(IR::RegOpnd *indexOpnd, const bool skipNegativeCheck, IR::LabelInstr *const notTaggedIntLabel, IR::LabelInstr *const negativeLabel, IR::Instr *const insertBeforeInstr);
  144. IR::RegOpnd * GenerateUntagVar(IR::RegOpnd * opnd, IR::LabelInstr * labelFail, IR::Instr * insertBeforeInstr, bool generateTagCheck = true);
  145. IR::IndirOpnd * GenerateFastElemIStringIndexCommon(IR::Instr * ldElem, bool isStore, IR::IndirOpnd * indirOpnd, IR::LabelInstr * labelHelper);
  146. bool GenerateFastLdMethodFromFlags(IR::Instr * instrLdFld);
  147. IR::Instr * GenerateFastScopedLdFld(IR::Instr * instrLdFld);
  148. IR::Instr * GenerateFastScopedStFld(IR::Instr * instrStFld);
  149. void GenerateFastBrBReturn(IR::Instr *instr);
  150. void GenerateFastAbs(IR::Opnd *dst, IR::Opnd *src, IR::Instr *callInstr, IR::Instr *insertInstr, IR::LabelInstr *labelHelper, IR::LabelInstr *doneLabel);
  151. IR::Instr * GenerateFloatAbs(IR::RegOpnd * regOpnd, IR::Instr * insertInstr);
  152. bool GenerateFastCharAt(Js::BuiltinFunction index, IR::Opnd *dst, IR::Opnd *srcStr, IR::Opnd *srcIndex, IR::Instr *callInstr, IR::Instr *insertInstr,
  153. IR::LabelInstr *labelHelper, IR::LabelInstr *doneLabel);
  154. void GenerateClz(IR::Instr * instr);
  155. bool TryGenerateFastMulAdd(IR::Instr * instrAdd, IR::Instr ** pInstrPrev);
  156. bool GenerateLdThisCheck(IR::Instr * instr);
  157. bool GenerateLdThisStrict(IR::Instr * instr);
  158. BVSparse<JitArenaAllocator>* GatherFltTmps();
  159. void GenerateFastInlineBuiltInCall(IR::Instr* instr, IR::JnHelperMethod helperMethod);
  160. void HelperCallForAsmMathBuiltin(IR::Instr* instr, IR::JnHelperMethod helperMethodFloat, IR::JnHelperMethod helperMethodDouble);
  161. void GenerateFastInlineBuiltInMathAbs(IR::Instr* instr);
  162. IR::Opnd* IsOpndNegZero(IR::Opnd* opnd, IR::Instr* instr);
  163. IR::Instr * CloneSlowPath(IR::Instr * instrEndFloatRange, IR::Instr * instrInsert);
  164. bool IsCloneDone(IR::Instr * instr, BVSparse<JitArenaAllocator> *bvTmps);
  165. IR::Instr * EnsureAdjacentArgs(IR::Instr * instrArg);
  166. void SaveDoubleToVar(IR::RegOpnd * dstOpnd, IR::RegOpnd *opndFloat, IR::Instr *instrOrig, IR::Instr *instrInsert, bool isHelper = false);
  167. #if !FLOATVAR
  168. void GenerateNumberAllocation(IR::RegOpnd * opndDst, IR::Instr * instrInsert, bool isHelper);
  169. #endif
  170. void GenerateFastRecyclerAlloc(size_t allocSize, IR::RegOpnd* newObjDst, IR::Instr* insertionPointInstr, IR::LabelInstr* allocHelperLabel, IR::LabelInstr* allocDoneLabel);
  171. #ifdef _CONTROL_FLOW_GUARD
  172. void GenerateCFGCheck(IR::Opnd * entryPointOpnd, IR::Instr * insertBeforeInstr);
  173. #endif
  174. static IR::Instr *LoadFloatZero(IR::Opnd * opndDst, IR::Instr * instrInsert);
  175. static IR::Instr *LoadFloatValue(IR::Opnd * opndDst, double value, IR::Instr * instrInsert);
  176. IR::Instr * LoadStackAddress(StackSym *sym, IR::RegOpnd *optionalDstOpnd = nullptr);
  177. static void EmitInt4Instr(IR::Instr *instr);
  178. static void EmitPtrInstr(IR::Instr *instr);
  179. void EmitLoadVar(IR::Instr *instr, bool isFromUint32 = false, bool isHelper = false);
  180. void EmitLoadVarNoCheck(IR::RegOpnd * dst, IR::RegOpnd * src, IR::Instr *instrLoad, bool isFromUint32, bool isHelper);
  181. bool EmitLoadInt32(IR::Instr *instr);
  182. void EmitIntToFloat(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
  183. void EmitUIntToFloat(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
  184. void EmitFloatToInt(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
  185. void EmitFloat32ToFloat64(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
  186. static IR::Instr *InsertConvertFloat64ToInt32(const RoundMode roundMode, IR::Opnd *const dst, IR::Opnd *const src, IR::Instr *const insertBeforeInstr);
  187. void ConvertFloatToInt32(IR::Opnd* intOpnd, IR::Opnd* floatOpnd, IR::LabelInstr * labelHelper, IR::LabelInstr * labelDone, IR::Instr * instInsert);
  188. void EmitLoadFloatFromNumber(IR::Opnd *dst, IR::Opnd *src, IR::Instr *insertInstr);
  189. IR::RegOpnd * EmitLoadFloat(IR::Opnd *dst, IR::Opnd *src, IR::Instr *insertInstr);
  190. static void EmitNon32BitOvfCheck(IR::Instr *instr, IR::Instr *insertInstr, IR::LabelInstr* bailOutLabel);
  191. static void LowerInt4NegWithBailOut(IR::Instr *const instr, const IR::BailOutKind bailOutKind, IR::LabelInstr *const bailOutLabel, IR::LabelInstr *const skipBailOutLabel);
  192. static void LowerInt4AddWithBailOut(IR::Instr *const instr, const IR::BailOutKind bailOutKind, IR::LabelInstr *const bailOutLabel, IR::LabelInstr *const skipBailOutLabel);
  193. static void LowerInt4SubWithBailOut(IR::Instr *const instr, const IR::BailOutKind bailOutKind, IR::LabelInstr *const bailOutLabel, IR::LabelInstr *const skipBailOutLabel);
  194. static void LowerInt4MulWithBailOut(IR::Instr *const instr, const IR::BailOutKind bailOutKind, IR::LabelInstr *const bailOutLabel, IR::LabelInstr *const skipBailOutLabel);
  195. void LowerInt4RemWithBailOut(IR::Instr *const instr, const IR::BailOutKind bailOutKind, IR::LabelInstr *const bailOutLabel, IR::LabelInstr *const skipBailOutLabel) const;
  196. static bool GenerateSimplifiedInt4Mul(IR::Instr *const mulInstr, const IR::BailOutKind bailOutKind = IR::BailOutInvalid, IR::LabelInstr *const bailOutLabel = nullptr);
  197. static bool GenerateSimplifiedInt4Rem(IR::Instr *const remInstr, IR::LabelInstr *const skipBailOutLabel = nullptr);
  198. IR::Instr * LowerCatch(IR::Instr *instr);
  199. IR::Instr * LowerGetCachedFunc(IR::Instr *instr);
  200. IR::Instr * LowerCommitScope(IR::Instr *instr);
  201. IR::Instr * LowerTry(IR::Instr *instr, IR::JnHelperMethod helperMethod);
  202. IR::Instr * LowerLeave(IR::Instr *instr, IR::LabelInstr * targetInstr, bool fromFinalLower, bool isOrphanedLeave = false);
  203. IR::Instr * LowerEHRegionReturn(IR::Instr * insertBeforeInstr, IR::Opnd * targetOpnd);
  204. IR::Instr * LowerLeaveNull(IR::Instr *instr);
  205. IR::Instr * LowerCallHelper(IR::Instr *instrCall);
  206. IR::LabelInstr *GetBailOutStackRestoreLabel(BailOutInfo * bailOutInfo, IR::LabelInstr * exitTargetInstr);
  207. StackSym * GetImplicitParamSlotSym(Js::ArgSlot argSlot);
  208. static StackSym * GetImplicitParamSlotSym(Js::ArgSlot argSlot, Func * func);
  209. Lowerer* GetLowerer() { return m_lowerer; }
  210. bool GenerateFastIsInst(IR::Instr * instr);
  211. void GenerateIsJsObjectTest(IR::RegOpnd* instanceReg, IR::Instr* insertInstr, IR::LabelInstr* labelHelper);
  212. public:
  213. //
  214. // These methods are simply forwarded to lowererMDArch
  215. //
  216. IR::Instr * LowerAsmJsCallI(IR::Instr * callInstr);
  217. IR::Instr * LowerAsmJsCallE(IR::Instr * callInstr);
  218. IR::Instr * LowerAsmJsLdElemHelper(IR::Instr * callInstr);
  219. IR::Instr * LowerAsmJsStElemHelper(IR::Instr * callInstr);
  220. IR::Instr * LowerCall(IR::Instr * callInstr, Js::ArgSlot argCount);
  221. IR::Instr * LowerCallI(IR::Instr * callInstr, ushort callFlags, bool isHelper = false, IR::Instr * insertBeforeInstrForCFG = nullptr);
  222. IR::Instr * LowerCallPut(IR::Instr * callInstr);
  223. IR::Instr * LoadHelperArgument(IR::Instr * instr, IR::Opnd * opndArg);
  224. IR::Instr * LoadDoubleHelperArgument(IR::Instr * instr, IR::Opnd * opndArg);
  225. IR::Instr * LowerEntryInstr(IR::EntryInstr * entryInstr);
  226. IR::Instr * LowerExitInstr(IR::ExitInstr * exitInstr);
  227. IR::Instr * LowerEntryInstrAsmJs(IR::EntryInstr * entryInstr);
  228. IR::Instr * LowerExitInstrAsmJs(IR::ExitInstr * exitInstr);
  229. IR::Instr * LoadNewScObjFirstArg(IR::Instr * instr, IR::Opnd * dst, ushort extraArgs = 0);
  230. IR::Instr * LowerToFloat(IR::Instr *instr);
  231. static IR::BranchInstr * LowerFloatCondBranch(IR::BranchInstr *instrBranch, bool ignoreNan = false);
  232. static Js::OpCode GetLoadOp(IRType type) { return LowererMDArch::GetAssignOp(type); }
  233. static Js::OpCode GetStoreOp(IRType type) { return LowererMDArch::GetAssignOp(type); }
  234. static RegNum GetRegStackPointer() { return LowererMDArch::GetRegStackPointer(); }
  235. static RegNum GetRegArgI4(int32 argNum) { return LowererMDArch::GetRegArgI4(argNum); }
  236. static RegNum GetRegArgR8(int32 argNum) { return LowererMDArch::GetRegArgR8(argNum); }
  237. static RegNum GetRegReturn(IRType type) { return LowererMDArch::GetRegReturn(type); }
  238. //All the following functions delegate to lowererMDArch
  239. IR::Instr * LowerCallIDynamic(IR::Instr * callInstr, IR::Instr* saveThis, IR::Opnd* argsLengthOpnd, ushort callFlags, IR::Instr * insertBeforeInstrForCFG = nullptr)
  240. {
  241. return this->lowererMDArch.LowerCallIDynamic(callInstr, saveThis, argsLengthOpnd, callFlags, insertBeforeInstrForCFG);
  242. }
  243. IR::Instr * LoadDynamicArgument(IR::Instr * instr, uint argNumber = 1) { return this->lowererMDArch.LoadDynamicArgument(instr, argNumber);}
  244. IR::Opnd* GenerateArgOutForStackArgs(IR::Instr* callInstr, IR::Instr* stackArgsInstr) { return lowererMDArch.GenerateArgOutForStackArgs(callInstr, stackArgsInstr);}
  245. static RegNum GetRegFramePointer() { return LowererMDArch::GetRegFramePointer(); }
  246. static BYTE GetDefaultIndirScale() { return LowererMDArch::GetDefaultIndirScale(); }
  247. IR::Instr * LoadDynamicArgumentUsingLength(IR::Instr *instr) { return this->lowererMDArch.LoadDynamicArgumentUsingLength(instr); }
  248. void GenerateFunctionObjectTest(IR::Instr * callInstr, IR::RegOpnd *functionObjOpnd, bool isHelper, IR::LabelInstr* afterCallLabel = nullptr) { this->lowererMDArch.GenerateFunctionObjectTest(callInstr, functionObjOpnd, isHelper, afterCallLabel); }
  249. int32 LowerCallArgs(IR::Instr *callInstr, ushort callFlags, ushort extraArgsCount = 1 /* for function object */) { return this->lowererMDArch.LowerCallArgs(callInstr, callFlags, extraArgsCount); }
  250. static void GenerateLoadTaggedType(IR::Instr * instrLdSt, IR::RegOpnd * opndType, IR::RegOpnd * opndTaggedType);
  251. static void GenerateLoadPolymorphicInlineCacheSlot(IR::Instr * instrLdSt, IR::RegOpnd * opndInlineCache, IR::RegOpnd * opndType, uint polymorphicInlineCacheSize);
  252. static void GenerateWriteBarrierAssign(IR::IndirOpnd * opndDst, IR::Opnd * opndSrc, IR::Instr * insertBeforeInstr);
  253. static void GenerateWriteBarrierAssign(IR::MemRefOpnd * opndDst, IR::Opnd * opndSrc, IR::Instr * insertBeforeInstr);
  254. static void ChangeToWriteBarrierAssign(IR::Instr * assignInstr);
  255. static IR::BranchInstr * GenerateLocalInlineCacheCheck(IR::Instr * instrLdSt, IR::RegOpnd * opndType, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelNext, bool checkTypeWithoutProperty = false);
  256. static IR::BranchInstr * GenerateProtoInlineCacheCheck(IR::Instr * instrLdSt, IR::RegOpnd * opndType, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelNext);
  257. static IR::BranchInstr * GenerateFlagInlineCacheCheck(IR::Instr * instrLdSt, IR::RegOpnd * opndType, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelNext);
  258. static IR::BranchInstr * GenerateFlagInlineCacheCheckForNoGetterSetter(IR::Instr * instrLdSt, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelNext);
  259. static IR::BranchInstr * GenerateFlagInlineCacheCheckForLocal(IR::Instr * instrLdSt, IR::RegOpnd * opndType, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelNext);
  260. static void GenerateLdFldFromLocalInlineCache(IR::Instr * instrLdFld, IR::RegOpnd * opndBase, IR::Opnd * opndDst, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelFallThru, bool isInlineSlot);
  261. static void GenerateLdFldFromProtoInlineCache(IR::Instr * instrLdFld, IR::RegOpnd * opndBase, IR::Opnd * opndDst, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelFallThru, bool isInlineSlot);
  262. static void GenerateLdLocalFldFromFlagInlineCache(IR::Instr * instrLdFld, IR::RegOpnd * opndBase, IR::Opnd * opndDst, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelFallThru, bool isInlineSlot);
  263. static void GenerateStFldFromLocalInlineCache(IR::Instr * instrStFld, IR::RegOpnd * opndBase, IR::Opnd * opndSrc, IR::RegOpnd * opndInlineCache, IR::LabelInstr * labelFallThru, bool isInlineSlot);
  264. IR::Instr * LowerDivI4AndBailOnReminder(IR::Instr * instr, IR::LabelInstr * bailOutLabel);
  265. void LowerInlineSpreadArgOutLoop(IR::Instr *callInstr, IR::RegOpnd *indexOpnd, IR::RegOpnd *arrayElementsStartOpnd)
  266. {
  267. this->lowererMDArch.LowerInlineSpreadArgOutLoop(callInstr, indexOpnd, arrayElementsStartOpnd);
  268. }
  269. public:
  270. static void InsertIncUInt8PreventOverflow(IR::Opnd *const dst, IR::Opnd *const src, IR::Instr *const insertBeforeInstr, IR::Instr * *const onOverflowInsertBeforeInstrRef = nullptr);
  271. static void InsertDecUInt8PreventOverflow(IR::Opnd *const dst, IR::Opnd *const src, IR::Instr *const insertBeforeInstr, IR::Instr * *const onOverflowInsertBeforeInstrRef = nullptr);
  272. void Simd128InitOpcodeMap();
  273. IR::Instr* Simd128Instruction(IR::Instr* instr);
  274. IR::Instr* Simd128LoadConst(IR::Instr* instr);
  275. bool Simd128TryLowerMappedInstruction(IR::Instr *instr);
  276. IR::Instr* Simd128LowerUnMappedInstruction(IR::Instr *instr);
  277. IR::Instr* Simd128LowerConstructor(IR::Instr *instr);
  278. IR::Instr* Simd128LowerLdLane(IR::Instr *instr);
  279. IR::Instr* SIMD128LowerReplaceLane(IR::Instr *instr);
  280. IR::Instr* Simd128LowerSplat(IR::Instr *instr);
  281. IR::Instr* Simd128LowerRcp(IR::Instr *instr, bool removeInstr = true);
  282. IR::Instr* Simd128LowerSqrt(IR::Instr *instr);
  283. IR::Instr* Simd128LowerRcpSqrt(IR::Instr *instr);
  284. IR::Instr* Simd128LowerSelect(IR::Instr *instr);
  285. IR::Instr* Simd128LowerNegI4(IR::Instr *instr);
  286. IR::Instr* Simd128LowerMulI4(IR::Instr *instr);
  287. IR::Instr* Simd128LowerLoadElem(IR::Instr *instr);
  288. IR::Instr* Simd128LowerStoreElem(IR::Instr *instr);
  289. IR::Instr* Simd128LowerShuffle(IR::Instr *instr);
  290. IR::Opnd * EnregisterIntConst(IR::Instr* instr, IR::Opnd *constOpnd);
  291. SList<IR::Opnd*> * Simd128GetExtendedArgs(IR::Instr *instr);
  292. void GenerateCheckedSimdLoad(IR::Instr * instr);
  293. void GenerateSimdStore(IR::Instr * instr);
  294. private:
  295. void GenerateFlagInlineCacheCheckForGetterSetter(
  296. IR::Instr * insertBeforeInstr,
  297. IR::RegOpnd * opndInlineCache,
  298. IR::LabelInstr * labelNext);
  299. void GenerateLdFldFromFlagInlineCache(
  300. IR::Instr * insertBeforeInstr,
  301. IR::RegOpnd * opndBase,
  302. IR::Opnd * opndDst,
  303. IR::RegOpnd * opndInlineCache,
  304. IR::LabelInstr * labelFallThru,
  305. bool isInlineSlot);
  306. IR::LabelInstr* EmitLoadFloatCommon(IR::Opnd *dst, IR::Opnd *src, IR::Instr *insertInstr, bool needLabelHelper);
  307. #ifdef RECYCLER_WRITE_BARRIER
  308. static void GenerateWriteBarrier(IR::Opnd * writeBarrierAddrRegOpnd, IR::Instr * insertBeforeInstr);
  309. #endif
  310. // Data
  311. protected:
  312. Func *m_func;
  313. Lowerer *m_lowerer;
  314. LowererMDArch lowererMDArch;
  315. StackSymMap *floatTmpMap;
  316. BVSparse<JitArenaAllocator> *bvFloatTmpInits;
  317. Js::OpCode *m_simd128OpCodesMap; // used to map single-opcode SIMD operations
  318. };