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 #include <cstdint> 20 21 namespace llvm { 22 23 class MCInst; 24 class MCInstrInfo; 25 class MCOperand; 26 class MCSubtargetInfo; 27 class FeatureBitset; 28 29 class AMDGPUMCCodeEmitter : public MCCodeEmitter { 30 virtual void anchor(); 31 32 protected: 33 const MCInstrInfo &MCII; 34 35 AMDGPUMCCodeEmitter(const MCInstrInfo &mcii) : MCII(mcii) {} 36 37 public: 38 void getBinaryCodeForInstr(const MCInst &MI, SmallVectorImpl<MCFixup> &Fixups, 39 APInt &Inst, APInt &Scratch, 40 const MCSubtargetInfo &STI) const; 41 42 virtual void getMachineOpValue(const MCInst &MI, const MCOperand &MO, 43 APInt &Op, SmallVectorImpl<MCFixup> &Fixups, 44 const MCSubtargetInfo &STI) const = 0; 45 46 virtual void getSOPPBrEncoding(const MCInst &MI, unsigned OpNo, APInt &Op, 47 SmallVectorImpl<MCFixup> &Fixups, 48 const MCSubtargetInfo &STI) const = 0; 49 50 virtual void getSMEMOffsetEncoding(const MCInst &MI, unsigned OpNo, APInt &Op, 51 SmallVectorImpl<MCFixup> &Fixups, 52 const MCSubtargetInfo &STI) const = 0; 53 54 virtual void getSDWASrcEncoding(const MCInst &MI, unsigned OpNo, APInt &Op, 55 SmallVectorImpl<MCFixup> &Fixups, 56 const MCSubtargetInfo &STI) const = 0; 57 58 virtual void getSDWAVopcDstEncoding(const MCInst &MI, unsigned OpNo, 59 APInt &Op, 60 SmallVectorImpl<MCFixup> &Fixups, 61 const MCSubtargetInfo &STI) const = 0; 62 63 virtual void getAVOperandEncoding(const MCInst &MI, unsigned OpNo, APInt &Op, 64 SmallVectorImpl<MCFixup> &Fixups, 65 const MCSubtargetInfo &STI) const = 0; 66 67 protected: 68 FeatureBitset computeAvailableFeatures(const FeatureBitset &FB) const; 69 void 70 verifyInstructionPredicates(const MCInst &MI, 71 const FeatureBitset &AvailableFeatures) const; 72 }; 73 74 } // End namespace llvm 75 76 #endif 77