xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
10b57cec5SDimitry Andric //===-- HexagonInstPrinter.h - Convert Hexagon MCInst to assembly syntax --===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric //
100b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H
130b57cec5SDimitry Andric #define LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric #include "llvm/MC/MCInstPrinter.h"
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric namespace llvm {
180b57cec5SDimitry Andric /// Prints bundles as a newline separated list of individual instructions
190b57cec5SDimitry Andric /// Duplexes are separated by a vertical tab \v character
200b57cec5SDimitry Andric /// A trailing line includes bundle properties such as endloop0/1
210b57cec5SDimitry Andric ///
220b57cec5SDimitry Andric /// r0 = add(r1, r2)
230b57cec5SDimitry Andric /// r0 = #0 \v jump 0x0
240b57cec5SDimitry Andric /// :endloop0 :endloop1
250b57cec5SDimitry Andric class HexagonInstPrinter : public MCInstPrinter {
260b57cec5SDimitry Andric public:
HexagonInstPrinter(MCAsmInfo const & MAI,MCInstrInfo const & MII,MCRegisterInfo const & MRI)270b57cec5SDimitry Andric   explicit HexagonInstPrinter(MCAsmInfo const &MAI, MCInstrInfo const &MII,
280b57cec5SDimitry Andric                               MCRegisterInfo const &MRI)
290b57cec5SDimitry Andric     : MCInstPrinter(MAI, MII, MRI), MII(MII) {}
300b57cec5SDimitry Andric 
31480093f4SDimitry Andric   void printInst(MCInst const *MI, uint64_t Address, StringRef Annot,
32480093f4SDimitry Andric                  const MCSubtargetInfo &STI, raw_ostream &O) override;
33*bdd1243dSDimitry Andric   void printRegName(raw_ostream &O, MCRegister Reg) const override;
340b57cec5SDimitry Andric 
35*bdd1243dSDimitry Andric   static char const *getRegisterName(MCRegister Reg);
360b57cec5SDimitry Andric 
37e8d8bef9SDimitry Andric   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
38480093f4SDimitry Andric   void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
390b57cec5SDimitry Andric   void printOperand(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
400b57cec5SDimitry Andric   void printBrtarget(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
410b57cec5SDimitry Andric 
getMAI()420b57cec5SDimitry Andric   MCAsmInfo const &getMAI() const { return MAI; }
getMII()430b57cec5SDimitry Andric   MCInstrInfo const &getMII() const { return MII; }
440b57cec5SDimitry Andric 
450b57cec5SDimitry Andric private:
460b57cec5SDimitry Andric   MCInstrInfo const &MII;
470b57cec5SDimitry Andric   bool HasExtender = false;
480b57cec5SDimitry Andric };
490b57cec5SDimitry Andric 
500b57cec5SDimitry Andric } // end namespace llvm
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric #endif
53