llvm/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp

//===- GlobalISelMatchTable.cpp -------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "GlobalISelMatchTable.h"
#include "Common/CodeGenInstruction.h"
#include "Common/CodeGenRegisters.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TableGen/Error.h"

#define DEBUG_TYPE

STATISTIC(NumPatternEmitted, "Number of patterns emitted");

namespace llvm {
namespace gi {

namespace {

Error failUnsupported(const Twine &Reason) {}

/// Get the name of the enum value used to number the predicate function.
std::string getEnumNameForPredicate(const TreePredicateFn &Predicate) {}

std::string getMatchOpcodeForImmPredicate(const TreePredicateFn &Predicate) {}

// GIMT_Encode2/4/8
constexpr StringLiteral EncodeMacroName =;

} // namespace

//===- Helpers ------------------------------------------------------------===//

void emitEncodingMacrosDef(raw_ostream &OS) {}

void emitEncodingMacrosUndef(raw_ostream &OS) {}

std::string getNameForFeatureBitset(const std::vector<Record *> &FeatureBitset,
                                    int HwModeIdx) {}

template <class GroupT>
std::vector<Matcher *>
optimizeRules(ArrayRef<Matcher *> Rules,
              std::vector<std::unique_ptr<Matcher>> &MatcherStorage) {}

template std::vector<Matcher *> optimizeRules<GroupMatcher>(
    ArrayRef<Matcher *> Rules,
    std::vector<std::unique_ptr<Matcher>> &MatcherStorage);

template std::vector<Matcher *> optimizeRules<SwitchMatcher>(
    ArrayRef<Matcher *> Rules,
    std::vector<std::unique_ptr<Matcher>> &MatcherStorage);

static std::string getEncodedEmitStr(StringRef NamedValue, unsigned NumBytes) {}

//===- Global Data --------------------------------------------------------===//

std::set<LLTCodeGen> KnownTypes;

//===- MatchTableRecord ---------------------------------------------------===//

void MatchTableRecord::emit(raw_ostream &OS, bool LineBreakIsNextAfterThis,
                            const MatchTable &Table) const {}

//===- MatchTable ---------------------------------------------------------===//

MatchTableRecord MatchTable::LineBreak =;

MatchTableRecord MatchTable::Comment(StringRef Comment) {}

MatchTableRecord MatchTable::Opcode(StringRef Opcode, int IndentAdjust) {}

MatchTableRecord MatchTable::NamedValue(unsigned NumBytes,
                                        StringRef NamedValue) {}

MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef NamedValue,
                                        int64_t RawValue) {}

MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
                                        StringRef NamedValue) {}

MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
                                        StringRef NamedValue,
                                        int64_t RawValue) {}

MatchTableRecord MatchTable::IntValue(unsigned NumBytes, int64_t IntValue) {}

MatchTableRecord MatchTable::ULEB128Value(uint64_t IntValue) {}

MatchTableRecord MatchTable::Label(unsigned LabelID) {}

MatchTableRecord MatchTable::JumpTarget(unsigned LabelID) {}

void MatchTable::emitUse(raw_ostream &OS) const {}

void MatchTable::emitDeclaration(raw_ostream &OS) const {}

MatchTable MatchTable::buildTable(ArrayRef<Matcher *> Rules, bool WithCoverage,
                                  bool IsCombiner) {}

//===- LLTCodeGen ---------------------------------------------------------===//

std::string LLTCodeGen::getCxxEnumValue() const {}

void LLTCodeGen::emitCxxEnumValue(raw_ostream &OS) const {}

void LLTCodeGen::emitCxxConstructorCall(raw_ostream &OS) const {}

/// This ordering is used for std::unique() and llvm::sort(). There's no
/// particular logic behind the order but either A < B or B < A must be
/// true if A != B.
bool LLTCodeGen::operator<(const LLTCodeGen &Other) const {}

//===- LLTCodeGen Helpers -------------------------------------------------===//

std::optional<LLTCodeGen> MVTToLLT(MVT::SimpleValueType SVT) {}

//===- Matcher ------------------------------------------------------------===//

