{"id":24440314,"url":"https://github.com/junlarsen/eight","last_synced_at":"2025-03-14T01:43:37.817Z","repository":{"id":271579362,"uuid":"901304707","full_name":"junlarsen/eight","owner":"junlarsen","description":"Toy compiler","archived":false,"fork":false,"pushed_at":"2025-02-15T15:12:28.000Z","size":1374,"stargazers_count":1,"open_issues_count":21,"forks_count":0,"subscribers_count":1,"default_branch":"trunk","last_synced_at":"2025-03-09T22:28:18.151Z","etag":null,"topics":["compiler","llvm"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/junlarsen.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-12-10T12:17:39.000Z","updated_at":"2025-02-15T15:12:28.000Z","dependencies_parsed_at":"2025-01-08T16:50:38.111Z","dependency_job_id":"d593c7be-2afa-4812-af16-a4a6162b1622","html_url":"https://github.com/junlarsen/eight","commit_stats":null,"previous_names":["junlarsen/eight"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junlarsen%2Feight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junlarsen%2Feight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junlarsen%2Feight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junlarsen%2Feight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junlarsen","download_url":"https://codeload.github.com/junlarsen/eight/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243508987,"owners_count":20302106,"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","llvm"],"created_at":"2025-01-20T20:54:22.159Z","updated_at":"2025-03-14T01:43:37.809Z","avatar_url":"https://github.com/junlarsen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eight\n\nEight is a toy programming language built to learn compiler infrastructure, optimization, and code generation. The\ncompiler compiles an imperative-style programming language with a static type system. It has great type inference and\nits semantics closely resemble the C programming language.\n\nThe compiler is written in Rust and uses LLVM as the primary code generator backend. Development of the compiler also\nrequires additional tools as described in [the Development secion](#development).\n\n**Current project status**: The frontend is mostly complete, and current work is on the mid-level IR and LLVM codegen.\n\n```rust\n// Naive O(MKN) matrix-matrix multiplication\nstruct Matrix {\n  r: i32,\n  c: i32,\n  buf: *i32,\n}\n\nfn matrix_matrix_multiply(a: Matrix, b: Matrix) -\u003e Matrix {\n  let c = new Matrix {\n    r: a.r,\n    c: b.c,\n    buf: malloc(a.r * b.c * 4),\n  };\n\n  for (let i = 0; i \u003c a.r; i = i + 1) {\n    for (let j = 0; j \u003c b.c; j = j + 1) {\n      let sum = 0;\n      for (let k = 0; k \u003c a.c; k = k + 1) {\n        sum = sum + a.buf[i * a.c + k] * b.buf[k * b.c + j];\n      }\n      c.buf[i * b.c + j] = sum;\n    }\n  }\n  return c;\n}\n```\n\n## Development\n\nThe compiler is written in Rust, and requires the LLVM Integrated Tester to run its test suite. The easiest way to get\nstarted is to install both Rust and Poetry (to download Lit).\n\nWe also have some developer tooling specifically built for Eight (like our Lit-based regression tester) which will be\nbuilt alongside the compiler with `cargo build --all`. This is important as the Lit configuration searches for these\nbinaries in order to execute the tests.\n\nThe scripts below will take care of all the requirements needed to get started with developing the compiler.\n\n```bash\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\ncurl -sSL https://install.python-poetry.org | python3 -\n\nsudo apt install llvm-18-dev llvm-18-tools clang-18 libpolly-18-dev\n# Configure llvm-sys to point at the installed LLVM\nexport LLVM_SYS_180_PREFIX=\"/usr/lib/llvm-18\"\n\n# Run unit tests\ncargo test\n\n# Install Lit, and run the integration test suite\npoetry install\ncargo xtask lit\n\n# If any of the regression snapshots were updated, review them with eight-regtest\ncargo regtest\n# Which is a workspace alias for\ncargo run --bin eightc-regtest -- verify tests\n```\n\nRunning the compiler is done through `cargo run --bin eightc`, or using the build output if you compile the project.\n\n```bash\nUsage: eightc [OPTIONS] \u003cINPUT\u003e\n\nArguments:\n  \u003cINPUT\u003e  The input source. If this is `-`, the input is read from stdin\n\nOptions:\n      --emit-ast                 Should the plain AST be emitted?\n      --emit-hir                 Should the fully-typed, lowered HIR be emitted?\n      --emit-mir                 Should the MIR be emitted?\n      --emit-query \u003cEMIT_QUERY\u003e  Emission queries to specify which nodes should be emitted\n      --terminator \u003cTERMINATOR\u003e  Stop the compiler after the given step [default: never] [possible values: never, syntax, hir, mir]\n  -h, --help                     Print help\n  -V, --version                  Print version\n```\n\n## License\n\nEverything in the repository is licensed under the Apache 2.0 License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunlarsen%2Feight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunlarsen%2Feight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunlarsen%2Feight/lists"}