https://github.com/bhavjitchauhan/llsimd
Portable SIMD intrinsics through LLVM IR.
https://github.com/bhavjitchauhan/llsimd
llvm simd
Last synced: about 1 year ago
JSON representation
Portable SIMD intrinsics through LLVM IR.
- Host: GitHub
- URL: https://github.com/bhavjitchauhan/llsimd
- Owner: bhavjitChauhan
- Created: 2025-03-02T22:56:00.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-23T14:49:52.000Z (about 1 year ago)
- Last Synced: 2025-03-23T15:35:44.265Z (about 1 year ago)
- Topics: llvm, simd
- Language: C++
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# llsimd
## Usage
Requirements:
- LLVM/Clang 20
- CMake 3.20+
Recommended:
- Linux
### Build
```bash
cd build
cmake ..
cmake --build . --target llsimd
```
### Run
```bash
clang -fpass-plugin=./libllsimd.so ../in.c
```
To see pass statistics, LLVM needs to be compiled with assertion checks enabled.
## Development
### Get LLVM/Clang
#### Building from Source
Requirements:
- Git
Recommended:
- Ninja
> [!WARNING]
> Debug builds need 10-15 GB of disk space. Confirm that just enabling assertion
> checks or a `RelWithDebInfo` build doesn't cover your needs.
See the official
[Getting Started with the LLVM System](https://llvm.org/docs/GettingStarted.html)
tutorial for more information.
```bash
git clone -b llvmorg-20.1.0 --depth 1 https://github.com/llvm/llvm-project
cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON
cmake --build build
# Optionally install the build (to `/usr/local` by default)
sudo cmake --install build
```
#### Installing Pre-built Binaries
##### Debian/Ubuntu
Install the official APT packages:
```bash
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
```
##### Other
Download the binaries from LLVM's
[GitHub releases](https://github.com/llvm/llvm-project/tree/llvmorg-20.1.0).
### Test
#### Unit Tests
Requirements:
- Python 3
- [lit](https://pypi.org/project/lit/)
```bash
cmake --build build --target check
```
#### Manual
```bash
# C/C++ -> IR
clang -S -emit-llvm ../in.c
# Run pass on IR
opt -load-pass-plugin ./libllsimd.so -passes=llsimd -S in.ll -stats -o out.ll
# Interpret IR
lli in.ll
lli out.ll
```
The output assembly can be compared to the original:
```bash
# C/C++ -> assembly
clang -S ../in.c -o in.s
# IR -> assembly
llc out.ll
```