LoongArchInstrInfo.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //=- LoongArchInstrInfo.h - LoongArch 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 LoongArch implementation of the TargetInstrInfo class.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H
  13. #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H
  14. #include "LoongArchRegisterInfo.h"
  15. #include "llvm/CodeGen/TargetInstrInfo.h"
  16. #define GET_INSTRINFO_HEADER
  17. #include "LoongArchGenInstrInfo.inc"
  18. namespace llvm {
  19. class LoongArchSubtarget;
  20. class LoongArchInstrInfo : public LoongArchGenInstrInfo {
  21. public:
  22. explicit LoongArchInstrInfo(LoongArchSubtarget &STI);
  23. void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
  24. const DebugLoc &DL, MCRegister DstReg, MCRegister SrcReg,
  25. bool KillSrc) const override;
  26. void storeRegToStackSlot(MachineBasicBlock &MBB,
  27. MachineBasicBlock::iterator MBBI, Register SrcReg,
  28. bool IsKill, int FrameIndex,
  29. const TargetRegisterClass *RC,
  30. const TargetRegisterInfo *TRI,
  31. Register VReg) const override;
  32. void loadRegFromStackSlot(MachineBasicBlock &MBB,
  33. MachineBasicBlock::iterator MBBI, Register DstReg,
  34. int FrameIndex, const TargetRegisterClass *RC,
  35. const TargetRegisterInfo *TRI,
  36. Register VReg) const override;
  37. // Materializes the given integer Val into DstReg.
  38. void movImm(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
  39. const DebugLoc &DL, Register DstReg, uint64_t Val,
  40. MachineInstr::MIFlag Flag = MachineInstr::NoFlags) const;
  41. unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
  42. MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;
  43. bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
  44. MachineBasicBlock *&FBB,
  45. SmallVectorImpl<MachineOperand> &Cond,
  46. bool AllowModify) const override;
  47. bool isBranchOffsetInRange(unsigned BranchOpc,
  48. int64_t BrOffset) const override;
  49. unsigned removeBranch(MachineBasicBlock &MBB,
  50. int *BytesRemoved = nullptr) const override;
  51. unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
  52. MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
  53. const DebugLoc &dl,
  54. int *BytesAdded = nullptr) const override;
  55. void insertIndirectBranch(MachineBasicBlock &MBB,
  56. MachineBasicBlock &NewDestBB,
  57. MachineBasicBlock &RestoreBB, const DebugLoc &DL,
  58. int64_t BrOffset, RegScavenger *RS) const override;
  59. bool
  60. reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
  61. std::pair<unsigned, unsigned>
  62. decomposeMachineOperandsTargetFlags(unsigned TF) const override;
  63. ArrayRef<std::pair<unsigned, const char *>>
  64. getSerializableDirectMachineOperandTargetFlags() const override;
  65. protected:
  66. const LoongArchSubtarget &STI;
  67. };
  68. } // end namespace llvm
  69. #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H