{"id":15400280,"url":"https://github.com/indutny/bitcode","last_synced_at":"2025-04-15T22:30:43.673Z","repository":{"id":65990787,"uuid":"123741938","full_name":"indutny/bitcode","owner":"indutny","description":"Generate binary LLVM-compatible bitcode from JS","archived":false,"fork":false,"pushed_at":"2018-03-20T16:51:00.000Z","size":216,"stargazers_count":61,"open_issues_count":0,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T03:22:07.942Z","etag":null,"topics":["bitcode","llvm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/indutny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-03-04T00:02:14.000Z","updated_at":"2025-02-18T01:47:37.000Z","dependencies_parsed_at":"2023-02-28T11:15:49.188Z","dependency_job_id":null,"html_url":"https://github.com/indutny/bitcode","commit_stats":{"total_commits":126,"total_committers":1,"mean_commits":126.0,"dds":0.0,"last_synced_commit":"a1bca157612dc6ce5dad6ed85fb16f1df4735147"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indutny%2Fbitcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indutny%2Fbitcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indutny%2Fbitcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indutny%2Fbitcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indutny","download_url":"https://codeload.github.com/indutny/bitcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249165874,"owners_count":21223341,"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":["bitcode","llvm"],"created_at":"2024-10-01T15:53:25.143Z","updated_at":"2025-04-15T22:30:43.321Z","avatar_url":"https://github.com/indutny.png","language":"TypeScript","readme":"# bitcode\n[![Build Status](https://secure.travis-ci.org/indutny/bitcode.svg)](http://travis-ci.org/indutny/bitcode)\n[![NPM version](https://badge.fury.io/js/bitcode.svg)](https://badge.fury.io/js/bitcode)\n\nGenerate LLVM bitcode with JS API and no C++ bindings.\n\n## What is bitcode?\n\n[LLVM bitcode][1] is a binary representation of [LLVM IR][2] (where `IR` stands\nfor Intermediate Representation, and [LLVM][3] is a compiler infrastructure that\nis used for building C/C++/swift/rust/etc projects with [clang][4]).\n\n## Who needs this project?\n\nLLVM is perfect for building languages, and for tools that generate machine\ncode. Instead of manual support of multiple architectures (e.g. x86_64, arm,\narm64), an architecture-independent Intermediate Representation might be\ngenerated out of the source program. LLVM takes this representation and\ntransforms it to highly-optimized machine code.\n\nUsually this is achieved through C/C++ API of LLVM. This project, however, does\nthe same thing using only JavaScript and Node.js Buffer API.\n\n## Limitations\n\nThere're tons of unsupported instructions and data types in this module.\nIn fact, it has barely enough instructions to be useful in [llparse][5]. Should\nyou have any need in more types/instructions for your project - please do not\nhesitate to file a bug, or (better) send a Pull Request for the feature.\n\nIn particular:\n\n* floating point is not supported\n* floating-point related optimization features (for calls, and so on) are\n  absent\n* int64 constant values are limited to int32 range\n* vectors are not supported\n* opaque structure fields are not supported\n* try/catch-related instructions are not supported\n* stack allocation is not supported\n* memory fencing, and atomics is not supported\n* no addrspace support\n* no varargs\n* no GC support even\n* probably more\n\n## Usage\n\nSee [`bitcode-builder`][0] for Builder API.\n\n```typescript\nimport * as fs from 'fs';\nimport { Module } from 'bitcode';\n\nconst bitcode = new Module('source-name');\n\n// Create an instance of `bitcode-builder`\nconst b = bitcode.createBuilder();\n\n// Define a function\nconst sig = b.signature(b.i(32), [ b.i(32), b.i(32) ]);\nconst fn = sig.defineFunction('fn_name', [ 'param0', 'param1' ]);\n\nconst param0 = fn.getArgument('param0');\nconst param1 = fn.getArgument('param1');\nconst sum = fn.body.binop('add', param0, param1);\n\nfn.body.ret(sum);\n\n// Add function to the module\nbitcode.add(fn);\n\n// Build module\nfs.writeFileSync('out.bc', bitcode.build());\n```\n\nRunning `opt -S out.bc` (`opt` is a part of LLVM suite) will print:\n\n```bitcode\n; ModuleID = 'out.bc'\nsource_filename = \"source-name\"\n\ndefine i32 @fn_name(i32 %param0, i32 %param1) {\n  %1 = add i32 %param0, %param1\n  ret i32 %1\n}\n```\n\n#### LICENSE\n\nThis software is licensed under the MIT License.\n\nCopyright Fedor Indutny, 2018.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the\nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\nNO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[0]: https://github.com/indutny/bitcode-builder\n[1]: https://llvm.org/docs/BitCodeFormat.html\n[2]: https://llvm.org/docs/LangRef.html\n[3]: http://llvm.org/\n[4]: https://clang.llvm.org/\n[5]: http://github.com/indutny/llparse\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findutny%2Fbitcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findutny%2Fbitcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findutny%2Fbitcode/lists"}