Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>IPU AssemblyNew to Visual Studio Code? Get it now.
IPU Assembly

IPU Assembly

yarden carmi

|
15 installs
| (0) | Free
Language support for IPU VLIW assembly (.asm, .asm.j2 templates): highlighting, completion, operand hints, hover docs, navigation, formatting and live assembler errors. In the IPU emulator repository it also adds Run, Debug, Test and Benchmark buttons and a kernel sidebar.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

IPU Assembly — VS Code extension

Editing support for IPU VLIW assembly (.asm, .asm.j2): highlighting, semantic highlighting, completion, hover, navigation, rename, formatting and assembler diagnostics, plus Run/Debug/Test buttons and an IPU sidebar for the kernel library.

Anything that runs a process needs an IPU checkout: the nearest Bazel workspace above the file holding src/ipu-as, with the open folder at, inside, or up to three levels above it; switching checkouts is picked up live. Elsewhere a .asm is only coloured.

Where its knowledge comes from

Knowledge Source When
Token shapes, comments, ; / ;;, labels asm_grammar.lark terminals extension build
Instructions, their slots, slots per word, operands, docs instruction_spec.py extension build
What each register is; CR0/CR1 fixed values ipu_isa.registers, ipu_isa.constants extension build
What each operand type accepts (registers, enums, ranges) the assembler's token classes, completion_domain() extension build
Which names ignore case probe programs run through the assembler extension build
Kernels, families and their Bazel targets kernels/defs.bzl (//kernels:kernel_targets) runtime, from the workspace
Cases, options, operations the kernel registry (//kernels:manifest) runtime, from the workspace
Which kernel handles a computation query --json runtime, from the workspace
Whether a program assembles ipu-as check runtime, from the workspace
Each token's role, each word's slot fit, each Jinja tag's names ipu-as check --json --json-version 2 (analysis) runtime, from the workspace
The same, without such a checker isa.json and the editor's own rules (fallback/) as isa.json
isa.json itself (hover, completion, signature help, slot fit, formatting) the checkout's ISA (ipu-gen vscode-data), else data/isa.json runtime, else extension build

None of it is hand-written but the fallback rules, which read only isa.json. Build-time knowledge is bundled as data/isa.json; runtime knowledge comes from the open checkout, so branch-only kernels and instructions show up.

Which ISA

On a branch that changes the ISA, the bundled data/isa.json (built from master) would disagree with the checkout's assembler: hover would call an instruction unknown that assembles cleanly. So in a trusted workspace a checkout's own ISA is used. It is generated with bazel run //src/ipu-gen:ipu-gen -- vscode-data <cache> (language-source.js) the first time a file of that checkout is opened, and again after the sources it is generated from change (the ISA, the assembler and the generator). The cache lives in the extension's global storage, so the next window reads it at once. The bundled data answers until the checkout's is ready; then hover, completion and the rest switch over.

The bundled data is used, and the status bar adds (bundled ISA) (its tooltip says why), when:

  • the file is in no checkout;
  • the workspace is in Restricted Mode;
  • generation is running or failed;
  • the checkout's isa.json has a newer layout (schemaVersion) than this extension reads. A warning then says once to update the extension.

ipuAsm.languageSource forces a source: checkout uses the checkout's ISA and warns when generating it fails; bundled never generates. Only editing help follows the setting: the TextMate grammar (highlighting) is always the bundled one.

Generated, not written

The TextMate grammar in syntaxes/ is generated by ipu_gen/vscode_data.py from two sources, and it is worth being precise about which is which:

  • Structure — comments, ; / ;;, :, the identifier shape — from get_parser().terminals via pattern.to_regexp(). No token text is restated.
  • Vocabulary — which identifiers are instructions or registers — from instruction_spec.py and the register enums.

The vocabulary cannot come from the parser: asm_grammar.lark has a single catch-all TOKEN terminal, so the parser genuinely does not distinguish HALT from lr0 from my_label. Neither layer is written by hand; both are enumerated.

This matters because the previous, hand-written grammar drifted from the language: it coloured BEQ lr0, cr0, +1;; as valid (commas are a lex error) and failed to recognise end: in HALT;; end: HALT;; as a label. Nothing detected either, because nothing compared the grammar to the parser. That is what the agreement test below now does.

Edits reflect automatically on the next build:

Change Effect
A terminal's value in asm_grammar.lark picked up automatically
An instruction added to instruction_spec.py picked up automatically
A new terminal named COMMENT_* / STRING_* / PUNCT_* / WS_* scoped by convention
A new terminal with an unrecognised name build fails, naming the terminal

The last row is the one manual step, and it is deliberate: nothing can guess what colour a brand-new lexical concept should be, so the build stops at the moment of the change rather than quietly leaving it unhighlighted.

Regenerate

bazel run //vscode-ipu-asm:gen_vscode

syntaxes/ipu-asm.tmLanguage.json, language-configuration.json and data/isa.json are build outputs and are not committed.

The agreement test

test/agreement.js tokenizes a corpus twice — once with the Lark parser, once with the exact engine VS Code ships (vscode-textmate + vscode-oniguruma) — and fails on any disagreement about a token's boundaries or role. It runs in .github/workflows/vscode-extension.yml.

The Jinja layer is checked on the raw files: every {# … #}, {% … %} and {{ … }} (even in an assembly comment) must carry its Jinja scope and nothing else may. The regions come from ipu_as.language_service, which reads them with Jinja's own lexer (the same regions ipu-as check --json --json-version 2 --jinja prints), so the test checks the editor against Jinja, not against a copy of the editor's algorithm.

Kernels aside, test/corpus/edge_cases.asm covers constructs they happen not to use (mid-line labels, labels spelled like mnemonics, every numeric base). It must keep assembling; a change that breaks it is a real grammar regression.

Analysis from the checkout

With a checkout whose assembler speaks version 2 of the check --json contract, the editor's analysis comes from that assembler, not from the extension. One run per document version answers every provider:

ipu-as check --json --json-version 2 --tokens --words --jinja --input -

analysis.js (AnalysisClient) asks each checker command once which contract versions it speaks (ipu-as check --json-versions), per checkout, and again only after that checkout's assembler sources change; a probe that runs out of time counts as version 1 for a minute. An assembler from before versions exits 2 on that option: it is run as version 1, which gives diagnostics only, and no error is shown. A checker command of another shape (a configured ipuAsm.checkCommand that does not end in check … --json --input) is run as written, as version 1.

Each document version's answer is kept by document and version and read by every provider, so asking for hover, completion, tokens and the outline runs nothing more; a rename checks only the renamed text. The contract counts columns and offsets in code points; the extension converts them to VS Code's UTF-16 positions (they differ only past the Basic Multilingual Plane). An answer that lacks an analysis it was asked for (the analysis failed; an internal diagnostic says why) shows its diagnostics, and the providers fall back.

v2 checkout v1 checkout, no checkout, Restricted Mode
Diagnostics the assembler's the assembler's (v1); none without a checker
Words that do not fit their slots the assembler's first, as an error; every other, from words, as information (ipu-as (slot fit)) the assembler's first only
Semantic tokens (mnemonic, register, enum, number, label, comment) the assembler's tokens none: the grammar's colours
Mnemonics that fit the word, in completion the assembler's words (slots after pseudo-instructions and {{ }} expand); fallback/ while the source does not parse or render fallback/ on isa.json
Jinja names: completion, rename, definition, references, hover, inlay values, unused, outline the assembler's jinja (names as Jinja's parser reads them, the ipu:params header included) fallback/ (Jinja scoping written in JS)
Format Document, Format Selection the assembler's ipu-as format (the same rules, and a check that the result is the same program: a refusal edits nothing and says why), where the assembler has format and runs directly (the prebuilt binary or ipuAsm.checkCommand; not bazel run, at about 8s a run) and answers within 10s; else language.js language.js
Highlighting, operand hints, labels, formatting as you type, word separation, folding language.js (scan()) the same

Until a document's first answer arrives (the first paint), and with a version-1 checker, the providers answer at once from language.js and fallback/; faded names and inlay values are repainted when the answer comes. Completion, which cannot wait for a check, reads the latest answer, mapped across the edit since. The others, once a document has had an answer, wait for the one to the version on screen (up to 5 seconds), else answer from fallback/. Semantic tokens wait for it from the start: the grammar's colours show meanwhile.

The Jinja answer names which names each tag defines and uses, not how Jinja scopes them, so with it a name is one symbol across the file: a rename changes every use of the name (a macro parameter with the keyword arguments that pass it to that macro, not those to other callees such as dict(x=…) or an imported macro; never a filter | name or an attribute .name). That keeps the program the same as long as that reading of the tags holds, and the assembler checks the renamed text before it is applied. It refuses a new name used anywhere in the file's Jinja. A name only the ipu:params header declares belongs to the harness and is not renamed. Which definition is in force (hover, inlay values, completion) follows the tags' nesting: a definition inside a macro or for body counts only there.

Known gaps. test/analysis-agreement.js compares fallback/ with the assembler's answers in both directions; every difference is listed in test/fixtures/analysis-known-gaps.json and an unlisted one, or a listed one that no longer happens, fails the test. CI runs it on the committed recordings (test/fixtures/analysis-v2.json: 12 files and 16 snippets, 12 gaps); the list also covers a whole-corpus bundle recorded locally with test/record-analysis.js (112 files, 59 gaps in 21; at 5 MB it is not committed). They are:

  • the ipu:params header's names, which only the assembler reads;
  • a filter's name (x | length), which fallback/ counts as a use;
  • a keyword argument's name (m(dest=…), dict(x=…)), which fallback/ counts as a use of that name and the assembler as none;
  • a mnemonic glued to a tag (ACC.ADD{{ suffix }}), which fallback/ leaves to the template and the assembler reads as written;
  • words in an {% if %} branch the render does not take, which only fallback/ reads, and words a loop renders with and without the label before it, which the assembler lists once per range;
  • an unknown mnemonic, which fallback/ leaves out of the slot fit and the assembler counts as not fitting;
  • a source that does not render (a template error, a required ipu:params parameter), for which the assembler lists no tokens or words, and one that renders but does not parse, for which it lists tokens up to the error only, and no words (a character no token takes, such as 😀 outside a comment).

The completion filter counts free slots, as the assembler gave them, rather than replaying the fill order: next to a NOP it may offer a mnemonic that fits only once the NOP moves.

The other tests

Test Checks
test/checker.js which checker runs, when the prebuilt one is stale, and how a process that runs too long is stopped
test/project.js which IPU checkout a file or an open folder belongs to, if any
test/activation.js the extension activated on a stand-in vscode: nothing runs in Restricted Mode and trusting the workspace starts it; each checkout's status is its own; a failed check is retried; which checkout an unsaved or non-file document is checked in; activation touches the disk only asynchronously
test/language.js <isa.json> [parser-tokens.json] completion and navigation logic (language.js, fallback/), and agreement with the parser on the corpus
test/analysis.js the analysis client and each provider on recorded version-2 answers (fake-checker.js, fixtures/analysis-v2.json): positions in UTF-16, one check per document version (on the Bazel path too), every misfit word marked, a checker from before versions falling back silently, and no checker
test/formatting.js <isa.json> [<ipu-as> ...] the format provider over ipu-as format (formatting.js, on a stand-in fake-formatter.js): asked once whether it formats, its range read back, a refusal edits nothing, an assembler without format falls back; with an assembler, it formats the corpus as language.js does
test/language-source.js, test/languages.js which ISA a document's editing help reads (the checkout's, generated once per source change, or the bundled one) and why; the swap once it is generated; the status bar's (bundled ISA)
test/analysis-agreement.js <isa.json> [bundle.json] fallback/ against the assembler's analysis, both ways, but for the known gaps
test/runs.js [manifest.json] the run, test, debug, benchmark and query commands, against the real manifest; a manifest value that is no label or flag is refused
test/rewrites.js + check_rewrites renaming each label and Jinja symbol (with and without the assembler's analysis), and formatting, leaves the assembled binary unchanged
test/integration/run.js the extension in a real VS Code, then in a parent folder, another project and a pre-manifest checkout

Re-record the analysis fixtures when the assembler's answers or the recorded files change (test/record-analysis.js with the checker's argv; with files after it, it records a bundle of those instead, such as the whole corpus for analysis-agreement.js):

node vscode-ipu-asm/test/record-analysis.js vscode-ipu-asm/test/fixtures/analysis-v2.json \
  '["bazel", "run", "--ui_event_filters=-info,-stdout,-stderr", "--noshow_progress", "//src/ipu-as:ipu-as", "--", "check", "--json", "--input"]'
node vscode-ipu-asm/test/analysis-agreement.js vscode-ipu-asm/data/isa.json --write-gaps   # after review only

All run in the workflow. The integration test needs @vscode/test-electron (installed without saving) and a display (xvfb-run -a on a server); set IPU_TEST_CHECK_COMMAND to a checker argv to include checker-backed tests.

Publishing and versions

Every push to master that touches the extension or its inputs republishes it. The patch number is the workflow run number, applied on the runner only — the version in package.json is just the major/minor base.

Nothing is written back to the repository. A bumped package.json committed to master would land under this workflow's own paths filter and retrigger it, so the version is set at build time and thrown away.

Marketplace publishing needs a VSCE_PAT repository secret: an Azure DevOps personal access token scoped to Marketplace → Manage, issued for all accessible organizations. Without it the Marketplace step logs a note and skips — a missing secret should not fail an otherwise good build — and the GitHub release below still happens.

Install

Every push to master that changes the extension or the sources its language data is generated from republishes the vscode-latest prerelease:

curl -LO https://github.com/rechefe/ipu-emulator/releases/download/vscode-latest/ipu-asm.vsix
code --install-extension ipu-asm.vsix

Features

  • Hover: an instruction's reference, a register's role, a Jinja name's value.
  • Semantic highlighting, with a version-2 checkout: each token coloured by the role the assembler gives it (a label spelled like a mnemonic is a label).
  • Completion: at an instruction start, the mnemonics that still fit the word (from the assembler's slot assignment, or without it, slots filled as ipu_as.encode.assign_slots does), each bringing its operands as tab stops named as the instruction spec names them; at an operand, what its type accepts, labels and fitting Jinja names, with an operand hint. A typed space opens it only at an operand, so Enter still ends a line. Templates are read as one rendering ({% if %} branches are alternatives).
  • Values inline: {{ lr_row }} shows the literal value in force there (lr1).
  • Unused names faded: a label nothing branches to, or a set nothing reads. A name written anywhere else in the file counts as used.
  • Navigation and rename for labels and Jinja set / macro / for names and parameters (see Analysis from the checkout for how they are scoped). Rename refuses a clash or a change that the assembler reports as a new problem (without the assembler it proceeds on the lexical check and says so). Outline and folding too.
  • Formatting: a label at column 0 on its own line, instructions one indent in, one ;; word per line; nothing but that whitespace changes, and every kernel is already formatted. A checkout's assembler formats the document or selection (ipu-as format) where it can. Typing indents after a label, splits code after a typed ;; and moves a label to column 0 on :.
  • Buttons on a kernel's .asm: Run (bazel run <target> -- --case default), Debug (the same with --config=debug), Test (bazel test <target>) and Benchmark if it has one. They run in a terminal named after the kernel, reused only when its shell is idle.
  • Cases, in the sidebar (a case's pencil, a kernel's +): a form with a field per option, typed as the runner parses it, to run or debug a case with other values, edit a registry case, or add one that starts from a registry case. Saved cases go to ipuAsm.cases; kernel.toml is never written.
  • IPU sidebar: family, kernel and case with the same actions, and a query that asks the registry which kernel handles an operation. Both read //kernels:manifest, which joins Bazel's targets with the registry's cases and refuses if they disagree; it reloads when kernels or build files change. With several checkouts, each row acts on its own. While it is open, it selects the kernel whose .asm is in the editor.

Settings

Setting Default Purpose
ipuAsm.checkCommand Bazel the checker, as an argv (e.g. a virtualenv's ipu-as check --json --input)
ipuAsm.manifestCommand Bazel the command that prints the kernel manifest
ipuAsm.queryCommand Bazel the query command; --json, the operation and parameters are appended
ipuAsm.bazelFlags none extra flags for Run, Debug, Test and Benchmark, e.g. --define=ipu_proto=1
ipuAsm.cases none cases saved from the form, by kernel: { "tall": { "base": "default", "options": { "rows": 64 } } }
ipuAsm.timeoutSeconds 300 the longest the checker, the manifest or a query may run before it is stopped; 0 for no limit
ipuAsm.languageSource auto which ISA editing help reads (Which ISA): auto (the checkout's once generated, else the bundled one), checkout (the same, and a warning when generating fails), bundled
ipuAsm.wordSeparation space how ;; words are set apart (a label, comment or opening Jinja tag stays with its word): space (an empty CodeLens row; file unchanged), emptyLine (written by formatting), line (colour ipuAsm.wordSeparator) or none
ipuAsm.diagnostics true on/off switches, one per feature: the assembler's errors as you type (off: no check runs as you type, and the editing help reads the editor's own rules)
ipuAsm.hover true hover on instructions, registers and Jinja names
ipuAsm.completion true completion
ipuAsm.operandHints true operand hints (signature help)
ipuAsm.jinjaValueHints true a set name's literal value after each {{ name }}: {{ lr_row }} lr1
ipuAsm.unusedNames true fading unused labels and set names
ipuAsm.navigation true Go to Definition, Find References and Rename
ipuAsm.outline true the Outline and breadcrumbs
ipuAsm.folding true folding of comments and Jinja blocks
ipuAsm.formatting true Format Document and format on type
ipuAsm.kernelButtons true Run, Debug, Test and Benchmark buttons on a kernel's .asm
ipuAsm.sidebar true the IPU sidebar

Restricted Mode

VS Code opens a folder it has not been told to trust in Restricted Mode. There, the folder's own files would choose what runs: its .vscode/settings.json can set ipuAsm.checkCommand, ipuAsm.manifestCommand, ipuAsm.queryCommand and ipuAsm.bazelFlags, and its BUILD files decide what bazel does. So in Restricted Mode the extension runs nothing:

  • Works: highlighting, hover, completion, operand hints, navigation, rename (on its lexical check, and it says so), formatting, all on the bundled ISA.
  • Off: diagnostics, the kernel sidebar and its buttons, Run, Debug, Test, Benchmark and query. The status bar shows $(shield) IPU: Restricted Mode (bundled ISA); clicking it opens VS Code's trust settings.

VS Code also ignores the four settings above when a Restricted Mode workspace sets them. Trusting the workspace starts the checker and loads the kernels at once, with no reload.

Whatever the trust, a kernel manifest value that reaches a terminal (a target, a family's test suite, an option's flag) must be a Bazel label or a plain flag and is quoted; anything else is refused with an error and nothing is run.

Diagnostics

The grammar colours tokens; it cannot say a program is wrong. A TextMate rule assigns scopes to spans and has no notion of what the grammar expects next, and validity is not a lexical property — whether a comma is legal depends on the parser's state, not on the characters. BEQ lr0, cr0, +1;; would be coloured perfectly normally.

So checking.js runs the real assembler and turns its errors into squiggles, covering all three stages:

Example Reported at
template {% for x in %} the template line
parse BEQ lr0, cr0, +1;; the comma
encode BGT.S lr0 lr1;;, mac.ee r0;; the mnemonic

Templates render in Jinja's sandbox, as the assembler does, because a file is checked as soon as it opens; in Restricted Mode nothing is checked at all (see Restricted Mode). A template that expects harness values declares them in an ipu:params header; give each a default there so the file checks on its own (an undefined name is an error).

What ipu-as check --json prints is a versioned contract between the two: schema/check-json.md.

It shells out to ipu-as check --json rather than speaking LSP, which keeps the extension dependency-free — no vscode-languageclient, no bundled node_modules, and the vsix stays a few kilobytes.

By default the extension builds //src/ipu-as:ipu-as in the background when the workspace opens, then runs the resulting binary directly. This avoids Bazel's client startup and workspace lock while typing. It compares the binary with the assembler sources, and compares again only once a file watcher reports a source change (or the binary is rebuilt); if the binary is missing or the sources are newer, checks fall back to bazel run, which rebuilds it, and later checks use the binary directly again.

test/checker.js covers this selection and freshness rule and runs in .github/workflows/vscode-extension.yml.

To bypass Bazel entirely, point ipuAsm.checkCommand at a virtualenv instead:

"ipuAsm.checkCommand": [".venv/bin/ipu-as", "check", "--json", "--input"]

The file path is appended to whatever you configure.

When diagnostics are not running

A broken toolchain must not paint the file red — that would be a diagnostic about the environment masquerading as one about the code. But it must not be silent either: "checker unavailable" and "your code is fine" look identical, and silence is the worse failure.

So a status bar item reports which state you are in — $(check) IPU when diagnostics are live, $(warning) IPU: checks off when they are not. Clicking it, or running IPU Assembly: Why are diagnostics not running?, gives the reason. With several checkouts open, it shows the active editor's: each checkout has its own toolchain. A check that failed is run again on the next save or IPU Assembly: Check current file, even if the text has not changed.

An unsaved buffer is checked in the window's checkout when there is exactly one, and not at all when there are several. A git diff view is checked in the checkout holding its file; a document with no file on disk is not checked.

The most common reason: ipu-as check is added by the same change as this extension, so a workspace on a branch predating it has no check subcommand and diagnostics cannot run there. Highlighting still works — that is self-contained in the vsix.

ipu-as check is a normal CLI too: it exits 1 on problems and prints file:line:col: error: …, so it works in a pre-commit hook or CI.

Positions inside Jinja templates

The parser only ever sees rendered text, so a byte offset in what it parsed has no general relationship to the file on screen — loops repeat lines, conditionals drop them, whitespace control joins them.

Rather than guess afterwards by matching line content, the checker renders the template a second time with each line tagged by its own line number. The tags are # comments, so they are invisible to the parser, and Jinja carries them through whatever it does to the text — so a diagnostic names the source line exactly, including inside a loop body or below a block of {%- set -%} aliases. The tagged render is used only when it is equivalent to the real one.

Where a construct cannot be tagged safely, or an error carries no position at all, the diagnostic says so with (position approximate) rather than implying byte accuracy.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft