WebAssemblyInstrInfo.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //=- WebAssemblyInstrInfo.h - WebAssembly 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. /// \file
  10. /// This file contains the WebAssembly implementation of the
  11. /// TargetInstrInfo class.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYINSTRINFO_H
  15. #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYINSTRINFO_H
  16. #include "WebAssemblyRegisterInfo.h"
  17. #include "llvm/ADT/ArrayRef.h"
  18. #include "llvm/CodeGen/TargetInstrInfo.h"
  19. #define GET_INSTRINFO_HEADER
  20. #include "WebAssemblyGenInstrInfo.inc"
  21. #define GET_INSTRINFO_OPERAND_ENUM
  22. #include "WebAssemblyGenInstrInfo.inc"
  23. namespace llvm {
  24. namespace WebAssembly {
  25. int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIndex);
  26. }
  27. class WebAssemblySubtarget;
  28. class WebAssemblyInstrInfo final : public WebAssemblyGenInstrInfo {
  29. const WebAssemblyRegisterInfo RI;
  30. public:
  31. explicit WebAssemblyInstrInfo(const WebAssemblySubtarget &STI);
  32. const WebAssemblyRegisterInfo &getRegisterInfo() const { return RI; }
  33. bool isReallyTriviallyReMaterializable(const MachineInstr &MI) const override;
  34. void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
  35. const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg,
  36. bool KillSrc) const override;
  37. MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
  38. unsigned OpIdx1,
  39. unsigned OpIdx2) const override;
  40. bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
  41. MachineBasicBlock *&FBB,
  42. SmallVectorImpl<MachineOperand> &Cond,
  43. bool AllowModify = false) const override;
  44. unsigned removeBranch(MachineBasicBlock &MBB,
  45. int *BytesRemoved = nullptr) const override;
  46. unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
  47. MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
  48. const DebugLoc &DL,
  49. int *BytesAdded = nullptr) const override;
  50. bool
  51. reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
  52. ArrayRef<std::pair<int, const char *>>
  53. getSerializableTargetIndices() const override;
  54. const MachineOperand &getCalleeOperand(const MachineInstr &MI) const override;
  55. bool isExplicitTargetIndexDef(const MachineInstr &MI, int &Index,
  56. int64_t &Offset) const override;
  57. };
  58. } // end namespace llvm
  59. #endif