• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- MipsMCInstLower.h - Lower MachineInstr to MCInst -------*- C++ -*--===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
11 #define LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
12 #include "MCTargetDesc/MipsMCExpr.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/CodeGen/MachineOperand.h"
15 #include "llvm/Support/Compiler.h"
16 
17 namespace llvm {
18   class MCContext;
19   class MCInst;
20   class MCOperand;
21   class MachineInstr;
22   class MachineFunction;
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   typedef MachineOperand::MachineOperandType MachineOperandType;
29   MCContext *Ctx;
30   MipsAsmPrinter &AsmPrinter;
31 public:
32   MipsMCInstLower(MipsAsmPrinter &asmprinter);
33   void Initialize(MCContext *C);
34   void Lower(const MachineInstr *MI, MCInst &OutMI) const;
35   MCOperand LowerOperand(const MachineOperand& MO, unsigned offset = 0) const;
36 
37 private:
38   MCOperand LowerSymbolOperand(const MachineOperand &MO,
39                                MachineOperandType MOTy, unsigned Offset) const;
40   MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2,
41                       MCSymbolRefExpr::VariantKind Kind) const;
42   void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const;
43   void lowerLongBranchADDiu(const MachineInstr *MI, MCInst &OutMI,
44                             int Opcode,
45                             MCSymbolRefExpr::VariantKind Kind) const;
46   bool lowerLongBranch(const MachineInstr *MI, MCInst &OutMI) const;
47 };
48 }
49 
50 #endif
51