wuica-cli 0.1.9 → 0.1.12
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 +140 -40
- package/dist/data/arch/ADL-P.bin.br +0 -0
- package/dist/data/arch/ICX.bin.br +0 -0
- package/dist/data/arch/ZEN3.bin.br +0 -0
- package/dist/data/uarch.json.br +0 -0
- package/dist/manifest.json +19 -19
- package/dist/wuica_wasm.wasm.br +0 -0
- package/index.d.ts +175 -15
- package/lib/cli.js +205 -44
- package/lib/core.js +9 -1
- package/lib/details.js +4 -23
- package/lib/examples.js +1 -0
- package/lib/files.js +2 -1
- package/lib/index.js +120 -21
- package/lib/mcp.js +108 -85
- package/lib/objfile.js +51 -11
- package/lib/thread-worker.js +9 -6
- package/lib/threads.js +8 -2
- package/lib/wasm.js +12 -6
- package/lib/web/ab-diff.js +217 -0
- package/lib/web/accum.js +10 -2
- package/lib/web/asm-regions.js +27 -20
- package/lib/web/asm-tokens.js +357 -0
- package/lib/web/assembler.js +36 -6
- package/lib/web/block-diff.js +165 -0
- package/lib/web/bound-core.js +211 -0
- package/lib/web/branch-label.js +155 -0
- package/lib/web/caveats.js +107 -3
- package/lib/web/details.js +91 -0
- package/lib/web/examples.js +5 -1
- package/lib/web/loop-find.js +398 -35
- package/lib/web/markdown.js +437 -0
- package/lib/web/whatif-core.js +339 -0
- package/package.json +7 -2
- package/lib/insights.js +0 -100
- package/lib/whatif.js +0 -136
package/index.d.ts
CHANGED
|
@@ -24,14 +24,19 @@ export interface AnalysisOptions {
|
|
|
24
24
|
/** "auto" (the default): detected from the text (%registers, $immediates: AT&T; else Intel noprefix). */
|
|
25
25
|
export type Syntax = 'auto' | 'intel' | 'att';
|
|
26
26
|
|
|
27
|
-
/** What of `source` is analyzed: "auto" (default: the innermost
|
|
28
|
-
*
|
|
27
|
+
/** What of `source` is analyzed: "auto" (default: of the deepest innermost loops in the function of the first of them, the one with the
|
|
28
|
+
* widest vector registers, then the most vector instructions, then the most instructions, then the first; its body if
|
|
29
|
+
* it has no loop; else the text as it is), "whole", the index of a loop (as listLoops lists them), or its label. */
|
|
29
30
|
export type LoopChoice = 'auto' | 'whole' | number | string;
|
|
30
31
|
/** The named loop choices ('auto', 'whole'); a number is a loop's index (0-based), any other string its label. */
|
|
31
32
|
export declare const LOOP_CHOICES: readonly ['auto', 'whole'];
|
|
32
|
-
/** A loop of
|
|
33
|
+
/** A loop of the text that was not analyzed (analyze's `otherLoops`): listLoops' entry without `auto`. */
|
|
34
|
+
export type OtherLoop = Omit<LoopListing, 'auto'>;
|
|
35
|
+
/** A loop of assembly text (listLoops; the CLI's -loops; the MCP tool list_loops). */
|
|
33
36
|
export interface LoopListing {
|
|
34
|
-
/** Its index for `loop` (0-based): the deepest loops first, then in code order
|
|
37
|
+
/** Its index for `loop` (0-based): the deepest innermost loops first, then in code order (the default, `auto`, need
|
|
38
|
+
* not be the first; a loop three or more deep in clang's notes keeps the place it had when only the notes' first two
|
|
39
|
+
* lines were read). */
|
|
35
40
|
index: number;
|
|
36
41
|
label: string;
|
|
37
42
|
/** The function it is in (the last non-local label before it), or null. */
|
|
@@ -105,7 +110,8 @@ export type CodeRequest =
|
|
|
105
110
|
export type AnalyzeRequest = CodeRequest & { options?: AnalysisOptions };
|
|
106
111
|
|
|
107
112
|
/** Body of POST /api/compare. */
|
|
108
|
-
|
|
113
|
+
/** `per`: elements per iteration (also cycles per element: `elementsPerIteration` and each row's `perElement`). */
|
|
114
|
+
export type CompareRequest = CodeRequest & { archs?: string[]; options?: AnalysisOptions; per?: number };
|
|
109
115
|
|
|
110
116
|
/** Result codes, like an exit status. */
|
|
111
117
|
export declare const CODES: Readonly<{ OK: 0; REQUEST: 1; ASSEMBLER: 2; ANALYSIS: 3 }>;
|
|
@@ -141,6 +147,14 @@ export interface Row {
|
|
|
141
147
|
notes: string;
|
|
142
148
|
/** values[i] belongs to columns[i]; averages per iteration. */
|
|
143
149
|
values: number[];
|
|
150
|
+
/** 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. */
|
|
151
|
+
line?: number;
|
|
152
|
+
loc?: string;
|
|
153
|
+
/** objdump -S and perf annotate input: the interleaved source line in force ("s += a[i] * b[i];"). */
|
|
154
|
+
source?: string;
|
|
155
|
+
/** perf annotate input: the instruction's percent of all the samples of the output (each symbol's own percent weighted
|
|
156
|
+
* by its sample count). */
|
|
157
|
+
samples?: number;
|
|
144
158
|
}
|
|
145
159
|
|
|
146
160
|
/** A successful analysis: the response of docs/WASM-API.md plus code, hex and stderr. */
|
|
@@ -171,10 +185,19 @@ export interface AnalyzeResult {
|
|
|
171
185
|
hex?: string;
|
|
172
186
|
/** What of `source` was analyzed, when not the whole text as given (request.loop). */
|
|
173
187
|
loop?: LoopInfo;
|
|
188
|
+
/** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
|
|
189
|
+
otherLoops?: OtherLoop[];
|
|
174
190
|
/** The syntax `source` was read in (detected unless the request said). */
|
|
175
191
|
syntax?: 'intel' | 'att';
|
|
176
192
|
/** Assembler warnings, notes (exits taken as not taken), and the decode warning. */
|
|
177
193
|
stderr: StderrLine[];
|
|
194
|
+
/** Only when this CPU cannot run the code (positions its decoder skipped, or an instruction of an extension it lacks,
|
|
195
|
+
* e.g. AVX-512 on ZEN3): why ("needs AVX-512", "12 undecodable"). `tp` is then the reference's number, which leaves
|
|
196
|
+
* that code out: not a result for this CPU. */
|
|
197
|
+
unsupported?: string;
|
|
198
|
+
/** Only when the CPU can run the code but some of its instructions are not in its instruction tables (rows with the
|
|
199
|
+
* note X: x87 tbyte loads, syscall, ...): their count. The result stands; their cost is left out. */
|
|
200
|
+
noData?: number;
|
|
178
201
|
}
|
|
179
202
|
|
|
180
203
|
/** The compact form of an analysis (summarize(); the MCP `analyze` JSON). */
|
|
@@ -190,11 +213,21 @@ export interface AnalyzeSummary {
|
|
|
190
213
|
bottlenecks: string[];
|
|
191
214
|
limits: Limit[];
|
|
192
215
|
decodeErrors: number;
|
|
216
|
+
/** As AnalyzeResult's: why this CPU cannot run the code, only then. */
|
|
217
|
+
unsupported?: string;
|
|
218
|
+
/** As AnalyzeResult's: the instructions without data of code it can run, only if any. */
|
|
219
|
+
noData?: number;
|
|
193
220
|
hex?: string;
|
|
194
221
|
loop?: LoopInfo;
|
|
222
|
+
/** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
|
|
223
|
+
otherLoops?: OtherLoop[];
|
|
195
224
|
stderr: StderrLine[];
|
|
196
225
|
instructions: Array<{
|
|
197
226
|
instr: string;
|
|
227
|
+
line?: number;
|
|
228
|
+
loc?: string;
|
|
229
|
+
source?: string;
|
|
230
|
+
samples?: number;
|
|
198
231
|
bytes?: string;
|
|
199
232
|
kind?: 'regMerge' | 'stackSync';
|
|
200
233
|
issued?: number;
|
|
@@ -228,9 +261,9 @@ export interface Insights {
|
|
|
228
261
|
/** Cycles per iteration that no single limit explains. */
|
|
229
262
|
unexplained?: number;
|
|
230
263
|
/** The critical loop-carried dependency chain (index: into `instructions`). */
|
|
231
|
-
chain?: { index: number; instr: string; operand: string; latency: number; carried: boolean }[];
|
|
264
|
+
chain?: { index: number; instr: string; line?: number; loc?: string; operand: string; latency: number; carried: boolean }[];
|
|
232
265
|
/** 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 }[] };
|
|
266
|
+
hot?: { resource: string; ports?: string[]; instructions: { index: number; instr: string; line?: number; loc?: string; share: number }[] };
|
|
234
267
|
/** Known blind spots of the model the block meets (absent if none): rmw-index, paths, exit, split. */
|
|
235
268
|
caveats?: Caveat[];
|
|
236
269
|
/** With options.details: the ports behind the Ports limit (cycles = uops / ports) and the instructions that load them. */
|
|
@@ -264,7 +297,7 @@ export interface AssembleResult {
|
|
|
264
297
|
}
|
|
265
298
|
|
|
266
299
|
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 }
|
|
300
|
+
| { 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
301
|
| { arch: string; name: string; year: number | null; prototype: boolean; code: 1 | 2 | 3; error: string };
|
|
269
302
|
|
|
270
303
|
export interface CompareResult {
|
|
@@ -272,9 +305,15 @@ export interface CompareResult {
|
|
|
272
305
|
/** The assembled machine code, when `source` was given. */
|
|
273
306
|
hex?: string;
|
|
274
307
|
loop?: LoopInfo;
|
|
308
|
+
/** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
|
|
309
|
+
otherLoops?: OtherLoop[];
|
|
310
|
+
/** With the request's `per`. */
|
|
311
|
+
elementsPerIteration?: number;
|
|
275
312
|
stderr: StderrLine[];
|
|
276
313
|
results: CompareRow[];
|
|
277
314
|
}
|
|
315
|
+
/** A compare() result with cycles per element (`per` elements per iteration); unchanged without `per`. */
|
|
316
|
+
export function comparePerElement(result: CompareResult | Failure, per?: number): CompareResult | Failure;
|
|
278
317
|
|
|
279
318
|
export interface Wuica {
|
|
280
319
|
/** POST /api/analyze/<arch>. Failures resolve to a Failure (never throw for bad input). */
|
|
@@ -283,7 +322,7 @@ export interface Wuica {
|
|
|
283
322
|
analyze(request: AnalyzeRequest & { arch?: string }): Promise<AnalyzeResult | Failure>;
|
|
284
323
|
/** The machine code an analysis of assembly text gets (as the web page reads it: the loop of a whole function, objdump
|
|
285
324
|
* 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>;
|
|
325
|
+
machineCode(source: string, syntax?: Syntax, loop?: LoopChoice, func?: string | null): Promise<{ code: 0; hex: string; bytes: Uint8Array; stderr: StderrLine[]; loop: LoopInfo | null } | Failure>;
|
|
287
326
|
/** POST /api/compare: one block on several microarchitectures (default: all of archs()); assembled once. The
|
|
288
327
|
* microarchitectures are analyzed on worker threads (CreateOptions.threads); the response is the same either way. */
|
|
289
328
|
compare(request: CompareRequest): Promise<CompareResult | Failure>;
|
|
@@ -296,8 +335,11 @@ export interface Wuica {
|
|
|
296
335
|
/** An object file or executable (ELF or Mach-O, x86-64; a universal file's x86-64 slice) as llvm-objdump -d's text
|
|
297
336
|
* of its code sections, which analyze() and compare() read as `source` (the loop at its address, the alignment from
|
|
298
337
|
* it). Another architecture or format is a Failure that says what it is and how to get x86-64. `func` is resolved
|
|
299
|
-
* (exact, without Mach-O's "_", or a unique part of a name) and returned as `func`.
|
|
300
|
-
|
|
338
|
+
* (exact, without Mach-O's "_", or a unique part of a name) and returned as `func`. A name the file gives several
|
|
339
|
+
* functions (static functions of different source files, .cold parts) is NAME.0xADDR, `symbol` the name in the file;
|
|
340
|
+
* `func` set to that name alone is a Failure that lists them. With `func`, `text` is that function's alone (a
|
|
341
|
+
* function of one instruction: with its neighbor), whose loops are the whole text's loops that lie in it. */
|
|
342
|
+
disassemble(bytes: Uint8Array, options?: { name?: string; func?: string | null }): { code: 0; text: string; format: string; functions: { name: string; section: string; address: number; size: number; symbol?: string }[]; func?: string } | Failure;
|
|
301
343
|
/** GET /api/archs: in order of release (uiCA's ablation variants, ids with "_", are left out). */
|
|
302
344
|
archs(): ArchInfo[];
|
|
303
345
|
archs(fields: ArchField[] | string): Partial<ArchInfo>[];
|
|
@@ -309,6 +351,12 @@ export interface Wuica {
|
|
|
309
351
|
/** The derived diagnosis of a successful analyze() result with its microarchitecture's configuration (as in the REST
|
|
310
352
|
* response and summarize()); null for a failure. */
|
|
311
353
|
insights(result: AnalyzeResult | Failure): Insights | null;
|
|
354
|
+
/** The what-if experiments (the MCP tool what_if, POST /api/what-if/<arch>): analyze's request with `variants`
|
|
355
|
+
* (default all) and `per` (elements per iteration: also cycles per element). */
|
|
356
|
+
whatIf(arch: string, request: WhatIfRequest): Promise<WhatIfPerElement | Failure>;
|
|
357
|
+
/** Two blocks, A (before) and B (after), on one microarchitecture (wuica diff, the MCP tool diff_blocks,
|
|
358
|
+
* POST /api/diff/<arch>). A failure's error starts with "A: " or "B: ". */
|
|
359
|
+
diff(arch: string, request: DiffRequest): Promise<DiffResult | Failure>;
|
|
312
360
|
/** The id for a user-supplied name (case-insensitive, "-" optional), DEFAULT_ARCH for empty input, or null. */
|
|
313
361
|
resolveArch(arch?: string | null): string | null;
|
|
314
362
|
/** How many times the analyzer was restarted after a trap. */
|
|
@@ -371,8 +419,11 @@ export interface Caveat {
|
|
|
371
419
|
instructions: number[];
|
|
372
420
|
}
|
|
373
421
|
|
|
374
|
-
export type WhatIfVariant = 'unroll2' | 'unroll4' | 'unroll8' | 'acc2' | 'acc3' | 'acc4' | 'acc8' | 'simpleFrontEnd' | 'noMacroFusion' | 'noMicroFusion' | 'nochain';
|
|
422
|
+
export type WhatIfVariant = 'unroll2' | 'unroll4' | 'unroll8' | 'acc2' | 'acc3' | 'acc4' | 'acc8' | 'simpleFrontEnd' | 'noMacroFusion' | 'noMicroFusion' | 'nochain' | 'align';
|
|
423
|
+
/** The default variants (not align). */
|
|
375
424
|
export const WHAT_IF_VARIANTS: readonly WhatIfVariant[];
|
|
425
|
+
/** The variants that run only when asked for: align (64 analyses). */
|
|
426
|
+
export const WHAT_IF_OPT_IN_VARIANTS: readonly WhatIfVariant[];
|
|
376
427
|
export interface WhatIfResult {
|
|
377
428
|
code: 0;
|
|
378
429
|
arch: string;
|
|
@@ -381,16 +432,79 @@ export interface WhatIfResult {
|
|
|
381
432
|
bottlenecks: string[];
|
|
382
433
|
unit: 'cycles per original iteration';
|
|
383
434
|
loop?: LoopInfo;
|
|
435
|
+
/** The base's decode errors and warnings (they hold for the variants too). */
|
|
436
|
+
decodeErrors?: number;
|
|
437
|
+
stderr?: StderrLine[];
|
|
438
|
+
/** Only when the CPU cannot run the base (as AnalyzeResult's): why. `variants` is then empty: no variant compares with
|
|
439
|
+
* a number that is not a result. */
|
|
440
|
+
unsupported?: string;
|
|
384
441
|
/** 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
|
-
|
|
442
|
+
* renamed (accN): the chain's registers and the ones of the copies after the first; approx: the simulation (tp) came
|
|
443
|
+
* out under the variant's own Ports or Issue limit by at most 1% (a short steady state): the text and the Markdown
|
|
444
|
+
* show `shown`, that limit per original iteration, marked ≈ (~ in text). */
|
|
445
|
+
variants: { id: WhatIfVariant; label: string; tp?: number; delta?: number; speedup?: number | null; estimate?: boolean; bottlenecks?: string[]; renamed?: { from: string; to: string[] }[]; error?: string;
|
|
446
|
+
approx?: { limit: 'Ports' | 'Issue'; shown: number };
|
|
447
|
+
/** align: the 64 alignment offsets (tp: the median); best and worst: the first offset with the minimum, the maximum; offset: this block's. */
|
|
448
|
+
alignment?: { min: number; median: number; max: number; best: number; worst: number; spread: number; offset: number } }[];
|
|
387
449
|
/** With accumulator variants: the best N (the smallest within 1% of the fastest; 1 = as it is) and its tp. */
|
|
388
450
|
accumulators?: { best: number; tp: number };
|
|
451
|
+
/** From the API server: its time limit for the whole request ("deadline") ran out, or it was busy, after the base:
|
|
452
|
+
* the variants without a result have error "not run: <notRun>" (align: with how many offsets were analyzed). */
|
|
453
|
+
notRun?: string;
|
|
389
454
|
}
|
|
390
455
|
|
|
391
456
|
/** The CLI's `-json -whatif`: one WhatIfResult per CPU, keyed by its id, with one CPU as with several. With `-per N`,
|
|
392
457
|
* each has elementsPerIteration (N) and perElement (tp / N), and each variant with a tp its perElement. */
|
|
393
|
-
export type CliWhatIf = Record<string,
|
|
458
|
+
export type CliWhatIf = Record<string, WhatIfPerElement | Failure>;
|
|
459
|
+
/** A what-if result; with `per`, elementsPerIteration and perElement (tp / per), and each variant with a tp its perElement. */
|
|
460
|
+
export type WhatIfPerElement = WhatIfResult & { elementsPerIteration?: number; perElement?: number; variants: (WhatIfResult['variants'][number] & { perElement?: number })[] };
|
|
461
|
+
/** The request of Wuica.diff: two blocks (each as analyze's request), `options` for both (unless a block has its own),
|
|
462
|
+
* `per` elements per iteration (N for both, or [A, B]). */
|
|
463
|
+
export interface DiffRequest { a: AnalyzeRequest; b: AnalyzeRequest; options?: AnalysisOptions; per?: number | [number, number] }
|
|
464
|
+
/** One side of a DiffResult: as analyze gives it; perElement = tp / per (unrounded, as compare's and what-if's). */
|
|
465
|
+
export interface DiffSide { tp: number; mode: 'loop' | 'unroll'; bottlenecks: string[]; decodeErrors: number; unsupported?: string; perElement?: number; loop?: LoopInfo; stderr?: StderrLine[] }
|
|
466
|
+
/** The result of Wuica.diff. tp and limits as analyze gives them; delta (B − A, 0 when the same within 0.25 %) and
|
|
467
|
+
* speedup (A / B) rounded to two decimals; perElement's a, b and delta unrounded; uop changes rounded to two decimals.
|
|
468
|
+
* Both blocks must be analyzed the same way (both loops, or both unrolled): else a Failure "not comparable". */
|
|
469
|
+
export interface DiffResult {
|
|
470
|
+
code: 0;
|
|
471
|
+
arch: string;
|
|
472
|
+
a: DiffSide;
|
|
473
|
+
b: DiffSide;
|
|
474
|
+
/** Not when a side's CPU cannot run its code (a side with `unsupported`): the verdict is then "not comparable". */
|
|
475
|
+
delta?: number;
|
|
476
|
+
speedup?: number | null;
|
|
477
|
+
verdict: 'better' | 'worse' | 'same' | 'not comparable';
|
|
478
|
+
perElement?: { a: number; b: number; delta?: number; speedup?: number | null; verdict: 'better' | 'worse' | 'same' | 'not comparable' };
|
|
479
|
+
/** The warnings of both sides (decode errors, assembler warnings), each starting with "A: " or "B: ". */
|
|
480
|
+
stderr?: StderrLine[];
|
|
481
|
+
bottlenecks: { a: string[]; b: string[]; gone: string[]; new: string[] };
|
|
482
|
+
limits: { name: string; a: number | null; b: number | null; delta: number | null }[];
|
|
483
|
+
/** uops per iteration of each execution port (both sides' ports; [] if they differ). */
|
|
484
|
+
ports: { port: string; a: number; b: number; delta: number }[];
|
|
485
|
+
/** The instructions aligned as a diff: changed (same instruction, other uops), modified (other operands), added (only
|
|
486
|
+
* in B), removed (only in A); `uops`: the change of the issued uops and of each port's, where not 0; `minor`: a change
|
|
487
|
+
* of uops under 0.05 per iteration in every column (left out of the Markdown and the text). */
|
|
488
|
+
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 }[] };
|
|
489
|
+
}
|
|
490
|
+
/** Wuica.diff with any w that has analyze. */
|
|
491
|
+
export function diffRequest(w: Pick<Wuica, 'analyze'>, arch: string, request: DiffRequest): Promise<DiffResult | Failure>;
|
|
492
|
+
/** The two analyses and the result (for diffMarkdown), or the failure. */
|
|
493
|
+
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 }>;
|
|
494
|
+
/** The result from two analyze() responses. */
|
|
495
|
+
export function diffResult(a: AnalyzeResult, b: AnalyzeResult, options?: { per?: [number, number] | null; sourceA?: string | null; sourceB?: string | null }): DiffResult | Failure;
|
|
496
|
+
/** Markdown of diffAnalyses' result (the page's A–B tables; markdown.compare), naming the microarchitecture (archTitle, else its id), with the warnings. */
|
|
497
|
+
export function diffMarkdown(x: Awaited<ReturnType<typeof diffAnalyses>>, options?: { archTitle?: string }): string;
|
|
498
|
+
/** The result as text (wuica diff; REST text/plain). */
|
|
499
|
+
export function diffText(result: DiffResult | Failure): string;
|
|
500
|
+
/** The request of Wuica.whatIf, the MCP tool what_if and POST /api/what-if/<arch>. */
|
|
501
|
+
export type WhatIfRequest = AnalyzeRequest & { variants?: readonly WhatIfVariant[]; per?: number };
|
|
502
|
+
/** whatIf with a request as the interfaces take it (`variants`, `per`), with w's analyze and assemble. */
|
|
503
|
+
export function whatIfRequest(w: Pick<Wuica, 'analyze' | 'assemble'>, arch: string, request: WhatIfRequest): Promise<WhatIfPerElement | Failure>;
|
|
504
|
+
/** A what-if result per element (`per` elements per iteration); unchanged without `per` or for a failure. */
|
|
505
|
+
export function whatIfPerElement(result: WhatIfResult | Failure, per?: number): WhatIfPerElement | Failure;
|
|
506
|
+
/** The what-if table as the CLI prints it (-whatif; REST text/plain). */
|
|
507
|
+
export function whatIfText(result: WhatIfPerElement | Failure): string;
|
|
394
508
|
/** The CLI's `-json` with one CPU: the analyze result with insights (caveats in insights.caveats), perElement (-per)
|
|
395
509
|
* and whatIf (-whatif). */
|
|
396
510
|
export type CliAnalyzeJson = AnalyzeResult & { insights?: Insights; perElement?: number; whatIf?: CliWhatIf };
|
|
@@ -408,3 +522,49 @@ export interface CliVersionJson { wuica: string; uiCA: { repository: string; com
|
|
|
408
522
|
* for the accumulator variants, `assemble` (e.g. a Wuica's assemble, bound). */
|
|
409
523
|
export function whatIf(analyze: (arch: string, request: AnalyzeRequest) => Promise<AnalyzeResult | Failure>, arch: string, request: AnalyzeRequest, variants?: readonly WhatIfVariant[],
|
|
410
524
|
tools?: { assemble?: (text: string) => Promise<AssembleResult | Failure> }): Promise<WhatIfResult | Failure>;
|
|
525
|
+
/** Results as GitHub-flavoured Markdown (the page's copy controls and `wuica -md`; lib/web/markdown.js): deterministic
|
|
526
|
+
* text, columns padded for a monospace font, pipes and backticks escaped, numbers as the CLI prints them. Every
|
|
527
|
+
* generator returns text that ends with one newline. */
|
|
528
|
+
/** Where the Markdown's branch targets come from (branch-label.js): the labels per row as shown, the analyzed lines of
|
|
529
|
+
* the assembly ({text, from, to}), or the request's source text; else the offset in the block ("jnz 0x0"). */
|
|
530
|
+
export interface MarkdownLabels { shown?: (string | null)[] | null; src?: { text: string; from?: number; to?: number } | null; source?: string }
|
|
531
|
+
export namespace markdown {
|
|
532
|
+
/** The whole result: headline, limits, next limit, caveats ("not modelled"), critical chain, uop table, the code
|
|
533
|
+
* (meta.code) in a fenced block, a link (meta.link). A failure: its error and stderr lines. */
|
|
534
|
+
function report(result: AnalyzeResult | Failure, meta?: MarkdownLabels & { arch?: string; archTitle?: string; per?: number; insights?: Insights | null;
|
|
535
|
+
config?: { splitLoadCycles?: number } | null; code?: string; lang?: string; link?: string; title?: string }): string;
|
|
536
|
+
/** The headline alone (one line, no newline). */
|
|
537
|
+
function headline(result: AnalyzeResult, meta?: { arch?: string; archTitle?: string; per?: number }): string;
|
|
538
|
+
/** The uop table: every row, the used columns, the totals (no newline at the end). */
|
|
539
|
+
function uopTable(result: AnalyzeResult, meta?: MarkdownLabels): string;
|
|
540
|
+
/** Each row's instruction text with its branch target as a label. */
|
|
541
|
+
function shownLabels(result: AnalyzeResult, meta?: MarkdownLabels): string[];
|
|
542
|
+
/** Several CPUs, one row each (a compare result or its rows); or files x CPUs: [{file, result}]. */
|
|
543
|
+
function cpuTable(input: CompareResult | CliCompareJson | CompareResult['results'] | Failure | { file: string; result: CompareResult | AnalyzeResult | Failure }[],
|
|
544
|
+
options?: { per?: number }): string;
|
|
545
|
+
/** The what-if table of one CPU (per element with elementsPerIteration). */
|
|
546
|
+
function whatIf(result: (WhatIfResult & { elementsPerIteration?: number }) | (Failure & { arch?: string })): string;
|
|
547
|
+
/** whatIf's table, and the alignment line when the result has the variant align. */
|
|
548
|
+
function whatIfAlignment(result: (WhatIfResult & { elementsPerIteration?: number }) | (Failure & { arch?: string })): string;
|
|
549
|
+
/** The loops of assembly text (listLoops). */
|
|
550
|
+
function loops(list: LoopListing[]): string;
|
|
551
|
+
/** A against B (as the page's A–B view): summary, bottlenecks, limits, the aligned instructions with B − A per column;
|
|
552
|
+
* meta.cpus adds the A/B/Δ table per CPU. workA, workB: elements per iteration of each side (cycles per element). */
|
|
553
|
+
function compare(a: AnalyzeResult | Failure, b: AnalyzeResult | Failure, meta?: { workA?: number; workB?: number; archA?: string; archB?: string;
|
|
554
|
+
cpus?: { arch: string; a: number | null; b: number | null }[];
|
|
555
|
+
shownA?: (string | null)[]; srcA?: MarkdownLabels['src']; shownB?: (string | null)[]; srcB?: MarkdownLabels['src'] }): string;
|
|
556
|
+
/** The uop table as CSV (RFC 4180, CRLF). */
|
|
557
|
+
function toCSV(result: AnalyzeResult): string;
|
|
558
|
+
/** The request and the response as JSON (without trace and text). */
|
|
559
|
+
function toJSON(result: AnalyzeResult, request?: unknown): string;
|
|
560
|
+
/** Building blocks for further generators: a padded GFM table, a code span, escaped text, a fenced block. */
|
|
561
|
+
function table(head: string[], rows: string[][], align?: ('l' | 'r' | 'c')[]): string;
|
|
562
|
+
function code(text: string): string;
|
|
563
|
+
function text(s: unknown): string;
|
|
564
|
+
function fence(body: string, lang?: string): string;
|
|
565
|
+
/** A cycle count as the page shows it (two decimals; three significant digits below 0.1); with its sign. */
|
|
566
|
+
function cycles(v: number): string;
|
|
567
|
+
function signedCycles(v: number): string;
|
|
568
|
+
/** A uop-table value as uiCA prints it (up to two decimals, zero blank). */
|
|
569
|
+
function uopValue(v: number): string;
|
|
570
|
+
}
|