Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/rcalc-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:

env:
CARGO_TERM_COLOR: always
LLVM_VERSION: 18.1
LLVM_VERSION: 21.1
LLVM_VERSION_MAJOR: 21

jobs:
test-rcalc:
Expand All @@ -22,9 +23,18 @@ jobs:
- name: Update rust toolchain
run: rustup update
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ env.LLVM_VERSION }}
run: |
sudo apt install --no-install-recommends -y lsb-release wget software-properties-common gnupg
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ env.LLVM_VERSION_MAJOR }}
sudo apt-get update
sudo apt install --no-install-recommends -y libllvm${{ env.LLVM_VERSION_MAJOR }} \
llvm-${{ env.LLVM_VERSION_MAJOR }} \
llvm-${{ env.LLVM_VERSION_MAJOR }}-dev \
llvm-${{ env.LLVM_VERSION_MAJOR }}-runtime \
libpolly-${{ env.LLVM_VERSION_MAJOR }}-dev
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${{ env.LLVM_VERSION_MAJOR }} 10
- name: Run llvm-config
run: llvm-config --version --bindir --libdir
- name: Cache cargo build
Expand Down
43 changes: 18 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jit = ["inkwell"]

[dependencies]
clap = { version = "4.5.38", features = ["derive"] }
inkwell = { version = "0.6.0", features = ["llvm18-1"], optional = true }
inkwell = { version = "0.7.1", features = ["llvm21-1"], optional = true }
peg = "0.8.5"
8 changes: 3 additions & 5 deletions src/visitor/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ impl<'ctx> CalculatorJIT<'ctx> {
func: FuncLLVM<'ctx, FloatValue<'ctx>>,
) -> Result<(), SymbolError> {
let ret_type = self.double();
let args_types = std::iter::repeat(ret_type)
.take(argc)
let args_types = std::iter::repeat_n(ret_type, argc)
.map(|f| f.into())
.collect::<Vec<BasicMetadataTypeEnum>>();
let args_types = args_types.as_slice();
Expand Down Expand Up @@ -124,7 +123,7 @@ impl<'ctx> CalculatorJIT<'ctx> {
Ok(())
}

pub fn compile(&mut self, ast: &Expr) -> Option<JitFunction<CalcMain>> {
pub fn compile(&mut self, ast: &Expr) -> Option<JitFunction<'_, CalcMain>> {
let sig = self.double().fn_type(&[], false);
let func = self.module.add_function(CALC_ENTRYPOINT, sig, None);
let basic_block = self.context.append_basic_block(func, "entry");
Expand Down Expand Up @@ -202,8 +201,7 @@ impl<'ctx> Visitor<FloatValue<'ctx>> for CalculatorJIT<'ctx> {
.build_call(func, argsv.as_slice(), "tmp")
.expect("Unable to call function")
.try_as_basic_value()
.left()
.unwrap();
.unwrap_basic();

ret_val.into_float_value()
}
Expand Down