llvm.org GIT mirror
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).
 199 199 // 200 200 // (decimate GPR, 2) - Pick every N'th element, starting with the first. 201 201 // 202 // (interleave A, B, ...) - Interleave the elements from each argument list. 203 // 202 204 // All of these operators work on ordered sets, not lists. That means 203 205 // duplicates are removed from sub-expressions. 204 206 205 207 // Set operators. The rest is defined in TargetSelectionDAG.td. 206 208 def sequence; 207 209 def decimate; 210 def interleave; 208 211 209 212 // RegisterTuples - Automatically generate super-registers by forming tuples of 210 213 // sub-registers. This is useful for modeling register sequence constraints
 164 164 // CHECK: S9b = [ e7 e6 e5 e4 e3 ] 165 165 // CHECK: S9c = [ e0 ] 166 166 // 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 ]
 135 135 throw "Positive stride required: " + Expr->getAsString(); 136 136 for (unsigned I = 0; I < Set.size(); I += N) 137 137 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]); 138 156 } 139 157 }; 140 158 210 228 addOperator("rotl", new RotOp(false)); 211 229 addOperator("rotr", new RotOp(true)); 212 230 addOperator("decimate", new DecimateOp); 231 addOperator("interleave", new InterleaveOp); 213 232 addOperator("sequence", new SequenceOp); 214 233 } 215 234