xref: /openbsd-src/gnu/llvm/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCCodeEmitter.h (revision d415bd752c734aee168c4ee86ff32e8cc249eb16)
1 //===-- AMDGPUCodeEmitter.h - AMDGPU Code Emitter interface -----*- 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 /// \file
10 /// CodeEmitter interface for SI codegen.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCCODEEMITTER_H
15 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCCODEEMITTER_H
16 
17 #include "llvm/ADT/APInt.h"
18 #include "llvm/MC/MCCodeEmitter.h"
19 
20 namespace llvm {
21 
22 class MCInst;
23 class MCInstrInfo;
24 class MCOperand;
25 class MCSubtargetInfo;
26 
27 class AMDGPUMCCodeEmitter : public MCCodeEmitter {
28   virtual void anchor();
29 
30 protected:
31   const MCInstrInfo &MCII;
32 
AMDGPUMCCodeEmitter(const MCInstrInfo & mcii)33   AMDGPUMCCodeEmitter(const MCInstrInfo &mcii) : MCII(mcii) {}
34 
35 public:
36   void getBinaryCodeForInstr(const MCInst &MI, SmallVectorImpl<MCFixup> &Fixups,
37                              APInt &Inst, APInt &Scratch,
38                              const MCSubtargetInfo &STI) const;
39 
40   virtual void getMachineOpValue(const MCInst &MI, const MCOperand &MO,
41                                  APInt &Op, SmallVectorImpl<MCFixup> &Fixups,
42                                  const MCSubtargetInfo &STI) const = 0;
43 
44   virtual void getSOPPBrEncoding(const MCInst &MI, unsigned OpNo, APInt &Op,
45                                  SmallVectorImpl<MCFixup> &Fixups,
46                                  const MCSubtargetInfo &STI) const = 0;
47 
48   virtual void getSMEMOffsetEncoding(const MCInst &MI, unsigned OpNo, APInt &Op,
49                                      SmallVectorImpl<MCFixup> &Fixups,
50                                      const MCSubtargetInfo &STI) const = 0;
51 
52   virtual void getSDWASrcEncoding(const MCInst &MI, unsigned OpNo, APInt &Op,
53                                   SmallVectorImpl<MCFixup> &Fixups,
54                                   const MCSubtargetInfo &STI) const = 0;
55 
56   virtual void getSDWAVopcDstEncoding(const MCInst &MI, unsigned OpNo,
57                                       APInt &Op,
58                                       SmallVectorImpl<MCFixup> &Fixups,
59                                       const MCSubtargetInfo &STI) const = 0;
60 
61   virtual void getAVOperandEncoding(const MCInst &MI, unsigned OpNo, APInt &Op,
62                                     SmallVectorImpl<MCFixup> &Fixups,
63                                     const MCSubtargetInfo &STI) const = 0;
64 };
65 
66 } // End namespace llvm
67 
68 #endif
69