1 //===-- CSKYAsmPrinter.h - CSKY implementation of AsmPrinter ----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_CSKY_CSKYASMPRINTER_H
10 #define LLVM_LIB_TARGET_CSKY_CSKYASMPRINTER_H
12 #include "CSKYMCInstLower.h"
13 #include "CSKYSubtarget.h"
14 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/MC/MCDirectives.h"
18 class LLVM_LIBRARY_VISIBILITY CSKYAsmPrinter
: public AsmPrinter
{
19 CSKYMCInstLower MCInstLowering
;
21 const MCSubtargetInfo
*Subtarget
;
22 const TargetInstrInfo
*TII
;
24 bool InConstantPool
= false;
26 /// Keep a pointer to constantpool entries of the current
28 MachineConstantPool
*MCP
;
30 void expandTLSLA(const MachineInstr
*MI
);
31 void emitCustomConstantPool(const MachineInstr
*MI
);
32 void emitAttributes();
35 explicit CSKYAsmPrinter(TargetMachine
&TM
,
36 std::unique_ptr
<MCStreamer
> Streamer
);
38 StringRef
getPassName() const override
{ return "CSKY Assembly Printer"; }
40 void EmitToStreamer(MCStreamer
&S
, const MCInst
&Inst
);
42 /// tblgen'erated driver function for lowering simple MI->MC
43 /// pseudo instructions.
44 bool lowerPseudoInstExpansion(const MachineInstr
*MI
, MCInst
&Inst
);
46 void emitMachineConstantPoolValue(MachineConstantPoolValue
*MCPV
) override
;
48 void emitFunctionBodyEnd() override
;
50 void emitStartOfAsmFile(Module
&M
) override
;
52 void emitEndOfAsmFile(Module
&M
) override
;
54 void emitInstruction(const MachineInstr
*MI
) override
;
56 bool runOnMachineFunction(MachineFunction
&MF
) override
;
58 // we emit constant pools customly!
59 void emitConstantPool() override
{}
61 bool PrintAsmOperand(const MachineInstr
*MI
, unsigned OpNo
,
62 const char *ExtraCode
, raw_ostream
&OS
) override
;
64 bool PrintAsmMemoryOperand(const MachineInstr
*MI
, unsigned OpNo
,
65 const char *ExtraCode
, raw_ostream
&OS
) override
;
67 } // end namespace llvm
69 #endif // LLVM_LIB_TARGET_CSKY_CSKYASMPRINTER_H