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"
14#include "llvm/CodeGen/AsmPrinter.h"
15
16namespace llvm {
17
18class BPFAsmPrinter : public AsmPrinter {
19public:
20 explicit BPFAsmPrinter(TargetMachine &TM,
21 std::unique_ptr<MCStreamer> Streamer);
22 ~BPFAsmPrinter() override;
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 */
51