LinearScanMD.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 OpHelperBlock;
  7. class LinearScan;
  8. class BailOutRecord;
  9. class BranchBailOutRecord;
  10. class LinearScanMD : public LinearScanMDShared
  11. {
  12. private:
  13. StackSym ** helperSpillSlots;
  14. Func * func;
  15. uint32 maxOpHelperSpilledLiveranges;
  16. BitVector byteableRegsBv;
  17. StackSym *xmmSymTable128[XMM_REGCOUNT];
  18. StackSym *xmmSymTable64[XMM_REGCOUNT];
  19. StackSym *xmmSymTable32[XMM_REGCOUNT];
  20. public:
  21. LinearScanMD(Func *func);
  22. StackSym *EnsureSpillSymForXmmReg(RegNum reg, Func *func, IRType type);
  23. BitVector FilterRegIntSizeConstraints(BitVector regsBv, BitVector sizeUsageBv) const;
  24. bool FitRegIntSizeConstraints(RegNum reg, BitVector sizeUsageBv) const;
  25. bool FitRegIntSizeConstraints(RegNum reg, IRType type) const;
  26. bool IsAllocatable(RegNum reg, Func *func) const { return true; }
  27. uint UnAllocatableRegCount(Func *func) const { return 2; /* RSP, RBP */ }
  28. void LegalizeDef(IR::Instr * instr) { /* This is a nop for amd64 */ }
  29. void LegalizeUse(IR::Instr * instr, IR::Opnd * opnd) { /* A nop for amd64 */ }
  30. void LegalizeConstantUse(IR::Instr * instr, IR::Opnd * opnd);
  31. void InsertOpHelperSpillAndRestores(SList<OpHelperBlock> *opHelperBlockList);
  32. void EndOfHelperBlock(uint32 helperSpilledLiveranges);
  33. void GenerateBailOut(IR::Instr * instr,
  34. __in_ecount(registerSaveSymsCount) StackSym ** registerSaveSyms,
  35. uint registerSaveSymsCount);
  36. private:
  37. static void SaveAllRegisters(BailOutRecord *const bailOutRecord);
  38. public:
  39. static void SaveAllRegistersAndBailOut(BailOutRecord *const bailOutRecord);
  40. static void SaveAllRegistersAndBranchBailOut(BranchBailOutRecord *const bailOutRecord, const BOOL condition);
  41. static RegNum GetParamReg(IR::SymOpnd *symOpnd, Func *func);
  42. static uint GetRegisterSaveSlotCount() {
  43. return RegisterSaveSlotCount;
  44. }
  45. static uint GetRegisterSaveIndex(RegNum reg);
  46. static RegNum GetRegisterFromSaveIndex(uint offset);
  47. // All regs, including XMMs, plus extra slot space for XMMs (1 XMM = 2 Vars)
  48. static const uint RegisterSaveSlotCount = RegNumCount + XMM_REGCOUNT;
  49. private:
  50. void InsertOpHelperSpillsAndRestores(const OpHelperBlock& opHelperBlock);
  51. };