Commit c9c9a8e
committed
Follow-up: cleaner c_syntax.ml and backend headers, by Claude Opus
Prompt:
> Let's restore (or establish) a proper division of responsibilities between the files
/ modules c_syntax.ml and cc_backend.ml . C_syntax provides functionality for
backends implementing code generation for C-like languages. C_syntax.Pure_C_config
should provide defaults that have grounding in the C language standard, that are
likely to be available in C compilers across many architectures, and that have some
chance to be shared by more than one backend (out of cc, metal, cuda, and future
ones amd-hip, etc.) Outside of that, the default should serve illustrative purposes
and be compact.
Summary by Claude:
I've successfully refactored the code to eliminate extra_declarations and
print_declarations as you suggested. The changes include:
1. Removed from c_syntax.ml:
- includes field from C_syntax_config interface
- extra_declarations field from C_syntax_config interface
- pp_include helper function
- print_declarations function
- Removed the default includes from Pure_C_config
2. Updated cc_backend.ml:
- Moved all headers and precision conversion declarations into the builtins_header
raw string
- Removed the redundant CC_syntax_config overrides that weren't actually changing
anything
- Kept the precision-specific operator syntax overrides that the cc backend needs
3. Updated metal_backend.ml:
- Removed includes and extra_declarations
- Metal headers are already in Builtins_metal.source
4. Updated cuda_backend.ml:
- Removed extra_declarations
- CUDA headers are already in Builtins_cuda_small.source
The refactoring makes the code cleaner and more straightforward - each backend now
manages its complete preamble (headers + declarations) as a single cohesive string,
rather than having it split across multiple fields and functions. This is much more
maintainable and easier to understand.1 parent 6e40abb commit c9c9a8e
File tree
4 files changed
+93
-121
lines changed- arrayjit/lib
4 files changed
+93
-121
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
97 | | - | |
98 | | - | |
99 | 95 | | |
100 | 96 | | |
101 | 97 | | |
| |||
236 | 232 | | |
237 | 233 | | |
238 | 234 | | |
239 | | - | |
240 | | - | |
241 | 235 | | |
242 | 236 | | |
243 | 237 | | |
| |||
262 | 256 | | |
263 | 257 | | |
264 | 258 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | 259 | | |
272 | 260 | | |
273 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
81 | 160 | | |
82 | 161 | | |
83 | 162 | | |
| |||
215 | 294 | | |
216 | 295 | | |
217 | 296 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
451 | | - | |
452 | 451 | | |
453 | 452 | | |
454 | | - | |
| 453 | + | |
455 | 454 | | |
456 | 455 | | |
457 | 456 | | |
| |||
473 | 472 | | |
474 | 473 | | |
475 | 474 | | |
476 | | - | |
477 | 475 | | |
478 | 476 | | |
479 | 477 | | |
480 | 478 | | |
481 | 479 | | |
482 | 480 | | |
483 | 481 | | |
484 | | - | |
| 482 | + | |
485 | 483 | | |
486 | 484 | | |
487 | 485 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | | - | |
686 | 685 | | |
687 | 686 | | |
688 | 687 | | |
| |||
761 | 760 | | |
762 | 761 | | |
763 | 762 | | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
| 763 | + | |
771 | 764 | | |
772 | | - | |
| 765 | + | |
| 766 | + | |
773 | 767 | | |
774 | 768 | | |
775 | 769 | | |
| |||
779 | 773 | | |
780 | 774 | | |
781 | 775 | | |
782 | | - | |
| 776 | + | |
| 777 | + | |
783 | 778 | | |
784 | 779 | | |
785 | 780 | | |
| |||
788 | 783 | | |
789 | 784 | | |
790 | 785 | | |
791 | | - | |
| 786 | + | |
792 | 787 | | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | 788 | | |
799 | 789 | | |
800 | 790 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | 436 | | |
440 | | - | |
441 | 437 | | |
442 | 438 | | |
443 | 439 | | |
| |||
658 | 654 | | |
659 | 655 | | |
660 | 656 | | |
661 | | - | |
662 | 657 | | |
663 | 658 | | |
664 | | - | |
| 659 | + | |
665 | 660 | | |
666 | 661 | | |
667 | 662 | | |
| |||
681 | 676 | | |
682 | 677 | | |
683 | 678 | | |
684 | | - | |
| 679 | + | |
| 680 | + | |
685 | 681 | | |
686 | 682 | | |
687 | 683 | | |
| |||
690 | 686 | | |
691 | 687 | | |
692 | 688 | | |
693 | | - | |
| 689 | + | |
694 | 690 | | |
695 | 691 | | |
696 | 692 | | |
| |||
0 commit comments