xref: /freebsd/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
10b57cec5SDimitry Andric //=- WebAssemblyInstrInfo.h - WebAssembly Instruction Information -*- C++ -*-=//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric ///
90b57cec5SDimitry Andric /// \file
100b57cec5SDimitry Andric /// This file contains the WebAssembly implementation of the
110b57cec5SDimitry Andric /// TargetInstrInfo class.
120b57cec5SDimitry Andric ///
130b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYINSTRINFO_H
160b57cec5SDimitry Andric #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYINSTRINFO_H
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric #include "WebAssemblyRegisterInfo.h"
19480093f4SDimitry Andric #include "llvm/ADT/ArrayRef.h"
200b57cec5SDimitry Andric #include "llvm/CodeGen/TargetInstrInfo.h"
210b57cec5SDimitry Andric 
220b57cec5SDimitry Andric #define GET_INSTRINFO_HEADER
230b57cec5SDimitry Andric #include "WebAssemblyGenInstrInfo.inc"
240b57cec5SDimitry Andric 
250b57cec5SDimitry Andric #define GET_INSTRINFO_OPERAND_ENUM
260b57cec5SDimitry Andric #include "WebAssemblyGenInstrInfo.inc"
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric namespace llvm {
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric namespace WebAssembly {
310b57cec5SDimitry Andric 
320b57cec5SDimitry Andric int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIndex);
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric }
350b57cec5SDimitry Andric 
360b57cec5SDimitry Andric class WebAssemblySubtarget;
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric class WebAssemblyInstrInfo final : public WebAssemblyGenInstrInfo {
390b57cec5SDimitry Andric   const WebAssemblyRegisterInfo RI;
400b57cec5SDimitry Andric 
410b57cec5SDimitry Andric public:
420b57cec5SDimitry Andric   explicit WebAssemblyInstrInfo(const WebAssemblySubtarget &STI);
430b57cec5SDimitry Andric 
getRegisterInfo()440b57cec5SDimitry Andric   const WebAssemblyRegisterInfo &getRegisterInfo() const { return RI; }
450b57cec5SDimitry Andric 
46fcaf7f86SDimitry Andric   bool isReallyTriviallyReMaterializable(const MachineInstr &MI) const override;
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric   void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
49480093f4SDimitry Andric                    const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg,
500b57cec5SDimitry Andric                    bool KillSrc) const override;
510b57cec5SDimitry Andric   MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
520b57cec5SDimitry Andric                                        unsigned OpIdx1,
530b57cec5SDimitry Andric                                        unsigned OpIdx2) const override;
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric   bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
560b57cec5SDimitry Andric                      MachineBasicBlock *&FBB,
570b57cec5SDimitry Andric                      SmallVectorImpl<MachineOperand> &Cond,
580b57cec5SDimitry Andric                      bool AllowModify = false) const override;
590b57cec5SDimitry Andric   unsigned removeBranch(MachineBasicBlock &MBB,
600b57cec5SDimitry Andric                         int *BytesRemoved = nullptr) const override;
610b57cec5SDimitry Andric   unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
620b57cec5SDimitry Andric                         MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
630b57cec5SDimitry Andric                         const DebugLoc &DL,
640b57cec5SDimitry Andric                         int *BytesAdded = nullptr) const override;
650b57cec5SDimitry Andric   bool
660b57cec5SDimitry Andric   reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
67480093f4SDimitry Andric 
68480093f4SDimitry Andric   ArrayRef<std::pair<int, const char *>>
69480093f4SDimitry Andric   getSerializableTargetIndices() const override;
70fe6060f1SDimitry Andric 
71fe6060f1SDimitry Andric   const MachineOperand &getCalleeOperand(const MachineInstr &MI) const override;
72*bdd1243dSDimitry Andric 
73*bdd1243dSDimitry Andric   bool isExplicitTargetIndexDef(const MachineInstr &MI, int &Index,
74*bdd1243dSDimitry Andric                                 int64_t &Offset) const override;
750b57cec5SDimitry Andric };
760b57cec5SDimitry Andric 
770b57cec5SDimitry Andric } // end namespace llvm
780b57cec5SDimitry Andric 
790b57cec5SDimitry Andric #endif
80