xref: /llvm-project/llvm/lib/Target/Xtensa/XtensaAsmPrinter.h (revision dc2d0d5e1a4e7a7524f68aa9739acf22bee13b9e)
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   void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
46 
47   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
48                        const char *ExtraCode, raw_ostream &O) override;
49 
50   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
51                              const char *ExtraCode, raw_ostream &OS) override;
52 
53   MCSymbol *GetConstantPoolIndexSymbol(const MachineOperand &MO) const;
54 
55   MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
56 
57   MCOperand LowerSymbolOperand(const MachineOperand &MO,
58                                MachineOperand::MachineOperandType MOTy,
59                                unsigned Offset) const;
60 
61   // Lower MachineInstr MI to MCInst OutMI.
62   void lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) const;
63 
64   // Return an MCOperand for MO.  Return an empty operand if MO is implicit.
65   MCOperand lowerOperand(const MachineOperand &MO, unsigned Offset = 0) const;
66 };
67 } // end namespace llvm
68 
69 #endif /* LLVM_LIB_TARGET_XTENSA_XTENSAASMPRINTER_H */
70