LLVM 23.0.0git
BPFAsmPrinter.h
Go to the documentation of this file.
1//===-- BPFFrameLowering.h - Define frame lowering for BPF -----*- 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#ifndef LLVM_LIB_TARGET_BPF_BPFASMPRINTER_H
10#define LLVM_LIB_TARGET_BPF_BPFASMPRINTER_H
11
12#include "BPFTargetMachine.h"
13#include "BTFDebug.h"
15
16namespace llvm {
17
18class BPFAsmPrinter : public AsmPrinter {
19public:
21 std::unique_ptr<MCStreamer> Streamer)
22 : AsmPrinter(TM, std::move(Streamer), ID), BTF(nullptr), TM(TM) {}
23
24 StringRef getPassName() const override { return "BPF Assembly Printer"; }
25 bool doInitialization(Module &M) override;
26 bool doFinalization(Module &M) override;
27 void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
28 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
29 const char *ExtraCode, raw_ostream &O) override;
30 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
31 const char *ExtraCode, raw_ostream &O) override;
32
33 void emitInstruction(const MachineInstr *MI) override;
34 void emitFunctionBodyEnd() override;
35 MCSymbol *getJTPublicSymbol(unsigned JTI);
36 void emitJumpTableInfo() override;
37
38 static char ID;
39
40private:
41 BTFDebug *BTF;
42 TargetMachine &TM;
43 bool SawTrapCall = false;
44
45 const BPFTargetMachine &getBTM() const;
46};
47
48} // namespace llvm
49
50#endif /* LLVM_LIB_TARGET_BPF_BPFASMPRINTER_H */
This file contains support for writing BTF debug info.
IRTranslator LLVM IR MI
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer, char &ID=AsmPrinter::ID)
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
MCSymbol * getJTPublicSymbol(unsigned JTI)
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O)
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
BPFAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
bool doFinalization(Module &M) override
Shut down the asmprinter.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
void emitJumpTableInfo() override
Print assembly representations of the jump tables used by the current function to the current output ...
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
Collect and emit BTF information.
Definition BTFDebug.h:289
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Representation of each machine instruction.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Primary interface to the complete machine description for the target machine.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870