{"id":14991129,"url":"https://github.com/cr0a3/ygen","last_synced_at":"2025-04-06T07:14:57.438Z","repository":{"id":247422559,"uuid":"825804877","full_name":"Cr0a3/ygen","owner":"Cr0a3","description":"Ygen - Yet another code generation libary (abandoned; gained two internships from it)","archived":false,"fork":false,"pushed_at":"2025-04-02T13:48:33.000Z","size":7454,"stargazers_count":107,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T07:14:52.657Z","etag":null,"topics":["codegen","compiler","llvm"],"latest_commit_sha":null,"homepage":"https://ygen.vercel.app/","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/Cr0a3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Cr0a3"}},"created_at":"2024-07-08T14:29:45.000Z","updated_at":"2025-04-05T23:01:11.000Z","dependencies_parsed_at":"2024-09-24T16:05:46.490Z","dependency_job_id":"bbbef180-945c-4e21-a533-a0a716353cd6","html_url":"https://github.com/Cr0a3/ygen","commit_stats":{"total_commits":226,"total_committers":4,"mean_commits":56.5,"dds":"0.27876106194690264","last_synced_commit":"0d93a23a113cfef4d4a72ddafede6e04fc3bfae1"},"previous_names":["toni-graphics/ygen","cr0a3/ygen"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cr0a3%2Fygen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cr0a3%2Fygen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cr0a3%2Fygen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cr0a3%2Fygen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cr0a3","download_url":"https://codeload.github.com/Cr0a3/ygen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445681,"owners_count":20939961,"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":["codegen","compiler","llvm"],"created_at":"2024-09-24T14:21:31.644Z","updated_at":"2025-04-06T07:14:57.417Z","avatar_url":"https://github.com/Cr0a3.png","language":"Rust","funding_links":["https://github.com/sponsors/Cr0a3"],"categories":[],"sub_categories":[],"readme":"# Ygen - Yet another Code Generator\n![GitHub branch check runs](https://img.shields.io/github/check-runs/Cr0a3/ygen/main?style=flat-square\u0026label=build)\n![Crates.io Version](https://img.shields.io/crates/v/Ygen?style=flat-square)\n![GitHub Repo stars](https://img.shields.io/github/stars/cr0a3/ygen?style=flat-square)\n\nWelcome to Ygen!\nThis repository contains the source code of the ygen project.\n\nYgen is a toolkit for building modern compilers, using a llvm like api.\n\n## Why ygen?\n\nYou are probably wondering: Why would I choose ygen and not llvm?\nHere are a few reasons:\n\n- **Simplicity**: One of ygens main focus is simplicity which means to us that as much code as possible is readable and shared\n- **Similare API**: Ygens API is very similar to LLVMs API. For example all function names for building ir are nearly the safe as llvms.\n- **Simple start**: You can easily start with ygen. You do not need to install any dlls, or build it. Ygen also has many simple examples.\n\n\u003e [!WARNING]\n\u003e This project is still early in its developement. Bugs and miscompilations are expected. \u003cbr\u003e\n\u003e ONLY USE YGEN FOR TOY COMPILERS\n\n\n### Contributions\n\n![Contribution activity](https://repobeats.axiom.co/api/embed/70cb0d167ed0a296468773b0bf8d569f74d1b33a.svg \"Repobeats analytics image\")\n\n### Simple example\nHere is a simple example on how to use Ygen to build an add function:\n```rust\nuse std::error::Error;\nuse Ygen::prelude::*;\n\npub fn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let mut module = Module();\n\n    let ty = FnTy(vec![TypeMetadata::i32, TypeMetadata::i32], TypeMetadata::i32);\n    \n    let func = module.add(\n        \"add\", \u0026ty\n    );\n\n    func.extrn();\n\n    func.addBlock(\"entry\");\n\n    let val = func.BuildAdd(ty.arg(0), ty.arg(1));\n    \n    func.BuildRet( val );\n\n    module.verify()?;\n\n    // prints out the ir of the module\n    println!(\"{}\", module.dump());\n\n    let triple = Triple::host();\n\n    // compiles the module in the host assembly and saves it in the specified path\n    module.emitToAsmFile(\n        triple,\n        \u0026mut initializeAllTargets(triple)?,\n        Path::new(\"out.asm\")\n    )?;\n\n    // compiles the module to a host object file\n    module\n        .emitMachineCode(\n            triple, \n            \u0026mut initializeAllTargets(triple)?,\n            false // is debugging metadata enabled\n        )?.0.emit(\n            OpenOptions::new().write(true).truncate(true).create(true).open(\"out.o\")?, \n            None // if debugging metadata is enabled here is the outputed metadata\n    )?;\n\n    Ok(())\n}\n```\nWhen executed this simple program builds an add function and dumps it's ir:\n```LLVM\ndefine i32 @add( i32 %0,  i32 %1 ) {\n entry:\n    %2 = add i32 %0, %1\n    ret i32 %2\n}\n```\n\n### Copyright\nThis project is owned by Cr0a3 and licensed under the Apache2 License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcr0a3%2Fygen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcr0a3%2Fygen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcr0a3%2Fygen/lists"}