void Matcher::optimize() {}

Matcher::~Matcher() {}

//===- GroupMatcher -------------------------------------------------------===//

bool GroupMatcher::candidateConditionMatches(
    const PredicateMatcher &Predicate) const {}

bool GroupMatcher::addMatcher(Matcher &Candidate) {}

void GroupMatcher::finalize() {}

void GroupMatcher::emit(MatchTable &Table) {}

void GroupMatcher::optimize() {}

//===- SwitchMatcher ------------------------------------------------------===//

bool SwitchMatcher::isSupportedPredicateType(const PredicateMatcher &P) {}

bool SwitchMatcher::candidateConditionMatches(
    const PredicateMatcher &Predicate) const {}

bool SwitchMatcher::addMatcher(Matcher &Candidate) {}

void SwitchMatcher::finalize() {}

void SwitchMatcher::emitPredicateSpecificOpcodes(const PredicateMatcher &P,
                                                 MatchTable &Table) {}

void SwitchMatcher::emit(MatchTable &Table) {}

//===- RuleMatcher --------------------------------------------------------===//

uint64_t RuleMatcher::NextRuleID =;

StringRef RuleMatcher::getOpcode() const {}

LLTCodeGen RuleMatcher::getFirstConditionAsRootType() {}

void RuleMatcher::optimize() {}

bool RuleMatcher::hasFirstCondition() const {}

const PredicateMatcher &RuleMatcher::getFirstCondition() const {}

std::unique_ptr<PredicateMatcher> RuleMatcher::popFirstCondition() {}

GISelFlags RuleMatcher::updateGISelFlag(GISelFlags CurFlags, const Record *R,
                                        StringRef FlagName,
                                        GISelFlags FlagBit) {}

SaveAndRestore<GISelFlags> RuleMatcher::setGISelFlags(const Record *R) {}

Error RuleMatcher::defineComplexSubOperand(StringRef SymbolicName,
                                           Record *ComplexPattern,
                                           unsigned RendererID,
                                           unsigned SubOperandID,
                                           StringRef ParentSymbolicName) {}

InstructionMatcher &RuleMatcher::addInstructionMatcher(StringRef SymbolicName) {}

void RuleMatcher::addRequiredSimplePredicate(StringRef PredName) {}

const std::vector<std::string> &RuleMatcher::getRequiredSimplePredicates() {}

void RuleMatcher::addRequiredFeature(Record *Feature) {}

const std::vector<Record *> &RuleMatcher::getRequiredFeatures() const {}

unsigned RuleMatcher::implicitlyDefineInsnVar(InstructionMatcher &Matcher) {}

unsigned RuleMatcher::getInsnVarID(InstructionMatcher &InsnMatcher) const {}

void RuleMatcher::defineOperand(StringRef SymbolicName, OperandMatcher &OM) {}

void RuleMatcher::definePhysRegOperand(Record *Reg, OperandMatcher &OM) {}

InstructionMatcher &
RuleMatcher::getInstructionMatcher(StringRef SymbolicName) const {}

const OperandMatcher &RuleMatcher::getPhysRegOperandMatcher(Record *Reg) const {}

OperandMatcher &RuleMatcher::getOperandMatcher(StringRef Name) {}

const OperandMatcher &RuleMatcher::getOperandMatcher(StringRef Name) const {}

void RuleMatcher::emit(MatchTable &Table) {}

bool RuleMatcher::isHigherPriorityThan(const RuleMatcher &B) const {}

unsigned RuleMatcher::countRendererFns() const {}

//===- PredicateMatcher ---------------------------------------------------===//

PredicateMatcher::~PredicateMatcher() {}

//===- OperandPredicateMatcher --------------------------------------------===//

OperandPredicateMatcher::~OperandPredicateMatcher() {}

bool OperandPredicateMatcher::isHigherPriorityThan(
    const OperandPredicateMatcher &B) const {}

//===- SameOperandMatcher -------------------------------------------------===//

void SameOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                              RuleMatcher &Rule) const {}

//===- LLTOperandMatcher --------------------------------------------------===//

