56 for (RecSet::iterator
I = Add.begin(),
E = Add.end();
I !=
E; ++
I)
72 for (RecSet::iterator
I = S1.begin(),
E = S1.end();
I !=
E; ++
I)
94 apply2(ST, Expr, Set, II->
getValue(), Elts, Loc);
99 struct ShlOp :
public SetIntBinOp {
105 if (
unsigned(N) < Set.size())
106 Elts.insert(Set.begin() +
N, Set.end());
111 struct TruncOp :
public SetIntBinOp {
117 if (
unsigned(N) > Set.size())
119 Elts.insert(Set.begin(), Set.begin() +
N);
124 struct RotOp :
public SetIntBinOp {
127 RotOp(
bool Rev) : Reverse(Rev) {}
137 N = Set.size() - (-N % Set.size());
140 Elts.insert(Set.begin() +
N, Set.end());
141 Elts.insert(Set.begin(), Set.begin() +
N);
146 struct DecimateOp :
public SetIntBinOp {
152 for (
unsigned I = 0;
I < Set.size();
I +=
N)
163 unsigned MaxSize = 0;
164 for (
unsigned i = 0,
e = Expr->
getNumArgs(); i !=
e; ++i) {
169 for (
unsigned n = 0; n != MaxSize; ++n)
170 for (
unsigned i = 0,
e = Expr->
getNumArgs(); i !=
e; ++i)
172 Elts.insert(
Args[i][n]);
194 Format =
SI->getValue();
203 if (From < 0 || From >= (1 << 30))
210 if (To < 0 || To >= (1 << 30))
214 cast<DefInit>(Expr->
getOperator())->getDef()->getRecords();
216 Step *= From <= To ? 1 : -1;
218 if (Step > 0 && From > To)
220 else if (Step < 0 && From < To)
230 if (
const RecVec *Result = ST.
expand(Rec))
244 FieldExpander(
StringRef fn) : FieldName(fn) {}
254 void SetTheory::Operator::anchor() {}
255 void SetTheory::Expander::anchor() {}
258 addOperator(
"add", std::make_unique<AddOp>());
259 addOperator(
"sub", std::make_unique<SubOp>());
260 addOperator(
"and", std::make_unique<AndOp>());
261 addOperator(
"shl", std::make_unique<ShlOp>());
262 addOperator(
"trunc", std::make_unique<TruncOp>());
263 addOperator(
"rotl", std::make_unique<RotOp>(
false));
264 addOperator(
"rotr", std::make_unique<RotOp>(
true));
265 addOperator(
"decimate", std::make_unique<DecimateOp>());
266 addOperator(
"interleave", std::make_unique<InterleaveOp>());
267 addOperator(
"sequence", std::make_unique<SequenceOp>());
271 Operators[
Name] = std::move(Op);
275 Expanders[ClassName] = std::move(E);
279 addExpander(ClassName, std::make_unique<FieldExpander>(FieldName));
286 return Elts.
insert(Result->begin(), Result->end());
292 if (
ListInit *LI = dyn_cast<ListInit>(Expr))
293 return evaluate(LI->begin(), LI->end(), Elts, Loc);
302 auto I = Operators.find(OpInit->getDef()->getName());
303 if (I == Operators.end())
305 I->second->apply(*
this, DagExpr, Elts, Loc);
310 ExpandMap::iterator
I = Expansions.find(Set);
311 if (I != Expansions.end())
316 for (
const auto &SCPair :
SC) {
318 if (!isa<StringInit>(SCPair.first->getNameInit()))
320 auto I = Expanders.find(SCPair.first->getName());
321 if (I != Expanders.end()) {
323 RecVec &EltVec = Expansions[Set];
325 I->second->expand(*
this, Set, Elts);
326 EltVec.assign(Elts.
begin(), Elts.
end());
This class represents lattice values for constants.
Operator - A callback representing a DAG operator.
[AL, AH, CL] - Represent a list of defs
'7' - Represent an initialization by a literal integer value.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
AL - Represent a reference to a 'def' in the description.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
SetTheory()
Create a SetTheory instance with only the standard operators.
Expander - A callback function that can transform a Record representing a set into a fully expanded l...
iterator end()
Get an iterator to the end of the SetVector.
Init * getArg(unsigned Num) const
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const
void apply(Opt *O, const Mod &M, const Mods &... Ms)
Init * getValueInit(StringRef FieldName) const
Return the initializer for a value with the specified name, or throw an exception if the field does n...
ArrayRef< SMLoc > getLoc() const
bool insert(const value_type &X)
Insert a new element into the SetVector.
SmallSetVector< Record *, 16 > RecSet
iterator begin()
Get an iterator to the beginning of the SetVector.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Base class for operators.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
"foo" - Represent an initialization by a string value.
static Expected< BitVector > expand(StringRef S, StringRef Original)
std::string getAsString() const override
Convert this value to a string form.
void addFieldExpander(StringRef ClassName, StringRef FieldName)
addFieldExpander - Add an expander for ClassName that simply evaluates FieldName in the Record to get...
A SetVector that performs no allocations if smaller than a certain size.
void addExpander(StringRef ClassName, std::unique_ptr< Expander >)
addExpander - Add an expander for Records with the named super class.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
BlockVerifier::State From
Align max(MaybeAlign Lhs, Align Rhs)
Init * getOperator() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
CHAIN = SC CHAIN, Imm128 - System call.
unsigned getNumArgs() const
void addOperator(StringRef Name, std::unique_ptr< Operator >)
addOperator - Add a DAG operator.
LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const Twine &Msg)
const RecVec * expand(Record *Set)
expand - Expand a record into a set of elements if possible.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Record * getDef(StringRef Name) const
A raw_ostream that writes to an std::string.
std::vector< Record * > RecVec
(v a, b) - Represent a DAG tree value.
virtual std::string getAsString() const =0
Convert this value to a string form.
StringRef - Represent a constant reference to a string, i.e.
const_arg_iterator arg_begin() const
void evaluate(Init *Expr, RecSet &Elts, ArrayRef< SMLoc > Loc)
evaluate - Evaluate Expr and append the resulting set to Elts.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
const_arg_iterator arg_end() const