{"id":25171640,"url":"https://github.com/basemax/firstllvmc","last_synced_at":"2025-05-05T21:09:20.835Z","repository":{"id":49467185,"uuid":"377512888","full_name":"BaseMax/FirstLLVMC","owner":"BaseMax","description":"Generate object code and IR code of a simple program using LLVM in Pure C.","archived":false,"fork":false,"pushed_at":"2021-06-17T01:17:58.000Z","size":29,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-04T21:45:38.475Z","etag":null,"topics":["c","compiler","compiler-design","llvm","llvm-bitcode","llvm-c","llvm-compiler","llvm-frontend","llvm-ir","llvm-tutorial"],"latest_commit_sha":null,"homepage":"https://github.com/One-Language/","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/BaseMax.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}},"created_at":"2021-06-16T13:52:16.000Z","updated_at":"2024-04-10T19:50:09.000Z","dependencies_parsed_at":"2022-09-01T02:32:09.800Z","dependency_job_id":null,"html_url":"https://github.com/BaseMax/FirstLLVMC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstLLVMC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstLLVMC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstLLVMC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstLLVMC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/FirstLLVMC/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252577003,"owners_count":21770721,"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","compiler-design","llvm","llvm-bitcode","llvm-c","llvm-compiler","llvm-frontend","llvm-ir","llvm-tutorial"],"created_at":"2025-02-09T09:21:25.660Z","updated_at":"2025-05-05T21:09:20.788Z","avatar_url":"https://github.com/BaseMax.png","language":"C","readme":"# First LLVM in C (Not C++)\n\nGenerate object code and IR code of a simple program using LLVM in Pure C.\n\n## Features\n\n- My best attempt to write well documented code\n- Design `strlen(char* s)` function\n- Extern `printf` function\n- Call `printf` function\n- Show **Hello, {WORLD}**\n- Print **IR** LLVM code\n- Generate object code in a file\n- You are able to easily build an executable file using a linker\n\n## AIM\n\nI'm working on compiler projects for some recent years and it's why I'm studying more about the compiler field.\n\nWe are working on the [ONE Language](https://github.com/One-Language/) with the team.\n\n## Output of running the program\n\n**max@workstation ~]$ ./llvm**\n\n```\n; ModuleID = 'module-c'\nsource_filename = \"module-c\"\n\n@format = private unnamed_addr constant [12 x i8] c\"Hello, %s.\\0A\\00\", align 1\n@name = private unnamed_addr constant [9 x i8] c\"Max Base\\00\", align 1\n@format2 = private unnamed_addr constant [20 x i8] c\"own_len(Name) = %d\\0A\\00\", align 1\n\ndefine i32 @strlen(i8* %s) {\ninit:\n  %i = alloca i32, align 4\n  store i32 0, i32* %i, align 4\n  br label %check\n\ncheck:                                            ; preds = %body, %init\n  %0 = load i32, i32* %i, align 4\n  %1 = getelementptr i8, i8* %s, i32 %0\n  %2 = load i8, i8* %1, align 1\n  %3 = icmp ne i8 0, %2\n  br i1 %3, label %body, label %end\n\nbody:                                             ; preds = %check\n  %4 = load i32, i32* %i, align 4\n  %5 = add i32 %4, 1\n  store i32 %5, i32* %i, align 4\n  br label %check\n\nend:                                              ; preds = %check\n  %6 = load i32, i32* %i, align 4\n  ret i32 %6\n}\n\ndeclare i32 @printf(...)\n\ndefine void @main() {\nentrypoint:\n  %printf = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @name, i32 0, i32 0))\n  %0 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @name, i32 0, i32 0))\n  %1 = call i32 (...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @format2, i32 0, i32 0), i32 %0)\n  ret void\n}\n```\n\n--------\n\nMax Base 2021, An attempt to rewrite and design a compiler by LLVM at C (Not c++) based on studies.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Ffirstllvmc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Ffirstllvmc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Ffirstllvmc/lists"}