Skip to content

Commit

Permalink
The final push
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Jan 10, 2024
1 parent 3f324ad commit f5a1771
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 63 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ on: [push, pull_request]

env:
CARGO_TERM_COLOR: always
DOC_LLVM_FEATURE: llvm16-0
DOC_LLVM_VERSION: '16.0'
DOC_LLVM_FEATURE: llvm17-0
DOC_LLVM_VERSION: '17.0'
DOC_PATH: target/doc

jobs:
typos:
name: Typos
runs-on: ubuntu-latest
steps:
- name: Install Rust Stable
run: rustup toolchain install stable
- name: Install typos
run: cargo install typos-cli
- name: Run typos
run: typos .
tests:
name: "LLVM ${{ matrix.llvm-version[0] }}: ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
needs: typos
strategy:
matrix:
llvm-version:
Expand All @@ -37,11 +38,14 @@ jobs:
- ["14.0", "14-0"]
- ["15.0", "15-0"]
- ["16.0", "16-0"]
- ["17.0", "17-0"]
# only use ubuntu-22.04 for llvm 16 and higher
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
llvm-version: ["16.0", "16-0"]
- os: ubuntu-22.04
llvm-version: ["17.0", "17-0"]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand All @@ -58,7 +62,7 @@ jobs:
doc:
name: Documentation
runs-on: ubuntu-latest
needs: tests
needs: [typos, tests]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ llvm-sys-130 = { package = "llvm-sys", version = "130.0.4", optional = true }
llvm-sys-140 = { package = "llvm-sys", version = "140.0.2", optional = true }
llvm-sys-150 = { package = "llvm-sys", version = "150.0.3", optional = true }
llvm-sys-160 = { package = "llvm-sys", version = "160.1.0", optional = true }
llvm-sys-170 = { package = "llvm-sys", version = "170.0.0", optional = true }
llvm-sys-170 = { package = "llvm-sys", version = "170.0.1", optional = true }
once_cell = "1.16"
static-alloc = { version = "0.2", optional = true }
thiserror = "1.0.48"
Expand Down
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Inkwell aims to help you pen your own programming languages by safely wrapping l
## Requirements

* Rust 1.56+ (Stable, Beta, or Nightly)
* LLVM 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, or 16.0
* One of LLVM 4-17

## Usage

Expand All @@ -23,26 +23,11 @@ branch with a corresponding LLVM feature flag:

```toml
[dependencies]
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm12-0"] }
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm17-0"] }
```

Supported versions:

| LLVM Version | Cargo Feature Flag |
| :----------: | :-----------: |
| 4.0.x | llvm4-0 |
| 5.0.x | llvm5-0 |
| 6.0.x | llvm6-0 |
| 7.0.x | llvm7-0 |
| 8.0.x | llvm8-0 |
| 9.0.x | llvm9-0 |
| 10.0.x | llvm10-0 |
| 11.0.x | llvm11-0 |
| 12.0.x | llvm12-0 |
| 13.0.x | llvm13-0 |
| 14.0.x | llvm14-0 |
| 15.0.x | llvm15-0 |
| 16.0.x | llvm16-0 |
LLVM 4-17 mapping to a cargo feature flag `llvmM-0` where `M` corresponds to the LLVM major version.

Please be aware that we may make breaking changes on master from time to time since we are
pre-v1.0.0, in compliance with semver. Please prefer a crates.io release whenever possible!
Expand Down
2 changes: 1 addition & 1 deletion examples/kaleidoscope/implementation_typed_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use inkwell::types::BasicMetadataTypeEnum;
use inkwell::values::{BasicMetadataValueEnum, FloatValue, FunctionValue, PointerValue};
use inkwell::FloatPredicate;

use crate::Token::*;
use Token::*;

const ANONYMOUS_FUNCTION_NAME: &str = "anonymous";

Expand Down
2 changes: 1 addition & 1 deletion examples/kaleidoscope/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use inkwell::OptimizationLevel;

use inkwell_internals::llvm_versions;

#[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0")))]
#[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
mod implementation_typed_pointers;

