llvm/mlir/lib/TableGen/Predicate.cpp

//===- Predicate.cpp - Predicate class ------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// Wrapper around predicates defined in TableGen.
//
//===----------------------------------------------------------------------===//

#include "mlir/TableGen/Predicate.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"

usingnamespacemlir;
usingnamespacetblgen;

// Construct a Predicate from a record.
Pred::Pred(const llvm::Record *record) :{}

// Construct a Predicate from an initializer.
Pred::Pred(const llvm::Init *init) {}

std::string Pred::getCondition() const {}

bool Pred::isCombined() const {}

ArrayRef<SMLoc> Pred::getLoc() const {}

CPred::CPred(const llvm::Record *record) :{}

CPred::CPred(const llvm::Init *init) :{}

// Get condition of the C Predicate.
std::string CPred::getConditionImpl() const {}

CombinedPred::CombinedPred(const llvm::Record *record) :{}

CombinedPred::CombinedPred(const llvm::Init *init) :{}

const llvm::Record *CombinedPred::getCombinerDef() const {}

std::vector<llvm::Record *> CombinedPred::getChildren() const {}

namespace {
// Kinds of nodes in a logical predicate tree.
enum class PredCombinerKind {};

// A node in a logical predicate tree.
struct PredNode {};
} // namespace

// Get a predicate tree node kind based on the kind used in the predicate
// TableGen record.
static PredCombinerKind getPredCombinerKind(const Pred &pred) {}

namespace {
// Substitution<pattern, replacement>.
Subst;
} // namespace

/// Perform the given substitutions on 'str' in-place.
static void performSubstitutions(std::string &str,
                                 ArrayRef<Subst> substitutions) {}

// Build the predicate tree starting from the top-level predicate, which may
// have children, and perform leaf substitutions inplace.  Note that after
// substitution, nodes are still pointing to the original TableGen record.
// All nodes are created within "allocator".
static PredNode *
buildPredicateTree(const Pred &root,
                   llvm::SpecificBumpPtrAllocator<PredNode> &allocator,
                   ArrayRef<Subst> substitutions) {}

// Simplify a predicate tree rooted at "node" using the predicates that are
// known to be true(false).  For AND(OR) combined predicates, if any of the
// children is known to be false(true), the result is also false(true).
// Furthermore, for AND(OR) combined predicates, children that are known to be
// true(false) don't have to be checked dynamically.
static PredNode *
propagateGroundTruth(PredNode *node,
                     const llvm::SmallPtrSetImpl<Pred *> &knownTruePreds,
                     const llvm::SmallPtrSetImpl<Pred *> &knownFalsePreds) {}

// Combine a list of predicate expressions using a binary combiner.  If a list
// is empty, return "init".
static std::string combineBinary(ArrayRef<std::string> children,
                                 const std::string &combiner,
                                 std::string init) {}

// Prepend negation to the only condition in the predicate expression list.
static std::string combineNot(ArrayRef<std::string> children) {}

// Recursively traverse the predicate tree in depth-first post-order and build
// the final expression.
static std::string getCombinedCondition(const PredNode &root) {}

std::string CombinedPred::getConditionImpl() const {}

StringRef SubstLeavesPred::getPattern() const {}

StringRef SubstLeavesPred::getReplacement() const {}

StringRef ConcatPred::getPrefix() const {}

StringRef ConcatPred::getSuffix() const {}