LoongArchAsmPrinter.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //===- LoongArchAsmPrinter.h - LoongArch LLVM Assembly Printer -*- 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. // LoongArch Assembly printer class.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHASMPRINTER_H
  13. #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHASMPRINTER_H
  14. #include "LoongArchSubtarget.h"
  15. #include "llvm/CodeGen/AsmPrinter.h"
  16. #include "llvm/MC/MCStreamer.h"
  17. #include "llvm/Support/Compiler.h"
  18. namespace llvm {
  19. class LLVM_LIBRARY_VISIBILITY LoongArchAsmPrinter : public AsmPrinter {
  20. const MCSubtargetInfo *STI;
  21. public:
  22. explicit LoongArchAsmPrinter(TargetMachine &TM,
  23. std::unique_ptr<MCStreamer> Streamer)
  24. : AsmPrinter(TM, std::move(Streamer)), STI(TM.getMCSubtargetInfo()) {}
  25. StringRef getPassName() const override {
  26. return "LoongArch Assembly Printer";
  27. }
  28. bool runOnMachineFunction(MachineFunction &MF) override;
  29. void emitInstruction(const MachineInstr *MI) override;
  30. bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
  31. const char *ExtraCode, raw_ostream &OS) override;
  32. bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
  33. const char *ExtraCode, raw_ostream &OS) override;
  34. // tblgen'erated function.
  35. bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
  36. const MachineInstr *MI);
  37. // Wrapper needed for tblgenned pseudo lowering.
  38. bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const {
  39. return lowerLoongArchMachineOperandToMCOperand(MO, MCOp, *this);
  40. }
  41. };
  42. } // end namespace llvm
  43. #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHASMPRINTER_H