Skip to content

Commit 237cbc7

Browse files
authored
Merge pull request #5 from rtfeldman/update-inkwell-llvm12
Update inkwell llvm12
2 parents f0a32d3 + 7a7ffa8 commit 237cbc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1132
-1110
lines changed

.travis.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,22 @@ matrix:
197197
- libclang-common-11-dev
198198
rust: 1.45.2
199199
dist: bionic
200+
- env:
201+
- LLVM_VERSION="12.0"
202+
<<: *BASE
203+
addons:
204+
apt:
205+
sources:
206+
- *BASE_SOURCES
207+
- llvm-toolchain-bionic-12
208+
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
209+
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
210+
packages:
211+
- *BASE_PACKAGES
212+
- llvm-12-dev
213+
- libclang-common-12-dev
214+
rust: 1.45.2
215+
dist: bionic
200216
- deploy: # Documentation build; Only latest supported LLVM version for now
201217
provider: pages
202218
skip-cleanup: true
@@ -206,10 +222,10 @@ matrix:
206222
on:
207223
branch: master
208224
before_install:
209-
- export PATH=/usr/lib/llvm-11/bin/:$HOME/.local/bin:$PATH
210-
- export LLVM_PATH=/usr/share/llvm-11/cmake/
225+
- export PATH=/usr/lib/llvm-12/bin/:$HOME/.local/bin:$PATH
226+
- export LLVM_PATH=/usr/share/llvm-12/cmake/
211227
script:
212-
- cargo doc --no-default-features --features "target-all,llvm11-0,nightly" --color=always
228+
- cargo doc --no-default-features --features "target-all,llvm12-0,nightly" --color=always
213229
- echo '<meta http-equiv="refresh" content="1; url=inkwell/index.html">' > target/doc/index.html
214230
rust: nightly
215231
name: "GitHub IO Documentation Deployment"
@@ -228,8 +244,9 @@ matrix:
228244
# - llvm-toolchain-trusty-8
229245
# - llvm-toolchain-bionic-9
230246
# llvm-toolchain-bionic-10
231-
- llvm-toolchain-bionic-11
232-
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
247+
# llvm-toolchain-bionic-11
248+
- llvm-toolchain-bionic-12
249+
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
233250
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
234251
packages:
235252
- *BASE_PACKAGES
@@ -243,8 +260,10 @@ matrix:
243260
# - llvm-7-dev
244261
# - llvm-8-dev
245262
# - llvm-9-dev
246-
# llvm-10-dev
247-
- llvm-11-dev
263+
# - llvm-10-dev
264+
# - llvm-11-dev
265+
- llvm-12-dev
266+
- libclang-common-12-dev
248267
dist: bionic
249268

250269
env:

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ llvm8-0 = ["llvm-sys-80"]
2626
llvm9-0 = ["llvm-sys-90"]
2727
llvm10-0 = ["llvm-sys-100"]
2828
llvm11-0 = ["llvm-sys-110"]
29+
llvm12-0 = ["llvm-sys-120"]
2930
# Don't link aganist LLVM libraries. This is useful if another dependency is
3031
# installing LLVM. See llvm-sys for more details. We can't enable a single
3132
# `no-llvm-linking` feature across the board of llvm versions, as it'll cause
@@ -43,6 +44,7 @@ llvm8-0-no-llvm-linking = ["llvm8-0", "llvm-sys-80/no-llvm-linking"]
4344
llvm9-0-no-llvm-linking = ["llvm9-0", "llvm-sys-90/no-llvm-linking"]
4445
llvm10-0-no-llvm-linking = ["llvm10-0", "llvm-sys-100/no-llvm-linking"]
4546
llvm11-0-no-llvm-linking = ["llvm11-0", "llvm-sys-110/no-llvm-linking"]
47+
llvm12-0-no-llvm-linking = ["llvm12-0", "llvm-sys-120/no-llvm-linking"]
4648
# Don't force linking to libffi on non-windows platforms. Without this feature
4749
# inkwell always links to libffi on non-windows platforms.
4850
no-libffi-linking = []
@@ -99,6 +101,7 @@ llvm-sys-80 = { package = "llvm-sys", version = "80.3", optional = true }
99101
llvm-sys-90 = { package = "llvm-sys", version = "90.2", optional = true }
100102
llvm-sys-100 = { package = "llvm-sys", version = "100.2", optional = true }
101103
llvm-sys-110 = { package = "llvm-sys", version = "110.0", optional = true }
104+
llvm-sys-120 = { package = "llvm-sys", version = "120.0", optional = true }
102105
once_cell = "1.4.1"
103106
parking_lot = "0.11"
104107
regex = "1"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Inkwell aims to help you pen your own programming languages by safely wrapping l
1515

1616
* Rust 1.42+
1717
* Rust Stable, Beta, or Nightly
18-
* 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
18+
* 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
1919