#[llvm_versions(4.0..=14.0)]
Expand Down
2 changes: 1 addition & 1 deletion src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use llvm_sys::initialization::{
use llvm_sys::initialization::{LLVMInitializeInstrumentation, LLVMInitializeObjCARCOpts};
use llvm_sys::prelude::LLVMPassManagerRef;
#[llvm_versions(4.0..=16.0)]
use llvm_sys::prelude::LLVMPassRegistry;
use llvm_sys::prelude::LLVMPassRegistryRef;
#[llvm_versions(10.0..=16.0)]
use llvm_sys::transforms::ipo::LLVMAddMergeFunctionsPass;
#[llvm_versions(4.0..=15.0)]
Expand Down
1 change: 1 addition & 0 deletions tests/all/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod test_instruction_values;
mod test_intrinsics;
mod test_module;
mod test_object_file;
#[cfg(not(any(feature = "llvm17-0")))]
mod test_passes;
mod test_targets;
mod test_tari_example;
Expand Down
24 changes: 12 additions & 12 deletions tests/all/test_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn test_build_call() {
feature = "llvm14-0"
))]
let load = builder.build_load(alloca, "load").unwrap().into_pointer_value();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let load = builder
.build_load(fn_ptr_type, alloca, "load")
.unwrap()
Expand All @@ -94,7 +94,7 @@ fn test_build_call() {
let callable_value = CallableValue::try_from(load).unwrap();
builder.build_call(callable_value, &[], "call").unwrap();
}
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
builder.build_indirect_call(fn_type2, load, &[], "call");
builder.build_return(None).unwrap();

Expand Down Expand Up @@ -394,7 +394,7 @@ fn test_null_checked_ptr_ops() {
feature = "llvm14-0"
))]
let index1 = builder.build_load(new_ptr, "deref").unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let index1 = builder.build_load(i8_ptr_type, new_ptr, "deref").unwrap();

builder.build_return(Some(&index1)).unwrap();
Expand Down Expand Up @@ -448,7 +448,7 @@ fn test_null_checked_ptr_ops() {
feature = "llvm14-0"
))]
let index1 = builder.build_load(new_ptr, "deref").unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let index1 = builder.build_load(i8_ptr_type, new_ptr, "deref").unwrap();

builder.build_return(Some(&index1)).unwrap();
Expand Down Expand Up @@ -984,7 +984,7 @@ fn test_insert_value() {
.build_load(array_alloca, "array_load")
.unwrap()
.into_array_value();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let array = builder
.build_load(array_type, array_alloca, "array_load")
.unwrap()
Expand Down Expand Up @@ -1038,7 +1038,7 @@ fn test_insert_value() {
.build_load(struct_alloca, "struct_load")
.unwrap()
.into_struct_value();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let struct_value = builder
.build_load(struct_type, struct_alloca, "struct_load")
.unwrap()
Expand Down Expand Up @@ -1207,7 +1207,7 @@ fn run_memcpy_on<'ctx>(
feature = "llvm14-0"
))]
let elem_ptr = unsafe { builder.build_in_bounds_gep(array_ptr, &[index_val], "index") }.unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let elem_ptr = unsafe {
builder
.build_in_bounds_gep(element_type, array_ptr, &[index_val], "index")
Expand Down Expand Up @@ -1237,7 +1237,7 @@ fn run_memcpy_on<'ctx>(
feature = "llvm14-0"
))]
let dest_ptr = unsafe { builder.build_in_bounds_gep(array_ptr, &[index_val], "index") }.unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let dest_ptr = unsafe {
builder
.build_in_bounds_gep(element_type, array_ptr, &[index_val], "index")
Expand Down Expand Up @@ -1317,7 +1317,7 @@ fn run_memmove_on<'ctx>(
feature = "llvm14-0"
))]
let elem_ptr = unsafe { builder.build_in_bounds_gep(array_ptr, &[index_val], "index") }.unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let elem_ptr = unsafe {
builder
.build_in_bounds_gep(element_type, array_ptr, &[index_val], "index")
Expand Down Expand Up @@ -1347,7 +1347,7 @@ fn run_memmove_on<'ctx>(
feature = "llvm14-0"
))]
let dest_ptr = unsafe { builder.build_in_bounds_gep(array_ptr, &[index_val], "index") }.unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let dest_ptr = unsafe {
builder
.build_in_bounds_gep(element_type, array_ptr, &[index_val], "index")
Expand Down Expand Up @@ -1434,7 +1434,7 @@ fn run_memset_on<'ctx>(
feature = "llvm14-0"
))]
let part_2 = unsafe { builder.build_in_bounds_gep(array_ptr, &[index], "index") }.unwrap();
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
let part_2 = unsafe {
builder
.build_in_bounds_gep(element_type, array_ptr, &[index], "index")
Expand Down Expand Up @@ -1798,7 +1798,7 @@ fn test_safe_struct_gep() {
assert!(builder.build_struct_gep(struct_ptr, 1, "struct_gep").is_ok());
assert!(builder.build_struct_gep(struct_ptr, 2, "struct_gep").is_err());
}
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
#[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
{
assert!(builder.build_struct_gep(i32_ty, i32_ptr, 0, "struct_gep").is_err());
assert!(builder.build_struct_gep(i32_ty, i32_ptr, 10, "struct_gep").is_err());
Expand Down
Loading

0 comments on commit f5a1771

Please sign in to comment.