xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Xtensa/XtensaAsmPrinter.h (revision 47ef2a131091508e049ab10cad7f91a3c1342cd9)
1 //===- XtensaAsmPrinter.h - Xtensa 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 // Xtensa Assembly printer class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_XTENSA_XTENSAASMPRINTER_H
14 #define LLVM_LIB_TARGET_XTENSA_XTENSAASMPRINTER_H
15 
16 #include "XtensaTargetMachine.h"
17 #include "llvm/CodeGen/AsmPrinter.h"
18 #include "llvm/CodeGen/MachineConstantPool.h"
19 #include "llvm/Support/Compiler.h"
20 
21 namespace llvm {
22 class MCStreamer;
23 class MachineBasicBlock;
24 class MachineInstr;
25 class Module;
26 class raw_ostream;
27 
28 class LLVM_LIBRARY_VISIBILITY XtensaAsmPrinter : public AsmPrinter {
29   const MCSubtargetInfo *STI;
30 
31 public:
32   explicit XtensaAsmPrinter(TargetMachine &TM,
33                             std::unique_ptr<MCStreamer> Streamer)
34       : AsmPrinter(TM, std::move(Streamer)), STI(TM.getMCSubtargetInfo()) {}
35 
36   StringRef getPassName() const override { return "Xtensa Assembly Printer"; }
37   void emitInstruction(const MachineInstr *MI) override;
38 
39   void emitConstantPool() override;
40 
41   void emitMachineConstantPoolEntry(const MachineConstantPoolEntry &CPE, int i);
42 
43   void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
44 
45   MCSymbol *GetConstantPoolIndexSymbol(const MachineOperand &MO) const;
46 
47   MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
48 
49   MCOperand LowerSymbolOperand(const MachineOperand &MO,
50                                MachineOperand::MachineOperandType MOTy,
51                                unsigned Offset) const;
52 
53   // Lower MachineInstr MI to MCInst OutMI.
54   void lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) const;
55 
56   // Return an MCOperand for MO.  Return an empty operand if MO is implicit.
57   MCOperand lowerOperand(const MachineOperand &MO, unsigned Offset = 0) const;
58 };
59 } // end namespace llvm
60 
61 #endif /* LLVM_LIB_TARGET_XTENSA_XTENSAASMPRINTER_H */
62