CGRA-ME
OpGraphsForTesting.cpp
Go to the documentation of this file.
1 #include "OpGraphsForTesting.hpp"
2 
3 #include <cmath>
4 
6  verifyAndPrintReport(opgraph, std::cerr, true, true);
7  // opgraph.print_dot(std::cout);
8 
9  return opgraph;
10 }
11 
14 };
15 
16 BinaryOperandTags parseBinaryOperandOption(const std::string& option) {
17  if (option == "commutative") {
19  } else if (option == "non-commutative") {
21  } else if (option == "untagged") {
23  } else if (option == "mixed_lhs") {
25  } else if (option == "mixed_any") {
27  } else if (option == "all_lhs") {
29  } else {
30  throw std::logic_error("Unexpected value for operands key: " + option);
31  }
32 }
33 
35  const auto ops_csv = options.getStringOr("ops", "add,add");
36  std::vector<OpCode> ops;
37  for (std::size_t next_pos = 0, pos = 0; next_pos != ops_csv.size(); pos = next_pos + 1) {
38  next_pos = std::min(ops_csv.find_first_of(',', pos), ops_csv.size());
39  ops.push_back(opcode_from_string(ops_csv.substr(pos, next_pos - pos)));
40  }
41 
42  OpGraph opgraph;
43  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, ops.at(0)));
44  const auto op_b = opgraph.insert(op_a, OpGraphOp("op_b", 32, ops.at(1)), Operands::BINARY_ANY).newOp;
45  (void)op_b;
46 
47  return finalFixup(std::move(opgraph));
48 }
49 
51  OpGraph opgraph;
52  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, OpCode::ADD));
53  const auto op_b = opgraph.insert(op_a, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
54  const auto op_c = opgraph.insert(op_b, OpGraphOp("op_c", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
55  (void)op_c;
56 
57  return finalFixup(std::move(opgraph));
58 }
59 
61  OpGraph opgraph;
62  const auto op_l = opgraph.insert( OpGraphOp("op_l", 32, OpCode::ADD));
63  (void)op_l;
64 
65  opgraph.link(op_l, op_l, Operands::BINARY_ANY);
66 
67  return finalFixup(std::move(opgraph));
68 }
69 
71  OpGraph opgraph;
72  const auto op_l = opgraph.insert( OpGraphOp("op_l", 32, OpCode::ADD));
73  opgraph.insert(op_l, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY);
74 
75  opgraph.link(op_l, op_l, Operands::BINARY_ANY);
76 
77  return finalFixup(std::move(opgraph));
78 }
79 
81  OpGraph opgraph;
82  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, OpCode::ADD));
83  const auto op_l = opgraph.insert(op_a, OpGraphOp("op_l", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
84  const auto op_c = opgraph.insert(op_l, OpGraphOp("op_c", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
85  (void)op_c;
86 
87  opgraph.link(op_l, op_l, Operands::BINARY_ANY);
88 
89  return finalFixup(std::move(opgraph));
90 }
91 
93  OpGraph opgraph;
94  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, OpCode::ADD));
95  const auto op_b = opgraph.insert(op_a, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
96  (void)op_b;
97 
98  opgraph.link(op_b, op_a, Operands::BINARY_ANY);
99 
100  return finalFixup(std::move(opgraph));
101 }
102 
104  OpGraph opgraph;
105  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, OpCode::ADD));
106  const auto op_b = opgraph.insert(op_a, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
107  const auto op_c = opgraph.insert(op_b, OpGraphOp("op_c", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
108  (void)op_c;
109 
110  opgraph.link(op_c, op_a, Operands::BINARY_ANY);
111 
112  return finalFixup(std::move(opgraph));
113 }
114 
116  OpGraph opgraph;
117  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, OpCode::ADD));
118  const auto op_l = opgraph.insert(op_a, OpGraphOp("op_l", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
119  const auto op_m = opgraph.insert(op_l, OpGraphOp("op_m", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
120  const auto op_d = opgraph.insert(op_m, OpGraphOp("op_d", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
121  (void)op_d;
122 
123  opgraph.link(op_m, op_l, Operands::BINARY_ANY);
124 
125  return finalFixup(std::move(opgraph));
126 }
127 
129  OpGraph opgraph;
130  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, OpCode::ADD));
131  const auto op_b = opgraph.insert(op_a, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
132  const auto op_b2 = opgraph.insert(op_a, OpGraphOp("op_b2", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
133  (void)op_b;
134  (void)op_b2;
135 
136  return finalFixup(std::move(opgraph));
137 }
138 
140  OpGraph opgraph;
141  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, OpCode::ADD));
142  const auto op_b = opgraph.insert(op_a, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
143  const auto op_c = opgraph.insert(op_b, OpGraphOp("op_c", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
144  const auto op_c2 = opgraph.insert(op_b, OpGraphOp("op_c2", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
145  (void)op_c;
146  (void)op_c2;
147 
148  return finalFixup(std::move(opgraph));
149 }
150 
152  OpGraph opgraph;
153  const auto op_a = opgraph.insert( OpGraphOp("op_a", 32, OpCode::ADD));
154  const auto op_b = opgraph.insert(op_a, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
155  const auto op_b2 = opgraph.insert(op_a, OpGraphOp("op_b2", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
156  const auto op_c = opgraph.insert(op_b, OpGraphOp("op_c", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
157 
158  opgraph.link(op_b2, op_c, Operands::BINARY_ANY);
159 
160  return finalFixup(std::move(opgraph));
161 }
162 
164  const auto operands = parseBinaryOperandOption(options.getStringOr("operands", "commutative"));
165  OpGraph opgraph;
166  const auto op_a = opgraph.insert(OpGraphOp("op_a", 32, OpCode::ADD));
167  const auto op_a2 = opgraph.insert(OpGraphOp("op_a2", 32, OpCode::ADD));
168  const auto op_b = opgraph.insert(OpGraphOp("op_b", 32, OpCode::ADD));
169 
170  opgraph.link(op_a, op_b, operands.rhs);
171  opgraph.link(op_a2, op_b, operands.lhs);
172 
173  return finalFixup(std::move(opgraph));
174 }
175 
177  OpGraph opgraph;
178  const auto op_a1 = opgraph.insert( OpGraphOp("op_a1", 32, OpCode::ADD));
179  const auto op_b1 = opgraph.insert(op_a1, OpGraphOp("op_b1", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
180  const auto op_a2 = opgraph.insert( OpGraphOp("op_a2", 32, OpCode::ADD));
181  const auto op_b2 = opgraph.insert(op_a2, OpGraphOp("op_b2", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
182  (void)op_b1;
183  (void)op_b2;
184 
185  return finalFixup(std::move(opgraph));
186 }
187 
189  OpGraph opgraph;
190  const auto op_a1 = opgraph.insert( OpGraphOp("op_a1", 32, OpCode::ADD) );
191  const auto op_a2 = opgraph.insert( OpGraphOp("op_a2", 32, OpCode::ADD) );
192  const auto op_b = opgraph.insert(op_a1, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
193  const auto op_c1 = opgraph.insert(op_b, OpGraphOp("op_c1", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
194  const auto op_c2 = opgraph.insert(op_b, OpGraphOp("op_c2", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
195  const auto op_d = opgraph.insert(op_c1, OpGraphOp("op_d", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
196 
197  opgraph.link(op_a2, op_b, Operands::BINARY_ANY);
198  opgraph.link(op_c2, op_d, Operands::BINARY_ANY);
199 
200  return finalFixup(std::move(opgraph));
201 }
202 
204  OpGraph opgraph;
205  const auto op_a = opgraph.insert(OpGraphOp("op_a", 32, OpCode::ADD));
206  const auto op_b = opgraph.insert(OpGraphOp("op_b", 32, OpCode::ADD));
207 
208  const auto num_edges = options.getIntOr("num_edges", 2);
209  if (num_edges == 2) {
210  const auto operands = parseBinaryOperandOption(options.getStringOr("operands", "commutative"));
211  opgraph.link(op_a, op_b, operands.lhs);
212  opgraph.link(op_a, op_b, operands.rhs);
213  } else {
214  for (int i = 0; i < num_edges; ++i) {
215  opgraph.link(op_a, op_b, Operands::UNTAGGED);
216  }
217  }
218 
219  return finalFixup(std::move(opgraph));
220 }
221 
223  OpGraph opgraph;
224  const auto op_i = opgraph.insert( OpGraphOp("op_i", 32, OpCode::INPUT));
225  const auto op_a = opgraph.insert(op_i, OpGraphOp("op_a", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
226  const auto op_b = opgraph.insert(op_i, OpGraphOp("op_b", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
227 
228  opgraph.link(op_a, op_b, Operands::BINARY_ANY);
229  opgraph.link(op_b, op_a, Operands::BINARY_ANY);
230 
231  return finalFixup(std::move(opgraph));
232 }
233 
235  OpGraph opgraph;
236  const auto op_i1 = opgraph.insert( OpGraphOp("op_i1", 32, OpCode::INPUT));
237  const auto op_i2 = opgraph.insert( OpGraphOp("op_i2", 32, OpCode::INPUT));
238  const auto op_a1 = opgraph.insert(op_i1, OpGraphOp("op_a1", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
239  const auto op_a2 = opgraph.insert(op_i1, OpGraphOp("op_a2", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
240  const auto op_b1 = opgraph.insert(op_a1, OpGraphOp("op_b1", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
241  const auto op_b2 = opgraph.insert(op_a2, OpGraphOp("op_b2", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
242  const auto op_c = opgraph.insert(op_b1, OpGraphOp("op_c", 32, OpCode::ADD), Operands::BINARY_ANY).newOp;
243 
244  opgraph.link(op_i2, op_a2, Operands::BINARY_ANY);
245  opgraph.link(op_a2, op_b1, Operands::BINARY_ANY);
246  opgraph.link(op_b2, op_c, Operands::BINARY_ANY);
247 
248  return finalFixup(std::move(opgraph));
249 }
250 
252  OpGraph opgraph;
253 
254  const auto op_i1 = opgraph.insert({"i1", 32, OpCode::INPUT});
255  const auto op_i2 = opgraph.insert({"i2", 32, OpCode::INPUT});
256  const auto op_a1 = opgraph.insert({"a1", 32, OpCode::ADD});
257  const auto op_a2 = opgraph.insert({"a2", 32, OpCode::ADD});
258  opgraph.link(op_i1, op_a1, Operands::BINARY_LHS);
259  opgraph.link(op_i1, op_a2, Operands::BINARY_LHS);
260  opgraph.link(op_i2, op_a1, Operands::BINARY_RHS);
261  opgraph.link(op_i2, op_a2, Operands::BINARY_RHS);
262  opgraph.link(op_a1, opgraph.insert({"o1", 32, OpCode::OUTPUT}), Operands::UNTAGGED);
263  opgraph.link(op_a2, opgraph.insert({"b1", 32, OpCode::BR}), Operands::UNTAGGED);
264 
265  return finalFixup(std::move(opgraph));
266 }
267 
269  OpGraph opgraph;
270  const auto mul0 = opgraph.insert(OpGraphOp("mul0", 32, OpCode::MUL));
271  const auto const1 = opgraph.insert(OpGraphOp("const1", 32, OpCode::CONST, 3));
272  const auto add2 = opgraph.insert(OpGraphOp("add2", 32, OpCode::ADD));
273  const auto output3 = opgraph.insert(OpGraphOp("output3", 32, OpCode::OUTPUT));
274  const auto add4 = opgraph.insert(OpGraphOp("add4", 32, OpCode::ADD));
275  const auto const5 = opgraph.insert(OpGraphOp("const5", 32, OpCode::CONST, 1));
276 
277  opgraph.link(mul0, add2, Operands::BINARY_ANY);
278  opgraph.link(add2, output3, Operands::UNTAGGED);
279  opgraph.link(add2, add2, Operands::BINARY_ANY);
280  opgraph.link(add4, mul0, Operands::BINARY_ANY);
281  opgraph.link(add4, add4, Operands::BINARY_ANY);
282  opgraph.link(const1, mul0, Operands::BINARY_ANY);
283  opgraph.link(const5, add4, Operands::BINARY_ANY);
284 
285  return finalFixup(std::move(opgraph));
286 }
287 
288 OpGraph makeDFG_Large(bool require_non_NN_FUs) {
289  OpGraph opgraph;
290  const auto add0 = opgraph.insert(OpGraphOp("add0", 32, OpCode::ADD ));
291  const auto const1 = opgraph.insert(OpGraphOp("const1", 32, OpCode::CONST, 1 ));
292  const auto mul2 = opgraph.insert(OpGraphOp("mul2", 32, OpCode::MUL ));
293  const auto const3 = opgraph.insert(OpGraphOp("const3", 32, OpCode::CONST, 3 ));
294  const auto load4 = opgraph.insert(OpGraphOp("load4", 32, OpCode::LOAD ));
295  const auto add5 = opgraph.insert(OpGraphOp("add5", 32, OpCode::ADD ));
296  const auto const6 = opgraph.insert(OpGraphOp("const6", 32, OpCode::CONST, 6 ));
297  const auto mul7 = opgraph.insert(OpGraphOp("mul7", 32, OpCode::MUL ));
298  const auto const8 = opgraph.insert(OpGraphOp("const8", 32, OpCode::CONST, 8));
299  const auto load9 = opgraph.insert(OpGraphOp("load9", 32, OpCode::LOAD ));
300  const auto add10 = opgraph.insert(OpGraphOp("add10", 32, OpCode::ADD ));
301  const auto mul11 = opgraph.insert(OpGraphOp("mul11", 32, OpCode::MUL ));
302  const auto const12 = opgraph.insert(OpGraphOp("const12", 32, OpCode::CONST, 12 ));
303  const auto load13 = opgraph.insert(OpGraphOp("load13", 32, OpCode::LOAD ));
304  const auto mul14 = opgraph.insert(OpGraphOp("mul14", 32, OpCode::MUL ));
305  const auto store15 = opgraph.insert(OpGraphOp("store15", 32, OpCode::STORE ));
306  const auto add16 = opgraph.insert(OpGraphOp("add16", 32, OpCode::ADD ));
307  const auto output17 = require_non_NN_FUs ? opgraph.insert(OpGraphOp("output17", 32, OpCode::OUTPUT)) : nullptr;
308 
309  opgraph.link(add0, mul2, Operands::BINARY_ANY);
310  opgraph.link(add0, add5, Operands::BINARY_ANY);
311  opgraph.link(add0, mul11, Operands::BINARY_ANY);
312  opgraph.link(add0, add0, Operands::BINARY_ANY);
313  opgraph.link(load4, add10, Operands::BINARY_ANY);
314  opgraph.link(add5, mul7, Operands::BINARY_ANY);
315  if (require_non_NN_FUs) { opgraph.link(load9, add10, Operands::BINARY_ANY); }
316  opgraph.link(add10, mul14, Operands::BINARY_ANY);
317  opgraph.link(load13, mul14, Operands::BINARY_ANY);
318  opgraph.link(mul14, store15, Operands::BINARY_ANY);
319  opgraph.link(mul14, add16, Operands::BINARY_ANY);
320  if (require_non_NN_FUs) { opgraph.link(add16, output17, Operands::UNTAGGED); }
321  opgraph.link(add16, add16, Operands::BINARY_ANY);
322  opgraph.link(const1, add0, Operands::BINARY_ANY);
323  opgraph.link(const3, mul2, Operands::BINARY_ANY);
324  opgraph.link(mul2, load4, Operands::BINARY_ANY);
325  opgraph.link(const6, add5, Operands::BINARY_ANY);
326  opgraph.link(const8, mul7, Operands::BINARY_ANY);
327  opgraph.link(mul7, load9, Operands::BINARY_ANY);
328  opgraph.link(const12, mul11, Operands::BINARY_ANY);
329  opgraph.link(mul11, load13, Operands::BINARY_ANY);
330  if (require_non_NN_FUs) { opgraph.link(mul11, store15, Operands::BINARY_ANY); }
331 
332  return finalFixup(std::move(opgraph));
333 }
334 
336  OpGraph opgraph;
337  const auto mul0 = opgraph.insert(OpGraphOp("mul0", 32, OpCode::MUL));
338  const auto const1 = opgraph.insert(OpGraphOp("const1", 32, OpCode::CONST, 1));
339  const auto load2 = opgraph.insert(OpGraphOp("load2", 32, OpCode::LOAD));
340  const auto mul3 = opgraph.insert(OpGraphOp("mul3", 32, OpCode::MUL));
341  const auto const4 = opgraph.insert(OpGraphOp("const4", 32, OpCode::CONST, 1));
342  const auto add5 = opgraph.insert(OpGraphOp("add5", 32, OpCode::ADD));
343  const auto const6 = opgraph.insert(OpGraphOp("const6", 32, OpCode::CONST, 1));
344  const auto mul7 = opgraph.insert(OpGraphOp("mul7", 32, OpCode::MUL));
345  const auto const8 = opgraph.insert(OpGraphOp("const8", 32, OpCode::CONST, 1));
346  const auto load9 = opgraph.insert(OpGraphOp("load9", 32, OpCode::LOAD));
347  const auto mul10 = opgraph.insert(OpGraphOp("mul10", 32, OpCode::MUL));
348  const auto const11 = opgraph.insert(OpGraphOp("const11", 32, OpCode::CONST, 1));
349  const auto add12 = opgraph.insert(OpGraphOp("add12", 32, OpCode::ADD));
350  const auto const13 = opgraph.insert(OpGraphOp("const13", 32, OpCode::CONST, 1));
351  const auto mul14 = opgraph.insert(OpGraphOp("mul14", 32, OpCode::MUL));
352  const auto const15 = opgraph.insert(OpGraphOp("const15", 32, OpCode::CONST, 1));
353  const auto load16 = opgraph.insert(OpGraphOp("load16", 32, OpCode::LOAD));
354  const auto mul17 = opgraph.insert(OpGraphOp("mul17", 32, OpCode::MUL));
355  const auto const18 = opgraph.insert(OpGraphOp("const18", 32, OpCode::CONST, 1));
356  const auto add19 = opgraph.insert(OpGraphOp("add19", 32, OpCode::ADD));
357  const auto const20 = opgraph.insert(OpGraphOp("const20", 32, OpCode::CONST, 1));
358  const auto mul21 = opgraph.insert(OpGraphOp("mul21", 32, OpCode::MUL));
359  const auto const22 = opgraph.insert(OpGraphOp("const22", 32, OpCode::CONST, 1));
360  const auto load23 = opgraph.insert(OpGraphOp("load23", 32, OpCode::LOAD));
361  const auto mul24 = opgraph.insert(OpGraphOp("mul24", 32, OpCode::MUL));
362  const auto const25 = opgraph.insert(OpGraphOp("const25", 32, OpCode::CONST, 1));
363  const auto add26 = opgraph.insert(OpGraphOp("add26", 32, OpCode::ADD));
364  const auto add27 = opgraph.insert(OpGraphOp("add27", 32, OpCode::ADD));
365  const auto add28 = opgraph.insert(OpGraphOp("add28", 32, OpCode::ADD));
366  const auto add29 = opgraph.insert(OpGraphOp("add29", 32, OpCode::ADD));
367  const auto output30 = opgraph.insert(OpGraphOp("output30", 32, OpCode::OUTPUT));
368 
369  opgraph.link(load2, mul3, Operands::BINARY_ANY);
370  opgraph.link(mul3, add26, Operands::BINARY_ANY);
371  opgraph.link(add5, mul7, Operands::BINARY_ANY);
372  opgraph.link(add5, mul0, Operands::BINARY_ANY);
373  opgraph.link(add5, add5, Operands::BINARY_ANY);
374  opgraph.link(add5, add12, Operands::BINARY_ANY);
375  opgraph.link(add5, add19, Operands::BINARY_ANY);
376  opgraph.link(load9, mul10, Operands::BINARY_ANY);
377  opgraph.link(mul10, add27, Operands::BINARY_ANY);
378  opgraph.link(add12, mul14, Operands::BINARY_ANY);
379  opgraph.link(load16, mul17, Operands::BINARY_ANY);
380  opgraph.link(mul17, add28, Operands::BINARY_ANY);
381  opgraph.link(add19, mul21, Operands::BINARY_ANY);
382  opgraph.link(load23, mul24, Operands::BINARY_ANY);
383  opgraph.link(mul24, add29, Operands::BINARY_ANY);
384  opgraph.link(add26, add27, Operands::BINARY_ANY);
385  opgraph.link(add27, add28, Operands::BINARY_ANY);
386  opgraph.link(add28, add29, Operands::BINARY_ANY);
387  opgraph.link(add29, output30, Operands::UNTAGGED);
388  opgraph.link(add29, add26, Operands::BINARY_ANY);
389  opgraph.link(const1, mul0, Operands::BINARY_ANY);
390  opgraph.link(mul0, load2, Operands::BINARY_ANY);
391  opgraph.link(const4, mul3, Operands::BINARY_ANY);
392  opgraph.link(const6, add5, Operands::BINARY_ANY);
393  opgraph.link(const8, mul7, Operands::BINARY_ANY);
394  opgraph.link(mul7, load9, Operands::BINARY_ANY);
395  opgraph.link(const11, mul10, Operands::BINARY_ANY);
396  opgraph.link(const13, add12, Operands::BINARY_ANY);
397  opgraph.link(const15, mul14, Operands::BINARY_ANY);
398  opgraph.link(mul14, load16, Operands::BINARY_ANY);
399  opgraph.link(const18, mul17, Operands::BINARY_ANY);
400  opgraph.link(const20, add19, Operands::BINARY_ANY);
401  opgraph.link(const22, mul21, Operands::BINARY_ANY);
402  opgraph.link(mul21, load23, Operands::BINARY_ANY);
403  opgraph.link(const25, mul24, Operands::BINARY_ANY);
404 
405  return finalFixup(std::move(opgraph));
406 }
407 
408 OpGraph makeDFG_Huge(const std::vector<int>& allowed_ids, ConfigStore options) {
409  const bool filter_consts = options.getBoolOr("filter_consts", false);
410  OpGraph opgraph;
411 
412  const auto maybeInsert = [&](OpGraphOp op) -> OpGraph::OpDescriptor {
413  auto num_index = op.getName().find_first_of("0123456789");
414  auto const_index = op.getName().find("const");
415  const auto num = std::stoi(op.getName().substr(num_index, std::string::npos));
416  if (filter_consts && const_index != op.getName().npos) {
417  return nullptr;
418  } else if (allowed_ids.empty() || std::find(allowed_ids.begin(), allowed_ids.end(), num) != allowed_ids.end()) {
419  return opgraph.insert(std::move(op));
420  } else {
421  return nullptr;
422  }
423  };
424 
425  const auto input0 = maybeInsert(OpGraphOp("input0", 32, OpCode::INPUT));
426  const auto shrl1 = maybeInsert(OpGraphOp("shrl1", 32, OpCode::LSHR));
427  const auto const2 = maybeInsert(OpGraphOp("const2", 32, OpCode::CONST, 1));
428  const auto and3 = maybeInsert(OpGraphOp("and3", 32, OpCode::AND));
429  const auto const4 = maybeInsert(OpGraphOp("const4", 32, OpCode::CONST, 1));
430  const auto mul5 = maybeInsert(OpGraphOp("mul5", 32, OpCode::MUL));
431  const auto const6 = maybeInsert(OpGraphOp("const6", 32, OpCode::CONST, 1));
432  const auto load7 = maybeInsert(OpGraphOp("load7", 32, OpCode::LOAD));
433  const auto shl8 = maybeInsert(OpGraphOp("shl8", 32, OpCode::SHL));
434  const auto const9 = maybeInsert(OpGraphOp("const9", 32, OpCode::CONST, 1));
435  const auto shrl10 = maybeInsert(OpGraphOp("shrl10", 32, OpCode::LSHR));
436  const auto const11 = maybeInsert(OpGraphOp("const11", 32, OpCode::CONST, 1));
437  const auto and12 = maybeInsert(OpGraphOp("and12", 32, OpCode::AND));
438  const auto const13 = maybeInsert(OpGraphOp("const13", 32, OpCode::CONST, 1));
439  const auto mul14 = maybeInsert(OpGraphOp("mul14", 32, OpCode::MUL));
440  const auto const15 = maybeInsert(OpGraphOp("const15", 32, OpCode::CONST, 1));
441  const auto load16 = maybeInsert(OpGraphOp("load16", 32, OpCode::LOAD));
442  const auto shl17 = maybeInsert(OpGraphOp("shl17", 32, OpCode::SHL));
443  const auto const18 = maybeInsert(OpGraphOp("const18", 32, OpCode::CONST, 1));
444  const auto or19 = maybeInsert(OpGraphOp("or19", 32, OpCode::OR));
445  const auto shrl20 = maybeInsert(OpGraphOp("shrl20", 32, OpCode::LSHR));
446  const auto const21 = maybeInsert(OpGraphOp("const21", 32, OpCode::CONST, 1));
447  const auto and22 = maybeInsert(OpGraphOp("and22", 32, OpCode::AND));
448  const auto const23 = maybeInsert(OpGraphOp("const23", 32, OpCode::CONST, 1));
449  const auto mul24 = maybeInsert(OpGraphOp("mul24", 32, OpCode::MUL));
450  const auto const25 = maybeInsert(OpGraphOp("const25", 32, OpCode::CONST, 1));
451  const auto load26 = maybeInsert(OpGraphOp("load26", 32, OpCode::LOAD));
452  const auto shl27 = maybeInsert(OpGraphOp("shl27", 32, OpCode::SHL));
453  const auto const28 = maybeInsert(OpGraphOp("const28", 32, OpCode::CONST, 1));
454  const auto or29 = maybeInsert(OpGraphOp("or29", 32, OpCode::OR));
455  const auto and30 = maybeInsert(OpGraphOp("and30", 32, OpCode::AND));
456  const auto const31 = maybeInsert(OpGraphOp("const31", 32, OpCode::CONST, 1));
457  const auto mul32 = maybeInsert(OpGraphOp("mul32", 32, OpCode::MUL));
458  const auto const33 = maybeInsert(OpGraphOp("const33", 32, OpCode::CONST, 1));
459  const auto load34 = maybeInsert(OpGraphOp("load34", 32, OpCode::LOAD));
460  const auto or35 = maybeInsert(OpGraphOp("or35", 32, OpCode::OR));
461  const auto shl36 = maybeInsert(OpGraphOp("shl36", 32, OpCode::SHL));
462  const auto const37 = maybeInsert(OpGraphOp("const37", 32, OpCode::CONST, 1));
463  const auto and38 = maybeInsert(OpGraphOp("and38", 32, OpCode::AND));
464  const auto const39 = maybeInsert(OpGraphOp("const39", 32, OpCode::CONST, 1));
465  const auto shrl40 = maybeInsert(OpGraphOp("shrl40", 32, OpCode::LSHR));
466  const auto const41 = maybeInsert(OpGraphOp("const41", 32, OpCode::CONST, 1));
467  const auto and42 = maybeInsert(OpGraphOp("and42", 32, OpCode::AND));
468  const auto const43 = maybeInsert(OpGraphOp("const43", 32, OpCode::CONST, 1));
469  const auto mul44 = maybeInsert(OpGraphOp("mul44", 32, OpCode::MUL));
470  const auto const45 = maybeInsert(OpGraphOp("const45", 32, OpCode::CONST, 1));
471  const auto xor46 = maybeInsert(OpGraphOp("xor46", 32, OpCode::XOR));
472  const auto xor47 = maybeInsert(OpGraphOp("xor47", 32, OpCode::XOR));
473  const auto shl48 = maybeInsert(OpGraphOp("shl48", 32, OpCode::SHL));
474  const auto const49 = maybeInsert(OpGraphOp("const49", 32, OpCode::CONST, 1));
475  const auto shrl50 = maybeInsert(OpGraphOp("shrl50", 32, OpCode::LSHR));
476  const auto const51 = maybeInsert(OpGraphOp("const51", 32, OpCode::CONST, 1));
477  const auto or52 = maybeInsert(OpGraphOp("or52", 32, OpCode::OR));
478  const auto shl53 = maybeInsert(OpGraphOp("shl53", 32, OpCode::SHL));
479  const auto const54 = maybeInsert(OpGraphOp("const54", 32, OpCode::CONST, 1));
480  const auto shrl55 = maybeInsert(OpGraphOp("shrl55", 32, OpCode::LSHR));
481  const auto const56 = maybeInsert(OpGraphOp("const56", 32, OpCode::CONST, 1));
482  const auto or57 = maybeInsert(OpGraphOp("or57", 32, OpCode::OR));
483  const auto shl58 = maybeInsert(OpGraphOp("shl58", 32, OpCode::SHL));
484  const auto const59 = maybeInsert(OpGraphOp("const59", 32, OpCode::CONST, 1));
485  const auto or60 = maybeInsert(OpGraphOp("or60", 32, OpCode::OR));
486  const auto load61 = maybeInsert(OpGraphOp("load61", 32, OpCode::LOAD));
487  const auto xor62 = maybeInsert(OpGraphOp("xor62", 32, OpCode::XOR));
488  const auto xor63 = maybeInsert(OpGraphOp("xor63", 32, OpCode::XOR));
489  const auto xor64 = maybeInsert(OpGraphOp("xor64", 32, OpCode::XOR));
490  const auto xor65 = maybeInsert(OpGraphOp("xor65", 32, OpCode::XOR));
491  const auto output66 = maybeInsert(OpGraphOp("output66", 32, OpCode::OUTPUT));
492  const auto shrl67 = maybeInsert(OpGraphOp("shrl67", 32, OpCode::LSHR));
493  const auto const68 = maybeInsert(OpGraphOp("const68", 32, OpCode::CONST, 1));
494  const auto and69 = maybeInsert(OpGraphOp("and69", 32, OpCode::AND));
495  const auto const70 = maybeInsert(OpGraphOp("const70", 32, OpCode::CONST, 1));
496  const auto mul71 = maybeInsert(OpGraphOp("mul71", 32, OpCode::MUL));
497  const auto const72 = maybeInsert(OpGraphOp("const72", 32, OpCode::CONST, 1));
498  const auto load73 = maybeInsert(OpGraphOp("load73", 32, OpCode::LOAD));
499  const auto shl74 = maybeInsert(OpGraphOp("shl74", 32, OpCode::SHL));
500  const auto const75 = maybeInsert(OpGraphOp("const75", 32, OpCode::CONST, 1));
501  const auto shrl76 = maybeInsert(OpGraphOp("shrl76", 32, OpCode::LSHR));
502  const auto const77 = maybeInsert(OpGraphOp("const77", 32, OpCode::CONST, 1));
503  const auto and78 = maybeInsert(OpGraphOp("and78", 32, OpCode::AND));
504  const auto const79 = maybeInsert(OpGraphOp("const79", 32, OpCode::CONST, 1));
505  const auto mul80 = maybeInsert(OpGraphOp("mul80", 32, OpCode::MUL));
506  const auto const81 = maybeInsert(OpGraphOp("const81", 32, OpCode::CONST, 1));
507  const auto load82 = maybeInsert(OpGraphOp("load82", 32, OpCode::LOAD));
508  const auto shl83 = maybeInsert(OpGraphOp("shl83", 32, OpCode::SHL));
509  const auto const84 = maybeInsert(OpGraphOp("const84", 32, OpCode::CONST, 1));
510  const auto or85 = maybeInsert(OpGraphOp("or85", 32, OpCode::OR));
511  const auto shrl86 = maybeInsert(OpGraphOp("shrl86", 32, OpCode::LSHR));
512  const auto const87 = maybeInsert(OpGraphOp("const87", 32, OpCode::CONST, 1));
513  const auto and88 = maybeInsert(OpGraphOp("and88", 32, OpCode::AND));
514  const auto const89 = maybeInsert(OpGraphOp("const89", 32, OpCode::CONST, 1));
515  const auto mul90 = maybeInsert(OpGraphOp("mul90", 32, OpCode::MUL));
516  const auto const91 = maybeInsert(OpGraphOp("const91", 32, OpCode::CONST, 1));
517  const auto load92 = maybeInsert(OpGraphOp("load92", 32, OpCode::LOAD));
518  const auto shl93 = maybeInsert(OpGraphOp("shl93", 32, OpCode::SHL));
519  const auto const94 = maybeInsert(OpGraphOp("const94", 32, OpCode::CONST, 1));
520  const auto or95 = maybeInsert(OpGraphOp("or95", 32, OpCode::OR));
521  const auto and96 = maybeInsert(OpGraphOp("and96", 32, OpCode::AND));
522  const auto const97 = maybeInsert(OpGraphOp("const97", 32, OpCode::CONST, 1));
523  const auto mul98 = maybeInsert(OpGraphOp("mul98", 32, OpCode::MUL));
524  const auto const99 = maybeInsert(OpGraphOp("const99", 32, OpCode::CONST, 1));
525  const auto load100 = maybeInsert(OpGraphOp("load100", 32, OpCode::LOAD));
526  const auto or101 = maybeInsert(OpGraphOp("or101", 32, OpCode::OR));
527  const auto shl102 = maybeInsert(OpGraphOp("shl102", 32, OpCode::SHL));
528  const auto const103 = maybeInsert(OpGraphOp("const103", 32, OpCode::CONST, 1));
529  const auto and104 = maybeInsert(OpGraphOp("and104", 32, OpCode::AND));
530  const auto const105 = maybeInsert(OpGraphOp("const105", 32, OpCode::CONST, 1));
531  const auto shrl106 = maybeInsert(OpGraphOp("shrl106", 32, OpCode::LSHR));
532  const auto const107 = maybeInsert(OpGraphOp("const107", 32, OpCode::CONST, 1));
533  const auto and108 = maybeInsert(OpGraphOp("and108", 32, OpCode::AND));
534  const auto const109 = maybeInsert(OpGraphOp("const109", 32, OpCode::CONST, 1));
535  const auto mul110 = maybeInsert(OpGraphOp("mul110", 32, OpCode::MUL));
536  const auto const111 = maybeInsert(OpGraphOp("const111", 32, OpCode::CONST, 1));
537  const auto xor112 = maybeInsert(OpGraphOp("xor112", 32, OpCode::XOR));
538  const auto xor113 = maybeInsert(OpGraphOp("xor113", 32, OpCode::XOR));
539  const auto shl114 = maybeInsert(OpGraphOp("shl114", 32, OpCode::SHL));
540  const auto const115 = maybeInsert(OpGraphOp("const115", 32, OpCode::CONST, 1));
541  const auto shrl116 = maybeInsert(OpGraphOp("shrl116", 32, OpCode::LSHR));
542  const auto const117 = maybeInsert(OpGraphOp("const117", 32, OpCode::CONST, 1));
543  const auto or118 = maybeInsert(OpGraphOp("or118", 32, OpCode::OR));
544  const auto shl119 = maybeInsert(OpGraphOp("shl119", 32, OpCode::SHL));
545  const auto const120 = maybeInsert(OpGraphOp("const120", 32, OpCode::CONST, 1));
546  const auto shrl121 = maybeInsert(OpGraphOp("shrl121", 32, OpCode::LSHR));
547  const auto const122 = maybeInsert(OpGraphOp("const122", 32, OpCode::CONST, 1));
548  const auto or123 = maybeInsert(OpGraphOp("or123", 32, OpCode::OR));
549  const auto shl124 = maybeInsert(OpGraphOp("shl124", 32, OpCode::SHL));
550  const auto const125 = maybeInsert(OpGraphOp("const125", 32, OpCode::CONST, 1));
551  const auto or126 = maybeInsert(OpGraphOp("or126", 32, OpCode::OR));
552  const auto const127 = maybeInsert(OpGraphOp("const127", 32, OpCode::CONST, 1));
553  const auto load128 = maybeInsert(OpGraphOp("load128", 32, OpCode::LOAD));
554  const auto xor129 = maybeInsert(OpGraphOp("xor129", 32, OpCode::XOR));
555  const auto xor130 = maybeInsert(OpGraphOp("xor130", 32, OpCode::XOR));
556  const auto xor131 = maybeInsert(OpGraphOp("xor131", 32, OpCode::XOR));
557  const auto xor132 = maybeInsert(OpGraphOp("xor132", 32, OpCode::XOR));
558  const auto output133 = maybeInsert(OpGraphOp("output133", 32, OpCode::OUTPUT));
559  const auto shrl134 = maybeInsert(OpGraphOp("shrl134", 32, OpCode::LSHR));
560  const auto const135 = maybeInsert(OpGraphOp("const135", 32, OpCode::CONST, 1));
561  const auto and136 = maybeInsert(OpGraphOp("and136", 32, OpCode::AND));
562  const auto const137 = maybeInsert(OpGraphOp("const137", 32, OpCode::CONST, 1));
563  const auto mul138 = maybeInsert(OpGraphOp("mul138", 32, OpCode::MUL));
564  const auto const139 = maybeInsert(OpGraphOp("const139", 32, OpCode::CONST, 1));
565  const auto load140 = maybeInsert(OpGraphOp("load140", 32, OpCode::LOAD));
566  const auto shl141 = maybeInsert(OpGraphOp("shl141", 32, OpCode::SHL));
567  const auto const142 = maybeInsert(OpGraphOp("const142", 32, OpCode::CONST, 1));
568  const auto shrl143 = maybeInsert(OpGraphOp("shrl143", 32, OpCode::LSHR));
569  const auto const144 = maybeInsert(OpGraphOp("const144", 32, OpCode::CONST, 1));
570  const auto and145 = maybeInsert(OpGraphOp("and145", 32, OpCode::AND));
571  const auto const146 = maybeInsert(OpGraphOp("const146", 32, OpCode::CONST, 1));
572  const auto mul147 = maybeInsert(OpGraphOp("mul147", 32, OpCode::MUL));
573  const auto const148 = maybeInsert(OpGraphOp("const148", 32, OpCode::CONST, 1));
574  const auto load149 = maybeInsert(OpGraphOp("load149", 32, OpCode::LOAD));
575  const auto shl150 = maybeInsert(OpGraphOp("shl150", 32, OpCode::SHL));
576  const auto const151 = maybeInsert(OpGraphOp("const151", 32, OpCode::CONST, 1));
577  const auto or152 = maybeInsert(OpGraphOp("or152", 32, OpCode::OR));
578  const auto shrl153 = maybeInsert(OpGraphOp("shrl153", 32, OpCode::LSHR));
579  const auto const154 = maybeInsert(OpGraphOp("const154", 32, OpCode::CONST, 1));
580  const auto and155 = maybeInsert(OpGraphOp("and155", 32, OpCode::AND));
581  const auto const156 = maybeInsert(OpGraphOp("const156", 32, OpCode::CONST, 1));
582  const auto mul157 = maybeInsert(OpGraphOp("mul157", 32, OpCode::MUL));
583  const auto const158 = maybeInsert(OpGraphOp("const158", 32, OpCode::CONST, 1));
584  const auto load159 = maybeInsert(OpGraphOp("load159", 32, OpCode::LOAD));
585  const auto shl160 = maybeInsert(OpGraphOp("shl160", 32, OpCode::SHL));
586  const auto const161 = maybeInsert(OpGraphOp("const161", 32, OpCode::CONST, 1));
587  const auto or162 = maybeInsert(OpGraphOp("or162", 32, OpCode::OR));
588  const auto and163 = maybeInsert(OpGraphOp("and163", 32, OpCode::AND));
589  const auto const164 = maybeInsert(OpGraphOp("const164", 32, OpCode::CONST, 1));
590  const auto mul165 = maybeInsert(OpGraphOp("mul165", 32, OpCode::MUL));
591  const auto const166 = maybeInsert(OpGraphOp("const166", 32, OpCode::CONST, 1));
592  const auto load167 = maybeInsert(OpGraphOp("load167", 32, OpCode::LOAD));
593  const auto or168 = maybeInsert(OpGraphOp("or168", 32, OpCode::OR));
594  const auto shl169 = maybeInsert(OpGraphOp("shl169", 32, OpCode::SHL));
595  const auto const170 = maybeInsert(OpGraphOp("const170", 32, OpCode::CONST, 1));
596  const auto and171 = maybeInsert(OpGraphOp("and171", 32, OpCode::AND));
597  const auto const172 = maybeInsert(OpGraphOp("const172", 32, OpCode::CONST, 1));
598  const auto shrl173 = maybeInsert(OpGraphOp("shrl173", 32, OpCode::LSHR));
599  const auto const174 = maybeInsert(OpGraphOp("const174", 32, OpCode::CONST, 1));
600  const auto and175 = maybeInsert(OpGraphOp("and175", 32, OpCode::AND));
601  const auto const176 = maybeInsert(OpGraphOp("const176", 32, OpCode::CONST, 1));
602  const auto mul177 = maybeInsert(OpGraphOp("mul177", 32, OpCode::MUL));
603  const auto const178 = maybeInsert(OpGraphOp("const178", 32, OpCode::CONST, 1));
604  const auto xor179 = maybeInsert(OpGraphOp("xor179", 32, OpCode::XOR));
605  const auto xor180 = maybeInsert(OpGraphOp("xor180", 32, OpCode::XOR));
606  const auto shl181 = maybeInsert(OpGraphOp("shl181", 32, OpCode::SHL));
607  const auto const182 = maybeInsert(OpGraphOp("const182", 32, OpCode::CONST, 1));
608  const auto shrl183 = maybeInsert(OpGraphOp("shrl183", 32, OpCode::LSHR));
609  const auto const184 = maybeInsert(OpGraphOp("const184", 32, OpCode::CONST, 1));
610  const auto or185 = maybeInsert(OpGraphOp("or185", 32, OpCode::OR));
611  const auto shl186 = maybeInsert(OpGraphOp("shl186", 32, OpCode::SHL));
612  const auto const187 = maybeInsert(OpGraphOp("const187", 32, OpCode::CONST, 1));
613  const auto shrl188 = maybeInsert(OpGraphOp("shrl188", 32, OpCode::LSHR));
614  const auto const189 = maybeInsert(OpGraphOp("const189", 32, OpCode::CONST, 1));
615  const auto or190 = maybeInsert(OpGraphOp("or190", 32, OpCode::OR));
616  const auto shl191 = maybeInsert(OpGraphOp("shl191", 32, OpCode::SHL));
617  const auto const192 = maybeInsert(OpGraphOp("const192", 32, OpCode::CONST, 1));
618  const auto or193 = maybeInsert(OpGraphOp("or193", 32, OpCode::OR));
619  const auto const194 = maybeInsert(OpGraphOp("const194", 32, OpCode::CONST, 1));
620  const auto load195 = maybeInsert(OpGraphOp("load195", 32, OpCode::LOAD));
621  const auto xor196 = maybeInsert(OpGraphOp("xor196", 32, OpCode::XOR));
622  const auto xor197 = maybeInsert(OpGraphOp("xor197", 32, OpCode::XOR));
623  const auto xor198 = maybeInsert(OpGraphOp("xor198", 32, OpCode::XOR));
624  const auto xor199 = maybeInsert(OpGraphOp("xor199", 32, OpCode::XOR));
625  const auto output200 = maybeInsert(OpGraphOp("output200", 32, OpCode::OUTPUT));
626  const auto shrl201 = maybeInsert(OpGraphOp("shrl201", 32, OpCode::LSHR));
627  const auto const202 = maybeInsert(OpGraphOp("const202", 32, OpCode::CONST, 1));
628  const auto and203 = maybeInsert(OpGraphOp("and203", 32, OpCode::AND));
629  const auto const204 = maybeInsert(OpGraphOp("const204", 32, OpCode::CONST, 1));
630  const auto mul205 = maybeInsert(OpGraphOp("mul205", 32, OpCode::MUL));
631  const auto const206 = maybeInsert(OpGraphOp("const206", 32, OpCode::CONST, 1));
632  const auto load207 = maybeInsert(OpGraphOp("load207", 32, OpCode::LOAD));
633  const auto shl208 = maybeInsert(OpGraphOp("shl208", 32, OpCode::SHL));
634  const auto const209 = maybeInsert(OpGraphOp("const209", 32, OpCode::CONST, 1));
635  const auto shrl210 = maybeInsert(OpGraphOp("shrl210", 32, OpCode::LSHR));
636  const auto const211 = maybeInsert(OpGraphOp("const211", 32, OpCode::CONST, 1));
637  const auto and212 = maybeInsert(OpGraphOp("and212", 32, OpCode::AND));
638  const auto const213 = maybeInsert(OpGraphOp("const213", 32, OpCode::CONST, 1));
639  const auto mul214 = maybeInsert(OpGraphOp("mul214", 32, OpCode::MUL));
640  const auto const215 = maybeInsert(OpGraphOp("const215", 32, OpCode::CONST, 1));
641  const auto load216 = maybeInsert(OpGraphOp("load216", 32, OpCode::LOAD));
642  const auto shl217 = maybeInsert(OpGraphOp("shl217", 32, OpCode::SHL));
643  const auto const218 = maybeInsert(OpGraphOp("const218", 32, OpCode::CONST, 1));
644  const auto or219 = maybeInsert(OpGraphOp("or219", 32, OpCode::OR));
645  const auto shrl220 = maybeInsert(OpGraphOp("shrl220", 32, OpCode::LSHR));
646  const auto const221 = maybeInsert(OpGraphOp("const221", 32, OpCode::CONST, 1));
647  const auto and222 = maybeInsert(OpGraphOp("and222", 32, OpCode::AND));
648  const auto const223 = maybeInsert(OpGraphOp("const223", 32, OpCode::CONST, 1));
649  const auto mul224 = maybeInsert(OpGraphOp("mul224", 32, OpCode::MUL));
650  const auto const225 = maybeInsert(OpGraphOp("const225", 32, OpCode::CONST, 1));
651  const auto load226 = maybeInsert(OpGraphOp("load226", 32, OpCode::LOAD));
652  const auto shl227 = maybeInsert(OpGraphOp("shl227", 32, OpCode::SHL));
653  const auto const228 = maybeInsert(OpGraphOp("const228", 32, OpCode::CONST, 1));
654  const auto or229 = maybeInsert(OpGraphOp("or229", 32, OpCode::OR));
655  const auto and230 = maybeInsert(OpGraphOp("and230", 32, OpCode::AND));
656  const auto const231 = maybeInsert(OpGraphOp("const231", 32, OpCode::CONST, 1));
657  const auto mul232 = maybeInsert(OpGraphOp("mul232", 32, OpCode::MUL));
658  const auto const233 = maybeInsert(OpGraphOp("const233", 32, OpCode::CONST, 1));
659  const auto load234 = maybeInsert(OpGraphOp("load234", 32, OpCode::LOAD));
660  const auto or235 = maybeInsert(OpGraphOp("or235", 32, OpCode::OR));
661  const auto shl236 = maybeInsert(OpGraphOp("shl236", 32, OpCode::SHL));
662  const auto const237 = maybeInsert(OpGraphOp("const237", 32, OpCode::CONST, 1));
663  const auto and238 = maybeInsert(OpGraphOp("and238", 32, OpCode::AND));
664  const auto const239 = maybeInsert(OpGraphOp("const239", 32, OpCode::CONST, 1));
665  const auto shrl240 = maybeInsert(OpGraphOp("shrl240", 32, OpCode::LSHR));
666  const auto const241 = maybeInsert(OpGraphOp("const241", 32, OpCode::CONST, 1));
667  const auto and242 = maybeInsert(OpGraphOp("and242", 32, OpCode::AND));
668  const auto const243 = maybeInsert(OpGraphOp("const243", 32, OpCode::CONST, 1));
669  const auto mul244 = maybeInsert(OpGraphOp("mul244", 32, OpCode::MUL));
670  const auto const245 = maybeInsert(OpGraphOp("const245", 32, OpCode::CONST, 1));
671  const auto xor246 = maybeInsert(OpGraphOp("xor246", 32, OpCode::XOR));
672  const auto xor247 = maybeInsert(OpGraphOp("xor247", 32, OpCode::XOR));
673  const auto shl248 = maybeInsert(OpGraphOp("shl248", 32, OpCode::SHL));
674  const auto const249 = maybeInsert(OpGraphOp("const249", 32, OpCode::CONST, 1));
675  const auto shrl250 = maybeInsert(OpGraphOp("shrl250", 32, OpCode::LSHR));
676  const auto const251 = maybeInsert(OpGraphOp("const251", 32, OpCode::CONST, 1));
677  const auto or252 = maybeInsert(OpGraphOp("or252", 32, OpCode::OR));
678  const auto shl253 = maybeInsert(OpGraphOp("shl253", 32, OpCode::SHL));
679  const auto const254 = maybeInsert(OpGraphOp("const254", 32, OpCode::CONST, 1));
680  const auto shrl255 = maybeInsert(OpGraphOp("shrl255", 32, OpCode::LSHR));
681  const auto const256 = maybeInsert(OpGraphOp("const256", 32, OpCode::CONST, 1));
682  const auto or257 = maybeInsert(OpGraphOp("or257", 32, OpCode::OR));
683  const auto shl258 = maybeInsert(OpGraphOp("shl258", 32, OpCode::SHL));
684  const auto const259 = maybeInsert(OpGraphOp("const259", 32, OpCode::CONST, 1));
685  const auto or260 = maybeInsert(OpGraphOp("or260", 32, OpCode::OR));
686  const auto const261 = maybeInsert(OpGraphOp("const261", 32, OpCode::CONST, 1));
687  const auto load262 = maybeInsert(OpGraphOp("load262", 32, OpCode::LOAD));
688  const auto xor263 = maybeInsert(OpGraphOp("xor263", 32, OpCode::XOR));
689  const auto xor264 = maybeInsert(OpGraphOp("xor264", 32, OpCode::XOR));
690  const auto xor265 = maybeInsert(OpGraphOp("xor265", 32, OpCode::XOR));
691  const auto xor266 = maybeInsert(OpGraphOp("xor266", 32, OpCode::XOR));
692  const auto output267 = maybeInsert(OpGraphOp("output267", 32, OpCode::OUTPUT));
693  const auto add268 = maybeInsert(OpGraphOp("add268", 32, OpCode::ADD));
694  const auto const269 = maybeInsert(OpGraphOp("const269", 32, OpCode::CONST, 1));
695 
696  // TODO: Routing Operand: remove inputnum arg
697  const auto maybeLink = [&](const OpGraphOp* o1, const OpGraphOp* o2, std::string input = Operands::BINARY_ANY) {
698  if (o1 && o2) {
699  opgraph.link(o1, o2, input);
700  }
701  };
702 
703  maybeLink(shrl1, and3);
704  maybeLink(and3, mul5);
705  maybeLink(mul5, load7, Operands::BINARY_RHS);
706  maybeLink(load7, shl8);
707  maybeLink(load7, or60);
708  maybeLink(shl8, or19);
709  maybeLink(shrl10, and12);
710  maybeLink(and12, mul14);
711  maybeLink(mul14, load16, Operands::BINARY_RHS);
712  maybeLink(load16, shl17, Operands::BINARY_LHS);
713  maybeLink(shl17, or19);
714  maybeLink(or19, or29);
715  maybeLink(or19, shrl55, Operands::BINARY_LHS);
716  maybeLink(shrl20, and22);
717  maybeLink(and22, mul24);
718  maybeLink(mul24, load26, Operands::BINARY_RHS);
719  maybeLink(load26, shl27, Operands::BINARY_LHS);
720  maybeLink(shl27, or29);
721  maybeLink(or29, or35);
722  maybeLink(and30, mul32);
723  maybeLink(mul32, load34, Operands::BINARY_RHS);
724  maybeLink(load34, or35);
725  maybeLink(or35, shl36, Operands::BINARY_LHS);
726  maybeLink(or35, shrl40, Operands::BINARY_LHS);
727  maybeLink(or35, xor47);
728  maybeLink(or35, shl53, Operands::BINARY_LHS);
729  maybeLink(or35, shl58, Operands::BINARY_LHS);
730  maybeLink(shl36, and38);
731  maybeLink(and38, xor46);
732  maybeLink(shrl40, and42);
733  maybeLink(and42, mul44);
734  maybeLink(mul44, xor46);
735  maybeLink(xor46, xor47);
736  maybeLink(xor46, xor64);
737  maybeLink(xor47, shl48, Operands::BINARY_LHS);
738  maybeLink(xor47, shrl50, Operands::BINARY_LHS);
739  maybeLink(shl48, or52);
740  maybeLink(shrl50, or52);
741  maybeLink(or52, xor65);
742  maybeLink(shl53, or57);
743  maybeLink(shrl55, or57);
744  maybeLink(or57, xor62);
745  maybeLink(shl58, or60);
746  maybeLink(or60, xor63);
747  maybeLink(load61, xor62);
748  maybeLink(xor62, xor63);
749  maybeLink(xor63, xor64);
750  maybeLink(xor64, xor65);
751  maybeLink(xor65, output66);
752  maybeLink(xor65, and30);
753  maybeLink(xor65, shrl67, Operands::BINARY_LHS);
754  maybeLink(xor65, shrl143, Operands::BINARY_LHS);
755  maybeLink(xor65, shrl220, Operands::BINARY_LHS);
756  maybeLink(shrl67, and69);
757  maybeLink(and69, mul71);
758  maybeLink(mul71, load73, Operands::BINARY_RHS);
759  maybeLink(load73, shl74, Operands::BINARY_LHS);
760  maybeLink(load73, or126);
761  maybeLink(shl74, or85);
762  maybeLink(shrl76, and78);
763  maybeLink(and78, mul80);
764  maybeLink(mul80, load82, Operands::BINARY_RHS);
765  maybeLink(load82, shl83, Operands::BINARY_LHS);
766  maybeLink(shl83, or85);
767  maybeLink(or85, or95);
768  maybeLink(or85, shrl121, Operands::BINARY_LHS);
769  maybeLink(shrl86, and88);
770  maybeLink(and88, mul90);
771  maybeLink(mul90, load92, Operands::BINARY_RHS);
772  maybeLink(load92, shl93, Operands::BINARY_LHS);
773  maybeLink(shl93, or95);
774  maybeLink(or95, or101);
775  maybeLink(and96, mul98);
776  maybeLink(mul98, load100, Operands::BINARY_RHS);
777  maybeLink(load100, or101);
778  maybeLink(or101, shl102, Operands::BINARY_LHS);
779  maybeLink(or101, shrl106, Operands::BINARY_LHS);
780  maybeLink(or101, xor113);
781  maybeLink(or101, shl119, Operands::BINARY_LHS);
782  maybeLink(or101, shl124, Operands::BINARY_LHS);
783  maybeLink(shl102, and104);
784  maybeLink(and104, xor112);
785  maybeLink(shrl106, and108);
786  maybeLink(and108, mul110);
787  maybeLink(mul110, xor112);
788  maybeLink(xor112, xor113);
789  maybeLink(xor112, xor131);
790  maybeLink(xor113, shl114, Operands::BINARY_LHS);
791  maybeLink(xor113, shrl116, Operands::BINARY_LHS);
792  maybeLink(shl114, or118);
793  maybeLink(shrl116, or118);
794  maybeLink(or118, xor132);
795  maybeLink(shl119, or123);
796  maybeLink(shrl121, or123);
797  maybeLink(or123, xor129);
798  maybeLink(shl124, or126);
799  maybeLink(or126, xor130);
800  maybeLink(const127, load128, Operands::BINARY_RHS);
801  maybeLink(load128, xor129);
802  maybeLink(xor129, xor130);
803  maybeLink(xor130, xor131);
804  maybeLink(xor131, xor132);
805  maybeLink(xor132, output133, Operands::BINARY_LHS);
806  maybeLink(xor132, shrl20, Operands::BINARY_LHS);
807  maybeLink(xor132, and96);
808  maybeLink(xor132, shrl134, Operands::BINARY_LHS);
809  maybeLink(xor132, shrl210, Operands::BINARY_LHS);
810  maybeLink(shrl134, and136);
811  maybeLink(and136, mul138);
812  maybeLink(mul138, load140, Operands::BINARY_RHS);
813  maybeLink(load140, shl141, Operands::BINARY_LHS);
814  maybeLink(load140, or193);
815  maybeLink(shl141, or152);
816  maybeLink(shrl143, and145);
817  maybeLink(and145, mul147);
818  maybeLink(mul147, load149, Operands::BINARY_RHS);
819  maybeLink(load149, shl150, Operands::BINARY_LHS);
820  maybeLink(shl150, or152);
821  maybeLink(or152, or162);
822  maybeLink(or152, shrl188, Operands::BINARY_LHS);
823  maybeLink(shrl153, and155);
824  maybeLink(and155, mul157);
825  maybeLink(mul157, load159, Operands::BINARY_RHS);
826  maybeLink(load159, shl160, Operands::BINARY_LHS);
827  maybeLink(shl160, or162);
828  maybeLink(or162, or168);
829  maybeLink(and163, mul165);
830  maybeLink(mul165, load167, Operands::BINARY_RHS);
831  maybeLink(load167, or168);
832  maybeLink(or168, shl169, Operands::BINARY_LHS);
833  maybeLink(or168, shrl173, Operands::BINARY_LHS);
834  maybeLink(or168, xor180);
835  maybeLink(or168, shl186, Operands::BINARY_LHS);
836  maybeLink(or168, shl191, Operands::BINARY_LHS);
837  maybeLink(shl169, and171);
838  maybeLink(and171, xor179);
839  maybeLink(shrl173, and175);
840  maybeLink(and175, mul177);
841  maybeLink(mul177, xor179);
842  maybeLink(xor179, xor180);
843  maybeLink(xor179, xor198);
844  maybeLink(xor180, shl181, Operands::BINARY_LHS);
845  maybeLink(xor180, shrl183, Operands::BINARY_LHS);
846  maybeLink(shl181, or185);
847  maybeLink(shrl183, or185);
848  maybeLink(or185, xor199);
849  maybeLink(shl186, or190);
850  maybeLink(shrl188, or190);
851  maybeLink(or190, xor196);
852  maybeLink(shl191, or193);
853  maybeLink(or193, xor197);
854  maybeLink(const194, load195, Operands::BINARY_RHS);
855  maybeLink(load195, xor196);
856  maybeLink(xor196, xor197);
857  maybeLink(xor197, xor198);
858  maybeLink(xor198, xor199);
859  maybeLink(xor199, output200, Operands::BINARY_LHS);
860  maybeLink(xor199, shrl10, Operands::BINARY_LHS);
861  maybeLink(xor199, shrl86, Operands::BINARY_LHS);
862  maybeLink(xor199, and163);
863  maybeLink(xor199, shrl201, Operands::BINARY_LHS);
864  maybeLink(shrl201, and203);
865  maybeLink(and203, mul205);
866  maybeLink(mul205, load207, Operands::BINARY_RHS);
867  maybeLink(load207, shl208, Operands::BINARY_LHS);
868  maybeLink(load207, or260);
869  maybeLink(shl208, or219);
870  maybeLink(shrl210, and212);
871  maybeLink(and212, mul214);
872  maybeLink(mul214, load216, Operands::BINARY_RHS);
873  maybeLink(load216, shl217, Operands::BINARY_LHS);
874  maybeLink(shl217, or219);
875  maybeLink(or219, or229);
876  maybeLink(or219, shrl255, Operands::BINARY_LHS);
877  maybeLink(shrl220, and222);
878  maybeLink(and222, mul224);
879  maybeLink(mul224, load226, Operands::BINARY_RHS);
880  maybeLink(load226, shl227, Operands::BINARY_LHS);
881  maybeLink(shl227, or229);
882  maybeLink(or229, or235);
883  maybeLink(and230, mul232);
884  maybeLink(mul232, load234, Operands::BINARY_RHS);
885  maybeLink(load234, or235);
886  maybeLink(or235, shl236, Operands::BINARY_LHS);
887  maybeLink(or235, shrl240, Operands::BINARY_LHS);
888  maybeLink(or235, xor247);
889  maybeLink(or235, shl253, Operands::BINARY_LHS);
890  maybeLink(or235, shl258, Operands::BINARY_LHS);
891  maybeLink(shl236, and238);
892  maybeLink(and238, xor246);
893  maybeLink(shrl240, and242);
894  maybeLink(and242, mul244);
895  maybeLink(mul244, xor246);
896  maybeLink(xor246, xor247);
897  maybeLink(xor246, xor265);
898  maybeLink(xor247, shl248, Operands::BINARY_LHS);
899  maybeLink(xor247, shrl250, Operands::BINARY_LHS);
900  maybeLink(shl248, or252);
901  maybeLink(shrl250, or252);
902  maybeLink(or252, xor266);
903  maybeLink(shl253, or257);
904  maybeLink(shrl255, or257);
905  maybeLink(or257, xor263);
906  maybeLink(shl258, or260);
907  maybeLink(or260, xor264);
908  maybeLink(const261, load262, Operands::BINARY_RHS);
909  maybeLink(load262, xor263);
910  maybeLink(xor263, xor264);
911  maybeLink(xor264, xor265);
912  maybeLink(xor265, xor266);
913  maybeLink(xor266, output267, Operands::BINARY_LHS);
914  maybeLink(xor266, shrl1, Operands::BINARY_LHS);
915  maybeLink(xor266, shrl76, Operands::BINARY_LHS);
916  maybeLink(xor266, shrl153, Operands::BINARY_LHS);
917  maybeLink(xor266, and230);
918  maybeLink(add268, add268);
919  maybeLink(input0, load61, Operands::BINARY_RHS);
920  maybeLink(const2, shrl1, Operands::BINARY_RHS);
921  maybeLink(const4, and3);
922  maybeLink(const6, mul5);
923  maybeLink(const9, shl8, Operands::BINARY_RHS);
924  maybeLink(const11, shrl10, Operands::BINARY_RHS);
925  maybeLink(const13, and12);
926  maybeLink(const15, mul14);
927  maybeLink(const18, shl17, Operands::BINARY_RHS);
928  maybeLink(const21, shrl20, Operands::BINARY_RHS);
929  maybeLink(const23, and22);
930  maybeLink(const25, mul24);
931  maybeLink(const28, shl27, Operands::BINARY_RHS);
932  maybeLink(const31, and30);
933  maybeLink(const33, mul32);
934  maybeLink(const37, shl36, Operands::BINARY_RHS);
935  maybeLink(const39, and38);
936  maybeLink(const41, shrl40, Operands::BINARY_RHS);
937  maybeLink(const43, and42);
938  maybeLink(const45, mul44);
939  maybeLink(const49, shl48, Operands::BINARY_RHS);
940  maybeLink(const51, shrl50, Operands::BINARY_RHS);
941  maybeLink(const54, shl53, Operands::BINARY_RHS);
942  maybeLink(const56, shrl55, Operands::BINARY_RHS);
943  maybeLink(const59, shl58, Operands::BINARY_RHS);
944  maybeLink(const68, shrl67, Operands::BINARY_RHS);
945  maybeLink(const70, and69);
946  maybeLink(const72, mul71);
947  maybeLink(const75, shl74, Operands::BINARY_RHS);
948  maybeLink(const77, shrl76, Operands::BINARY_RHS);
949  maybeLink(const79, and78);
950  maybeLink(const81, mul80);
951  maybeLink(const84, shl83, Operands::BINARY_RHS);
952  maybeLink(const87, shrl86, Operands::BINARY_RHS);
953  maybeLink(const89, and88);
954  maybeLink(const91, mul90);
955  maybeLink(const94, shl93, Operands::BINARY_RHS);
956  maybeLink(const97, and96);
957  maybeLink(const99, mul98);
958  maybeLink(const103, shl102, Operands::BINARY_RHS);
959  maybeLink(const105, and104);
960  maybeLink(const107, shrl106, Operands::BINARY_RHS);
961  maybeLink(const109, and108);
962  maybeLink(const111, mul110);
963  maybeLink(const115, shl114, Operands::BINARY_RHS);
964  maybeLink(const117, shrl116, Operands::BINARY_RHS);
965  maybeLink(const120, shl119, Operands::BINARY_RHS);
966  maybeLink(const122, shrl121, Operands::BINARY_RHS);
967  maybeLink(const125, shl124, Operands::BINARY_RHS);
968  maybeLink(const135, shrl134, Operands::BINARY_RHS);
969  maybeLink(const137, and136);
970  maybeLink(const139, mul138);
971  maybeLink(const142, shl141, Operands::BINARY_RHS);
972  maybeLink(const144, shrl143, Operands::BINARY_RHS);
973  maybeLink(const146, and145);
974  maybeLink(const148, mul147);
975  maybeLink(const151, shl150, Operands::BINARY_RHS);
976  maybeLink(const154, shrl153, Operands::BINARY_RHS);
977  maybeLink(const156, and155);
978  maybeLink(const158, mul157);
979  maybeLink(const161, shl160, Operands::BINARY_RHS);
980  maybeLink(const164, and163);
981  maybeLink(const166, mul165);
982  maybeLink(const170, shl169, Operands::BINARY_RHS);
983  maybeLink(const172, and171);
984  maybeLink(const174, shrl173, Operands::BINARY_RHS);
985  maybeLink(const176, and175);
986  maybeLink(const178, mul177);
987  maybeLink(const182, shl181, Operands::BINARY_RHS);
988  maybeLink(const184, shrl183, Operands::BINARY_RHS);
989  maybeLink(const187, shl186, Operands::BINARY_RHS);
990  maybeLink(const189, shrl188, Operands::BINARY_RHS);
991  maybeLink(const192, shl191, Operands::BINARY_RHS);
992  maybeLink(const202, shrl201, Operands::BINARY_RHS);
993  maybeLink(const204, and203);
994  maybeLink(const206, mul205);
995  maybeLink(const209, shl208, Operands::BINARY_RHS);
996  maybeLink(const211, shrl210, Operands::BINARY_RHS);
997  maybeLink(const213, and212);
998  maybeLink(const215, mul214);
999  maybeLink(const218, shl217, Operands::BINARY_RHS);
1000  maybeLink(const221, shrl220, Operands::BINARY_RHS);
1001  maybeLink(const223, and222);
1002  maybeLink(const225, mul224);
1003  maybeLink(const228, shl227, Operands::BINARY_RHS);
1004  maybeLink(const231, and230);
1005  maybeLink(const233, mul232);
1006  maybeLink(const237, shl236, Operands::BINARY_RHS);
1007  maybeLink(const239, and238);
1008  maybeLink(const241, shrl240, Operands::BINARY_RHS);
1009  maybeLink(const243, and242);
1010  maybeLink(const245, mul244);
1011  maybeLink(const249, shl248, Operands::BINARY_RHS);
1012  maybeLink(const251, shrl250, Operands::BINARY_RHS);
1013  maybeLink(const254, shl253, Operands::BINARY_RHS);
1014  maybeLink(const256, shrl255, Operands::BINARY_RHS);
1015  maybeLink(const259, shl258, Operands::BINARY_RHS);
1016  maybeLink(const269, add268);
1017 
1018  return finalFixup(std::move(opgraph));
1019 }
1020 
1022  OpGraph opgraph;
1023  const auto num_levels = options.getInt("num_levels");
1024  const auto op_fanout = options.getIntOr("op_fanout", 1);
1025  const auto num_trees = options.getIntOr("num_trees", 1);
1026  const auto level_xshift = options.getIntOr("level_xshift", 0);
1027  const auto tree_ovelap = options.getRealOr("tree_ovelap", 0);
1028  const auto opcode = OpCode::ADD;
1029  const auto opcode_arity = options.getIntOr("opcode_arity", 2);
1030 
1031  if (not( num_levels > 0)) { throw std::invalid_argument( "num_levels must be > 0 (it is " + std::to_string(num_levels) + ')'); }
1032  if (not( op_fanout > 0)) { throw std::invalid_argument( "op_fanout must be > 0 (it is " + std::to_string(op_fanout) + ')'); }
1033  if (not( num_trees > 0)) { throw std::invalid_argument( "num_trees must be > 0 (it is " + std::to_string(num_trees) + ')'); }
1034  if (not( level_xshift >= 0)) { throw std::invalid_argument( "level_xshift must be >= 0 (it is " + std::to_string(level_xshift) + ')'); }
1035  if (not( tree_ovelap >= 0)) { throw std::invalid_argument( "tree_ovelap must be >= 0 (it is " + std::to_string(tree_ovelap) + ')'); }
1036  if (not( tree_ovelap <= 1)) { throw std::invalid_argument( "tree_ovelap must be <= 1 (it is " + std::to_string(tree_ovelap) + ')'); }
1037 
1038  const auto tree_arity = opcode_arity + 1 - op_fanout;
1039 
1040  const auto level_size = [&](long long level) -> long long {
1041  const long long for_one_tree = std::lround(std::pow(tree_arity, level));
1042  const long long overlapping_for_one_tree = std::lround(tree_ovelap * for_one_tree);
1043  return for_one_tree + (num_trees - 1) * (for_one_tree - overlapping_for_one_tree);
1044  };
1045 
1046  std::vector<OpGraph::OpDescriptor> inputs;
1047  for (int i = 0; i < level_size(num_levels); ++i) {
1048  inputs.push_back(opgraph.insert(OpGraphOp(
1049  "input_" + std::to_string(i), 32, OpCode::INPUT
1050  )));
1051  }
1052 
1053  std::vector<OpGraph::OpDescriptor> current_row = inputs;
1054  std::vector<OpGraph::OpDescriptor> previous_row;
1055  for (int l = num_levels - 1; l != 0; ++l) {
1056  current_row.clear();
1057 
1058  for (long long i = 0; i != level_size(l); ++i) {
1059  current_row.emplace_back(opgraph.insert(OpGraphOp(
1060  "op_l" + std::to_string(l) + '_' + std::to_string(i), 32,
1061  opcode
1062  )));
1063  const auto& opdesc = current_row.back();
1064  for (int a = 0; a != opcode_arity; ++a) {
1065  opgraph.link(previous_row.at(( i*tree_arity + a ) % previous_row.size()), opdesc, Operands::BINARY_ANY);
1066  }
1067  }
1068 
1069  std::rotate(previous_row.begin(), std::next(previous_row.begin(), level_xshift), previous_row.end());
1070  std::swap(current_row, previous_row);
1071  }
1072 
1073  std::vector<OpGraph::OpDescriptor> outputs;
1074  for (int i = 0; i != num_trees; ++i) {
1075  outputs.push_back(opgraph.insert(
1076  previous_row.at(i % previous_row.size()),
1077  OpGraphOp("out" + std::to_string(i), 32, OpCode::OUTPUT),
1079  ).newOp);
1080  }
1081 
1082  return finalFixup(std::move(opgraph));
1083 }
1084 
1085 
1087  using std::to_string;
1088  using std::make_tuple;
1089  OpGraph opgraph;
1090  const auto w = options.getInt("width");
1091  const auto h = options.getInt("height");
1092  const auto Nc = options.getInt("num_contexts");
1093  const auto num_consts_in_pe = options.getIntOr("num_consts_in_pe", 0);
1094  const auto self_loop_via_regfile = options.getBoolOr("self_loop_via_regfile", false);
1095 
1096  std::map<std::tuple<int,int,int>, OpGraph::OpDescriptor> loc2op;
1097 
1098  const auto make_const_op = [&](int x, int y, int c, int i) {
1099  return opgraph.insert(OpGraphOp(
1100  "ct_c" + to_string(c) + "x" + to_string(x) + "y" + to_string(y) + "i" + to_string(i),
1101  32, OpCode::CONST, 1
1102  ));
1103  };
1104 
1105  for (int c = 0; c < Nc; ++c) {
1106  for (int x = 0; x < w; ++x) {
1107  for (int y = 0; y < h; ++y) {
1108  loc2op[make_tuple(c,x,y)] = opgraph.insert(OpGraphOp(
1109  "op_c" + to_string(c) + "x" + to_string(x) + "y" + to_string(y),
1110  32, OpCode::ADD
1111  ));
1112  }
1113  }
1114  }
1115 
1116  for (int c = 0; c < Nc; ++c) {
1117  for (int x = 0; x < w; ++x) {
1118  for (int y = 0; y < h; ++y) {
1119  const auto& op = loc2op.at(make_tuple(c,x,y));
1120  if (x == 0) {
1121  if ((c+x+y) % 2 == 0 && self_loop_via_regfile) {
1122  opgraph.link(loc2op.at(make_tuple(c,x,y)), op, Operands::BINARY_ANY); // self loop
1123  } else if (num_consts_in_pe > 1) {
1124  opgraph.link(make_const_op(x,y,c,1), op, Operands::BINARY_ANY);
1125  }
1126  } else {
1127  opgraph.link(loc2op.at(make_tuple(c,x-1,y)), op, Operands::BINARY_ANY);
1128  }
1129 
1130  if (y % 2 == 0) {
1131  if (c == 0) {
1132  if ((c+x+y) % 2 == 1 && self_loop_via_regfile) {
1133  opgraph.link(loc2op.at(make_tuple(c,x,y)), op, Operands::BINARY_ANY); // self loop
1134  } else if (num_consts_in_pe > 0) {
1135  opgraph.link(make_const_op(x,y,c,1), op, Operands::BINARY_ANY);
1136  }
1137  } else {
1138  opgraph.link(loc2op.at(make_tuple(c-1,x,y)), op, Operands::BINARY_ANY); // connection from prev context
1139  }
1140  } else {
1141  opgraph.link(loc2op.at(make_tuple(c,x,y-1)), op, Operands::BINARY_ANY); // note: y can't be 0 in this branch
1142  }
1143  }
1144  }
1145  }
1146 
1147  return finalFixup(std::move(opgraph));
1148 }
makeDFG_Loop2Node
OpGraph makeDFG_Loop2Node()
Definition: OpGraphsForTesting.cpp:92
makeDFG_SelfLoop1Node
OpGraph makeDFG_SelfLoop1Node()
Definition: OpGraphsForTesting.cpp:60
OperandTag
std::string OperandTag
Definition: OpGraph.h:81
verifyAndPrintReport
bool verifyAndPrintReport(const MRRG &mrrg, std::ostream &os, bool silent_on_no_errors, bool throw_if_errors, const ConfigStore &extra_opts)
Definition: MRRG.cpp:473
makeDFG_Loop3Node
OpGraph makeDFG_Loop3Node()
Definition: OpGraphsForTesting.cpp:103
OpCode::CONST
@ CONST
ConfigStore::getBoolOr
bool getBoolOr(const std::string &key, bool otherwise) const
Definition: ConfigStore.h:201
makeDFG_SelfLoop1NodeWith1ExtraFanout
OpGraph makeDFG_SelfLoop1NodeWith1ExtraFanout()
Definition: OpGraphsForTesting.cpp:70
Operands::BINARY_LHS
static constexpr auto & BINARY_LHS
Definition: OpGraph.h:89
makeDFG_MultiInputReconverging2121
OpGraph makeDFG_MultiInputReconverging2121()
Definition: OpGraphsForTesting.cpp:188
OpCode::OR
@ OR
makeDFG_Converging121
OpGraph makeDFG_Converging121()
Definition: OpGraphsForTesting.cpp:151
ConfigStore::getRealOr
double getRealOr(const std::string &key, double otherwise) const
Definition: ConfigStore.h:196
OpCode::STORE
@ STORE
ConfigStore
Definition: ConfigStore.h:76
OpCode::ADD
@ ADD
parseBinaryOperandOption
BinaryOperandTags parseBinaryOperandOption(const std::string &option)
Definition: OpGraphsForTesting.cpp:16
BinaryOperandTags
Definition: OpGraphsForTesting.cpp:12
makeDFG_Small
OpGraph makeDFG_Small(ConfigStore options)
Definition: OpGraphsForTesting.cpp:268
Operands::UNTAGGED
static constexpr auto & UNTAGGED
Definition: OpGraph.h:87
BinaryOperandTags::rhs
OperandTag rhs
Definition: OpGraphsForTesting.cpp:13
to_string
const std::string & to_string(const OpGraphOpCode &opcode)
Definition: OpGraph.cpp:111
ConfigStore::getStringOr
const std::string & getStringOr(const std::string &key, const std::string &otherwise) const
Definition: ConfigStore.h:181
OpCode::LOAD
@ LOAD
OpCode::LSHR
@ LSHR
makeDFG_SelfLoop3Node
OpGraph makeDFG_SelfLoop3Node()
Definition: OpGraphsForTesting.cpp:80
makeDFG_Linear3Node
OpGraph makeDFG_Linear3Node()
Definition: OpGraphsForTesting.cpp:50
makeDFG_DeviceFiller
OpGraph makeDFG_DeviceFiller(const ConfigStore &options)
Definition: OpGraphsForTesting.cpp:1086
OpCode::XOR
@ XOR
Operands::BINARY_RHS
static constexpr auto & BINARY_RHS
Definition: OpGraph.h:90
OpCode::INPUT
@ INPUT
OpGraph::link
ValDescriptor link(OpDescriptor driver, OpDescriptor fanout, std::string operand_group, int bitwidth=32, int dist=0, EdgeKind kind=EdgeKind::kDataFlow, bool predicate=false)
Definition: OpGraph.cpp:364
makeDFG_TriangeWithAntiparellelDoubledBottomEdge
OpGraph makeDFG_TriangeWithAntiparellelDoubledBottomEdge()
Definition: OpGraphsForTesting.cpp:222
makeDFG_Tree
OpGraph makeDFG_Tree(const ConfigStore &options)
Definition: OpGraphsForTesting.cpp:1021
OpGraphsForTesting.hpp
makeDFG_MultiEdge11
OpGraph makeDFG_MultiEdge11(ConfigStore options)
Definition: OpGraphsForTesting.cpp:203
makeDFG_Huge
OpGraph makeDFG_Huge(const std::vector< int > &allowed_ids, ConfigStore options)
Definition: OpGraphsForTesting.cpp:408
OpCode::SHL
@ SHL
makeDFG_Larger
OpGraph makeDFG_Larger()
Definition: OpGraphsForTesting.cpp:335
finalFixup
OpGraph finalFixup(OpGraph opgraph)
Definition: OpGraphsForTesting.cpp:5
makeDFG_Linear2Node
OpGraph makeDFG_Linear2Node(ConfigStore options)
a--> b
Definition: OpGraphsForTesting.cpp:34
ConfigStore::getIntOr
long long getIntOr(const std::string &key, long long otherwise) const
Definition: ConfigStore.h:191
OpGraphOp
Definition: OpGraph.h:131
makeDFG_Tree12
OpGraph makeDFG_Tree12()
Definition: OpGraphsForTesting.cpp:128
makeDFG_Tree112
OpGraph makeDFG_Tree112()
Definition: OpGraphsForTesting.cpp:139
OpCode::OUTPUT
@ OUTPUT
makeDFG_2NodeLoop4Node
OpGraph makeDFG_2NodeLoop4Node()
Definition: OpGraphsForTesting.cpp:115
makeDFG_Converging21
OpGraph makeDFG_Converging21(ConfigStore options)
Definition: OpGraphsForTesting.cpp:163
OpCode::AND
@ AND
OpGraph::insert
OpDescriptor insert(OpGraphOp op)
Definition: OpGraph.cpp:338
OpCode::MUL
@ MUL
makeDFG_MultiInputReconverging3x2Grid
OpGraph makeDFG_MultiInputReconverging3x2Grid()
Definition: OpGraphsForTesting.cpp:234
opcode_from_string
OpGraphOpCode opcode_from_string(const std::string &str)
Definition: OpGraph.cpp:113
Operands::BINARY_ANY
static constexpr auto & BINARY_ANY
Definition: OpGraph.h:91
makeDFG_CrossbarWithBranchComp
OpGraph makeDFG_CrossbarWithBranchComp()
Definition: OpGraphsForTesting.cpp:251
ConfigStore::getInt
long long getInt(const std::string &key) const
Definition: ConfigStore.h:146
OpGraph
Definition: OpGraph.h:215
makeDFG_Large
OpGraph makeDFG_Large(bool require_non_NN_FUs)
Definition: OpGraphsForTesting.cpp:288
makeDFG_Parallel11_11
OpGraph makeDFG_Parallel11_11()
Definition: OpGraphsForTesting.cpp:176
OpGraphNode::getName
const std::string & getName() const
Definition: OpGraph.h:121
BinaryOperandTags::lhs
OperandTag lhs
Definition: OpGraphsForTesting.cpp:13