Thumb2InstrInfo.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //===-- Thumb2InstrInfo.h - Thumb-2 Instruction Information -----*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file contains the Thumb-2 implementation of the TargetInstrInfo class.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_ARM_THUMB2INSTRINFO_H
  13. #define LLVM_LIB_TARGET_ARM_THUMB2INSTRINFO_H
  14. #include "ARMBaseInstrInfo.h"
  15. #include "ThumbRegisterInfo.h"
  16. namespace llvm {
  17. class ARMSubtarget;
  18. class Thumb2InstrInfo : public ARMBaseInstrInfo {
  19. ThumbRegisterInfo RI;
  20. public:
  21. explicit Thumb2InstrInfo(const ARMSubtarget &STI);
  22. /// Return the noop instruction to use for a noop.
  23. MCInst getNop() const override;
  24. // Return the non-pre/post incrementing version of 'Opc'. Return 0
  25. // if there is not such an opcode.
  26. unsigned getUnindexedOpcode(unsigned Opc) const override;
  27. void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail,
  28. MachineBasicBlock *NewDest) const override;
  29. bool isLegalToSplitMBBAt(MachineBasicBlock &MBB,
  30. MachineBasicBlock::iterator MBBI) const override;
  31. void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
  32. const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg,
  33. bool KillSrc) const override;
  34. void storeRegToStackSlot(MachineBasicBlock &MBB,
  35. MachineBasicBlock::iterator MBBI,
  36. Register SrcReg, bool isKill, int FrameIndex,
  37. const TargetRegisterClass *RC,
  38. const TargetRegisterInfo *TRI) const override;
  39. void loadRegFromStackSlot(MachineBasicBlock &MBB,
  40. MachineBasicBlock::iterator MBBI,
  41. Register DestReg, int FrameIndex,
  42. const TargetRegisterClass *RC,
  43. const TargetRegisterInfo *TRI) const override;
  44. /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
  45. /// such, whenever a client has an instance of instruction info, it should
  46. /// always be able to get register info as well (through this method).
  47. ///
  48. const ThumbRegisterInfo &getRegisterInfo() const override { return RI; }
  49. MachineInstr *optimizeSelect(MachineInstr &MI,
  50. SmallPtrSetImpl<MachineInstr *> &SeenMIs,
  51. bool) const override;
  52. MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
  53. unsigned OpIdx1,
  54. unsigned OpIdx2) const override;
  55. private:
  56. void expandLoadStackGuard(MachineBasicBlock::iterator MI) const override;
  57. };
  58. /// getITInstrPredicate - Valid only in Thumb2 mode. This function is identical
  59. /// to llvm::getInstrPredicate except it returns AL for conditional branch
  60. /// instructions which are "predicated", but are not in IT blocks.
  61. ARMCC::CondCodes getITInstrPredicate(const MachineInstr &MI, Register &PredReg);
  62. // getVPTInstrPredicate: VPT analogue of that, plus a helper function
  63. // corresponding to MachineInstr::findFirstPredOperandIdx.
  64. int findFirstVPTPredOperandIdx(const MachineInstr &MI);
  65. ARMVCC::VPTCodes getVPTInstrPredicate(const MachineInstr &MI,
  66. Register &PredReg);
  67. inline ARMVCC::VPTCodes getVPTInstrPredicate(const MachineInstr &MI) {
  68. Register PredReg;
  69. return getVPTInstrPredicate(MI, PredReg);
  70. }
  71. // Recomputes the Block Mask of Instr, a VPT or VPST instruction.
  72. // This rebuilds the block mask of the instruction depending on the predicates
  73. // of the instructions following it. This should only be used after the
  74. // MVEVPTBlockInsertion pass has run, and should be used whenever a predicated
  75. // instruction is added to/removed from the block.
  76. void recomputeVPTBlockMask(MachineInstr &Instr);
  77. } // namespace llvm
  78. #endif