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

Add pointer offsetting (add) and intrinsic parsing #125

Closed edg-l closed 4 months ago

edg-l commented 4 months ago

Added the ability to offset a pointer, this allows us to do the following:

mod HelloWorld {
    pub extern fn malloc(size: u64) -> *mut u8;
    pub extern fn puts(data: *mut u8) -> i32;

    fn main() -> i32 {
        let origin: *mut u8 = malloc(12);
        let mut p: *mut u8 = origin;

        *p = 'H';
        p = p + 1;
        *p = 'e';
        p = p + 1;
        *p = 'l';
        p = p + 1;
        *p = 'l';
        p = p + 1;
         *p = 'o';
        p = p + 1;
         *p = ' ';
        p = p + 1;
         *p = 'W';
        p = p + 1;
         *p = 'o';
        p = p + 1;
         *p = 'r';
        p = p + 1;
         *p = 'l';
        p = p + 1;
         *p = 'd';
        p = p + 1;
        *p = '\0';
        puts(origin);

        return 0;
    }
}

Which prints "Hello World"

Also added the ability to add attributes to functions, and declare intrinsics:

mod MyMod {
    #[intrinsic = "simdsomething"]
    pub extern fn myintrinsic();
}
github-actions[bot] commented 4 months ago

Benchmarking factorial

Compiling factorial (factorial.con) Finished release in 30.809279ms Running 5000000 iterations Using input value: 20 Concrete Result = 2432902008176640000 Time taken : 59.21 ms Rust Result = 2432902008176640000 Time taken : 60.24 ms

Benchmarking fib

Compiling fib (fib.con) Finished release in 26.396626ms Running 5000 iterations Using input value: 20 Concrete Result = 6765 Time taken : 135.98 ms Rust Result = 6765 Time taken : 85.24 ms

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 71.42857% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 61.78%. Comparing base (27904dc) to head (aff819d).

Files Patch % Lines
crates/concrete_codegen_mlir/src/codegen.rs 69.44% 11 Missing :warning:
crates/concrete_ir/src/lib.rs 0.00% 6 Missing :warning:
crates/concrete_ir/src/lowering.rs 84.21% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #125 +/- ## ========================================== + Coverage 61.63% 61.78% +0.15% ========================================== Files 25 25 Lines 4329 4394 +65 ========================================== + Hits 2668 2715 +47 - Misses 1661 1679 +18 ```

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