1 //===-- CSKYAsmPrinter.h - CSKY implementation of AsmPrinter ----*- C++ -*-===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIB_TARGET_CSKY_CSKYASMPRINTER_H 10 #define LLVM_LIB_TARGET_CSKY_CSKYASMPRINTER_H 11 12 #include "CSKYMCInstLower.h" 13 #include "CSKYSubtarget.h" 14 #include "llvm/CodeGen/AsmPrinter.h" 15 #include "llvm/MC/MCDirectives.h" 16 17 namespace llvm { 18 class LLVM_LIBRARY_VISIBILITY CSKYAsmPrinter : public AsmPrinter { 19 CSKYMCInstLower MCInstLowering; 20 21 const CSKYSubtarget *Subtarget; 22 23 bool InConstantPool = false; 24 25 /// Keep a pointer to constantpool entries of the current 26 /// MachineFunction. 27 MachineConstantPool *MCP; 28 29 void emitCustomConstantPool(const MachineInstr *MI); 30 31 public: 32 explicit CSKYAsmPrinter(TargetMachine &TM, 33 std::unique_ptr<MCStreamer> Streamer); 34 35 StringRef getPassName() const override { return "CSKY Assembly Printer"; } 36 37 void EmitToStreamer(MCStreamer &S, const MCInst &Inst); 38 39 /// tblgen'erated driver function for lowering simple MI->MC 40 /// pseudo instructions. 41 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, 42 const MachineInstr *MI); 43 44 void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override; 45 46 void emitFunctionBodyEnd() override; 47 48 void emitInstruction(const MachineInstr *MI) override; 49 50 bool runOnMachineFunction(MachineFunction &MF) override; 51 52 // we emit constant pools customly! 53 void emitConstantPool() override{}; 54 }; 55 } // end namespace llvm 56 57 #endif // LLVM_LIB_TARGET_CSKY_CSKYASMPRINTER_H 58