55 for (
const auto &
I :
Add)
71 for (
const auto &
I :
S1)
93 apply2(ST, Expr, Set,
II->getValue(), Elts, Loc);
98struct ShlOp :
public SetIntBinOp {
104 if (
unsigned(
N) <
Set.size())
105 Elts.insert(
Set.begin() +
N,
Set.end());
110struct TruncOp :
public SetIntBinOp {
116 if (
unsigned(
N) >
Set.size())
118 Elts.insert(
Set.begin(),
Set.begin() +
N);
123struct RotOp :
public SetIntBinOp {
126 RotOp(
bool Rev) :
Reverse(Rev) {}
139 Elts.insert(
Set.begin() +
N,
Set.end());
140 Elts.insert(
Set.begin(),
Set.begin() +
N);
145struct DecimateOp :
public SetIntBinOp {
151 for (
unsigned I = 0;
I <
Set.size();
I +=
N)
162 unsigned MaxSize = 0;
163 for (
unsigned i = 0, e = Expr->
getNumArgs(); i != e; ++i) {
164 ST.evaluate(Expr->
getArg(i), Args[i], Loc);
165 MaxSize = std::max(MaxSize,
unsigned(Args[i].
size()));
168 for (
unsigned n = 0; n != MaxSize; ++n)
169 for (
unsigned i = 0, e = Expr->
getNumArgs(); i != e; ++i)
170 if (n < Args[i].
size())
171 Elts.insert(Args[i][n]);
185 Step =
II->getValue();
193 Format = std::string(
SI->getValue());
202 if (From < 0 || From >= (1 << 30))
209 if (To < 0 || To >= (1 << 30))
213 cast<DefInit>(Expr->
getOperator())->getDef()->getRecords();
215 Step *=
From <= To ? 1 : -1;
217 if (Step > 0 &&
From > To)
219 else if (Step < 0 &&
From < To)
229 if (
const RecVec *Result =
ST.expand(Rec))
243 FieldExpander(
StringRef fn) : FieldName(fn) {}
246 ST.evaluate(
Def->getValueInit(FieldName), Elts,
Def->getLoc());
253void SetTheory::Operator::anchor() {}
254void SetTheory::Expander::anchor() {}
262 addOperator(
"rotl", std::make_unique<RotOp>(
false));
263 addOperator(
"rotr", std::make_unique<RotOp>(
true));
264 addOperator(
"decimate", std::make_unique<DecimateOp>());
265 addOperator(
"interleave", std::make_unique<InterleaveOp>());
266 addOperator(
"sequence", std::make_unique<SequenceOp>());
270 Operators[
Name] = std::move(
Op);
274 Expanders[ClassName] = std::move(E);
278 addExpander(ClassName, std::make_unique<FieldExpander>(FieldName));
283 if (
DefInit *Def = dyn_cast<DefInit>(Expr)) {
285 return Elts.
insert(Result->begin(), Result->end());
286 Elts.
insert(Def->getDef());
291 if (
ListInit *LI = dyn_cast<ListInit>(Expr))
292 return evaluate(LI->begin(), LI->end(), Elts, Loc);
295 DagInit *DagExpr = dyn_cast<DagInit>(Expr);
301 auto I = Operators.find(
OpInit->getDef()->getName());
302 if (
I == Operators.end())
304 I->second->apply(*
this, DagExpr, Elts, Loc);
309 ExpandMap::iterator
I = Expansions.find(Set);
310 if (
I != Expansions.end())
315 for (
const auto &SCPair : SC) {
317 if (!isa<StringInit>(SCPair.first->getNameInit()))
319 auto I = Expanders.find(SCPair.first->getName());
320 if (
I != Expanders.end()) {
322 RecVec &EltVec = Expansions[Set];
324 I->second->expand(*
this, Set, Elts);
325 EltVec.assign(Elts.
begin(), Elts.
end());
BlockVerifier::State From
uint64_t IntrinsicInst * II
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents an Operation in the Expression.
(v a, b) - Represent a DAG tree value.
unsigned getNumArgs() const
Init * getOperator() const
const_arg_iterator arg_begin() const
const_arg_iterator arg_end() const
Init * getArg(unsigned Num) const
std::string getAsString() const override
Convert this value to a literal form.
AL - Represent a reference to a 'def' in the description.
virtual std::string getAsString() const =0
Convert this value to a literal form.
'7' - Represent an initialization by a literal integer value.
[AL, AH, CL] - Represent a list of defs
Base class for operators.
Expander - A callback function that can transform a Record representing a set into a fully expanded l...
virtual void expand(SetTheory &, Record *, RecSet &Elts)=0
Operator - A callback representing a DAG operator.
virtual void apply(SetTheory &, DagInit *Expr, RecSet &Elts, ArrayRef< SMLoc > Loc)=0
apply - Apply this operator to Expr's arguments and insert the result in Elts.
const RecVec * expand(Record *Set)
expand - Expand a record into a set of elements if possible.
void addOperator(StringRef Name, std::unique_ptr< Operator >)
addOperator - Add a DAG operator.
SetTheory()
Create a SetTheory instance with only the standard operators.
void evaluate(Init *Expr, RecSet &Elts, ArrayRef< SMLoc > Loc)
evaluate - Evaluate Expr and append the resulting set to Elts.
SmallSetVector< Record *, 16 > RecSet
std::vector< Record * > RecVec
void addFieldExpander(StringRef ClassName, StringRef FieldName)
addFieldExpander - Add an expander for ClassName that simply evaluates FieldName in the Record to get...
void addExpander(StringRef ClassName, std::unique_ptr< Expander >)
addExpander - Add an expander for Records with the named super class.
iterator end()
Get an iterator to the end of the SetVector.
iterator begin()
Get an iterator to the beginning of the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
"foo" - Represent an initialization by a string value.
StringRef - Represent a constant reference to a string, i.e.
A raw_ostream that writes to an std::string.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
llvm::SmallVector< std::shared_ptr< RecordsSlice >, 4 > Records
NodeAddr< DefNode * > Def
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
void PrintFatalError(const Twine &Msg)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.