lambdaclass / concrete

Concrete is a simple programming language specifically crafted for creating highly scalable systems that are reliable, efficient, and easy to maintain.
Apache License 2.0
123 stars 11 forks source link

Setup initial compiler driver and basic mlir boilerplate #60

Closed edg-l closed 8 months ago

edg-l commented 8 months ago

The cli interface or the driver is by no means anything ready but it's enough to be able to compile programs and help the development further.

Like rust, we use a folder to store intermediate files and artifacts (like object files) (like a target/), for now i called it build_artifacts.

cargo r -- --library examples/fib.con produces right now an empty shared library (since we dont have codegen implemented yet)

outputs this:

2024-01-08T15:11:42.387329Z DEBUG concrete_driver: source code:
mod FactorialModule {
    pub fn factorial(x: u64) -> u64  {
        return match x {
            0 -> return 1,
            n -> return n * factorial(n-1),
        };
    }
}

2024-01-08T15:11:42.387409Z DEBUG concrete_driver: Output file: "/snip/concrete/build_artifacts/fib.con"
2024-01-08T15:11:42.387414Z DEBUG concrete_driver: Compiling with session: Session {
    file_path: "examples/fib.con",
    debug_info: Full,
    optlevel: None,
    source: "mod FactorialModule {\n    pub fn factorial(x: u64) -> u64  {\n        return match x {\n            0 -> return 1,\n            n -> return n * factorial(n-1),\n        };\n    }\n}\n",
    library: true,
    target_dir: "/snip/concrete/build_artifacts/",
    output_file: "/snip/concrete/build_artifacts/fib.so",
}
2024-01-08T15:11:42.390431Z DEBUG concrete_codegen_mlir: Compiling to object file
2024-01-08T15:11:42.390443Z DEBUG concrete_codegen_mlir: Target file: "fib.o"
2024-01-08T15:11:42.390501Z DEBUG concrete_codegen_mlir: initialized llvm targets
2024-01-08T15:11:42.390632Z DEBUG concrete_codegen_mlir: filename to llvm: "/snip/concrete/build_artifacts/fib.o"
2024-01-08T15:11:42.397798Z DEBUG concrete_driver: Done in 11.054603ms
codecov-commenter commented 8 months ago

Codecov Report

Attention: 285 lines in your changes are missing coverage. Please review.

Comparison is base (6583301) 52.38% compared to head (a173826) 17.22%.

Files Patch % Lines
crates/concrete_codegen_mlir/src/lib.rs 0.00% 108 Missing :warning:
crates/concrete_driver/src/lib.rs 0.00% 43 Missing :warning:
crates/concrete_parser/src/lib.rs 0.00% 41 Missing :warning:
crates/concrete_codegen_mlir/src/context.rs 0.00% 35 Missing :warning:
crates/concrete_codegen_mlir/src/codegen.rs 0.00% 17 Missing :warning:
crates/concrete_codegen_mlir/src/pass_manager.rs 0.00% 13 Missing :warning:
crates/concrete_codegen_mlir/src/module.rs 0.00% 11 Missing :warning:
crates/concrete_session/src/lib.rs 0.00% 7 Missing :warning:
crates/concrete_codegen_mlir/src/error.rs 0.00% 4 Missing :warning:
crates/concrete/src/main.rs 0.00% 2 Missing :warning:
... and 2 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #60 +/- ## =========================================== - Coverage 52.38% 17.22% -35.16% =========================================== Files 14 25 +11 Lines 126 389 +263 =========================================== + Hits 66 67 +1 - Misses 60 322 +262 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

unbalancedparentheses commented 8 months ago

I will merge it, it looks fine, there are quite a few todo. I think it's a good idea to create issues rather than to keep the todos in the codebase. In a few weeks I will ask to move all the todos to issues.

I was speaking with @igaray. I would have gone the C generation route like Austral is doing. I think it's easier but you guys are proficient with MLIR so let's start with it. If things go sour we can go back, remove the MLIR and start with C generation and we add the MLIR generation afterwards.