{"id":18238259,"url":"https://github.com/williamfedele/crucible","last_synced_at":"2025-08-09T01:53:30.803Z","repository":{"id":260956218,"uuid":"882518285","full_name":"williamfedele/crucible","owner":"williamfedele","description":"🦀 Simple compiler written to learn about IR and optimization techniques","archived":false,"fork":false,"pushed_at":"2025-01-21T04:03:59.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T16:11:14.058Z","etag":null,"topics":["compiler","compiler-design","compiler-optimization","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/williamfedele.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2024-11-03T01:40:16.000Z","updated_at":"2025-01-21T04:04:02.000Z","dependencies_parsed_at":"2025-01-21T04:35:04.031Z","dependency_job_id":null,"html_url":"https://github.com/williamfedele/crucible","commit_stats":null,"previous_names":["williamfedele/crucible"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/williamfedele/crucible","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfedele%2Fcrucible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfedele%2Fcrucible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfedele%2Fcrucible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfedele%2Fcrucible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamfedele","download_url":"https://codeload.github.com/williamfedele/crucible/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfedele%2Fcrucible/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269518573,"owners_count":24430637,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","compiler-design","compiler-optimization","rust","rust-lang"],"created_at":"2024-11-05T03:04:42.011Z","updated_at":"2025-08-09T01:53:30.754Z","avatar_url":"https://github.com/williamfedele.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr/\u003e\u003cbr/\u003e\n\u003cdiv\u003e\n    \u003ch3 align=\"center\"\u003e🦀 Crucible\u003c/h3\u003e\n    \u003cp align=\"center\"\u003e\n      A simple compiler written to learn about intermediate representation and optimization techniques.\n    \u003c/p\u003e\n\u003c/div\u003e\n\u003cbr\u003e\u003cbr\u003e\n\nThis project is purely for experimenting while I was researching compiler optimization techniques.\n\n```shell\ncargo run\n```\n\n1. The source is lexed to get tokens.\n2. Next the parser creates an abstract syntax tree.\n3. The AST is lowered into a Static Single Assignment format (SSA) as intermediate representation (IR).\n4. The IR is analyzed for optimizations. Optimizations implemented: dead code elimination, constant folding.\n\nExample source:\n```ts\nlet x: int = 3;\nlet unused: int = 0;\nlet y: int = x + 1;\nlet z: int = x * y / 2;\nz = z + 1;\n```\n\nInitial intermediate representation:\n```\n[\n    Constant { result: \"x.1\", value: 3 },\n    Constant { result: \"unused.1\", value: 0 },\n    Binary { result: \"y.1\", op: Add, left: \"x.1\", right: \"1\" },\n    Binary { result: \"bin.1\", op: Multiply, left: \"x.1\", right: \"y.1\" },\n    Binary { result: \"z.1\", op: Divide, left: \"bin.1\", right: \"2\" },\n    Binary { result: \"z.2\", op: Add, left: \"z.1\", right: \"1\" }\n]\n```\n\nDead code eliminated (remove code that can't affect the program):\n```\n[\n    Constant { result: \"x.1\", value: 3 },\n    Binary { result: \"y.1\", op: Add, left: \"x.1\", right: \"1\" },\n    Binary { result: \"bin.1\", op: Multiply, left: \"x.1\", right: \"y.1\" },\n    Binary { result: \"z.1\", op: Divide, left: \"bin.1\", right: \"2\" }\n]\n```\n\nConstant folding (identify and evaluate constant expressions at compile time):\n```\n[\n    Constant { result: \"x.1\", value: 3 },\n    Constant { result: \"y.1\", value: 4 },\n    Constant { result: \"bin.1\", value: 12 },\n    Constant { result: \"z.1\", value: 6 }\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamfedele%2Fcrucible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamfedele%2Fcrucible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamfedele%2Fcrucible/lists"}