{"id":21176946,"url":"https://github.com/madmann91/fir","last_synced_at":"2026-01-07T17:56:28.242Z","repository":{"id":195153069,"uuid":"692212068","full_name":"madmann91/fir","owner":"madmann91","description":"Functional IR","archived":false,"fork":false,"pushed_at":"2024-05-26T09:35:27.000Z","size":728,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T20:57:46.001Z","etag":null,"topics":["c","compiler","continuation-passing-style","intermediate-representation","type-system"],"latest_commit_sha":null,"homepage":"","language":"C","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/madmann91.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-09-15T20:22:36.000Z","updated_at":"2024-08-27T22:54:58.000Z","dependencies_parsed_at":"2025-01-21T11:40:17.213Z","dependency_job_id":null,"html_url":"https://github.com/madmann91/fir","commit_stats":null,"previous_names":["madmann91/fir"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmann91%2Ffir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmann91%2Ffir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmann91%2Ffir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madmann91%2Ffir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madmann91","download_url":"https://codeload.github.com/madmann91/fir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246358323,"owners_count":20764366,"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":["c","compiler","continuation-passing-style","intermediate-representation","type-system"],"created_at":"2024-11-20T17:14:01.802Z","updated_at":"2026-01-07T17:56:28.216Z","avatar_url":"https://github.com/madmann91.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo](logo.svg)\n\n![Workflow status](https://github.com/madmann91/fir/actions/workflows/build-test-action.yml/badge.svg)\n\n# Fir\n\nFir is a functional intermediate represention (IR) with a graph-based design written completely in\nC. Here are a few features that differentiate this IR from similar projects:\n\n- It is entirely graph-based. In particular, instruction ordering is determined automatically via a\n  scheduling algorithm based on C. Click's \"Global Code Motion/Global Value Numbering\" article. The\n  algorithm used in this IR is an extension that does not generate partially-dead code and treats\n  operations with side-effects correctly.\n- Functions and basic-blocks are both encoded as functions in the IR, simplifying the implementation\n  and making optimizations more aggressive. For instance, some optimizations that apply to functions\n  can also be applied to basic-blocks without requiring any change. Calls and jumps are essentially\n  the same in the IR, only the return type determines whether the called function is a basic block\n  or not.\n- The IR supports functional programs: Functions are first-class citizens, meaning that they can be\n  passed as values to other functions. Closure conversion happens at the IR level and is responsible\n  for lowering any higher-order functions to first-order ones.\n- Due to being written in C, this project is very lightweight both at compile- and run-time. The\n  entire project compiles in around 5s on a Ryzen 2700U from 2019.\n- A small language (ash) that showcases the features of the IR is provided for testing and as an\n  example of how to use the API.\n\nThis project is inspired by [Thorin](https://github.com/AnyDSL/thorin), a project I used to worked\non, and by [libfirm](https://github.com/libfirm/libfirm), another compiler IR in C.\n\n## Building\n\nThis project requires a C23-compliant compiler and CMake. Optionally, it may use PCRE2 if it detects\nit for the unit test suite. The following commands build the project:\n\n    mkdir build\n    cd build\n    cmake -DCMAKE_BUILD_TYPE=\u003cDebug|Release\u003e ..\n    make\n\n## Testing\n\nOnce built, the project can be tested via:\n\n    make test\n\nor, alternatively, when trying to debug memory leaks or other memory errors with a memory checker:\n\n    make memcheck\n\n## Documentation\n\nThe project supports doxygen for the publicly visible API. This can be generated either by calling\ndoxygen from the `doc` directory or by typing `make doc` using the CMake-generated Makefile (see\ninstructions above to build using CMake).\n\n## License\n\nThis project is distributed under the [GPLv3](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadmann91%2Ffir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadmann91%2Ffir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadmann91%2Ffir/lists"}