46 for (RecSet::iterator
I = Add.begin(),
E = Add.end();
I !=
E; ++
I)
62 for (RecSet::iterator
I = S1.begin(),
E = S1.end();
I !=
E; ++
I)
84 apply2(ST, Expr, Set, II->
getValue(), Elts, Loc);
89 struct ShlOp :
public SetIntBinOp {
95 if (
unsigned(N) < Set.size())
96 Elts.insert(Set.begin() +
N, Set.end());
101 struct TruncOp :
public SetIntBinOp {
107 if (
unsigned(N) > Set.size())
109 Elts.insert(Set.begin(), Set.begin() +
N);
114 struct RotOp :
public SetIntBinOp {
117 RotOp(
bool Rev) : Reverse(Rev) {}
127 N = Set.size() - (-N % Set.size());
130 Elts.insert(Set.begin() +
N, Set.end());
131 Elts.insert(Set.begin(), Set.begin() +
N);
136 struct DecimateOp :
public SetIntBinOp {
142 for (
unsigned I = 0;
I < Set.size();
I +=
N)
153 unsigned MaxSize = 0;
156 MaxSize = std::max(MaxSize,
unsigned(
Args[
i].size()));
159 for (
unsigned n = 0; n != MaxSize; ++n)
161 if (n <
Args[
i].size())
162 Elts.insert(
Args[
i][n]);
184 Format =
SI->getValue();
193 if (From < 0 || From >= (1 << 30))
200 if (To < 0 || To >= (1 << 30))
206 Step *= From <= To ? 1 : -1;
208 if (Step > 0 && From > To)
210 else if (Step < 0 && From < To)
220 if (
const RecVec *Result = ST.
expand(Rec))
221 Elts.insert(Result->begin(), Result->end());
234 FieldExpander(
StringRef fn) : FieldName(fn) {}
243 void SetTheory::Operator::anchor() {}
244 void SetTheory::Expander::anchor() {}
252 addOperator(
"trunc", llvm::make_unique<TruncOp>());
253 addOperator(
"rotl", llvm::make_unique<RotOp>(
false));
254 addOperator(
"rotr", llvm::make_unique<RotOp>(
true));
255 addOperator(
"decimate", llvm::make_unique<DecimateOp>());
256 addOperator(
"interleave", llvm::make_unique<InterleaveOp>());
257 addOperator(
"sequence", llvm::make_unique<SequenceOp>());
261 Operators[
Name] = std::move(Op);
265 Expanders[ClassName] = std::move(E);
269 addExpander(ClassName, llvm::make_unique<FieldExpander>(FieldName));
275 if (
const RecVec *Result =
expand(
Def->getDef()))
276 return Elts.
insert(Result->begin(), Result->end());
282 if (
ListInit *LI = dyn_cast<ListInit>(Expr))
283 return evaluate(LI->begin(), LI->end(), Elts, Loc);
292 auto I = Operators.find(OpInit->getDef()->getName());
293 if (I == Operators.end())
295 I->second->apply(*
this, DagExpr, Elts, Loc);
300 ExpandMap::iterator
I = Expansions.find(Set);
301 if (I != Expansions.end())
306 for (
const auto &SCPair :
SC) {
308 if (!isa<StringInit>(SCPair.first->getNameInit()))
310 auto I = Expanders.find(SCPair.first->getName());
311 if (I != Expanders.end()) {
313 RecVec &EltVec = Expansions[Set];
315 I->second->expand(*
this, Set, Elts);
316 EltVec.assign(Elts.
begin(), Elts.
end());
unsigned getNumArgs() const
Operator - A callback representing a DAG operator.
[AL, AH, CL] - Represent a list of defs
'7' - Represent an initialization by a literal integer value.
AL - Represent a reference to a 'def' in the description.
Init * getValueInit(StringRef FieldName) const
Return the initializer for a value with the specified name, or throw an exception if the field does n...
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 * getOperator() const
std::vector< Record * > RecVec
bool insert(const value_type &X)
Insert a new element into the SetVector.
const_arg_iterator arg_end() const
iterator begin()
Get an iterator to the beginning of the SetVector.
Init * getArg(unsigned Num) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Record * getDef(StringRef Name) const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
Base class for operators.
"foo" - Represent an initialization by a string value.
static Expected< BitVector > expand(StringRef S, StringRef Original)
void apply(Opt *O, const Mod &M, const Mods &...Ms)
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.
ArrayRef< SMLoc > getLoc() 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.
void addOperator(StringRef Name, std::unique_ptr< Operator >)
addOperator - Add a DAG operator.
LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const Twine &Msg)
const_arg_iterator arg_begin() const
const RecVec * expand(Record *Set)
expand - Expand a record into a set of elements if possible.
static MachineInstr * getDef(unsigned Reg, const MachineRegisterInfo *MRI)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
A raw_ostream that writes to an std::string.
(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.
void evaluate(Init *Expr, RecSet &Elts, ArrayRef< SMLoc > Loc)
evaluate - Evaluate Expr and append the resulting set to Elts.
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const