xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Mips/MipsMCInstLower.h (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1 //===- MipsMCInstLower.h - Lower MachineInstr to MCInst --------*- 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 #ifndef LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
10 #define LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
11 
12 #include "MCTargetDesc/MipsMCExpr.h"
13 #include "llvm/CodeGen/MachineOperand.h"
14 #include "llvm/Support/Compiler.h"
15 
16 namespace llvm {
17 
18 class MachineBasicBlock;
19 class MachineInstr;
20 class MCContext;
21 class MCInst;
22 class MCOperand;
23 class MipsAsmPrinter;
24 
25 /// MipsMCInstLower - This class is used to lower an MachineInstr into an
26 ///                   MCInst.
27 class LLVM_LIBRARY_VISIBILITY MipsMCInstLower {
28   using MachineOperandType = MachineOperand::MachineOperandType;
29 
30   MCContext *Ctx;
31   MipsAsmPrinter &AsmPrinter;
32 
33 public:
34   MipsMCInstLower(MipsAsmPrinter &asmprinter);
35 
36   void Initialize(MCContext *C);
37   void Lower(const MachineInstr *MI, MCInst &OutMI) const;
38   MCOperand LowerOperand(const MachineOperand &MO, int64_t offset = 0) const;
39 
40 private:
41   MCOperand LowerSymbolOperand(const MachineOperand &MO,
42                                MachineOperandType MOTy, int64_t Offset) const;
43   MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2,
44                       MipsMCExpr::MipsExprKind Kind) const;
45   void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const;
46   void lowerLongBranchADDiu(const MachineInstr *MI, MCInst &OutMI,
47                             int Opcode) const;
48   bool lowerLongBranch(const MachineInstr *MI, MCInst &OutMI) const;
49 };
50 
51 } // end namespace llvm
52 
53 #endif // LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
54