From a08d91599d139b2faaa0673f5d55a8254cff60b0 Mon Sep 17 00:00:00 2001 From: Edgar Date: Thu, 18 Jan 2024 15:51:48 +0100 Subject: [PATCH] clean --- Cargo.lock | 4 +- crates/concrete_codegen_mlir/Cargo.toml | 2 +- crates/concrete_codegen_mlir/src/codegen.rs | 65 +-------------------- 3 files changed, 5 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4523aa7..25c2bd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -978,9 +978,9 @@ dependencies = [ [[package]] name = "melior" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758bbd4448db9e994578ab48a6da5210512378f70ac1632cc8c2ae0fbd6c21b5" +checksum = "878012ddccd6fdd099a4d98cebdecbaed9bc5eb325d0778ab9d4f4a52c67c18e" dependencies = [ "dashmap", "melior-macro", diff --git a/crates/concrete_codegen_mlir/Cargo.toml b/crates/concrete_codegen_mlir/Cargo.toml index 19ce13e..9df9c6f 100644 --- a/crates/concrete_codegen_mlir/Cargo.toml +++ b/crates/concrete_codegen_mlir/Cargo.toml @@ -11,7 +11,7 @@ concrete_ast = { path = "../concrete_ast"} concrete_session = { path = "../concrete_session"} itertools = "0.12.0" llvm-sys = "170.0.1" -melior = { version = "0.15.0", features = ["ods-dialects"] } +melior = { version = "0.15.2", features = ["ods-dialects"] } mlir-sys = "0.2.1" tracing.workspace = true diff --git a/crates/concrete_codegen_mlir/src/codegen.rs b/crates/concrete_codegen_mlir/src/codegen.rs index b4bf8bd..ce79401 100644 --- a/crates/concrete_codegen_mlir/src/codegen.rs +++ b/crates/concrete_codegen_mlir/src/codegen.rs @@ -3,8 +3,7 @@ use std::{collections::HashMap, error::Error}; use bumpalo::Bump; use concrete_ast::{ expressions::{ - ArithOp, BinaryOp, CmpOp, Expression, FnCallOp, IfExpr, LogicOp, PathOp, PathSegment, - ValueExpr, + ArithOp, BinaryOp, CmpOp, Expression, FnCallOp, IfExpr, LogicOp, PathOp, ValueExpr, }, functions::FunctionDef, modules::{Module, ModuleDefItem}, @@ -598,67 +597,7 @@ fn compile_assign_stmt<'ctx, 'parent: 'ctx>( Some(&local.type_spec), )?; - if info.target.extra.is_empty() { - block.append_operation(memref::store(value, local.value, &[], location)); - } else { - let mut store_target = block - .append_operation(memref::load(local.value, &[], location)) - .result(0)? - .into(); - - let mut segment_iter = info.target.extra.iter().peekable(); - - while let Some(segment) = segment_iter.next() { - match segment { - PathSegment::FieldAccess(_) => todo!(), - PathSegment::ArrayIndex(index) => { - let index = compile_value_expr( - session, context, scope_ctx, helper, block, index, None, - )?; - let index_ty = Type::index(context); - let index = block - .append_operation(melior::dialect::index::castu(index, index_ty, location)) - .result(0)? - .into(); - - if let TypeSpec::Array { - of_type: _, - size, - is_ref: _, - span, - } = &local.type_spec - { - let location = get_location(context, session, span.from); - - #[allow(clippy::if_same_then_else)] - if size.is_some() { - // todo: check inbounds? - store_target = block - .append_operation(memref::load(store_target, &[index], location)) - .result(0)? - .into(); - } else { - store_target = block - .append_operation(memref::load(store_target, &[index], location)) - .result(0)? - .into(); - } - - if segment_iter.peek().is_none() { - block.append_operation(memref::store( - value, - store_target, - &[index], - location, - )); - } - } else { - panic!("type should be a array when indexing a value"); - } - } - } - } - } + block.append_operation(memref::store(value, local.value, &[], location)); Ok(()) }