std::map<LLTCodeGen, unsigned> LLTOperandMatcher::TypeIDValues;

MatchTableRecord LLTOperandMatcher::getValue() const {}

bool LLTOperandMatcher::hasValue() const {}

void LLTOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                             RuleMatcher &Rule) const {}

//===- PointerToAnyOperandMatcher -----------------------------------------===//

void PointerToAnyOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                      RuleMatcher &Rule) const {}

//===- RecordNamedOperandMatcher ------------------------------------------===//

void RecordNamedOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                     RuleMatcher &Rule) const {}

//===- RecordRegisterType ------------------------------------------===//

void RecordRegisterType::emitPredicateOpcodes(MatchTable &Table,
                                              RuleMatcher &Rule) const {}

//===- ComplexPatternOperandMatcher ---------------------------------------===//

void ComplexPatternOperandMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

unsigned ComplexPatternOperandMatcher::getAllocatedTemporariesBaseID() const {}

//===- RegisterBankOperandMatcher -----------------------------------------===//

bool RegisterBankOperandMatcher::isIdentical(const PredicateMatcher &B) const {}

void RegisterBankOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                      RuleMatcher &Rule) const {}

//===- MBBOperandMatcher --------------------------------------------------===//

void MBBOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                             RuleMatcher &Rule) const {}

//===- ImmOperandMatcher --------------------------------------------------===//

void ImmOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                             RuleMatcher &Rule) const {}

//===- ConstantIntOperandMatcher ------------------------------------------===//

void ConstantIntOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                     RuleMatcher &Rule) const {}

//===- LiteralIntOperandMatcher -------------------------------------------===//

void LiteralIntOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                    RuleMatcher &Rule) const {}

//===- CmpPredicateOperandMatcher -----------------------------------------===//

void CmpPredicateOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                      RuleMatcher &Rule) const {}

//===- IntrinsicIDOperandMatcher ------------------------------------------===//

void IntrinsicIDOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                     RuleMatcher &Rule) const {}

//===- OperandImmPredicateMatcher -----------------------------------------===//

void OperandImmPredicateMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                      RuleMatcher &Rule) const {}

//===- OperandMatcher -----------------------------------------------------===//

std::string OperandMatcher::getOperandExpr(unsigned InsnVarID) const {}

unsigned OperandMatcher::getInsnVarID() const {}

TempTypeIdx OperandMatcher::getTempTypeIdx(RuleMatcher &Rule) {}

void OperandMatcher::emitPredicateOpcodes(MatchTable &Table,
                                          RuleMatcher &Rule) {}

bool OperandMatcher::isHigherPriorityThan(OperandMatcher &B) {}

unsigned OperandMatcher::countRendererFns() {}

Error OperandMatcher::addTypeCheckPredicate(const TypeSetByHwMode &VTy,
                                            bool OperandIsAPointer) {}

//===- InstructionOpcodeMatcher -------------------------------------------===//

DenseMap<const CodeGenInstruction *, unsigned>
    InstructionOpcodeMatcher::OpcodeValues;

MatchTableRecord
InstructionOpcodeMatcher::getInstValue(const CodeGenInstruction *I) const {}

void InstructionOpcodeMatcher::initOpcodeValuesMap(
    const CodeGenTarget &Target) {}

MatchTableRecord InstructionOpcodeMatcher::getValue() const {}

void InstructionOpcodeMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                    RuleMatcher &Rule) const {}

bool InstructionOpcodeMatcher::isHigherPriorityThan(
    const InstructionPredicateMatcher &B) const {}

bool InstructionOpcodeMatcher::isConstantInstruction() const {}

StringRef InstructionOpcodeMatcher::getOpcode() const {}

bool InstructionOpcodeMatcher::isVariadicNumOperands() const {}

StringRef InstructionOpcodeMatcher::getOperandType(unsigned OpIdx) const {}

//===- InstructionNumOperandsMatcher --------------------------------------===//

void InstructionNumOperandsMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- InstructionImmPredicateMatcher -------------------------------------===//

