Skip to content

Commit

Permalink
Merge pull request #5 from rtfeldman/update-inkwell-llvm12
Browse files Browse the repository at this point in the history
Update inkwell llvm12
  • Loading branch information
folkertdev authored Jun 7, 2021
2 parents f0a32d3 + 7a7ffa8 commit 237cbc7
Show file tree
Hide file tree
Showing 48 changed files with 1,132 additions and 1,110 deletions.
33 changes: 26 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ matrix:
- libclang-common-11-dev
rust: 1.45.2
dist: bionic
- env:
- LLVM_VERSION="12.0"
<<: *BASE
addons:
apt:
sources:
- *BASE_SOURCES
- llvm-toolchain-bionic-12
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages:
- *BASE_PACKAGES
- llvm-12-dev
- libclang-common-12-dev
rust: 1.45.2
dist: bionic
- deploy: # Documentation build; Only latest supported LLVM version for now
provider: pages
skip-cleanup: true
Expand All @@ -206,10 +222,10 @@ matrix:
on:
branch: master
before_install:
- export PATH=/usr/lib/llvm-11/bin/:$HOME/.local/bin:$PATH
- export LLVM_PATH=/usr/share/llvm-11/cmake/
- export PATH=/usr/lib/llvm-12/bin/:$HOME/.local/bin:$PATH
- export LLVM_PATH=/usr/share/llvm-12/cmake/
script:
- cargo doc --no-default-features --features "target-all,llvm11-0,nightly" --color=always
- cargo doc --no-default-features --features "target-all,llvm12-0,nightly" --color=always
- echo '<meta http-equiv="refresh" content="1; url=inkwell/index.html">' > target/doc/index.html
rust: nightly
name: "GitHub IO Documentation Deployment"
Expand All @@ -228,8 +244,9 @@ matrix:
# - llvm-toolchain-trusty-8
# - llvm-toolchain-bionic-9
# llvm-toolchain-bionic-10
- llvm-toolchain-bionic-11
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
# llvm-toolchain-bionic-11
- llvm-toolchain-bionic-12
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages:
- *BASE_PACKAGES
Expand All @@ -243,8 +260,10 @@ matrix:
# - llvm-7-dev
# - llvm-8-dev
# - llvm-9-dev
# llvm-10-dev
- llvm-11-dev
# - llvm-10-dev
# - llvm-11-dev
- llvm-12-dev
- libclang-common-12-dev
dist: bionic

env:
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ llvm8-0 = ["llvm-sys-80"]
llvm9-0 = ["llvm-sys-90"]
llvm10-0 = ["llvm-sys-100"]
llvm11-0 = ["llvm-sys-110"]
llvm12-0 = ["llvm-sys-120"]
# Don't link aganist LLVM libraries. This is useful if another dependency is
# installing LLVM. See llvm-sys for more details. We can't enable a single
# `no-llvm-linking` feature across the board of llvm versions, as it'll cause
Expand All @@ -43,6 +44,7 @@ llvm8-0-no-llvm-linking = ["llvm8-0", "llvm-sys-80/no-llvm-linking"]
llvm9-0-no-llvm-linking = ["llvm9-0", "llvm-sys-90/no-llvm-linking"]
llvm10-0-no-llvm-linking = ["llvm10-0", "llvm-sys-100/no-llvm-linking"]
llvm11-0-no-llvm-linking = ["llvm11-0", "llvm-sys-110/no-llvm-linking"]
llvm12-0-no-llvm-linking = ["llvm12-0", "llvm-sys-120/no-llvm-linking"]
# Don't force linking to libffi on non-windows platforms. Without this feature
# inkwell always links to libffi on non-windows platforms.
no-libffi-linking = []
Expand Down Expand Up @@ -99,6 +101,7 @@ llvm-sys-80 = { package = "llvm-sys", version = "80.3", optional = true }
llvm-sys-90 = { package = "llvm-sys", version = "90.2", optional = true }
llvm-sys-100 = { package = "llvm-sys", version = "100.2", optional = true }
llvm-sys-110 = { package = "llvm-sys", version = "110.0", optional = true }
llvm-sys-120 = { package = "llvm-sys", version = "120.0", optional = true }
once_cell = "1.4.1"
parking_lot = "0.11"
regex = "1"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Inkwell aims to help you pen your own programming languages by safely wrapping l

* Rust 1.42+
* Rust Stable, Beta, or Nightly
* LLVM 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, or 11.0
* LLVM 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0 or 12.0

## Usage

Expand All @@ -24,7 +24,7 @@ branch with a corresponding LLVM feature flag:

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

Supported versions:
Expand All @@ -43,6 +43,7 @@ Supported versions:
| 9.0.x | llvm9-0 |
| 10.0.x | llvm10-0 |
| 11.0.x | llvm11-0 |
| 12.0.x | llvm12-0 |

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
4 changes: 2 additions & 2 deletions internal_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use syn::spanned::Spanned;
use syn::{Token, LitFloat, Ident, Item, Field, Variant, Attribute};

