#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) { … }
std::string getEnumNameForPredicate(const TreePredicateFn &Predicate) { … }
std::string getMatchOpcodeForImmPredicate(const TreePredicateFn &Predicate) { … }
constexpr StringLiteral EncodeMacroName = …;
}
void emitEncodingMacrosDef(raw_ostream &OS) { … }
void emitEncodingMacrosUndef(raw_ostream &OS) { … }
std::string getNameForFeatureBitset(ArrayRef<const 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) { … }
std::set<LLTCodeGen> KnownTypes;
void MatchTableRecord::emit(raw_ostream &OS, bool LineBreakIsNextAfterThis,
const MatchTable &Table) const { … }
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) { … }
std::string LLTCodeGen::getCxxEnumValue() const { … }
void LLTCodeGen::emitCxxEnumValue(raw_ostream &OS) const { … }
void LLTCodeGen::emitCxxConstructorCall(raw_ostream &OS) const { … }
bool LLTCodeGen::operator<(const LLTCodeGen &Other) const { … }
std::optional<LLTCodeGen> MVTToLLT(MVT::SimpleValueType SVT) { … }
void Matcher::optimize() { … }
Matcher::~Matcher() { … }
bool GroupMatcher::candidateConditionMatches(
const PredicateMatcher &Predicate) const { … }
bool GroupMatcher::addMatcher(Matcher &Candidate) { … }
void GroupMatcher::finalize() { … }
void GroupMatcher::emit(MatchTable &Table) { … }
void GroupMatcher::optimize() { … }
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) { … }
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,
const 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() { … }
unsigned RuleMatcher::implicitlyDefineInsnVar(InstructionMatcher &Matcher) { … }
unsigned RuleMatcher::getInsnVarID(InstructionMatcher &InsnMatcher) const { … }
void RuleMatcher::defineOperand(StringRef SymbolicName, OperandMatcher &OM) { … }
void RuleMatcher::definePhysRegOperand(const Record *Reg, OperandMatcher &OM) { … }
InstructionMatcher &
RuleMatcher::getInstructionMatcher(StringRef SymbolicName) const { … }
const OperandMatcher &
RuleMatcher::getPhysRegOperandMatcher(const 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() { … }
OperandPredicateMatcher::~OperandPredicateMatcher() { … }
bool OperandPredicateMatcher::isHigherPriorityThan(
const OperandPredicateMatcher &B) const { … }
void SameOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
std::map<LLTCodeGen, unsigned> LLTOperandMatcher::TypeIDValues;
MatchTableRecord LLTOperandMatcher::getValue() const { … }
bool LLTOperandMatcher::hasValue() const { … }
void LLTOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void PointerToAnyOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void RecordNamedOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void RecordRegisterType::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void ComplexPatternOperandMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
unsigned ComplexPatternOperandMatcher::getAllocatedTemporariesBaseID() const { … }
bool RegisterBankOperandMatcher::isIdentical(const PredicateMatcher &B) const { … }
void RegisterBankOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void MBBOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void ImmOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void ConstantIntOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void LiteralIntOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void CmpPredicateOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void IntrinsicIDOperandMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void OperandImmPredicateMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
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) { … }
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 { … }
void InstructionNumOperandsMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
bool InstructionImmPredicateMatcher::isIdentical(
const PredicateMatcher &B) const { … }
void InstructionImmPredicateMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
bool AtomicOrderingMMOPredicateMatcher::isIdentical(
const PredicateMatcher &B) const { … }
void AtomicOrderingMMOPredicateMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
void MemorySizePredicateMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
bool MemoryAddressSpacePredicateMatcher::isIdentical(
const PredicateMatcher &B) const { … }
void MemoryAddressSpacePredicateMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
bool MemoryAlignmentPredicateMatcher::isIdentical(
const PredicateMatcher &B) const { … }
void MemoryAlignmentPredicateMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
bool MemoryVsLLTSizePredicateMatcher::isIdentical(
const PredicateMatcher &B) const { … }
void MemoryVsLLTSizePredicateMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
void VectorSplatImmPredicateMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
GenericInstructionPredicateMatcher::GenericInstructionPredicateMatcher(
unsigned InsnVarID, TreePredicateFn Predicate)
: … { … }
bool GenericInstructionPredicateMatcher::isIdentical(
const PredicateMatcher &B) const { … }
void GenericInstructionPredicateMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
bool MIFlagsInstructionPredicateMatcher::isIdentical(
const PredicateMatcher &B) const { … }
void MIFlagsInstructionPredicateMatcher::emitPredicateOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
OperandMatcher &
InstructionMatcher::addOperand(unsigned OpIdx, const std::string &SymbolicName,
unsigned AllocatedTemporariesBaseID,
bool IsVariadic) { … }
OperandMatcher &InstructionMatcher::getOperand(unsigned OpIdx) { … }
OperandMatcher &InstructionMatcher::addPhysRegInput(const Record *Reg,
unsigned OpIdx,
unsigned TempOpIdx) { … }
void InstructionMatcher::emitPredicateOpcodes(MatchTable &Table,
RuleMatcher &Rule) { … }
bool InstructionMatcher::isHigherPriorityThan(InstructionMatcher &B) { … }
unsigned InstructionMatcher::countRendererFns() { … }
void InstructionMatcher::optimize() { … }
void InstructionOperandMatcher::emitCaptureOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
bool InstructionOperandMatcher::isHigherPriorityThan(
const OperandPredicateMatcher &B) const { … }
OperandRenderer::~OperandRenderer() { … }
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 { … }
void CopyPhysRegRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void CopyOrAddZeroRegRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void CopyConstantAsImmRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void CopyFConstantAsFPImmRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void CopySubRegRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void AddRegisterRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void TempRegRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void ImmRenderer::emitAddImm(MatchTable &Table, RuleMatcher &RM,
unsigned InsnID, int64_t Imm, StringRef ImmName) { … }
void ImmRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void SubRegIndexRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void RenderComplexPatternOperand::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void IntrinsicIDRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void CustomRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void CustomOperandRenderer::emitRenderOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
bool BuildMIAction::canMutate(RuleMatcher &Rule,
const InstructionMatcher *Insn) const { … }
void BuildMIAction::chooseInsnToMutate(RuleMatcher &Rule) { … }
void BuildMIAction::emitActionOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void BuildConstantAction::emitActionOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void EraseInstAction::emitActionOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
bool EraseInstAction::emitActionOpcodesAndDone(MatchTable &Table,
RuleMatcher &Rule) const { … }
void ReplaceRegAction::emitAdditionalPredicates(MatchTable &Table,
RuleMatcher &Rule) const { … }
void ReplaceRegAction::emitActionOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
void ConstrainOperandToRegClassAction::emitActionOpcodes(
MatchTable &Table, RuleMatcher &Rule) const { … }
void MakeTempRegisterAction::emitActionOpcodes(MatchTable &Table,
RuleMatcher &Rule) const { … }
}
}