wuica-cli 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@ experimental models of the fork [jtl06/uiCA](https://github.com/jtl06/uiCA): **A
17
17
  Everything runs offline. The two WebAssembly modules (the analyzer, and LLVM's x86 assembler for assembly input) and the
18
18
  instruction tables are shipped brotli-compressed. A table is loaded the first time its microarchitecture is used.
19
19
  Requirements: Node.js 20 or later. **No dependencies**: `npm install wuica-cli` (or `npx wuica-cli`) adds this one
20
- package, 2.3 MB unpacked; the MCP server is part of it.
20
+ package, 2.4 MB unpacked; the MCP server is part of it.
21
21
 
22
22
  The commands are `wuica` and `wuica-mcp`. Install them with `npm install -g wuica-cli`, or run without installing
23
23
  with `npx wuica-cli ...`. The examples below write `wuica`.
@@ -32,11 +32,17 @@ wuica dot.s -arch SKL,ZEN3,ADL-P # one table for several CPUs ("al
32
32
  wuica dot.s -per 8 # the loop does 8 elements per iteration: cycles per element too
33
33
  wuica dot.s -loops # the loops in the file; -loop N or -loop .LBB0_12 picks one
34
34
  wuica dot.s -whatif # unrolled, N accumulators, front end and fusion variants
35
+ wuica dot.s -arch SKL,ZEN3 -md # Markdown to paste in an issue or a chat (any mode)
36
+ wuica diff dot.s dot4.s -per 8,32 # before and after: speed-up, bottlenecks, ports, instructions changed
35
37
  clang -O3 -c dot.c && wuica dot.o -func dot # an object file (ELF or Mach-O, x86-64): no objdump needed
36
38
  wuica *.s -arch SKL,ZEN3 # several files in one run: one table (-files LIST for long lists)
37
39
  objdump -d dot.o | wuica # objdump output: the loop's real alignment from its address
40
+ perf annotate --stdio -s dot | wuica # a profile: the hottest loop, samples and source lines per instruction
38
41
  ```
39
42
 
43
+ On an Arm Mac, give clang `--target=x86_64-linux-gnu` (wuica analyzes x86-64 code; Apple's clang knows no
44
+ `-march=haswell` for arm64).
45
+
40
46
  - **Syntax.** Intel (noprefix) or AT&T is detected from the text (`%rdx`, `$8`, `(%rdi,%rcx,4)` are AT&T);
41
47
  stderr says which (`analyzed: loop .LBB0_9 (lines 28-47, in dot), AT&T syntax (detected)`). `-att` or `-intel`
42
48
  force one.
@@ -80,6 +86,12 @@ objdump -d dot.o | wuica # objdump output: the loop's real
80
86
  - **What if** (`-whatif`): a table per CPU, in cycles per original iteration, or per element with `-per N`. With
81
87
  `-TPonly`, one `variant cycles` line per variant after the throughput (`acc2 16.00`; with `-per`, `acc2 16.00
82
88
  2.00`; with several CPUs, each line starts with the CPU). Estimates (`>=` in the table) are printed as plain numbers.
89
+ - **Markdown** (`-md`): GitHub-flavoured Markdown on stdout instead of the text report, for an issue, a review or a
90
+ chat: one CPU gives the headline (cycles per iteration, or per element with `-per N`; the CPU; the bottleneck or
91
+ `unknown · nearest X`), the limits, the next limit, the `not modelled` caveats, the critical chain, the uop table
92
+ (branch targets as the labels in the text) and the analyzed code; `-arch A,B,C` the CPU table; several files the
93
+ files × CPUs table (`-report`: each file's report); `-whatif` and `-loops` their tables. Columns are padded to read
94
+ in a monospace font. Not with `-json` or `-TPonly`; diagnostics and the exit status are as without it.
83
95
  - **JSON** (`-json`): one CPU gives the analyze response (`tp`, `bottlenecks`, `limits`, `rows`, `criticalPath`,
84
96
  `insights`, `loop`, `syntax`, and `perElement` / `whatIf` when asked); several give `{code, hex, loop, stderr,
85
97
  results: [{arch, tp, bottlenecks, limits, decodeErrors, perElement?, caveats?}]}`. The shapes are the same for one
@@ -90,7 +102,7 @@ objdump -d dot.o | wuica # objdump output: the loop's real
90
102
  {repository, commit, branch}, node}`: the uiCA commit whose data and model the package has.
91
103
  - **Syntax mistakes.** When the assembler fails, a `hint:` line names a line with the other syntax's operands (mixed
92
104
  AT&T and Intel lines, a `.intel_syntax` directive over AT&T code, `mov rdx, $8` in Intel code) and the flag to try.
93
- - No colours and no links, on a terminal or not.
105
+ - No colours and no links, on a terminal or not (`-md` is plain text too).
94
106
 
95
107
  ## What the numbers mean
96
108
 
@@ -107,7 +119,7 @@ Decoder or DSB. `limits` gives the throughput each component alone would allow.
107
119
  ## Library
108
120
 
109
121
  ```js
110
- import { createWuica } from 'wuica-cli';
122
+ import { createWuica, markdown } from 'wuica-cli';
111
123
 
112
124
  const w = await createWuica();
113
125
  const r = await w.analyze('SKL', { source: 'loop:\n add rax, [rsi]\n add rsi, 8\n dec rcx\n jnz loop\n' });
@@ -126,11 +138,13 @@ w.archs(); // [{id, name, year, p
126
138
  await w.assemble('vaddps zmm0, zmm1, zmm2'); // {code: 0, hex, length, bytes, stderr}
127
139
  w.summarize(r); // compact form (the MCP analyze result)
128
140
  w.insights(r); // the diagnosis alone (REST's insights)
141
+ markdown.report(r, { insights: w.insights(r) }); // Markdown, as wuica -md (also cpuTable, whatIf, loops, compare)
129
142
  ```
130
143
 
131
144
  Methods never throw for bad input: they resolve to a failure `{code, error, stderr}` (see the contract below).
132
- `createWuica({ dataDir })` reads the tables from another directory (`uarch.json` and `arch/<NAME>.json` or the binary
133
- `arch/<NAME>.bin`, plain or `.br`). `w.disassemble(bytes)` turns an object file into the text `analyze` reads. TypeScript declarations are included (`index.d.ts`).
145
+ `createWuica({ dataDir })` reads the tables from another directory (`uarch.json` and the binary `arch/<NAME>.bin`,
146
+ plain or `.br`; a uiCA export's `arch/<NAME>.json` is converted by `tools/encode-tables.sh IN_DIR OUT_DIR` of the
147
+ repository: the analyzer that ships reads no JSON tables). `w.disassemble(bytes)` turns an object file into the text `analyze` reads. TypeScript declarations are included (`index.d.ts`).
134
148
 
135
149
  `compare`, `analyzeMany(arch, requests)` and `compareMany(requests, {archs})` analyze on worker threads when the work
136
150
  is worth it: by default the number of threads comes from the work (the tables to load, the analyses and their
@@ -153,16 +167,18 @@ wuica loop.s # assembly file (syntax detected), uiCA's r
153
167
  wuica loop.s -arch ICL -TPonly # only the throughput
154
168
  cat loop.s | wuica -arch ZEN3 # stdin (or "-")
155
169
  wuica -att loop_att.s # AT&T syntax, forced (-intel forces Intel)
156
- wuica 4801d84801c349ffcf75f5 # a hex argument (as in the Rust CLI)
170
+ wuica 4801d84801c349ffcf75f5 # a hex argument (as in the repository's reference binary)
157
171
  wuica -hex code.txt # hex from a file or stdin ("48 01 d8", "0x48,0x01" are fine)
158
172
  wuica -raw code.bin # raw machine code
159
173
  wuica loop.s -arch all # throughput table for every microarchitecture (in parallel)
160
174
  wuica loop.s -arch SKL,ICL,ZEN3 # throughput table for these
161
175
  wuica -list # the microarchitectures
162
176
  wuica loop.s -json # the JSON result (the contract's analyze response)
177
+ wuica loop.s -arch SKL,ZEN3 -md # Markdown (an issue, a review, a chat); with -whatif, -loops, several files
163
178
  wuica psum.s -loop whole # the whole text, not the loop found in it (-loop auto, the default, or -loop N)
164
179
  wuica psum.s -loops # list the loops; -loop .LBB0_12 or -func psum to choose
165
180
  wuica psum.s -whatif -per 8 # what-if variants; cycles per element (8 elements per iteration)
181
+ wuica psum.s -variants align,acc4 # these variants only; align: the 64 alignment offsets (min, median, max)
166
182
  wuica dot.o -func dot # an object file (ELF or Mach-O x86-64); -funcs lists its functions
167
183
  wuica a.s b.s c.o -arch SKL,ZEN3 # several inputs: one table, a row per file and CPU
168
184
  wuica -files list.txt -TPonly # the names from a file (- for stdin): file<TAB>cycles lines
@@ -170,6 +186,7 @@ wuica *.s -json # {code, files: [{file, ...}]}, each entry
170
186
  wuica -examples # the built-in examples (the web page's set)
171
187
  wuica -example dot1 -whatif # one of them, as if it were the input file (every option applies)
172
188
  wuica -example dot1 -show > dot.s # its assembly, to save and edit
189
+ wuica diff a.s b.s -per 8 [-md|-json] # two blocks (files, - or hex): before and after
173
190
  wuica --version
174
191
  ```
175
192
 
@@ -190,13 +207,15 @@ newline-delimited JSON-RPC 2.0 with the `initialize` handshake of the protocol r
190
207
  (`isError`) that says what is wrong, an unknown tool a JSON-RPC error. The server ends with its stdin, and writes only
191
208
  protocol messages to stdout. `wuica mcp --help` prints the usage. The tool table itself (names, descriptions, JSON
192
209
  Schemas, handlers) is exported as `mcpTools(w)` from `wuica-cli/mcp`, with `callTool` and `validate`; the remote server
193
- (`server/`) serves the same table over HTTP. It has five tools:
210
+ (`server/`) serves the same table over HTTP. Its tools:
194
211
 
195
212
  | Tool | What it does |
196
213
  |---|---|
197
214
  | `analyze` | one block on one microarchitecture: `tp`, bottlenecks, limits, a compact per-instruction table (ports, uop sources, fusion notes) and uiCA's text report (`format`: `json`, `text`, `both`) |
198
- | `what_if` | one block re-analyzed with one change each (the web page's "try" row): `unroll2`/`unroll4`/`unroll8` (per original iteration), `acc2`/`acc3`/`acc4`/`acc8` (N accumulators: unrolled ×N with the loop-carried register renamed in each copy; `renamed` lists the registers, `accumulators.best` is the best N, 1 = as it is), `simpleFrontEnd`, `noMacroFusion`, `noMicroFusion`, and `nochain` (an estimate without the loop-carried chain); per variant `tp`, `delta`, `speedup` |
215
+ | `what_if` | one block re-analyzed with one change each (the web page's "try" row): `unroll2`/`unroll4`/`unroll8` (per original iteration), `acc2`/`acc3`/`acc4`/`acc8` (N accumulators: unrolled ×N with the loop-carried register renamed in each copy; `renamed` lists the registers, `accumulators.best` is the best N, 1 = as it is), `simpleFrontEnd`, `noMacroFusion`, `noMicroFusion`, `nochain` (an estimate without the loop-carried chain), and `align` when asked for (the 64 alignment offsets); per variant `tp`, `delta`, `speedup` (and `approx: {limit, shown}` when the simulation came out up to 1% under the variant's Ports or Issue limit: the text shows that limit, ≈) |
216
+ | `diff_blocks` | two blocks, A (before) and B (after), on one microarchitecture: `tp` of each, `delta`, `speedup`, per element with `per`, bottlenecks and limits before and after, each port's uops, the instructions changed, added or removed |
199
217
  | `compare_archs` | one block on several or all microarchitectures: `tp` and bottlenecks per microarchitecture |
218
+ | `list_loops` | the loops of assembly text (what `loop` can pick): index, label, function, lines, instructions, depth, the one picked by default |
200
219
  | `list_archs` | ids, names, years, prototype flags |
201
220
  | `assemble` | assembly → hex bytes, or diagnostics with line/column |
202
221
 
@@ -313,9 +332,11 @@ text, and errors with structured stderr.
313
332
  | REST | Library | MCP tool |
314
333
  |---|---|---|
315
334
  | `GET /api/archs[?fields=id,name]` | `w.archs(fields?)` | `list_archs {fields?}` |
335
+ | — | `listLoops(source, {func?})` | `list_loops {source, func?}` |
316
336
  | `POST /api/analyze/<arch>` | `w.analyze(arch, request)` | `analyze {arch, ...request, format?}` |
317
- | `POST /api/compare` | `w.compare(request)` | `compare_archs {...request}` |
318
- | — | `whatIf((a, r) => w.analyze(a, r), arch, request, variants?, {assemble: (t) => w.assemble(t)})` | `what_if {arch, ...request, variants?}` |
337
+ | `POST /api/compare` | `w.compare({...request, archs?, per?})` | `compare_archs {...request, archs?, per?}` |
338
+ | `POST /api/what-if/<arch>` | `w.whatIf(arch, {...request, variants?, per?})` | `what_if {arch, ...request, variants?, per?}` |
339
+ | `POST /api/diff/<arch>` | `w.diff(arch, {a, b, options?, per?})` | `diff_blocks {arch, a, b, options?, per?}` |
319
340
  | `POST /api/assemble` | `w.assemble(source, syntax)` | `assemble {source, syntax?}` |
320
341
 
321
342
  ### Microarchitectures: `GET /api/archs`
@@ -336,7 +357,6 @@ Request:
336
357
  ```json
337
358
  {
338
359
  "source": "loop: add rax, rbx\n dec rcx\n jnz loop",
339
- "hex": "4801d8...",
340
360
  "syntax": "intel",
341
361
  "options": {
342
362
  "alignmentOffset": 0, "initPolicy": "diff", "simpleFrontEnd": false, "noMicroFusion": false,
@@ -345,8 +365,8 @@ Request:
345
365
  }
346
366
  ```
347
367
 
348
- - Give exactly one of `source` (assembly; the library also accepts `asm`) and `hex` (machine code; spaces, commas and
349
- `0x` are allowed).
368
+ - Give exactly one of `source` (assembly; the library also accepts `asm`) and `hex` (machine code, `"4801d8..."`;
369
+ spaces, commas and `0x` are allowed).
350
370
  - `source` is read as the web page reads pasted assembly. `loop` (optional) says what of it is analyzed:
351
371
  - `"auto"` (the default): a whole function (`gcc -S`, `clang -S`, `objdump -d` lines with addresses, with or
352
372
  without the bytes, Intel or AT&T) is analyzed at its deepest loop (clang's `Inner Loop Header` notes count;
@@ -389,23 +409,39 @@ Request:
389
409
  (`{hex, arch, minIterations}`); `options` takes precedence. The MCP tools accept only the nested form.
390
410
  - The source must be 64-bit code: `.code16`, `.code16gcc` and `.code32` are an error (code 1), since the analyzer
391
411
  only models 64-bit mode. `assemble` alone accepts them.
392
- - `loop` exists in the library, REST (`/api/analyze`, `/api/compare`), the MCP tools `analyze`, `what_if` and
393
- `compare_archs`, and the package's CLI (`wuica -loop auto|whole|N`). The native CLI (`crates/wuica-cli`) reads
394
- machine code only (hex or `-raw`), so it has no `-loop`.
412
+ - `loop` exists in the library, REST (`/api/analyze`, `/api/compare`, `/api/what-if`, each block of `/api/diff`), the MCP
413
+ tools `analyze`, `what_if`, `compare_archs` and `diff_blocks` (per block), and the package's CLI (`wuica -loop
414
+ auto|whole|N`, also for `wuica diff`). The reference/test binary (`crates/wuica-cli`) reads
415
+ machine code only (hex or `-raw`), so it has no `-loop`. When the text has more than one loop, `otherLoops` lists the others (as `listLoops`
416
+ and `-loops` give them, without `auto`), in the analyze, summary and compare results.
417
+ - Assembly input: each instruction row (and `instructions[]`, `insights.chain[]`, `insights.hot.instructions[]`) has
418
+ `line`, its 1-based line in the text, and `loc` ("file.c:12") when the text has `.file`/`.loc` directives: what the
419
+ loop finder and the assembler record, not a match of the text. Machine code has neither.
420
+ - Profiles are read as they are: `objdump -dS` (or `-S`) output gives each instruction `source`, the interleaved source
421
+ line in force; `perf annotate --stdio` output gives `samples` (its percent of all the samples of the output: each
422
+ symbol's percentages weighted by its sample count; if a header has no count, each symbol's own percentages, said in a
423
+ note) and `source`, and when the text has several loops, the one whose
424
+ own instructions (not those of a loop nested in it) have the most samples is analyzed (`loop` still picks another).
425
+ `perf annotate --stdio2` output has no addresses: it is refused with a note to use `--stdio`. A text with `.rept`,
426
+ `.irp`, `.irpc`, `.macro` or `.if` has no `line` (its lines are not its instructions one to one) and is analyzed whole,
427
+ with a note; nor has code with a data directive (`.byte`, `.fill`, ...) among the analyzed instructions. A prefix alone
428
+ on its line (`lock`, then `add [rdi], eax`) is part of the next instruction.
395
429
 
396
430
  ### Option ranges per interface
397
431
 
398
- All interfaces run the same analyzer, but they accept different ranges for the numeric options. A value outside the
399
- range is refused (code 1, REST 400; the MCP tools' schema rejects it as invalid arguments), except in the web page,
400
- which clamps it into its range.
432
+ The numeric options have the same range in the library, the CLI, the MCP tools and the REST API: any integer up to
433
+ 2^53 - 1 in magnitude (`alignmentOffset`: negative values and values above 63 are read modulo 64; the reference
434
+ binary `crates/wuica-cli` refuses beyond ±2^62). Another value is refused (code 1, REST 400; the MCP tools' schema rejects
435
+ it).
436
+ Everywhere, a block of more than 250,000 uops per iteration is refused (a work budget, code 3), and very large values run
437
+ out of memory (code 3). The differences:
401
438
 
402
- | Interface | `alignmentOffset` | `minIterations` | `minCycles` | Other limits |
403
- |---|---|---|---|---|
404
- | library, `wuica` CLI, native CLI (`crates/wuica-cli`) | any integer (negative values and values above 63 are simulated as given) | any integer | any integer | none; very large values run out of memory (library: code 3) |
405
- | MCP tools of `wuica mcp` (stdio) | 0–63 | 1–100000 | 1–1000000 | |
406
- | REST API (`server/`) | any integer | at most 1000 | at most 20000 | `source` at most 64 KB, `hex` at most 65536 characters, at most 10,000 instructions |
407
- | remote MCP (`server/`, `/mcp`) | 0–63 | 1–1000 | 1–20000 | as REST |
408
- | web page | 0–63 | 1–10000 | 1–100000 | at most 1 MiB of machine code (assembled or as hex) |
439
+ | Interface | Limits |
440
+ |---|---|
441
+ | REST API and remote MCP (`server/`) | `minIterations` at most 1000, `minCycles` at most 20000; `source` at most 64 KB, `hex` at most 65536 characters, at most 10,000 instructions |
442
+ | MCP tools (stdio and remote) | `minIterations` 1–100000, `minCycles` 1–1000000 (an agent should not start a 3 GB simulation by accident) |
443
+ | API server, its rate limit | per client, a token bucket (`rateBurst`, `ratePerMinute`); a request costs in proportion to the analyses it can start, as many as a compare of every microarchitecture costing `compareCost` (3): analyze 1 token, what-if `ceil(3 × analyses / 15)` with the base and one analysis per variant (`nochain` none, `align` 64): 3 for the default variants, 13 for `align` alone, 15 for both; diff 1; a compare `compareCost` whatever it lists, and at least one token per job it can run at once (a compare split over idle workers); at least 1 per request, at most the burst; the same in REST and `/mcp`. What-if and diff run all their analyses within one job's time limit and start none once the client has gone: a what-if returns the variants that finished and marks the others `not run: deadline` (`notRun` on the result); a diff fails and says which block was analyzed |
444
+ | web page | clamps `alignmentOffset` to 0–63, `minIterations` to 1–10000, `minCycles` to 1–100000; at most 1 MiB of machine code |
409
445
 
410
446
  Microarchitecture ids are accepted the same way everywhere: exactly, or case-insensitively with `-` optional (`adlp`,
411
447
  `adl-p` → `ADL-P`). Hex may contain spaces, commas and `0x` / `\x` prefixes everywhere.
@@ -432,11 +468,20 @@ Response (JSON), on success:
432
468
  The fields from `arch` to `trace` are the analysis response of the WebAssembly module (`docs/WASM-API.md` in the wuica
433
469
  repository: `rows[].values[i]` belongs to `columns[i]`, and `notes` is `M` macro-fused, `J` JCC erratum or `X`
434
470
  unsupported). `hex` is present when `source` was given and holds the assembled bytes. `stderr` holds the assembler's
435
- warnings, the notes on exits taken as not taken, and the warning "N position(s) could not be decoded". `insights` (REST only; the library's `analyze()` result
471
+ warnings, the notes on exits taken as not taken, and the warning "N position(s) could not be decoded". `unsupported` is
472
+ present only when the CPU cannot run the code: positions its decoder skipped (AVX-512 on SKL), or an instruction of an
473
+ extension it lacks that its decoder accepts (AVX-512 on ZEN3, by the instruction's encoding). It holds the reason:
474
+ `"needs AVX-512"` when the extension is known (from the instruction, or from the analyzed assembly text without its
475
+ comments), else `"12 undecodable"`; `tp` is then the reference's number, which leaves that code out, and the text, the
476
+ Markdown and the page do not present it as a result. `noData` is present only when the CPU can run the code but some of
477
+ its instructions are not in its tables (the note X: x87 tbyte loads, syscall, CLWB on ICX): their count; the result
478
+ stands, without their cost. compare's rows have both. `insights` (REST only; the library's `analyze()` result
436
479
  does not have it, `w.insights(r)` computes it) is the diagnosis described under the compact form below, with `portSet`
437
480
  and `issueSlots` when `options.details` is true.
438
481
 
439
482
  **Plain text** (CE's `Accept: text/plain`): the response is `text` (uiCA's report), or the `stderr` lines on failure.
483
+
484
+ **Markdown** (`Accept: text/markdown`, analyze, compare, what-if and diff): what `wuica -md` prints (`markdown.report`, `markdown.cpuTable`), with the same status codes.
440
485
  In the library this is `r.text`; the MCP tool takes `format: "text"`.
441
486
 
442
487
  **Compact form** (the MCP `analyze` JSON, `w.summarize(r)`): `{code, arch, name, year, prototype, tp, unit, mode,
@@ -489,7 +534,7 @@ Every call can fail like a compiler run in Compiler Explorer, with a non-zero `c
489
534
 
490
535
  ### Compare: `POST /api/compare`
491
536
 
492
- The request is the same as for analyze, plus an optional `archs` (ids; missing or empty: all listed ones; a repeated id counts once). The response:
537
+ The request is the same as for analyze, plus an optional `archs` (ids; missing or empty: all listed ones; a repeated id counts once) and `per` (elements per iteration: `elementsPerIteration` and each row's `perElement`, as `wuica -arch A,B -per N`). The response:
493
538
 
494
539
  ```json
495
540
  {
@@ -505,13 +550,33 @@ The request is the same as for analyze, plus an optional `archs` (ids; missing o
505
550
  The top-level `code` is non-zero only if the request or the assembly fails. A failure on one microarchitecture is
506
551
  reported in its row.
507
552
 
553
+ ### What-if: `POST /api/what-if/<arch>`
554
+
555
+ The request is analyze's plus `variants` (ids, default all: `unroll2`, `unroll4`, `unroll8`, `acc2`, `acc3`, `acc4`,
556
+ `acc8`, `simpleFrontEnd`, `noMacroFusion`, `noMicroFusion`, `nochain`; also `align`, only when asked for: the block at
557
+ each of the 64 alignment offsets, 64 analyses, `tp` the median and `alignment` {min, median, max, best, worst, spread,
558
+ offset}) and `per` (elements per iteration: also cycles per element). The response is the MCP tool's and `wuica -whatif -json`'s (`WhatIfResult`): the base `tp` and per variant
559
+ `tp` per original iteration, `delta`, `speedup`, or `error`; `accumulators.best`. `text/plain` gives the CLI's table,
560
+ `text/markdown` the Markdown one. Each variant is one analysis (`nochain` none, `align` 64), and the request costs tokens
561
+ in proportion (the rate limit above).
562
+
563
+ ### Diff: `POST /api/diff/<arch>`
564
+
565
+ `{a: block, b: block, options?, per?}`: each block as analyze's request; `options` for both; `per` elements per iteration
566
+ (N for both, or [A, B]). The response (`DiffResult` in index.d.ts; `wuica diff -json`): `a` and `b` (`tp`,
567
+ `bottlenecks`, `perElement`), `delta`, `speedup`, `verdict`, `perElement`, `bottlenecks` (`gone`, `new`), `limits`,
568
+ `ports` (uops per iteration before and after) and `instructions` (`counts`; `changes`: `changed`, `modified`, `added`,
569
+ `removed`, with the change of their uops). A failure of one block has an `error` that starts with `A: ` or `B: `. `text/plain` gives the
570
+ CLI's text, `text/markdown` the page's A–B tables.
571
+
508
572
  ### Assemble: `POST /api/assemble`
509
573
 
510
574
  Request: `{"source": "...", "syntax": "intel"}`. The whole text is assembled as it is (no loop finding, no region
511
575
  markers; `;` comments as above). Response: `{"code": 0, "hex": "4801d8", "length": 3, "stderr": []}`;
512
576
  the library also returns `bytes` (a `Uint8Array`). On failure: `{code: 2, error, stderr}` as above. The assembler is
513
577
  LLVM 22.1.2's (the same bytes as `llvm-mc`). Only `.text` is returned. `.include`/`.incbin` always fail. GNU as's
514
- `{load}`/`{store}` hints, which LLVM rejects, are removed at the start of a line.
578
+ `{load}`/`{store}` hints, which LLVM rejects, are removed at the start of a line, clang 23's `.prefalign` is read as
579
+ `.p2align`, and the line table (`.loc`, numbered `.file`) is not assembled (gcc 11+ `-g` output assembles).
515
580
 
516
581
  ## Building from the repository
517
582
 
@@ -524,7 +589,8 @@ npm pack # wuica-cli-<version>.tgz
524
589
  `build.sh` uses `target/wasm32-unknown-unknown/release/wuica_wasm.wasm` (it runs `./build-wasm.sh` if the file is
525
590
  missing), `assembler/dist/wuica_asm.wasm` and `data/`. The instruction tables are shipped in a binary form
526
591
  (`dist/data/arch/<NAME>.bin.br`, written from `data/arch/*.json` by `tools/encode-tables.sh`; 6.4 MB instead of
527
- 14.6 MB, and loaded about 40% faster); `createWuica({ dataDir })` also reads JSON tables. `dist/manifest.json` records
592
+ 14.6 MB, and loaded about 40% faster); the analyzer module is built without the JSON table loader (the Cargo feature
593
+ `json-tables` of `crates/wuica`, which the native tools and tests use). `dist/manifest.json` records
528
594
  the size and SHA-256 of each
529
595
  uncompressed file.
530
596
 
Binary file
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "uiCA": {
3
3
  "repository": "https://github.com/jtl06/uiCA",
4
- "commit": "640e40e",
5
- "branch": "improve-r9"
4
+ "commit": "7301b04",
5
+ "branch": "improve-r10"
6
6
  },
7
7
  "tables": {
8
8
  "format": "WUICATBL 1",
@@ -10,16 +10,16 @@
10
10
  },
11
11
  "files": {
12
12
  "wuica_wasm.wasm": {
13
- "size": 3111653,
14
- "sha256": "1a004180a1c1a79a02b039a4737c9c457ceacf507d735c6955046b071f28e818"
13
+ "size": 3064326,
14
+ "sha256": "fe34e612cb5ec9ed7e8c409a63310e8fd4601b8fe95bc8bf23ff17ee3a377559"
15
15
  },
16
16
  "wuica_asm.wasm": {
17
17
  "size": 3802001,
18
18
  "sha256": "ee66811d0671cdea73176a3670f82816dcbb3cbb1fed13cd7dc2acbb69cb627d"
19
19
  },
20
20
  "data/uarch.json": {
21
- "size": 51318,
22
- "sha256": "f543714ba2927986671f1de045a6162296ce860c5d34a086cc4c72d6c828e7a1"
21
+ "size": 51885,
22
+ "sha256": "cce92ecddac13e6fa90902142a9e6cb03c4ef93d259039998488a31839426fd0"
23
23
  },
24
24
  "data/arch/ADL-P.bin": {
25
25
  "size": 819776,
Binary file
package/index.d.ts CHANGED
@@ -29,7 +29,9 @@ export type Syntax = 'auto' | 'intel' | 'att';
29
29
  export type LoopChoice = 'auto' | 'whole' | number | string;
30
30
  /** The named loop choices ('auto', 'whole'); a number is a loop's index (0-based), any other string its label. */
31
31
  export declare const LOOP_CHOICES: readonly ['auto', 'whole'];
32
- /** A loop of assembly text (listLoops; the CLI's -loops). */
32
+ /** A loop of the text that was not analyzed (analyze's `otherLoops`): listLoops' entry without `auto`. */
33
+ export type OtherLoop = Omit<LoopListing, 'auto'>;
34
+ /** A loop of assembly text (listLoops; the CLI's -loops; the MCP tool list_loops). */
33
35
  export interface LoopListing {
34
36
  /** Its index for `loop` (0-based): the deepest loops first, then in code order. */
35
37
  index: number;
@@ -105,7 +107,8 @@ export type CodeRequest =
105
107
  export type AnalyzeRequest = CodeRequest & { options?: AnalysisOptions };
106
108
 
107
109
  /** Body of POST /api/compare. */
108
- export type CompareRequest = CodeRequest & { archs?: string[]; options?: AnalysisOptions };
110
+ /** `per`: elements per iteration (also cycles per element: `elementsPerIteration` and each row's `perElement`). */
111
+ export type CompareRequest = CodeRequest & { archs?: string[]; options?: AnalysisOptions; per?: number };
109
112
 
110
113
  /** Result codes, like an exit status. */
111
114
  export declare const CODES: Readonly<{ OK: 0; REQUEST: 1; ASSEMBLER: 2; ANALYSIS: 3 }>;
@@ -141,6 +144,14 @@ export interface Row {
141
144
  notes: string;
142
145
  /** values[i] belongs to columns[i]; averages per iteration. */
143
146
  values: number[];
147
+ /** Assembly input: the instruction's 1-based line in the text, and its `.loc` source line ("file.c:12") when the text has .file/.loc directives. Absent for machine code. */
148
+ line?: number;
149
+ loc?: string;
150
+ /** objdump -S and perf annotate input: the interleaved source line in force ("s += a[i] * b[i];"). */
151
+ source?: string;
152
+ /** perf annotate input: the instruction's percent of all the samples of the output (each symbol's own percent weighted
153
+ * by its sample count). */
154
+ samples?: number;
144
155
  }
145
156
 
146
157
  /** A successful analysis: the response of docs/WASM-API.md plus code, hex and stderr. */
@@ -171,10 +182,19 @@ export interface AnalyzeResult {
171
182
  hex?: string;
172
183
  /** What of `source` was analyzed, when not the whole text as given (request.loop). */
173
184
  loop?: LoopInfo;
185
+ /** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
186
+ otherLoops?: OtherLoop[];
174
187
  /** The syntax `source` was read in (detected unless the request said). */
175
188
  syntax?: 'intel' | 'att';
176
189
  /** Assembler warnings, notes (exits taken as not taken), and the decode warning. */
177
190
  stderr: StderrLine[];
191
+ /** Only when this CPU cannot run the code (positions its decoder skipped, or an instruction of an extension it lacks,
192
+ * e.g. AVX-512 on ZEN3): why ("needs AVX-512", "12 undecodable"). `tp` is then the reference's number, which leaves
193
+ * that code out: not a result for this CPU. */
194
+ unsupported?: string;
195
+ /** Only when the CPU can run the code but some of its instructions are not in its instruction tables (rows with the
196
+ * note X: x87 tbyte loads, syscall, ...): their count. The result stands; their cost is left out. */
197
+ noData?: number;
178
198
  }
179
199
 
180
200
  /** The compact form of an analysis (summarize(); the MCP `analyze` JSON). */
@@ -190,11 +210,21 @@ export interface AnalyzeSummary {
190
210
  bottlenecks: string[];
191
211
  limits: Limit[];
192
212
  decodeErrors: number;
213
+ /** As AnalyzeResult's: why this CPU cannot run the code, only then. */
214
+ unsupported?: string;
215
+ /** As AnalyzeResult's: the instructions without data of code it can run, only if any. */
216
+ noData?: number;
193
217
  hex?: string;
194
218
  loop?: LoopInfo;
219
+ /** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
220
+ otherLoops?: OtherLoop[];
195
221
  stderr: StderrLine[];
196
222
  instructions: Array<{
197
223
  instr: string;
224
+ line?: number;
225
+ loc?: string;
226
+ source?: string;
227
+ samples?: number;
198
228
  bytes?: string;
199
229
  kind?: 'regMerge' | 'stackSync';
200
230
  issued?: number;
@@ -228,9 +258,9 @@ export interface Insights {
228
258
  /** Cycles per iteration that no single limit explains. */
229
259
  unexplained?: number;
230
260
  /** The critical loop-carried dependency chain (index: into `instructions`). */
231
- chain?: { index: number; instr: string; operand: string; latency: number; carried: boolean }[];
261
+ chain?: { index: number; instr: string; line?: number; loc?: string; operand: string; latency: number; carried: boolean }[];
232
262
  /** The instructions with the largest share of the binding resource, or of the largest limit (top 5). */
233
- hot?: { resource: string; ports?: string[]; instructions: { index: number; instr: string; share: number }[] };
263
+ hot?: { resource: string; ports?: string[]; instructions: { index: number; instr: string; line?: number; loc?: string; share: number }[] };
234
264
  /** Known blind spots of the model the block meets (absent if none): rmw-index, paths, exit, split. */
235
265
  caveats?: Caveat[];
236
266
  /** With options.details: the ports behind the Ports limit (cycles = uops / ports) and the instructions that load them. */
@@ -264,7 +294,7 @@ export interface AssembleResult {
264
294
  }
265
295
 
266
296
  export type CompareRow =
267
- | { arch: string; name: string; year: number | null; prototype: boolean; code: 0; tp: number; mode: 'loop' | 'unroll'; bottlenecks: string[]; limits: Limit[]; decodeErrors: number }
297
+ | { arch: string; name: string; year: number | null; prototype: boolean; code: 0; tp: number; mode: 'loop' | 'unroll'; bottlenecks: string[]; limits: Limit[]; decodeErrors: number; unsupported?: string; noData?: number; perElement?: number }
268
298
  | { arch: string; name: string; year: number | null; prototype: boolean; code: 1 | 2 | 3; error: string };
269
299
 
270
300
  export interface CompareResult {
@@ -272,9 +302,15 @@ export interface CompareResult {
272
302
  /** The assembled machine code, when `source` was given. */
273
303
  hex?: string;
274
304
  loop?: LoopInfo;
305
+ /** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
306
+ otherLoops?: OtherLoop[];
307
+ /** With the request's `per`. */
308
+ elementsPerIteration?: number;
275
309
  stderr: StderrLine[];
276
310
  results: CompareRow[];
277
311
  }
312
+ /** A compare() result with cycles per element (`per` elements per iteration); unchanged without `per`. */
313
+ export function comparePerElement(result: CompareResult | Failure, per?: number): CompareResult | Failure;
278
314
 
279
315
  export interface Wuica {
280
316
  /** POST /api/analyze/<arch>. Failures resolve to a Failure (never throw for bad input). */
@@ -283,7 +319,7 @@ export interface Wuica {
283
319
  analyze(request: AnalyzeRequest & { arch?: string }): Promise<AnalyzeResult | Failure>;
284
320
  /** The machine code an analysis of assembly text gets (as the web page reads it: the loop of a whole function, objdump
285
321
  * lines, exits as not taken, ';' comments, a marked region); `bytes` and `hex` of the analyzed code, `loop` what was picked. */
286
- machineCode(source: string, syntax?: Syntax, loop?: LoopChoice): Promise<{ code: 0; hex: string; bytes: Uint8Array; stderr: StderrLine[]; loop: LoopInfo | null } | Failure>;
322
+ machineCode(source: string, syntax?: Syntax, loop?: LoopChoice, func?: string | null): Promise<{ code: 0; hex: string; bytes: Uint8Array; stderr: StderrLine[]; loop: LoopInfo | null } | Failure>;
287
323
  /** POST /api/compare: one block on several microarchitectures (default: all of archs()); assembled once. The
288
324
  * microarchitectures are analyzed on worker threads (CreateOptions.threads); the response is the same either way. */
289
325
  compare(request: CompareRequest): Promise<CompareResult | Failure>;
@@ -309,6 +345,12 @@ export interface Wuica {
309
345
  /** The derived diagnosis of a successful analyze() result with its microarchitecture's configuration (as in the REST
310
346
  * response and summarize()); null for a failure. */
311
347
  insights(result: AnalyzeResult | Failure): Insights | null;
348
+ /** The what-if experiments (the MCP tool what_if, POST /api/what-if/<arch>): analyze's request with `variants`
349
+ * (default all) and `per` (elements per iteration: also cycles per element). */
350
+ whatIf(arch: string, request: WhatIfRequest): Promise<WhatIfPerElement | Failure>;
351
+ /** Two blocks, A (before) and B (after), on one microarchitecture (wuica diff, the MCP tool diff_blocks,
352
+ * POST /api/diff/<arch>). A failure's error starts with "A: " or "B: ". */
353
+ diff(arch: string, request: DiffRequest): Promise<DiffResult | Failure>;
312
354
  /** The id for a user-supplied name (case-insensitive, "-" optional), DEFAULT_ARCH for empty input, or null. */
313
355
  resolveArch(arch?: string | null): string | null;
314
356
  /** How many times the analyzer was restarted after a trap. */
@@ -371,8 +413,11 @@ export interface Caveat {
371
413
  instructions: number[];
372
414
  }
373
415
 
374
- export type WhatIfVariant = 'unroll2' | 'unroll4' | 'unroll8' | 'acc2' | 'acc3' | 'acc4' | 'acc8' | 'simpleFrontEnd' | 'noMacroFusion' | 'noMicroFusion' | 'nochain';
416
+ export type WhatIfVariant = 'unroll2' | 'unroll4' | 'unroll8' | 'acc2' | 'acc3' | 'acc4' | 'acc8' | 'simpleFrontEnd' | 'noMacroFusion' | 'noMicroFusion' | 'nochain' | 'align';
417
+ /** The default variants (not align). */
375
418
  export const WHAT_IF_VARIANTS: readonly WhatIfVariant[];
419
+ /** The variants that run only when asked for: align (64 analyses). */
420
+ export const WHAT_IF_OPT_IN_VARIANTS: readonly WhatIfVariant[];
376
421
  export interface WhatIfResult {
377
422
  code: 0;
378
423
  arch: string;
@@ -381,16 +426,79 @@ export interface WhatIfResult {
381
426
  bottlenecks: string[];
382
427
  unit: 'cycles per original iteration';
383
428
  loop?: LoopInfo;
429
+ /** The base's decode errors and warnings (they hold for the variants too). */
430
+ decodeErrors?: number;
431
+ stderr?: StderrLine[];
432
+ /** Only when the CPU cannot run the base (as AnalyzeResult's): why. `variants` is then empty: no variant compares with
433
+ * a number that is not a result. */
434
+ unsupported?: string;
384
435
  /** tp per original iteration, delta = tp − base tp, speedup = base tp / tp; estimate: no analysis (nochain);
385
- * renamed (accN): the chain's registers and the ones of the copies after the first. */
386
- variants: { id: WhatIfVariant; label: string; tp?: number; delta?: number; speedup?: number | null; estimate?: boolean; bottlenecks?: string[]; renamed?: { from: string; to: string[] }[]; error?: string }[];
436
+ * renamed (accN): the chain's registers and the ones of the copies after the first; approx: the simulation (tp) came
437
+ * out under the variant's own Ports or Issue limit by at most 1% (a short steady state): the text and the Markdown
438
+ * show `shown`, that limit per original iteration, marked ≈ (~ in text). */
439
+ variants: { id: WhatIfVariant; label: string; tp?: number; delta?: number; speedup?: number | null; estimate?: boolean; bottlenecks?: string[]; renamed?: { from: string; to: string[] }[]; error?: string;
440
+ approx?: { limit: 'Ports' | 'Issue'; shown: number };
441
+ /** align: the 64 alignment offsets (tp: the median); best and worst: the first offset with the minimum, the maximum; offset: this block's. */
442
+ alignment?: { min: number; median: number; max: number; best: number; worst: number; spread: number; offset: number } }[];
387
443
  /** With accumulator variants: the best N (the smallest within 1% of the fastest; 1 = as it is) and its tp. */
388
444
  accumulators?: { best: number; tp: number };
445
+ /** From the API server: its time limit for the whole request ("deadline") ran out, or it was busy, after the base:
446
+ * the variants without a result have error "not run: <notRun>" (align: with how many offsets were analyzed). */
447
+ notRun?: string;
389
448
  }
390
449
 
391
450
  /** The CLI's `-json -whatif`: one WhatIfResult per CPU, keyed by its id, with one CPU as with several. With `-per N`,
392
451
  * each has elementsPerIteration (N) and perElement (tp / N), and each variant with a tp its perElement. */
393
- export type CliWhatIf = Record<string, (WhatIfResult & { elementsPerIteration?: number; perElement?: number; variants: (WhatIfResult['variants'][number] & { perElement?: number })[] }) | Failure>;
452
+ export type CliWhatIf = Record<string, WhatIfPerElement | Failure>;
453
+ /** A what-if result; with `per`, elementsPerIteration and perElement (tp / per), and each variant with a tp its perElement. */
454
+ export type WhatIfPerElement = WhatIfResult & { elementsPerIteration?: number; perElement?: number; variants: (WhatIfResult['variants'][number] & { perElement?: number })[] };
455
+ /** The request of Wuica.diff: two blocks (each as analyze's request), `options` for both (unless a block has its own),
456
+ * `per` elements per iteration (N for both, or [A, B]). */
457
+ export interface DiffRequest { a: AnalyzeRequest; b: AnalyzeRequest; options?: AnalysisOptions; per?: number | [number, number] }
458
+ /** One side of a DiffResult: as analyze gives it; perElement = tp / per (unrounded, as compare's and what-if's). */
459
+ export interface DiffSide { tp: number; mode: 'loop' | 'unroll'; bottlenecks: string[]; decodeErrors: number; unsupported?: string; perElement?: number; loop?: LoopInfo; stderr?: StderrLine[] }
460
+ /** The result of Wuica.diff. tp and limits as analyze gives them; delta (B − A, 0 when the same within 0.25 %) and
461
+ * speedup (A / B) rounded to two decimals; perElement's a, b and delta unrounded; uop changes rounded to two decimals.
462
+ * Both blocks must be analyzed the same way (both loops, or both unrolled): else a Failure "not comparable". */
463
+ export interface DiffResult {
464
+ code: 0;
465
+ arch: string;
466
+ a: DiffSide;
467
+ b: DiffSide;
468
+ /** Not when a side's CPU cannot run its code (a side with `unsupported`): the verdict is then "not comparable". */
469
+ delta?: number;
470
+ speedup?: number | null;
471
+ verdict: 'better' | 'worse' | 'same' | 'not comparable';
472
+ perElement?: { a: number; b: number; delta?: number; speedup?: number | null; verdict: 'better' | 'worse' | 'same' | 'not comparable' };
473
+ /** The warnings of both sides (decode errors, assembler warnings), each starting with "A: " or "B: ". */
474
+ stderr?: StderrLine[];
475
+ bottlenecks: { a: string[]; b: string[]; gone: string[]; new: string[] };
476
+ limits: { name: string; a: number | null; b: number | null; delta: number | null }[];
477
+ /** uops per iteration of each execution port (both sides' ports; [] if they differ). */
478
+ ports: { port: string; a: number; b: number; delta: number }[];
479
+ /** The instructions aligned as a diff: changed (same instruction, other uops), modified (other operands), added (only
480
+ * in B), removed (only in A); `uops`: the change of the issued uops and of each port's, where not 0; `minor`: a change
481
+ * of uops under 0.05 per iteration in every column (left out of the Markdown and the text). */
482
+ instructions: { counts: Record<'same' | 'changed' | 'modified' | 'added' | 'removed', number>; changes: { status: 'changed' | 'modified' | 'added' | 'removed'; a: string | null; b: string | null; uops: Record<string, number>; minor?: true }[] };
483
+ }
484
+ /** Wuica.diff with any w that has analyze. */
485
+ export function diffRequest(w: Pick<Wuica, 'analyze'>, arch: string, request: DiffRequest): Promise<DiffResult | Failure>;
486
+ /** The two analyses and the result (for diffMarkdown), or the failure. */
487
+ export function diffAnalyses(w: Pick<Wuica, 'analyze'>, arch: string, request: DiffRequest): Promise<{ result: DiffResult; a: AnalyzeResult; b: AnalyzeResult; per: [number, number] | null; sourceA: string | null; sourceB: string | null } | { failure: Failure }>;
488
+ /** The result from two analyze() responses. */
489
+ export function diffResult(a: AnalyzeResult, b: AnalyzeResult, options?: { per?: [number, number] | null; sourceA?: string | null; sourceB?: string | null }): DiffResult | Failure;
490
+ /** Markdown of diffAnalyses' result (the page's A–B tables; markdown.compare), naming the microarchitecture (archTitle, else its id), with the warnings. */
491
+ export function diffMarkdown(x: Awaited<ReturnType<typeof diffAnalyses>>, options?: { archTitle?: string }): string;
492
+ /** The result as text (wuica diff; REST text/plain). */
493
+ export function diffText(result: DiffResult | Failure): string;
494
+ /** The request of Wuica.whatIf, the MCP tool what_if and POST /api/what-if/<arch>. */
495
+ export type WhatIfRequest = AnalyzeRequest & { variants?: readonly WhatIfVariant[]; per?: number };
496
+ /** whatIf with a request as the interfaces take it (`variants`, `per`), with w's analyze and assemble. */
497
+ export function whatIfRequest(w: Pick<Wuica, 'analyze' | 'assemble'>, arch: string, request: WhatIfRequest): Promise<WhatIfPerElement | Failure>;
498
+ /** A what-if result per element (`per` elements per iteration); unchanged without `per` or for a failure. */
499
+ export function whatIfPerElement(result: WhatIfResult | Failure, per?: number): WhatIfPerElement | Failure;
500
+ /** The what-if table as the CLI prints it (-whatif; REST text/plain). */
501
+ export function whatIfText(result: WhatIfPerElement | Failure): string;
394
502
  /** The CLI's `-json` with one CPU: the analyze result with insights (caveats in insights.caveats), perElement (-per)
395
503
  * and whatIf (-whatif). */
396
504
  export type CliAnalyzeJson = AnalyzeResult & { insights?: Insights; perElement?: number; whatIf?: CliWhatIf };
@@ -408,3 +516,49 @@ export interface CliVersionJson { wuica: string; uiCA: { repository: string; com
408
516
  * for the accumulator variants, `assemble` (e.g. a Wuica's assemble, bound). */
409
517
  export function whatIf(analyze: (arch: string, request: AnalyzeRequest) => Promise<AnalyzeResult | Failure>, arch: string, request: AnalyzeRequest, variants?: readonly WhatIfVariant[],
410
518
  tools?: { assemble?: (text: string) => Promise<AssembleResult | Failure> }): Promise<WhatIfResult | Failure>;
519
+ /** Results as GitHub-flavoured Markdown (the page's copy controls and `wuica -md`; lib/web/markdown.js): deterministic
520
+ * text, columns padded for a monospace font, pipes and backticks escaped, numbers as the CLI prints them. Every
521
+ * generator returns text that ends with one newline. */
522
+ /** Where the Markdown's branch targets come from (branch-label.js): the labels per row as shown, the analyzed lines of
523
+ * the assembly ({text, from, to}), or the request's source text; else the offset in the block ("jnz 0x0"). */
524
+ export interface MarkdownLabels { shown?: (string | null)[] | null; src?: { text: string; from?: number; to?: number } | null; source?: string }
525
+ export namespace markdown {
526
+ /** The whole result: headline, limits, next limit, caveats ("not modelled"), critical chain, uop table, the code
527
+ * (meta.code) in a fenced block, a link (meta.link). A failure: its error and stderr lines. */
528
+ function report(result: AnalyzeResult | Failure, meta?: MarkdownLabels & { arch?: string; archTitle?: string; per?: number; insights?: Insights | null;
529
+ config?: { splitLoadCycles?: number } | null; code?: string; lang?: string; link?: string; title?: string }): string;
530
+ /** The headline alone (one line, no newline). */
531
+ function headline(result: AnalyzeResult, meta?: { arch?: string; archTitle?: string; per?: number }): string;
532
+ /** The uop table: every row, the used columns, the totals (no newline at the end). */
533
+ function uopTable(result: AnalyzeResult, meta?: MarkdownLabels): string;
534
+ /** Each row's instruction text with its branch target as a label. */
535
+ function shownLabels(result: AnalyzeResult, meta?: MarkdownLabels): string[];
536
+ /** Several CPUs, one row each (a compare result or its rows); or files x CPUs: [{file, result}]. */
537
+ function cpuTable(input: CompareResult | CliCompareJson | CompareResult['results'] | Failure | { file: string; result: CompareResult | AnalyzeResult | Failure }[],
538
+ options?: { per?: number }): string;
539
+ /** The what-if table of one CPU (per element with elementsPerIteration). */
540
+ function whatIf(result: (WhatIfResult & { elementsPerIteration?: number }) | (Failure & { arch?: string })): string;
541
+ /** whatIf's table, and the alignment line when the result has the variant align. */
542
+ function whatIfAlignment(result: (WhatIfResult & { elementsPerIteration?: number }) | (Failure & { arch?: string })): string;
543
+ /** The loops of assembly text (listLoops). */
544
+ function loops(list: LoopListing[]): string;
545
+ /** A against B (as the page's A–B view): summary, bottlenecks, limits, the aligned instructions with B − A per column;
546
+ * meta.cpus adds the A/B/Δ table per CPU. workA, workB: elements per iteration of each side (cycles per element). */
547
+ function compare(a: AnalyzeResult | Failure, b: AnalyzeResult | Failure, meta?: { workA?: number; workB?: number; archA?: string; archB?: string;
548
+ cpus?: { arch: string; a: number | null; b: number | null }[];
549
+ shownA?: (string | null)[]; srcA?: MarkdownLabels['src']; shownB?: (string | null)[]; srcB?: MarkdownLabels['src'] }): string;
550
+ /** The uop table as CSV (RFC 4180, CRLF). */
551
+ function toCSV(result: AnalyzeResult): string;
552
+ /** The request and the response as JSON (without trace and text). */
553
+ function toJSON(result: AnalyzeResult, request?: unknown): string;
554
+ /** Building blocks for further generators: a padded GFM table, a code span, escaped text, a fenced block. */
555
+ function table(head: string[], rows: string[][], align?: ('l' | 'r' | 'c')[]): string;
556
+ function code(text: string): string;
557
+ function text(s: unknown): string;
558
+ function fence(body: string, lang?: string): string;
559
+ /** A cycle count as the page shows it (two decimals; three significant digits below 0.1); with its sign. */
560
+ function cycles(v: number): string;
561
+ function signedCycles(v: number): string;
562
+ /** A uop-table value as uiCA prints it (up to two decimals, zero blank). */
563
+ function uopValue(v: number): string;
564
+ }