From 2709eb874904c2cd50bcbe84d3fedbff115c867c Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 28 Jul 2025 12:21:00 +0300 Subject: [PATCH] Compile bitwise operations as well --- reid-llvm-lib/src/compile.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/reid-llvm-lib/src/compile.rs b/reid-llvm-lib/src/compile.rs index 039e9a5..4710846 100644 --- a/reid-llvm-lib/src/compile.rs +++ b/reid-llvm-lib/src/compile.rs @@ -975,11 +975,31 @@ impl InstructionHolder { ty.as_llvm(module.context_ref, &module.types), name.as_ptr(), ), - Or(instruction_value, instruction_value1) => todo!(), - XOr(instruction_value, instruction_value1) => todo!(), - ShiftRightLogical(instruction_value, instruction_value1) => todo!(), - ShiftRightArithmetic(instruction_value, instruction_value1) => todo!(), - ShiftLeft(instruction_value, instruction_value1) => todo!(), + Or(lhs, rhs) => { + let lhs_val = module.values.get(&lhs).unwrap().value_ref; + let rhs_val = module.values.get(&rhs).unwrap().value_ref; + LLVMBuildOr(module.builder_ref, lhs_val, rhs_val, name.as_ptr()) + } + XOr(lhs, rhs) => { + let lhs_val = module.values.get(&lhs).unwrap().value_ref; + let rhs_val = module.values.get(&rhs).unwrap().value_ref; + LLVMBuildXor(module.builder_ref, lhs_val, rhs_val, name.as_ptr()) + } + ShiftRightLogical(lhs, rhs) => { + let lhs_val = module.values.get(&lhs).unwrap().value_ref; + let rhs_val = module.values.get(&rhs).unwrap().value_ref; + LLVMBuildLShr(module.builder_ref, lhs_val, rhs_val, name.as_ptr()) + } + ShiftRightArithmetic(lhs, rhs) => { + let lhs_val = module.values.get(&lhs).unwrap().value_ref; + let rhs_val = module.values.get(&rhs).unwrap().value_ref; + LLVMBuildAShr(module.builder_ref, lhs_val, rhs_val, name.as_ptr()) + } + ShiftLeft(lhs, rhs) => { + let lhs_val = module.values.get(&lhs).unwrap().value_ref; + let rhs_val = module.values.get(&rhs).unwrap().value_ref; + LLVMBuildShl(module.builder_ref, lhs_val, rhs_val, name.as_ptr()) + } } }; if let Some(record) = &self.record {