Skip to content

Cr0a3/CodeGenLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A libary to generate x86-64Bit machine code

Warning: this libary is currently undergoing big changes so don't use in production

Example

use CodeGenLib::prelude::*;

#[rustfmt::skip]
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut builder = IrBuilder::new(Target::host());

    let add = builder.add("add");
    add.args(vec![
        ("x", Type::u64(0) ),
        ("y", Type::u64(0) ),
    ]);

    add.vars(vec![
        ("z", Type::u64(0) ),
    ]);

    add.build_add("x", "y", "z")?;
    add.build_return_var("z")?;

    add.set_public();

    builder.write("tmp/ir.o")?;

    Ok(())
}

Documentation

[ToDo]

Copyright

Copyright (C) 2024 Cr0a3

Releases

No releases published

Packages

No packages published