Thumb2InstrInfo.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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, Register SrcReg,
  36. bool isKill, int FrameIndex,
  37. const TargetRegisterClass *RC,
  38. const TargetRegisterInfo *TRI,
  39. Register VReg) const override;
  40. void loadRegFromStackSlot(MachineBasicBlock &MBB,
  41. MachineBasicBlock::iterator MBBI, Register DestReg,
  42. int FrameIndex, const TargetRegisterClass *RC,
  43. const TargetRegisterInfo *TRI,
  44. Register VReg) const override;
  45. /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
  46. /// such, whenever a client has an instance of instruction info, it should
  47. /// always be able to get register info as well (through this method).
  48. ///
  49. const ThumbRegisterInfo &getRegisterInfo() const override { return RI; }
  50. MachineInstr *optimizeSelect(MachineInstr &MI,
  51. SmallPtrSetImpl<MachineInstr *> &SeenMIs,
  52. bool) const override;
  53. MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
  54. unsigned OpIdx1,
  55. unsigned OpIdx2) const override;
  56. private:
  57. void expandLoadStackGuard(MachineBasicBlock::iterator MI) const override;
  58. };
  59. /// getITInstrPredicate - Valid only in Thumb2 mode. This function is identical
  60. /// to llvm::getInstrPredicate except it returns AL for conditional branch
  61. /// instructions which are "predicated", but are not in IT blocks.
  62. ARMCC::CondCodes getITInstrPredicate(const MachineInstr &MI, Register &PredReg);
  63. // getVPTInstrPredicate: VPT analogue of that, plus a helper function
  64. // corresponding to MachineInstr::findFirstPredOperandIdx.
  65. int findFirstVPTPredOperandIdx(const MachineInstr &MI);
  66. ARMVCC::VPTCodes getVPTInstrPredicate(const MachineInstr &MI,
  67. Register &PredReg);
  68. inline ARMVCC::VPTCodes getVPTInstrPredicate(const MachineInstr &MI) {
  69. Register PredReg;
  70. return getVPTInstrPredicate(MI, PredReg);
  71. }
  72. // Recomputes the Block Mask of Instr, a VPT or VPST instruction.
  73. // This rebuilds the block mask of the instruction depending on the predicates
  74. // of the instructions following it. This should only be used after the
  75. // MVEVPTBlockInsertion pass has run, and should be used whenever a predicated
  76. // instruction is added to/removed from the block.
  77. void recomputeVPTBlockMask(MachineInstr &Instr);
  78. } // namespace llvm
  79. #endif