Tree-sitter LLVM
A Tree-sitter grammar for LLVM IR assembly (.ll). This parser aims to closely follow LLVM's textual IR as parsed by LLParser, including modules, functions, types, instructions, attributes, metadata, and more.
Highlights and captures are provided in queries/highlights.scm.
Installation
-
Node.js
- npm install tree-sitter-llvm
- Usage:
- const Parser = require('tree-sitter');
- const llvm = require('tree-sitter-llvm');
- const parser = new Parser();
- parser.setLanguage(llvm);
- const tree = parser.parse('%x = alloca i32');
-
Rust
- Cargo.toml:
- tree-sitter-llvm = "1.1.0"
- Usage:
- let mut parser = tree_sitter::Parser::new();
- let language = tree_sitter_llvm::LANGUAGE;
- parser.set_language(&language.into()).unwrap();
- Cargo.toml:
-
Python (tree-sitter >= 0.25)
- pip install tree-sitter-llvm
- Usage:
- from tree_sitter import Language, Parser
- import tree_sitter_llvm
- parser = Parser()
- parser.set_language(Language(tree_sitter_llvm.language()))
-
C
- Include bindings/c/tree-sitter-llvm.h and link the generated parser in src/.
- The language symbol is: const TSLanguage *tree_sitter_llvm(void);
-
Go
- The binding is in bindings/go. Example with go-tree-sitter:
- import (
- "github.com/tree-sitter/go-tree-sitter"
- llvm "path/to/this/repo/bindings/go"
- )
- parser := sitter.NewParser()
- parser.SetLanguage(sitter.NewLanguage(llvm.Language()))
- import (
- The binding is in bindings/go. Example with go-tree-sitter:
-
Swift (SwiftPM)
- Add this repository as a dependency and use TreeSitterLlvm target.
- Example:
- import SwiftTreeSitter
- import TreeSitterLlvm
- let parser = Parser()
- let language = Language(language: tree_sitter_llvm())
- try parser.setLanguage(language)
Status and scope
- Language name: llvm (as used by grammar.js)
- Targets LLVM IR textual format (.ll). MIR is out of scope.
- Grammar rules are modeled after LLVM's LLParser constructs (target definitions, declarations/definitions, instructions incl. alloca, getelementptr, phi, cmpxchg, atomicrmw, br; comdat; metadata; summaries; attributes; etc.).
Queries
- queries/highlights.scm contains basic highlighting captures for common editors that consume Tree-sitter queries.
Development
- Prerequisites: Node.js, npm, and tree-sitter-cli (npx tree-sitter works via devDependencies)
- Generate/rebuild parser C sources:
- npx tree-sitter generate
- Run grammar tests (corpus under test/corpus):
- npx tree-sitter test
- Rust tests (ensures the language loads):
- cargo test
- Python tests:
- pip install -e .[core]
- pytest bindings/python/tests
- Swift tests:
- swift test
Example
- See example/ and test/corpus for sample LLVM IR snippets and expected parses.
Contributing
- Issues and PRs are welcome. Please run tree-sitter tests and format code before submitting.
License
- MIT (see LICENSE)
Acknowledgements
- Based on LLVM's existing bindings and textual IR structure: https://github.com/llvm/llvm-project/blob/main/llvm/utils/
Metadata
Release files for tree-sitter-llvm 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tree_sitter_llvm-1.1.0.tar.gz | 404.7 kB | Without provenance | Details for tree_sitter_llvm-1.1.0.tar.gz |
Built distributions (wheels)
Total release size: 1.5 MB
Release files / tree_sitter_llvm-1.1.0.tar.gz
| Download URL | tree_sitter_llvm-1.1.0.tar.gz |
|---|---|
| Size | 404.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b51d82413afd1738e75e2d766abc78ecf63ed77696c4dbd6d3d954881a9b1b1
|
|
BLAKE2b-256 checksum How to use checksums |
d1502e43a514dbaa5c525d419b22cadaa89b1665590d6bcf7fbb512472aa4002
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / tree_sitter_llvm-1.1.0-cp38-abi3-win_arm64.whl
| Download URL | tree_sitter_llvm-1.1.0-cp38-abi3-win_arm64.whl |
|---|---|
| Size | 145.9 kB |
| Tags | CPython 3.8 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
dcbaee9705715fd18f10612c6564e0acf8ab32c51828730b5d6161ab2f3725e3
|
|
BLAKE2b-256 checksum How to use checksums |
1485377f3a9255e05a248b3806628285e440e5d20e854f51f427d621b0b4ad6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / tree_sitter_llvm-1.1.0-cp38-abi3-win_amd64.whl
| Download URL | tree_sitter_llvm-1.1.0-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 153.6 kB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cf8b35a7e7025b2cb8902d9ad8ac6cf1b5043648dd33409ad1937ea42f6b8b28
|
|
BLAKE2b-256 checksum How to use checksums |
b4c9084dbcab733bdf0c3d14688decd578a02420ab3edab19c92419173ee5b57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / tree_sitter_llvm-1.1.0-cp38-abi3-musllinux_1_2_x86_64.whl
| Download URL | tree_sitter_llvm-1.1.0-cp38-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 163.2 kB |
| Tags | CPython 3.8 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8045bbe6474c88e6e2e8217a636c8cda0c48d56c9a35af446e27325e9b970585
|
|
BLAKE2b-256 checksum How to use checksums |
86ed34fa3e32cf0f262b461d6a3030b42b8eff49fb42847311fadff15c31210f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / tree_sitter_llvm-1.1.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | tree_sitter_llvm-1.1.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 162.4 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d81b31b4d2d476db6fa1d92b890564195552673a59c096f590fefc088ceb5885
|
|
BLAKE2b-256 checksum How to use checksums |
edfdddbac1ac922b488712061894cb77f9c34477b65880b39265a61175c8a772
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / tree_sitter_llvm-1.1.0-cp38-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | tree_sitter_llvm-1.1.0-cp38-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 166.3 kB |
| Tags | CPython 3.8 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
68ece3c0c6cd6f7f3bf259e5d5ff5e47545e878dd8f49458797e708cab22bd39
|
|
BLAKE2b-256 checksum How to use checksums |
dbb2b19fa2f2fa73dbab072237401685ce28a7d78a7d8999f1ba7686631770b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / tree_sitter_llvm-1.1.0-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | tree_sitter_llvm-1.1.0-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 160.1 kB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
beb184ad2e7f78e0df79c59ce6d2ac2baf3f0aaaf88abcc4726b37344bd50c3d
|
|
BLAKE2b-256 checksum How to use checksums |
f07f1d08a444dc7257659e83714b93706b2f5fc886339b7dff6f32df0d87ac81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / tree_sitter_llvm-1.1.0-cp38-abi3-macosx_10_9_x86_64.whl
| Download URL | tree_sitter_llvm-1.1.0-cp38-abi3-macosx_10_9_x86_64.whl |
|---|---|
| Size | 146.3 kB |
| Tags | CPython 3.8 abi3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
ee10b08af8c30ec199ffcde6934885f9b375d7e26b0a5364e61e122170ce5701
|
|
BLAKE2b-256 checksum How to use checksums |
6282a5d8aaf650339f196d85b5ed6e8951bb2b96d3013016bc0339835ff820df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for tree-sitter-llvm 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.