{"id":15350591,"url":"https://github.com/gaul/x86lint","last_synced_at":"2025-04-15T04:22:16.908Z","repository":{"id":144979733,"uuid":"156753478","full_name":"gaul/x86lint","owner":"gaul","description":"Examine x86 machine code to find suboptimal encodings and sequences of instructions","archived":false,"fork":false,"pushed_at":"2021-10-09T09:51:40.000Z","size":73,"stargazers_count":9,"open_issues_count":18,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T19:23:25.044Z","etag":null,"topics":["assembly","lint","machine-code","optimization","x86","x86-64"],"latest_commit_sha":null,"homepage":"","language":"C","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/gaul.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":"2018-11-08T18:48:15.000Z","updated_at":"2024-10-21T16:41:31.000Z","dependencies_parsed_at":"2023-04-11T01:31:19.639Z","dependency_job_id":null,"html_url":"https://github.com/gaul/x86lint","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"d897d9fdcbe5f26fbfe79169e98143261a4b2aa0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fx86lint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fx86lint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fx86lint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fx86lint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaul","download_url":"https://codeload.github.com/gaul/x86lint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249004381,"owners_count":21196865,"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":["assembly","lint","machine-code","optimization","x86","x86-64"],"created_at":"2024-10-01T11:58:46.422Z","updated_at":"2025-04-15T04:22:16.876Z","avatar_url":"https://github.com/gaul.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# x86lint\n\nx86lint examines x86 machine code to find suboptimal encodings and sequences.\nFor example, `add eax, 1` can encode with either an 8- or 32-bit immediate:\n\n```\n83C0 01\n81C0 01000000\n```\n\nUsing the former can result in smaller and faster code.  x86lint can help\ncompiler writers generate better code and documents the complexity of x86.\n\n## Implemented analyses\n\n* implicit EAX\n  - `81C0 00010000` instead of `05 00010000` (ADD EAX, 0x100)\n* missing LOCK prefix on CMPXCHG and XADD\n* oversized immediates\n  - `81C0 01000000` instead of `83C0 01` (ADD EAX, 1)\n* strength-reduce AND with immediate to MOVZBL\n* suboptimal CMP 0 `83FF 00` instead of TEST `85C0`\n* suboptimal no-ops\n  - multiple `90` instead of a single `60 90`, etc.\n* ~~suboptimal zero register~~, see [#7](https://github.com/gaul/x86lint/issues/7)\n  - MOV EAX, 0 instead of XOR EAX, EAX\n* unnecessary REX prefix\n  - XOR RAX, RAX `4831C0` instead of XOR EAX, EAX `31C0`\n  - `40C9` instead of `C9` (LEAVE)\n* unnecessary immediate\n  - `C1D0 01` instead of `D1D0` (RCL EAX, 1)\n* unneeded LOCK prefix on XCHG\n\n## Compilation\n\nFirst install the Intel x86 encoder decoder:\n\n```\ngit clone https://github.com/intelxed/xed.git xed\ngit clone https://github.com/intelxed/mbuild.git mbuild\ncd xed\n./mfile.py install --install-dir=kits/xed-install\n```\n\nNext build x86lint:\n\n```\ngit clone https://github.com/gaul/x86lint.git x86lint\ncd x86lint\nXED_PATH=/path/to/xed make all\n```\n\n## Usage\n\nx86lint is intended to be part of compiler test suites which should `#include\n\"x86lint.h\"` and link `libx86lint.a`.  It can also read arbitrary ELF executables via:\n\n```\n./x86lint /bin/ls\n```\n\n## References\n\n* [Agner Fog optimization guide](https://www.agner.org/optimize/optimizing_assembly.pdf)\n* [Intel instruction set reference](https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf)\n* [Intel optimization manual](https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf)\n* [Intel x86 encoder decoder](https://github.com/intelxed/xed) - library to parse instructions\n\n## License\n\nCopyright (C) 2018 Andrew Gaul\n\nLicensed under the Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaul%2Fx86lint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaul%2Fx86lint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaul%2Fx86lint/lists"}