llvm.org GIT mirror llvm / 5b52f6d
Add an (interleave A, B, ...) SetTheory operator. This will interleave the elements from two or more lists. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148824 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 7 years ago
3 changed file(s) with 29 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
199199 //
200200 // (decimate GPR, 2) - Pick every N'th element, starting with the first.
201201 //
202 // (interleave A, B, ...) - Interleave the elements from each argument list.
203 //
202204 // All of these operators work on ordered sets, not lists. That means
203205 // duplicates are removed from sub-expressions.
204206
205207 // Set operators. The rest is defined in TargetSelectionDAG.td.
206208 def sequence;
207209 def decimate;
210 def interleave;
208211
209212 // RegisterTuples - Automatically generate super-registers by forming tuples of
210213 // sub-registers. This is useful for modeling register sequence constraints
164164 // CHECK: S9b = [ e7 e6 e5 e4 e3 ]
165165 // CHECK: S9c = [ e0 ]
166166 // CHECK: S9d = [ a b c d e0 e3 e6 e9 e4 e5 e7 ]
167
168 // The 'interleave' operator is almost the inverse of 'decimate'.
169 def interleave;
170 def T0a : Set<(interleave S9a, S9b)>;
171 def T0b : Set<(interleave S8e, S8d)>;
172 // CHECK: T0a = [ e3 e7 e4 e6 e5 ]
173 // CHECK: T0b = [ e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ]
135135 throw "Positive stride required: " + Expr->getAsString();
136136 for (unsigned I = 0; I < Set.size(); I += N)
137137 Elts.insert(Set[I]);
138 }
139 };
140
141 // (interleave S1, S2, ...) Interleave elements of the arguments.
142 struct InterleaveOp : public SetTheory::Operator {
143 void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) {
144 // Evaluate the arguments individually.
145 SmallVector Args(Expr->getNumArgs());
146 unsigned MaxSize = 0;
147 for (unsigned i = 0, e = Expr->getNumArgs(); i != e; ++i) {
148 ST.evaluate(Expr->getArg(i), Args[i]);
149 MaxSize = std::max(MaxSize, unsigned(Args[i].size()));
150 }
151 // Interleave arguments into Elts.
152 for (unsigned n = 0; n != MaxSize; ++n)
153 for (unsigned i = 0, e = Expr->getNumArgs(); i != e; ++i)
154 if (n < Args[i].size())
155 Elts.insert(Args[i][n]);
138156 }
139157 };
140158
210228 addOperator("rotl", new RotOp(false));
211229 addOperator("rotr", new RotOp(true));
212230 addOperator("decimate", new DecimateOp);
231 addOperator("interleave", new InterleaveOp);
213232 addOperator("sequence", new SequenceOp);
214233 }
215234