{"id":18960976,"url":"https://github.com/sheredom/yair","last_synced_at":"2025-04-19T10:59:57.119Z","repository":{"id":45478802,"uuid":"176610362","full_name":"sheredom/yair","owner":"sheredom","description":"🦜 yair - a high-level compiler IR entirely written in Rust","archived":false,"fork":false,"pushed_at":"2021-12-11T20:03:50.000Z","size":735,"stargazers_count":38,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T12:38:49.042Z","etag":null,"topics":["intermediate-representation","ir","rust"],"latest_commit_sha":null,"homepage":"https://sheredom.github.io/yair","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sheredom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["sheredom"]}},"created_at":"2019-03-19T22:47:27.000Z","updated_at":"2025-02-07T10:42:12.000Z","dependencies_parsed_at":"2022-07-16T14:30:42.516Z","dependency_job_id":null,"html_url":"https://github.com/sheredom/yair","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheredom%2Fyair","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheredom%2Fyair/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheredom%2Fyair/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sheredom%2Fyair/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sheredom","download_url":"https://codeload.github.com/sheredom/yair/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249195373,"owners_count":21228186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["intermediate-representation","ir","rust"],"created_at":"2024-11-08T14:10:46.618Z","updated_at":"2025-04-16T04:32:29.977Z","avatar_url":"https://github.com/sheredom.png","language":"Rust","funding_links":["https://github.com/sponsors/sheredom"],"categories":[],"sub_categories":[],"readme":"# 🦜 yair\n\n[![Actions Status](https://github.com/sheredom/yair/workflows/Rust/badge.svg)](https://github.com/sheredom/yair/actions)\n[![Crates.io](https://img.shields.io/crates/v/yair.svg)](https://crates.io/crates/yair)\n[![API Docs](https://docs.rs/mio/badge.svg)](https://docs.rs/yair)\n\n**Y**et **A**nother **I**ntermediate **R**epresentation (pronounced Yarrrr! (like a pirate!)) is a compiler intermediate representation written entirely in Rust. Key design decisions make the representation unique:\n\n- Single Static Assignment representation [\\[1\\]](#References-1).\n- No Φ (phi) nodes, basic blocks take arguments instead [\\[2\\]](#References-2).\n- Target agnostic representation for de-coupling of components.\n- Strong seperation between library components (you don't need to build, link, or use components you don't need).\n\n## TODOs\n\n- Core:\n  - Add per-domain functions and function multi-versioning.\n- Verifier:\n  - When we have per-domain functions (CPU-only for instance) check for:\n    - Recursion.\n    - Calling a function in a conflicting domain (call GPU from CPU).\n  - Maybe restrict variables to non-any non-gpu?\n    - At the least we should have some form of thread_local (shared) variables, and cpu globals too. But any else doesn't really make sense I think?\n  - Check for casts to the same type as the value.\n  - Check for pointers in invalid domains being inside pointers of other domains (like stack pointer being stored into CPU memory).\n  - Check that blocks have correct terminating instructions (ret/br/etc).\n- Add a cranelift code generation library.\n- Add an optimizer!\n- Explain the syntax of the IR:\n  - Globals and structs both use `%name` to differentiate them from other symbols.\n- Verify that all statements in a block are reachable from the tree of blocks above.\n- Verify that a block doesn't have any instructions after a terminator.\n- Verify that names are all valid.\n\n## Features\n\nThe following features are present in the yair crate.\n\n### io\n\nThe 'io' feature is a **default** feature of the yair crate. It lets you consume and produce binary or textual intermediate representation files from yair. This allows for inspection, testing, and serialization to the intermediate representation.\n\nWhen this feature is enabled, two additional binaries are produced alongside the library crate - `yair-as` and `yair-dis`, allowing for assembling and disassembling of the intermediate representation between the human readable textual form, and the binary form.\n\nAdditionally, there is a `yair::io` module that lets users read/write the textual or binary representation into a yair `Library` that they can work with.\n\n#### .yail Files\n\nThe human readable representation of yair are .yail files. An example file is:\n\n```\nmod \"😀\" {\n  fn foo(a : i64, b : i64) : i64 {\n    bar(a : i64, b : i64):\n      r = or a, b\n      ret r\n  }\n}\n```\n\nConstants in .yail files are slightly strange - constants as used in the `Library` object are unique per the value and type combination for that given constant. But in the intermediate representation, constants are treated like any other value within the body of a basic block:\n\n```\nmod \"😀\" {\n  fn foo(a : i64) : i64 {\n    bar(a : i64):\n      b = const i64 4\n      r = or a, b\n      ret r\n  }\n}\n```\n\nThis means that constants behave like regular SSA notes for the purposes of the intermediate representation.\n\n## References\n\n### References 1\n\n[Static single assignment form](https://en.wikipedia.org/wiki/Static_single_assignment_form).\n\n### References 2\n\nThis approach is similar in some ways to the Swift Intermediate Language approach - [Swift's High-Level IR: A Case Study of Complementing LLVM IR with Language-Specific Optimization.](https://llvm.org/devmtg/2015-10/#talk7)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheredom%2Fyair","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsheredom%2Fyair","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsheredom%2Fyair/lists"}