D25618 added a method to verify the instruction predicates for an emitted instruction, through verifyInstructionPredicates added into <Target>MCCodeEmitter::encodeInstruction. This is a very useful idea, but the implementation inside MCCodeEmitter made it only fire for object files, not assembly which most of the llvm test suite uses. This patch moves the code into the <Target>_MC::verifyInstructionPredicates method, inside the InstrInfo. The allows it to be called from other places, such as in this patch where it is called from the <Target>AsmPrinter::emitInstruction methods which should trigger for both assembly and object files. It can also be called from other places such as verifyInstruction, but that is not done here (it tends to catch errors earlier, but in reality just shows all the mir tests that have incorrect feature predicates). The interface was also simplified slightly, moving computeAvailableFeatures into the function so that it does not need to be called externally. The ARM, AMDGPU (but not R600), AVR, Mips and X86 backends all currently show errors in the test-suite, so have been disabled with FIXME comments. Recommitted with some fixes for the leftover MCII variables in release builds. Differential Revision: https://reviews.llvm.org/D129506
70 lines
2.6 KiB
C++
70 lines
2.6 KiB
C++
//===-- AMDGPUCodeEmitter.h - AMDGPU Code Emitter interface -----*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
/// \file
|
|
/// CodeEmitter interface for SI codegen.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCCODEEMITTER_H
|
|
#define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCCODEEMITTER_H
|
|
|
|
#include "llvm/ADT/APInt.h"
|
|
#include "llvm/MC/MCCodeEmitter.h"
|
|
|
|
namespace llvm {
|
|
|
|
class MCInst;
|
|
class MCInstrInfo;
|
|
class MCOperand;
|
|
class MCSubtargetInfo;
|
|
class FeatureBitset;
|
|
|
|
class AMDGPUMCCodeEmitter : public MCCodeEmitter {
|
|
virtual void anchor();
|
|
|
|
protected:
|
|
const MCInstrInfo &MCII;
|
|
|
|
AMDGPUMCCodeEmitter(const MCInstrInfo &mcii) : MCII(mcii) {}
|
|
|
|
public:
|
|
void getBinaryCodeForInstr(const MCInst &MI, SmallVectorImpl<MCFixup> &Fixups,
|
|
APInt &Inst, APInt &Scratch,
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
virtual void getMachineOpValue(const MCInst &MI, const MCOperand &MO,
|
|
APInt &Op, SmallVectorImpl<MCFixup> &Fixups,
|
|
const MCSubtargetInfo &STI) const = 0;
|
|
|
|
virtual void getSOPPBrEncoding(const MCInst &MI, unsigned OpNo, APInt &Op,
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
const MCSubtargetInfo &STI) const = 0;
|
|
|
|
virtual void getSMEMOffsetEncoding(const MCInst &MI, unsigned OpNo, APInt &Op,
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
const MCSubtargetInfo &STI) const = 0;
|
|
|
|
virtual void getSDWASrcEncoding(const MCInst &MI, unsigned OpNo, APInt &Op,
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
const MCSubtargetInfo &STI) const = 0;
|
|
|
|
virtual void getSDWAVopcDstEncoding(const MCInst &MI, unsigned OpNo,
|
|
APInt &Op,
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
const MCSubtargetInfo &STI) const = 0;
|
|
|
|
virtual void getAVOperandEncoding(const MCInst &MI, unsigned OpNo, APInt &Op,
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
const MCSubtargetInfo &STI) const = 0;
|
|
};
|
|
|
|
} // End namespace llvm
|
|
|
|
#endif
|