Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MipsAsmPrinter.h
35269 views
//===- MipsAsmPrinter.h - Mips LLVM Assembly Printer -----------*- C++ -*--===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// Mips Assembly printer class.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H13#define LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H1415#include "Mips16HardFloatInfo.h"16#include "MipsMCInstLower.h"17#include "MipsSubtarget.h"18#include "llvm/CodeGen/AsmPrinter.h"19#include "llvm/MC/MCStreamer.h"20#include "llvm/Support/Compiler.h"21#include <algorithm>22#include <map>23#include <memory>2425namespace llvm {2627class MCOperand;28class MCSubtargetInfo;29class MCSymbol;30class MachineBasicBlock;31class MachineConstantPool;32class MachineFunction;33class MachineInstr;34class MachineOperand;35class MipsFunctionInfo;36class MipsTargetStreamer;37class Module;38class raw_ostream;39class TargetMachine;4041class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter {42MipsTargetStreamer &getTargetStreamer() const;4344void EmitInstrWithMacroNoAT(const MachineInstr *MI);4546//===------------------------------------------------------------------===//47// XRay implementation48//===------------------------------------------------------------------===//4950public:51// XRay-specific lowering for Mips.52void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);53void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);54void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);5556private:57/// MCP - Keep a pointer to constantpool entries of the current58/// MachineFunction.59const MachineConstantPool *MCP = nullptr;6061/// InConstantPool - Maintain state when emitting a sequence of constant62/// pool entries so we can properly mark them as data regions.63bool InConstantPool = false;6465std::map<const char *, const Mips16HardFloatInfo::FuncSignature *>66StubsNeeded;6768void EmitSled(const MachineInstr &MI, SledKind Kind);6970// tblgen'erated function.71bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,72const MachineInstr *MI);7374// Emit PseudoReturn, PseudoReturn64, PseudoIndirectBranch,75// and PseudoIndirectBranch64 as a JR, JR_MM, JALR, or JALR64 as appropriate76// for the target.77void emitPseudoIndirectBranch(MCStreamer &OutStreamer,78const MachineInstr *MI);7980// lowerOperand - Convert a MachineOperand into the equivalent MCOperand.81bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);8283void emitInlineAsmStart() const override;8485void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,86const MCSubtargetInfo *EndInfo) const override;8788void EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol);8990void EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, unsigned Reg);9192void EmitInstrRegReg(const MCSubtargetInfo &STI, unsigned Opcode,93unsigned Reg1, unsigned Reg2);9495void EmitInstrRegRegReg(const MCSubtargetInfo &STI, unsigned Opcode,96unsigned Reg1, unsigned Reg2, unsigned Reg3);9798void EmitMovFPIntPair(const MCSubtargetInfo &STI, unsigned MovOpc,99unsigned Reg1, unsigned Reg2, unsigned FPReg1,100unsigned FPReg2, bool LE);101102void EmitSwapFPIntParams(const MCSubtargetInfo &STI,103Mips16HardFloatInfo::FPParamVariant, bool LE,104bool ToFP);105106void EmitSwapFPIntRetval(const MCSubtargetInfo &STI,107Mips16HardFloatInfo::FPReturnVariant, bool LE);108109void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);110111void NaClAlignIndirectJumpTargets(MachineFunction &MF);112113bool isLongBranchPseudo(int Opcode) const;114115public:116const MipsSubtarget *Subtarget;117const MipsFunctionInfo *MipsFI;118MipsMCInstLower MCInstLowering;119120explicit MipsAsmPrinter(TargetMachine &TM,121std::unique_ptr<MCStreamer> Streamer)122: AsmPrinter(TM, std::move(Streamer)), MCInstLowering(*this) {}123124StringRef getPassName() const override { return "Mips Assembly Printer"; }125126bool runOnMachineFunction(MachineFunction &MF) override;127128void emitConstantPool() override {129bool UsingConstantPools =130(Subtarget->inMips16Mode() && Subtarget->useConstantIslands());131if (!UsingConstantPools)132AsmPrinter::emitConstantPool();133// we emit constant pools customly!134}135136void emitInstruction(const MachineInstr *MI) override;137void printSavedRegsBitmask();138void emitFrameDirective();139const char *getCurrentABIString() const;140void emitFunctionEntryLabel() override;141void emitFunctionBodyStart() override;142void emitFunctionBodyEnd() override;143void emitBasicBlockEnd(const MachineBasicBlock &MBB) override;144bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,145const char *ExtraCode, raw_ostream &O) override;146bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,147const char *ExtraCode, raw_ostream &O) override;148void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);149void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);150void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);151void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,152const char *Modifier = nullptr);153void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O);154void emitStartOfAsmFile(Module &M) override;155void emitEndOfAsmFile(Module &M) override;156void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);157void emitDebugValue(const MCExpr *Value, unsigned Size) const override;158};159160} // end namespace llvm161162#endif // LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H163164165