// This array should match the LLVM features in the top level Cargo manifest
const FEATURE_VERSIONS: [&str; 12] =
["llvm3-6", "llvm3-7", "llvm3-8", "llvm3-9", "llvm4-0", "llvm5-0", "llvm6-0", "llvm7-0", "llvm8-0", "llvm9-0", "llvm10-0", "llvm11-0"];
const FEATURE_VERSIONS: [&str; 13] =
["llvm3-6", "llvm3-7", "llvm3-8", "llvm3-9", "llvm4-0", "llvm5-0", "llvm6-0", "llvm7-0", "llvm8-0", "llvm9-0", "llvm10-0", "llvm11-0", "llvm12-0"];

/// Gets the index of the feature version that represents `latest`
fn get_latest_feature_index(features: &[&str]) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Attribute {

#[llvm_versions(3.9..=latest)]
impl Attribute {
pub(crate) fn new(attribute: LLVMAttributeRef) -> Self {
pub(crate) unsafe fn new(attribute: LLVMAttributeRef) -> Self {
debug_assert!(!attribute.is_null());

Attribute {
Expand Down
56 changes: 27 additions & 29 deletions src/basic_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ pub struct BasicBlock<'ctx> {
}

impl<'ctx> BasicBlock<'ctx> {
pub(crate) fn new(basic_block: LLVMBasicBlockRef) -> Option<Self> {
pub(crate) unsafe fn new(basic_block: LLVMBasicBlockRef) -> Option<Self> {
if basic_block.is_null() {
return None;
}

unsafe {
// NOTE: There is a LLVMBasicBlockAsValue but it might be the same as casting
assert!(!LLVMIsABasicBlock(basic_block as LLVMValueRef).is_null())
}
// NOTE: There is a LLVMBasicBlockAsValue but it might be the same as casting
assert!(!LLVMIsABasicBlock(basic_block as LLVMValueRef).is_null());

Some(BasicBlock { basic_block, _marker: PhantomData })
}
Expand Down Expand Up @@ -62,11 +60,9 @@ impl<'ctx> BasicBlock<'ctx> {
/// assert!(basic_block.get_parent().is_none());
/// ```
pub fn get_parent(self) -> Option<FunctionValue<'ctx>> {
let value = unsafe {
LLVMGetBasicBlockParent(self.basic_block)
};

FunctionValue::new(value)
unsafe {
FunctionValue::new(LLVMGetBasicBlockParent(self.basic_block))
}
}

/// Gets the `BasicBlock` preceeding the current one, in its own scope, if any.
Expand Down Expand Up @@ -98,11 +94,9 @@ impl<'ctx> BasicBlock<'ctx> {
pub fn get_previous_basic_block(self) -> Option<BasicBlock<'ctx>> {
self.get_parent()?;

let bb = unsafe {
LLVMGetPreviousBasicBlock(self.basic_block)
};

BasicBlock::new(bb)
unsafe {
BasicBlock::new(LLVMGetPreviousBasicBlock(self.basic_block))
}
}

/// Gets the `BasicBlock` succeeding the current one, in its own scope, if any.
Expand Down Expand Up @@ -135,11 +129,9 @@ impl<'ctx> BasicBlock<'ctx> {
pub fn get_next_basic_block(self) -> Option<BasicBlock<'ctx>> {
self.get_parent()?;

let bb = unsafe {
LLVMGetNextBasicBlock(self.basic_block)
};

BasicBlock::new(bb)
unsafe {
BasicBlock::new(LLVMGetNextBasicBlock(self.basic_block))
}
}

/// Prepends one `BasicBlock` before another.
Expand Down Expand Up @@ -247,7 +239,9 @@ impl<'ctx> BasicBlock<'ctx> {
return None;
}

Some(InstructionValue::new(value))
unsafe {
Some(InstructionValue::new(value))
}
}

/// Obtains the last `InstructionValue` in this `BasicBlock`, if any. A `BasicBlock` must have a last instruction to be valid.
Expand Down Expand Up @@ -281,7 +275,9 @@ impl<'ctx> BasicBlock<'ctx> {
return None;
}

Some(InstructionValue::new(value))
unsafe {
Some(InstructionValue::new(value))
}
}

/// Obtains the terminating `InstructionValue` in this `BasicBlock`, if any. A `BasicBlock` must have a terminating instruction to be valid.
Expand Down Expand Up @@ -319,7 +315,9 @@ impl<'ctx> BasicBlock<'ctx> {
return None;
}

Some(InstructionValue::new(value))
unsafe {
Some(InstructionValue::new(value))
}
}

/// Removes this `BasicBlock` from its parent `FunctionValue`.
Expand Down Expand Up @@ -411,11 +409,9 @@ impl<'ctx> BasicBlock<'ctx> {
/// assert_eq!(context, *basic_block.get_context());
/// ```
pub fn get_context(self) -> ContextRef<'ctx> {
let context = unsafe {
LLVMGetTypeContext(LLVMTypeOf(LLVMBasicBlockAsValue(self.basic_block)))
};

ContextRef::new(context)
unsafe {
ContextRef::new(LLVMGetTypeContext(LLVMTypeOf(LLVMBasicBlockAsValue(self.basic_block))))
}
}

/// Gets the name of a `BasicBlock`.
Expand Down Expand Up @@ -514,7 +510,9 @@ impl<'ctx> BasicBlock<'ctx> {
return None;
}

Some(BasicValueUse::new(use_))
unsafe {
Some(BasicValueUse::new(use_))
}
}
}

Expand Down
Loading

0 comments on commit 237cbc7

Please sign in to comment.