bool InstructionImmPredicateMatcher::isIdentical(
    const PredicateMatcher &B) const {}

void InstructionImmPredicateMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- AtomicOrderingMMOPredicateMatcher ----------------------------------===//

bool AtomicOrderingMMOPredicateMatcher::isIdentical(
    const PredicateMatcher &B) const {}

void AtomicOrderingMMOPredicateMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- MemorySizePredicateMatcher -----------------------------------------===//

void MemorySizePredicateMatcher::emitPredicateOpcodes(MatchTable &Table,
                                                      RuleMatcher &Rule) const {}

//===- MemoryAddressSpacePredicateMatcher ---------------------------------===//

bool MemoryAddressSpacePredicateMatcher::isIdentical(
    const PredicateMatcher &B) const {}

void MemoryAddressSpacePredicateMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- MemoryAlignmentPredicateMatcher ------------------------------------===//

bool MemoryAlignmentPredicateMatcher::isIdentical(
    const PredicateMatcher &B) const {}

void MemoryAlignmentPredicateMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- MemoryVsLLTSizePredicateMatcher ------------------------------------===//

bool MemoryVsLLTSizePredicateMatcher::isIdentical(
    const PredicateMatcher &B) const {}

void MemoryVsLLTSizePredicateMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- VectorSplatImmPredicateMatcher -------------------------------------===//

void VectorSplatImmPredicateMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- GenericInstructionPredicateMatcher ---------------------------------===//

GenericInstructionPredicateMatcher::GenericInstructionPredicateMatcher(
    unsigned InsnVarID, TreePredicateFn Predicate)
    :{}

bool GenericInstructionPredicateMatcher::isIdentical(
    const PredicateMatcher &B) const {}
void GenericInstructionPredicateMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- MIFlagsInstructionPredicateMatcher ---------------------------------===//

bool MIFlagsInstructionPredicateMatcher::isIdentical(
    const PredicateMatcher &B) const {}

void MIFlagsInstructionPredicateMatcher::emitPredicateOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- InstructionMatcher -------------------------------------------------===//

OperandMatcher &
InstructionMatcher::addOperand(unsigned OpIdx, const std::string &SymbolicName,
                               unsigned AllocatedTemporariesBaseID,
                               bool IsVariadic) {}

OperandMatcher &InstructionMatcher::getOperand(unsigned OpIdx) {}

OperandMatcher &InstructionMatcher::addPhysRegInput(Record *Reg, unsigned OpIdx,
                                                    unsigned TempOpIdx) {}

void InstructionMatcher::emitPredicateOpcodes(MatchTable &Table,
                                              RuleMatcher &Rule) {}

bool InstructionMatcher::isHigherPriorityThan(InstructionMatcher &B) {}

unsigned InstructionMatcher::countRendererFns() {}

void InstructionMatcher::optimize() {}

//===- InstructionOperandMatcher ------------------------------------------===//

void InstructionOperandMatcher::emitCaptureOpcodes(MatchTable &Table,
                                                   RuleMatcher &Rule) const {}

bool InstructionOperandMatcher::isHigherPriorityThan(
    const OperandPredicateMatcher &B) const {}

//===- OperandRenderer ----------------------------------------------------===//

OperandRenderer::~OperandRenderer() {}

//===- CopyRenderer -------------------------------------------------------===//

void CopyRenderer::emitRenderOpcodes(MatchTable &Table, RuleMatcher &Rule,
                                     unsigned NewInsnID, unsigned OldInsnID,
                                     unsigned OpIdx, StringRef Name,
                                     bool ForVariadic) {}

void CopyRenderer::emitRenderOpcodes(MatchTable &Table,
                                     RuleMatcher &Rule) const {}

//===- CopyPhysRegRenderer ------------------------------------------------===//

void CopyPhysRegRenderer::emitRenderOpcodes(MatchTable &Table,
                                            RuleMatcher &Rule) const {}

//===- CopyOrAddZeroRegRenderer -------------------------------------------===//

void CopyOrAddZeroRegRenderer::emitRenderOpcodes(MatchTable &Table,
                                                 RuleMatcher &Rule) const {}

