blob: fb5079643827288181339e7eaef2a226f6e0ce28 [file] [log] [blame]
Eugene Zelenko79220eae2017-08-03 22:12:30 +00001//===- MipsMCInstLower.h - Lower MachineInstr to MCInst --------*- C++ -*--===//
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +00002//
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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
11#define LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H
Eugene Zelenko79220eae2017-08-03 22:12:30 +000012
Sasa Stankovic7b061a42014-04-30 15:06:25 +000013#include "MCTargetDesc/MipsMCExpr.h"
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000014#include "llvm/CodeGen/MachineOperand.h"
15#include "llvm/Support/Compiler.h"
16
17namespace llvm {
Eugene Zelenko79220eae2017-08-03 22:12:30 +000018
19class MachineBasicBlock;
20class MachineInstr;
21class MCContext;
22class MCInst;
23class MCOperand;
24class MipsAsmPrinter;
Jia Liuf54f60f2012-02-28 07:46:26 +000025
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000026/// MipsMCInstLower - This class is used to lower an MachineInstr into an
Eugene Zelenko79220eae2017-08-03 22:12:30 +000027/// MCInst.
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000028class LLVM_LIBRARY_VISIBILITY MipsMCInstLower {
Eugene Zelenko79220eae2017-08-03 22:12:30 +000029 using MachineOperandType = MachineOperand::MachineOperandType;
30
Akira Hatanaka34ee3ff2012-03-28 00:22:50 +000031 MCContext *Ctx;
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000032 MipsAsmPrinter &AsmPrinter;
Eugene Zelenko79220eae2017-08-03 22:12:30 +000033
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000034public:
Akira Hatanaka34ee3ff2012-03-28 00:22:50 +000035 MipsMCInstLower(MipsAsmPrinter &asmprinter);
Eugene Zelenko79220eae2017-08-03 22:12:30 +000036
Rafael Espindola7d78b2a2013-10-29 16:24:21 +000037 void Initialize(MCContext *C);
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000038 void Lower(const MachineInstr *MI, MCInst &OutMI) const;
Akira Hatanaka42a35242012-09-27 01:59:07 +000039 MCOperand LowerOperand(const MachineOperand& MO, unsigned offset = 0) const;
Jack Carterf6490432012-07-16 15:14:51 +000040
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000041private:
42 MCOperand LowerSymbolOperand(const MachineOperand &MO,
Akira Hatanaka6520b982011-08-16 02:15:03 +000043 MachineOperandType MOTy, unsigned Offset) const;
Sasa Stankovic7b061a42014-04-30 15:06:25 +000044 MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2,
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000045 MipsMCExpr::MipsExprKind Kind) const;
Sasa Stankovice41db2f2014-05-27 18:53:06 +000046 void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const;
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000047 void lowerLongBranchADDiu(const MachineInstr *MI, MCInst &OutMI, int Opcode,
48 MipsMCExpr::MipsExprKind Kind) const;
Sasa Stankovic7b061a42014-04-30 15:06:25 +000049 bool lowerLongBranch(const MachineInstr *MI, MCInst &OutMI) const;
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000050};
Akira Hatanaka77a9e6e2011-07-07 20:24:54 +000051
Eugene Zelenko79220eae2017-08-03 22:12:30 +000052} // end namespace llvm
53
54#endif // LLVM_LIB_TARGET_MIPS_MIPSMCINSTLOWER_H