Skip to content

MartinPrograms/QbeGenerator-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QbeGenerator-cpp

This is an LLVM style builder for Qbe!

Example usage:

#include "Qbe.h"

Qbe::Module module(true); // 64-bit module

// declare printf, with varargs
auto printf = module.defineFunction("printf", Qbe::Int32, {Qbe::Local("fmt", Qbe::Pointer)}, true); 

// declare the main function with the entry point flag
auto main = module.addFunction("main", Qbe::Int32, {}, false, Qbe::FunctionFlags::EntryPoint);
{
    auto block = main->entryPoint();
    block->addCall(printf, {module.addGlobal("Hello, World!\\n")});
    block->addReturn(Qbe::CreateLiteral(0));
}

auto qbeCode = module.emit();

outputs Hello, World! :3

You can use this project by using fetch content and adding the QbeIR cmake project

Now you can use the qbe command line tool to compile the generated code to assembly!
Check out the docs here

About

A Qbe IR generator in C++ (instead of C#)!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published