xref: /openbsd-src/gnu/llvm/llvm/lib/Target/Mips/MipsMCInstLower.h (revision 09467b48e8bc8b4905716062da846024139afbf2)
1*09467b48Spatrick //===- MipsMCInstLower.h - Lower MachineInstr to MCInst --------*- C++ -*--===//
2*09467b48Spatrick //
3*09467b48Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*09467b48Spatrick // See https://llvm.org/LICENSE.txt for license information.
5*09467b48Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*09467b48Spatrick //
7*09467b48Spatrick //===----------------------------------------------------------------------===//
8*09467b48Spatrick 
9*09467b48Spatrick #ifndef LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
10*09467b48Spatrick #define LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
11*09467b48Spatrick 
12*09467b48Spatrick #include "MCTargetDesc/MipsMCExpr.h"
13*09467b48Spatrick #include "llvm/CodeGen/MachineOperand.h"
14*09467b48Spatrick #include "llvm/Support/Compiler.h"
15*09467b48Spatrick 
16*09467b48Spatrick namespace llvm {
17*09467b48Spatrick 
18*09467b48Spatrick class MachineBasicBlock;
19*09467b48Spatrick class MachineInstr;
20*09467b48Spatrick class MCContext;
21*09467b48Spatrick class MCInst;
22*09467b48Spatrick class MCOperand;
23*09467b48Spatrick class MipsAsmPrinter;
24*09467b48Spatrick 
25*09467b48Spatrick /// MipsMCInstLower - This class is used to lower an MachineInstr into an
26*09467b48Spatrick ///                   MCInst.
27*09467b48Spatrick class LLVM_LIBRARY_VISIBILITY MipsMCInstLower {
28*09467b48Spatrick   using MachineOperandType = MachineOperand::MachineOperandType;
29*09467b48Spatrick 
30*09467b48Spatrick   MCContext *Ctx;
31*09467b48Spatrick   MipsAsmPrinter &AsmPrinter;
32*09467b48Spatrick 
33*09467b48Spatrick public:
34*09467b48Spatrick   MipsMCInstLower(MipsAsmPrinter &asmprinter);
35*09467b48Spatrick 
36*09467b48Spatrick   void Initialize(MCContext *C);
37*09467b48Spatrick   void Lower(const MachineInstr *MI, MCInst &OutMI) const;
38*09467b48Spatrick   MCOperand LowerOperand(const MachineOperand &MO, int64_t offset = 0) const;
39*09467b48Spatrick 
40*09467b48Spatrick private:
41*09467b48Spatrick   MCOperand LowerSymbolOperand(const MachineOperand &MO,
42*09467b48Spatrick                                MachineOperandType MOTy, int64_t Offset) const;
43*09467b48Spatrick   MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2,
44*09467b48Spatrick                       MipsMCExpr::MipsExprKind Kind) const;
45*09467b48Spatrick   void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const;
46*09467b48Spatrick   void lowerLongBranchADDiu(const MachineInstr *MI, MCInst &OutMI,
47*09467b48Spatrick                             int Opcode) const;
48*09467b48Spatrick   bool lowerLongBranch(const MachineInstr *MI, MCInst &OutMI) const;
49*09467b48Spatrick };
50*09467b48Spatrick 
51*09467b48Spatrick } // end namespace llvm
52*09467b48Spatrick 
53*09467b48Spatrick #endif // LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
54