-
Notifications
You must be signed in to change notification settings - Fork 0
Cleanup #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Cleanup #52
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
93a1b68
Initial commit
CalebLItalien 625dc6f
Renamed files and reorganized functions
CalebLItalien 738ecc2
Cleanup
CalebLItalien 44f1181
Fixed imports in src
CalebLItalien af8e55b
Fixed imports in testing
CalebLItalien b05c55a
Cleaned up old files and modularized organization
CalebLItalien afbd2ea
Added configuration files to cargo and github
CalebLItalien 16a9295
Corrected typo
CalebLItalien 1b54b97
Added name of project to workflow
CalebLItalien 852aaa0
Resolved dependencies in src folders
CalebLItalien f8410b3
Fixed dependencies in tests
CalebLItalien a8fb7f9
Root documentation update
CalebLItalien ab4a1a1
Updated README to flow better
CalebLItalien 46d187d
Updated analysis readme
CalebLItalien a2812f5
Update README.md
CalebLItalien e5e29a7
Update README.md
CalebLItalien e501d32
Documented ir's src
CalebLItalien faad952
Update README.md
CalebLItalien 1272a3d
Updated in-code documentation
CalebLItalien 660541b
Merge commit
CalebLItalien 34bd279
Moved disclaimer to README
CalebLItalien 887e59c
Updated analysis and common README's
CalebLItalien 5c1a2c0
Updated logging README
CalebLItalien b5f0dcd
Wrote README for ir
CalebLItalien d894d50
Added JIT README
CalebLItalien 1f74151
Merge commit
CalebLItalien e582061
Moved util to common folder
CalebLItalien b5fc296
Removed redundant documentation
CalebLItalien 68a9a55
Fixed execute generic types
CalebLItalien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
rustflags = ["-W", "unused-imports", "-W", "missing-docs", "-W", "unused-variables", "-W", "dead-code"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
### Details | ||
|
||
### Issue Type | ||
- [ ] Feature | ||
- [ ] Bugfix | ||
- [ ] Documentation | ||
- [ ] Refactoring | ||
- [ ] Other: | ||
|
||
### Requirements | ||
|
||
### Dependencies | ||
|
||
### Notes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# [Module Name] | ||
|
||
## Overview | ||
This document provides details about the [Module Name] in the SafeLLVM project. The [Module Name] module is designed to [briefly describe the purpose and functionality]. | ||
|
||
## Features | ||
List the main features of the module: | ||
- **Feature 1**: | ||
- **Feature 2**; | ||
|
||
## Usage | ||
Explain how to use the module with examples: | ||
|
||
``` | ||
use safe_llvm::module_name::{function1, function2}; | ||
|
||
function1(); // Example usage of function1 | ||
function2(); // Example usage of function2 | ||
``` | ||
|
||
Provide any necessary warnings or special instructions for using the module correctly. | ||
|
||
## FAQ | ||
|
||
## Further Information | ||
For further information or questions regarding the use of `[Module Name]`, feel free to contact the main contributors or raise an issue on the GitHub repository. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: SafeLLVM | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y ca-certificates wget curl gnupg software-properties-common build-essential cmake libfreetype6-dev libfontconfig1-dev xclip valgrind libzstd-dev | ||
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | ||
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main" | ||
sudo apt-get update | ||
sudo apt-get install -y clang-17 llvm-17 llvm-17-dev llvm-17-tools libpolly-17-dev | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
components: rustfmt, clippy | ||
override: true | ||
|
||
- name: Set Environment Variables | ||
run: | | ||
echo "LLVM_SYS_170_PREFIX=/usr/lib/llvm-17" >> $GITHUB_ENV | ||
echo "PATH=$PATH:/root/.cargo/bin:/usr/lib/llvm-17/bin" >> $GITHUB_ENV | ||
|
||
- name: Build Project | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --all --verbose | ||
|
||
- name: Run Tests | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --all --verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
/Cargo.lock | ||
/target/ | ||
/Dockerfile | ||
/app.log | ||
/dev_toolchain/target/ | ||
/dev_toolchain/app.log | ||
/dev_toolchain/Cargo.lock | ||
/.vscode/ | ||
/jit/target/ | ||
/jit/app.log | ||
/ir/target/ | ||
/ir/app.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Contributing to SafeLLVM | ||
|
||
Welcome to the SafeLLVM project! We appreciate your interest in contributing to SafeLLVM, a wrapper around **[llvm-sys](https://github.com/tari/llvm-sys.rs)** designed to serve as the backend for the Simple Instructional C99 Compiler (SICC). | ||
|
||
## Getting Started | ||
|
||
Before contributing, please make sure to familiarize yourself with the project structure and the goals of both SafeLLVM and SICC. This understanding will help you make meaningful contributions that align with the project's objectives. | ||
|
||
### Setting Up Your Development Environment | ||
|
||
1. **Install the prerequisites found in README.md** | ||
|
||
2. **Fork and clone the repository:** | ||
Start by cloning the SafeLLVM repository to your local machine. | ||
``` | ||
git clone [email protected]:UnionCompilerDesign/safe_llvm.git | ||
``` | ||
|
||
3. **Build and test the project:** | ||
``` | ||
cd safe_llvm | ||
cargo build --all | ||
cargo test --all | ||
``` | ||
|
||
## Making Contributions | ||
|
||
### Reporting Bugs | ||
|
||
If you find a bug, please report it by opening a new issue on GitHub. Include as much detail as possible and please use the template found in `safe_llvm/.github/ISSUE_TEMPLATE`. | ||
|
||
### Suggesting Enhancements | ||
|
||
We welcome suggestions for improvements! If you have an idea to enhance SafeLLVM, please create an issue to discuss so we can discuss it. | ||
|
||
### Pull Requests | ||
|
||
We actively welcome your pull requests: | ||
|
||
1. Fork the repo and create your branch from `main`. | ||
2. If you've added code that should be tested, add tests. | ||
3. Ensure your code lints (use `cargo clippy`). | ||
4. Issue the pull request! | ||
|
||
### Coding Guidelines | ||
|
||
- Follow the [Rust style guide](https://doc.rust-lang.org/1.0.0/style/README.html). | ||
- Write clean, readable code and include comments where necessary. | ||
- Ensure that all tests pass before you make a pull request. | ||
|
||
## Recognition | ||
|
||
Contributors who make significant improvements will be recognized as "Contributors" in the project README. | ||
|
||
Thank you for your interest in contributing to SafeLLVM! We look forward to your contributions and are excited to see how the project grows and evolves with your help. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM ubuntu:20.04 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
WORKDIR /usr/src/safe_llvm | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
ca-certificates \ | ||
wget \ | ||
curl \ | ||
gnupg \ | ||
software-properties-common \ | ||
build-essential \ | ||
cmake \ | ||
libfreetype6-dev \ | ||
libfontconfig1-dev \ | ||
xclip \ | ||
valgrind \ | ||
libzstd-dev && \ | ||
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ | ||
apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main" && \ | ||
apt-get update && \ | ||
apt-get install -y clang-17 llvm-17 llvm-17-dev llvm-17-tools libpolly-17-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
|
||
ENV PATH="/root/.cargo/bin:/usr/lib/llvm-17/bin:$PATH" | ||
|
||
ENV LLVM_SYS_170_PREFIX="/usr/lib/llvm-17" | ||
|
||
COPY . . | ||
|
||
RUN cargo build --verbose | ||
|
||
CMD ["bash"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) [2024] Caleb L'Italien | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Safe LLVM | ||
|
||
## Contributors | ||
Caleb L'Italien, John Daly | ||
|
||
## Overview | ||
SafeLLVM is a Rust-based library designed to provide a safe and user-friendly interface to llvm-sys. It is developed specifically for the Simple Instructional C99 Compiler (SICC). The library aims to encapsulate the complexity of LLVM’s API, making it accessible for undergraduate work. | ||
|
||
## Disclaimer | ||
|
||
SafeLLVM is designed for educational purposes and is not intended for production use. If you are looking for a production-level LLVM crate for Rust projects, consider using the following crates: | ||
|
||
- **[Inkwell](https://github.com/TheDan64/inkwell)** | ||
- **[llvm-ir](https://github.com/cdisselkoen/llvm-ir)** | ||
|
||
## Project Structure | ||
- `analysis/`: Tools for performing various analyses on LLVM IR. | ||
- `common/`: Common utilities and helper functions shared across the project. | ||
- `ir/`: Manages the creation of LLVM Intermediate Representation (IR). | ||
- `jit/`: Implements an ExecutionEngine for execution of pre-compiled LLVM modules. | ||
- `logging/`: Handles logging functionalities for debugging. | ||
|
||
## Getting Started | ||
|
||
### Usage | ||
To use SafeLLVM in your Rust projects, you can include it directly via Cargo by adding it as a dependency in your `Cargo.toml` file using its GitHub repository URL. Here's how to do it: | ||
|
||
1. **Add SafeLLVM as a dependency in your `Cargo.toml`:** | ||
```toml | ||
[dependencies] | ||
safe_llvm = { git = "[email protected]:UnionCompilerDesign/safe_llvm.git", branch = "main" } | ||
``` | ||
|
||
2. **Refer to specific `README`s in each directory:** | ||
For more specific usage details, please refer to the READMEs located in each directory. These documents provide further instructions and examples on how to use the components within SafeLLVM. | ||
|
||
### How to Contribute | ||
Contributions are welcome! Please refer to the `CONTRIBUTING` file for guidelines on how to contribute. | ||
|
||
### License | ||
Distributed under the MIT License. See the `LICENSE` file for more details. | ||
|
||
### Acknowledgements | ||
Special thanks to Professor Aaron Cass of Union College for his guidance and expertise throughout the development of this project. | ||
|
||
### Contact | ||
For any inquiries, contact Caleb L'Italien at [email protected]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "analysis" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
name = "analysis" | ||
path = "src/lib.rs" | ||
|
||
[dependencies] | ||
llvm-sys = "170" | ||
common = { path = "../common" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Analysis Tools for SafeLLVM | ||
|
||
## Overview | ||
The Analysis module is a component of the SafeLLVM project for checking the correctness of LLVM modules and functions. | ||
|
||
## Features | ||
- **Module Validator**: Determines if an LLVM module is well-formed. | ||
- **Function Validator**: Determines if an LLVM function is well-formed. | ||
|
||
## Usage | ||
1. Initialize the Validator with a module: Create a Validator instance by passing a protected reference to the LLVM module you wish to validate. | ||
2. Validate Functions or Modules: | ||
- To validate an LLVM module, call the is_valid_module() method on your Validator instance: | ||
``` | ||
let validator = Validator::new(module_pointer); | ||
let is_module_valid = validator.is_valid_module(); | ||
eprintln!("Module is valid: ", is_module_valid); | ||
``` | ||
- Similarly, to validate a specific function within a module, provide a protected reference to the LLVM function to the is_valid_function() method: | ||
``` | ||
let validator = Validator::new(module_pointer); | ||
let is_function_valid = validator.is_valid_function(function_pointer); | ||
eprintln!("Function is valid: ", is_function_valid); | ||
``` | ||
|
||
Provide any necessary warnings or special instructions for using the module correctly, such as ensuring that pointers are correctly managed and threads are safely handled due to the use of Arc and RwLock. | ||
|
||
## FAQ | ||
|
||
## Further Information | ||
For further information or questions regarding the use of the analysis tools, feel free to contact the main contributors or raise an issue on the GitHub repository. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! Analysis Toolchain. | ||
|
||
pub mod validator; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would every single function need to be documented including private functions? I understand having documentation at least for every public function