2020
## Usage
2121

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

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

3030
Supported versions:
@@ -43,6 +43,7 @@ Supported versions:
4343
| 9.0.x | llvm9-0 |
4444
| 10.0.x | llvm10-0 |
4545
| 11.0.x | llvm11-0 |
46+
| 12.0.x | llvm12-0 |
4647

4748
Please be aware that we may make breaking changes on master from time to time since we are
4849
pre-v1.0.0, in compliance with semver. Please prefer a crates.io release whenever possible!

internal_macros/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use syn::spanned::Spanned;
1919
use syn::{Token, LitFloat, Ident, Item, Field, Variant, Attribute};
2020

2121
// This array should match the LLVM features in the top level Cargo manifest
22-
const FEATURE_VERSIONS: [&str; 12] =
23-
["llvm3-6", "llvm3-7", "llvm3-8", "llvm3-9", "llvm4-0", "llvm5-0", "llvm6-0", "llvm7-0", "llvm8-0", "llvm9-0", "llvm10-0", "llvm11-0"];
22+
const FEATURE_VERSIONS: [&str; 13] =
23+
["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"];
2424

2525
/// Gets the index of the feature version that represents `latest`
2626
fn get_latest_feature_index(features: &[&str]) -> usize {

src/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct Attribute {
1919

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

2525
Attribute {

src/basic_block.rs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ pub struct BasicBlock<'ctx> {
2626
}
2727

2828
impl<'ctx> BasicBlock<'ctx> {
29-
pub(crate) fn new(basic_block: LLVMBasicBlockRef) -> Option<Self> {
29+
pub(crate) unsafe fn new(basic_block: LLVMBasicBlockRef) -> Option<Self> {
3030
if basic_block.is_null() {
3131
return None;
3232
}
3333

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

3937
Some(BasicBlock { basic_block, _marker: PhantomData })
4038
}
@@ -62,11 +60,9 @@ impl<'ctx> BasicBlock<'ctx> {
6260
/// assert!(basic_block.get_parent().is_none());
6361
/// ```
6462
pub fn get_parent(self) -> Option<FunctionValue<'ctx>> {
65-
let value = unsafe {
66-
LLVMGetBasicBlockParent(self.basic_block)
67-
};
68-
69-
FunctionValue::new(value)
63+
unsafe {
64+
FunctionValue::new(LLVMGetBasicBlockParent(self.basic_block))
65+
}
7066
}
7167

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

101-
let bb = unsafe {
102-
LLVMGetPreviousBasicBlock(self.basic_block)
103-
};
104-
105-
BasicBlock::new(bb)
97+
unsafe {
98+
BasicBlock::new(LLVMGetPreviousBasicBlock(self.basic_block))
99+
}
106100
}
107101

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

138-
let bb = unsafe {
139-
LLVMGetNextBasicBlock(self.basic_block)
140-
};
141-
142-
BasicBlock::new(bb)
132+
unsafe {
133+
BasicBlock::new(LLVMGetNextBasicBlock(self.basic_block))
134+
}
143135
}
144136

145137
/// Prepends one `BasicBlock` before another.
@@ -247,7 +239,9 @@ impl<'ctx> BasicBlock<'ctx> {
247239
return None;
248240
}
249241

250-
Some(InstructionValue::new(value))
242+
unsafe {
243+
Some(InstructionValue::new(value))
244+
}
251245
}
252246

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

284-
Some(InstructionValue::new(value))
278+
unsafe {
279+
Some(InstructionValue::new(value))
280+
}
285281
}
286282

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

322-
Some(InstructionValue::new(value))
318+
unsafe {
319+
Some(InstructionValue::new(value))
320+
}
323321
}
324322

325323
/// Removes this `BasicBlock` from its parent `FunctionValue`.
@@ -411,11 +409,9 @@ impl<'ctx> BasicBlock<'ctx> {
411409
/// assert_eq!(context, *basic_block.get_context());
412410
/// ```
413411
pub fn get_context(self) -> ContextRef<'ctx> {
414-
let context = unsafe {
415-
LLVMGetTypeContext(LLVMTypeOf(LLVMBasicBlockAsValue(self.basic_block)))
416-
};
417-
418-
ContextRef::new(context)
412+
unsafe {
413+
ContextRef::new(LLVMGetTypeContext(LLVMTypeOf(LLVMBasicBlockAsValue(self.basic_block))))
414+
}
419415
}
420416

421417
/// Gets the name of a `BasicBlock`.
@@ -514,7 +510,9 @@ impl<'ctx> BasicBlock<'ctx> {
514510
return None;
515511
}
516512

517-
Some(BasicValueUse::new(use_))
513+
unsafe {
514+
Some(BasicValueUse::new(use_))
515+
}
518516
}
519517
}
520518

0 commit comments

Comments
 (0)