84 lines · c
1//===- HexagonAsmPrinter.h - Print machine code -----------------*- 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-exception6//7//===----------------------------------------------------------------------===//8//9// Hexagon Assembly printer class.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONASMPRINTER_H14#define LLVM_LIB_TARGET_HEXAGON_HEXAGONASMPRINTER_H15 16#include "HexagonSubtarget.h"17#include "llvm/CodeGen/AsmPrinter.h"18#include "llvm/CodeGen/MachineFunction.h"19#include "llvm/MC/MCStreamer.h"20#include <utility>21 22namespace llvm {23 24class MachineInstr;25class MCInst;26class raw_ostream;27class TargetMachine;28 29 class HexagonAsmPrinter : public AsmPrinter {30 public:31 static char ID;32 33 private:34 const HexagonSubtarget *Subtarget = nullptr;35 36 void emitAttributes();37 38 public:39 explicit HexagonAsmPrinter(TargetMachine &TM,40 std::unique_ptr<MCStreamer> Streamer)41 : AsmPrinter(TM, std::move(Streamer), ID) {}42 43 bool runOnMachineFunction(MachineFunction &Fn) override {44 Subtarget = &Fn.getSubtarget<HexagonSubtarget>();45 const bool Modified = AsmPrinter::runOnMachineFunction(Fn);46 // Emit the XRay table for this function.47 emitXRayTable();48 49 return Modified;50 }51 52 StringRef getPassName() const override {53 return "Hexagon Assembly Printer";54 }55 56 bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB)57 const override;58 59 void emitInstruction(const MachineInstr *MI) override;60 61 //===------------------------------------------------------------------===//62 // XRay implementation63 //===------------------------------------------------------------------===//64 // XRay-specific lowering for Hexagon.65 void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);66 void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);67 void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);68 void EmitSled(const MachineInstr &MI, SledKind Kind);69 70 void HexagonProcessInstruction(MCInst &Inst, const MachineInstr &MBB);71 72 void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);73 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,74 const char *ExtraCode, raw_ostream &OS) override;75 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,76 const char *ExtraCode, raw_ostream &OS) override;77 void emitStartOfAsmFile(Module &M) override;78 void emitEndOfAsmFile(Module &M) override;79 };80 81} // end namespace llvm82 83#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONASMPRINTER_H84