Coder Social home page Coder Social logo

rllvm's Introduction

RLLVM

Languages GitHub Repo stars GitHub License Dynamic TOML Badge

LLVM alternativ

Example

use std::error::Error;
use rllvm::prelude::*;

fn main() -> Result<(), Box<dyn Error>>{
    let mut contxt = Context::new( Triple::host() )?;
    let func = contxt.add_function("add", vec![Type::u32, Type::u32], Type::u32);
    let asm = func.asm_func()?;

    let x = asm.arg(0).unwrap();
    let y = asm.arg(1).unwrap();

    func.ir.push( Return::new(*(x + y) ) );


    unsafe {
        let mut func: JitFunction<unsafe extern "C" fn(u32, u32) -> u32> = contxt.get_jit_function("add")?;
        let out = func.call(5, 5);

        println!("main() -> {}", out);
    }

    Ok(())
}

ToDo

Here is a bit of ToDo for my libary:

v0.1.2

  • Starting high level ir struct
    • Use traits impl Compiler for Ir::Add<Var, Int> so i can overload the enum variants
    • Make it compilable
    • Implement mov, add, sub, mul, div | ints, floats
      • mov
      • add
      • sub
      • mul
      • div
      • ints
      • floats
    • Starting high level ir builder
      • via traits

v0.1.3

  • Implement args to the high level ir
  • Add option (in context) to compile to object file
  • Naming convention
    • generate
    • parse

rllvm's People

Contributors

toni-graphics avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

gmh5225

rllvm's Issues

Jitlinker: wrong adress

Memory dump:

main:

  • 0 mov ecx, 5
  • 5 mov edx, 5
  • 10 call 26
  • 15 ret

add:

  • 16 add ecx, edx
  • 18 mov eax, ecx
  • 20 ret

We see at adress 10 - call 26 - is the adress which is put in wrong. It should be call 20
Surly some offset bug

[JIT] sus output

The output of the function seems to be not copied so it is kept in the register which will shortly be overwritten after the call.

(Trough pure luck ~44% of uses work the rest not)

Docs

Docs workflow needs fix

Floats

Returning floats doesn't work

[JIT] Runtime Linker

Currently the runtime linker usage in the example gives acess violation:
error: process didn't exit successfully: `target\debug\examples\link.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.