//===- CopyConstantAsImmRenderer ------------------------------------------===//

void CopyConstantAsImmRenderer::emitRenderOpcodes(MatchTable &Table,
                                                  RuleMatcher &Rule) const {}

//===- CopyFConstantAsFPImmRenderer ---------------------------------------===//

void CopyFConstantAsFPImmRenderer::emitRenderOpcodes(MatchTable &Table,
                                                     RuleMatcher &Rule) const {}

//===- CopySubRegRenderer -------------------------------------------------===//

void CopySubRegRenderer::emitRenderOpcodes(MatchTable &Table,
                                           RuleMatcher &Rule) const {}

//===- AddRegisterRenderer ------------------------------------------------===//

void AddRegisterRenderer::emitRenderOpcodes(MatchTable &Table,
                                            RuleMatcher &Rule) const {}

//===- TempRegRenderer ----------------------------------------------------===//

void TempRegRenderer::emitRenderOpcodes(MatchTable &Table,
                                        RuleMatcher &Rule) const {}

//===- ImmRenderer --------------------------------------------------------===//

void ImmRenderer::emitAddImm(MatchTable &Table, RuleMatcher &RM,
                             unsigned InsnID, int64_t Imm, StringRef ImmName) {}

void ImmRenderer::emitRenderOpcodes(MatchTable &Table,
                                    RuleMatcher &Rule) const {}

//===- SubRegIndexRenderer ------------------------------------------------===//

void SubRegIndexRenderer::emitRenderOpcodes(MatchTable &Table,
                                            RuleMatcher &Rule) const {}

//===- RenderComplexPatternOperand ----------------------------------------===//

void RenderComplexPatternOperand::emitRenderOpcodes(MatchTable &Table,
                                                    RuleMatcher &Rule) const {}

//===- IntrinsicIDRenderer ------------------------------------------------===//

void IntrinsicIDRenderer::emitRenderOpcodes(MatchTable &Table,
                                            RuleMatcher &Rule) const {}

//===- CustomRenderer -----------------------------------------------------===//

void CustomRenderer::emitRenderOpcodes(MatchTable &Table,
                                       RuleMatcher &Rule) const {}

//===- CustomOperandRenderer ----------------------------------------------===//

void CustomOperandRenderer::emitRenderOpcodes(MatchTable &Table,
                                              RuleMatcher &Rule) const {}

//===- BuildMIAction ------------------------------------------------------===//

bool BuildMIAction::canMutate(RuleMatcher &Rule,
                              const InstructionMatcher *Insn) const {}

void BuildMIAction::chooseInsnToMutate(RuleMatcher &Rule) {}

void BuildMIAction::emitActionOpcodes(MatchTable &Table,
                                      RuleMatcher &Rule) const {}

//===- BuildConstantAction ------------------------------------------------===//

void BuildConstantAction::emitActionOpcodes(MatchTable &Table,
                                            RuleMatcher &Rule) const {}

//===- EraseInstAction ----------------------------------------------------===//

void EraseInstAction::emitActionOpcodes(MatchTable &Table,
                                        RuleMatcher &Rule) const {}

bool EraseInstAction::emitActionOpcodesAndDone(MatchTable &Table,
                                               RuleMatcher &Rule) const {}

//===- ReplaceRegAction ---------------------------------------------------===//

void ReplaceRegAction::emitAdditionalPredicates(MatchTable &Table,
                                                RuleMatcher &Rule) const {}

void ReplaceRegAction::emitActionOpcodes(MatchTable &Table,
                                         RuleMatcher &Rule) const {}

//===- ConstrainOperandToRegClassAction -----------------------------------===//

void ConstrainOperandToRegClassAction::emitActionOpcodes(
    MatchTable &Table, RuleMatcher &Rule) const {}

//===- MakeTempRegisterAction ---------------------------------------------===//

void MakeTempRegisterAction::emitActionOpcodes(MatchTable &Table,
                                               RuleMatcher &Rule) const {}

} // namespace gi
} // namespace llvm