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 expandTLSLA(const MachineInstr *MI); 30 void emitCustomConstantPool(const MachineInstr *MI); 31 32 public: 33 explicit CSKYAsmPrinter(TargetMachine &TM, 34 std::unique_ptr<MCStreamer> Streamer); 35 36 StringRef getPassName() const override { return "CSKY Assembly Printer"; } 37 38 void EmitToStreamer(MCStreamer &S, const MCInst &Inst); 39 40 /// tblgen'erated driver function for lowering simple MI->MC 41 /// pseudo instructions. 42 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, 43 const MachineInstr *MI); 44 45 void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override; 46 47 void emitFunctionBodyEnd() override; 48 49 void emitInstruction(const MachineInstr *MI) override; 50 51 bool runOnMachineFunction(MachineFunction &MF) override; 52 53 // we emit constant pools customly! 54 void emitConstantPool() override{}; 55 }; 56 } // end namespace llvm 57 58 #endif // LLVM_LIB_TARGET_CSKY_CSKYASMPRINTER_H 59