{"id":13667975,"url":"https://github.com/pku-minic/koopa","last_synced_at":"2025-04-26T18:30:51.221Z","repository":{"id":45165341,"uuid":"390193203","full_name":"pku-minic/koopa","owner":"pku-minic","description":"Library for generating/parsing/optimizing Koopa IR.","archived":false,"fork":false,"pushed_at":"2024-03-24T02:55:53.000Z","size":784,"stargazers_count":83,"open_issues_count":0,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T20:26:35.870Z","etag":null,"topics":["compiler","ir"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pku-minic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-28T02:57:50.000Z","updated_at":"2024-06-19T14:29:50.008Z","dependencies_parsed_at":"2024-06-19T14:29:43.491Z","dependency_job_id":"fe705221-2a4a-458e-9acd-aaf9dab40154","html_url":"https://github.com/pku-minic/koopa","commit_stats":{"total_commits":638,"total_committers":2,"mean_commits":319.0,"dds":"0.0015673981191222097","last_synced_commit":"70477b751c0aaa2413dcbca35bcf34ea0e7012c6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pku-minic%2Fkoopa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pku-minic%2Fkoopa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pku-minic%2Fkoopa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pku-minic%2Fkoopa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pku-minic","download_url":"https://codeload.github.com/pku-minic/koopa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251035188,"owners_count":21526319,"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":["compiler","ir"],"created_at":"2024-08-02T07:00:57.789Z","updated_at":"2025-04-26T18:30:51.200Z","avatar_url":"https://github.com/pku-minic.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Koopa\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-pku--minic/koopa-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/pku-minic/koopa)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/koopa.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/koopa)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-koopa-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logoColor=white\u0026logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K\" height=\"20\"\u003e](https://docs.rs/koopa)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/pku-minic/koopa/build-test.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/pku-minic/koopa/actions?query=branch%3Amaster)\n\nLibrary for generating/parsing/optimizing Koopa IR.\n\nKoopa IR is the next generation of education-oriented intermediate representation designed for compiler courses at Peking University.\n\n## Usage\n\n```\ncargo add koopa\n```\n\n## Koopa IR\n\nHere is a \"Hello, world!\" program in Koopa IR:\n\n```koopa\n// `putchar` function in libc.\ndecl @putchar(i32): i32\n\n// A helper function for printing strings (integer arrays).\nfun @putstr(@arr: *i32) {\n%entry:\n  jump %loop_entry(@arr)\n\n%loop_entry(%ptr: *i32):\n  %cur = load %ptr\n  br %cur, %loop_body, %end\n\n%loop_body:\n  call @putchar(%cur)\n  %next = getptr %ptr, 1\n  jump %loop_entry(%next)\n\n%end:\n  ret\n}\n\n// String \"Hello, world!\\n\\0\".\nglobal @str = alloc [i32, 15], {\n  72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0\n}\n\n// `main` function, the entry point of the program.\nfun @main(): i32 {\n%entry:\n  %str = getelemptr @str, 0\n  call @putstr(%str)\n  ret 0\n}\n```\n\nKoopa IR is a strongly-typed, SSA form based intermediate representation. It's simple but powerful enough to support compilation of code into machine instructions, or some advanced optimizations of it.\n\nFor more details, see [the document of Koopa IR](https://pku-minic.github.io/online-doc/#/misc-app-ref/koopa) (Chinese).\n\n## Examples\n\nSee the [`examples` directory](examples), which contains three examples:\n\n* [`opt`](examples/opt): a simple Koopa IR optimizer.\n* [`brainfuck`](examples/brainfuck): a brainfuck to Koopa IR compiler.\n* [`interpreter`](examples/interpreter): a simple Koopa IR interpreter.\n\nAnd there are some more complex examples:\n\n* [`kira-rs`](https://github.com/pku-minic/kira-rs): The Kira compiler (Rust version), which compiles SysY language into Koopa IR and RISC-V assembly.\n* [`kira-cpp`](https://github.com/pku-minic/kira-cpp): The Kira compiler (C++ version).\n\n## References\n\nKoopa IR library is heavily influenced by [LLVM](https://llvm.org/) and [Cranelift](https://wasmtime.dev/).\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md).\n\n## License\n\nCopyright (C) 2010-2024 MaxXing. License GPLv3.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpku-minic%2Fkoopa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpku-minic%2Fkoopa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpku-minic%2Fkoopa/lists"}