xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUMIRFormatter.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1e8d8bef9SDimitry Andric //===-- llvm/Target/AMDGPU/AMDGPUMIRFormatter.h -----------------*- C++ -*-===//
2e8d8bef9SDimitry Andric //
3e8d8bef9SDimitry Andric //                     The LLVM Compiler Infrastructure
4e8d8bef9SDimitry Andric //
5e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
7e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8e8d8bef9SDimitry Andric //
9e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
10e8d8bef9SDimitry Andric //
11e8d8bef9SDimitry Andric /// \file
12e8d8bef9SDimitry Andric /// AMDGPU specific overrides of MIRFormatter.
13e8d8bef9SDimitry Andric //
14e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
15e8d8bef9SDimitry Andric 
16e8d8bef9SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPUMIRFORMATTER_H
17e8d8bef9SDimitry Andric #define LLVM_LIB_TARGET_AMDGPUMIRFORMATTER_H
18e8d8bef9SDimitry Andric 
19e8d8bef9SDimitry Andric #include "llvm/CodeGen/MIRFormatter.h"
20e8d8bef9SDimitry Andric 
21e8d8bef9SDimitry Andric namespace llvm {
22e8d8bef9SDimitry Andric 
23e8d8bef9SDimitry Andric class MachineFunction;
24e8d8bef9SDimitry Andric struct PerFunctionMIParsingState;
25e8d8bef9SDimitry Andric 
26e8d8bef9SDimitry Andric class AMDGPUMIRFormatter final : public MIRFormatter {
27e8d8bef9SDimitry Andric public:
2881ad6265SDimitry Andric   AMDGPUMIRFormatter() = default;
29e8d8bef9SDimitry Andric   virtual ~AMDGPUMIRFormatter() = default;
30e8d8bef9SDimitry Andric 
31*0fca6ea1SDimitry Andric   /// Implement target specific printing for machine operand immediate value, so
32*0fca6ea1SDimitry Andric   /// that we can have more meaningful mnemonic than a 64-bit integer. Passing
33*0fca6ea1SDimitry Andric   /// None to OpIdx means the index is unknown.
34*0fca6ea1SDimitry Andric   virtual void printImm(raw_ostream &OS, const MachineInstr &MI,
35*0fca6ea1SDimitry Andric                         std::optional<unsigned> OpIdx,
36*0fca6ea1SDimitry Andric                         int64_t Imm) const override;
37*0fca6ea1SDimitry Andric 
38*0fca6ea1SDimitry Andric   /// Implement target specific parsing of immediate mnemonics. The mnemonic is
39*0fca6ea1SDimitry Andric   /// a string with a leading dot.
40*0fca6ea1SDimitry Andric   virtual bool parseImmMnemonic(const unsigned OpCode, const unsigned OpIdx,
41*0fca6ea1SDimitry Andric                                 StringRef Src, int64_t &Imm,
42*0fca6ea1SDimitry Andric                                 ErrorCallbackType ErrorCallback) const override;
43*0fca6ea1SDimitry Andric 
44e8d8bef9SDimitry Andric   /// Implement target specific parsing of target custom pseudo source value.
45972a253aSDimitry Andric   bool
46e8d8bef9SDimitry Andric   parseCustomPseudoSourceValue(StringRef Src, MachineFunction &MF,
47e8d8bef9SDimitry Andric                                PerFunctionMIParsingState &PFS,
48e8d8bef9SDimitry Andric                                const PseudoSourceValue *&PSV,
49e8d8bef9SDimitry Andric                                ErrorCallbackType ErrorCallback) const override;
50*0fca6ea1SDimitry Andric 
51*0fca6ea1SDimitry Andric private:
52*0fca6ea1SDimitry Andric   /// Print the string to represent s_delay_alu immediate value
53*0fca6ea1SDimitry Andric   void printSDelayAluImm(int64_t Imm, llvm::raw_ostream &OS) const;
54*0fca6ea1SDimitry Andric 
55*0fca6ea1SDimitry Andric   /// Parse the immediate pseudo literal for s_delay_alu
56*0fca6ea1SDimitry Andric   bool parseSDelayAluImmMnemonic(
57*0fca6ea1SDimitry Andric       const unsigned int OpIdx, int64_t &Imm, llvm::StringRef &Src,
58*0fca6ea1SDimitry Andric       llvm::MIRFormatter::ErrorCallbackType &ErrorCallback) const;
59*0fca6ea1SDimitry Andric 
60e8d8bef9SDimitry Andric };
61e8d8bef9SDimitry Andric 
62e8d8bef9SDimitry Andric } // end namespace llvm
63e8d8bef9SDimitry Andric 
64e8d8bef9SDimitry Andric #endif
65