garritfra/qbe-rs

This crate seeks to provide a Rust-y representation of QBE

It can be used for code generation of compilers

QBE IR for Rust

https://c9x.me/compile/

This crate seeks to provide a Rust-y representation of QBE IR. . A way to parse existing IR is planned.

Getting Started

This crate is on crates.io, so you can simply add it as a dependency in your Cargo.toml and off you go.

If you don't know where to get started, check out the hello_world example in the examples/ directory.

Projects using this crate

This crate is used by the Antimony project. Check out the QBE generator to see how they are using it.

License

The qbe crate is distributed under either of

at your option.

Issues

Collection of the latest Issues

icefoxen

icefoxen

Comment Icon2

The docstring for Function::add_block() says Adds a new empty block with a specified label and returns it, but the function doesn't return anything and you need to call last_block() instead. Is the function wrong, or the doc?

Oh, also last_block() doesn't return a mutable reference, so you can't do add_block() then last_block() and modify that block. The Function type's contents are transparent, so you can just do it manually, but it's surprising.

icefoxen

icefoxen

Comment Icon1

Just an idea I had while reading the example code. Pretty much what it says on the tin. If you like the idea I'll happily make a PR for it.

Pro's: Less typing function.add_block("foo".into()), more function.add_block("foo")

Con's: Probably a bit more compile time.

garritfra

garritfra

Comment Icon0

In the example/ directory, we should write a very simple compiler to demonstrate how to use this crate.

Versions

Find the latest versions by id

v2.0.0 - Mar 10, 2022

Changelog

Added

  • Function and DataDef now have a new constructor
  • Module now implements common traits (Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default and Copy)

Changed

  • Module::add_function, Module::add_type and Module::add_data now consume their corresponding structs, instead of constructing them

v1.0.0 - Feb 11, 2022

Changelog

Added

  • Data types now implement common traits (Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default and Copy) where applicable
  • Added Linkage data type (see Linkage)
  • Added a Module data type that houses functions and data definitions

Changed

  • Remove Qbe prefix from data structures. QbeValue becomes qbe::Value
  • The exported flag of a Function has been replaced with Linkage

v0.1.0 - Feb 09, 2022

This is the first release of the QBE IR for Rust.

Full Changelog: https://github.com/garritfra/qbe-rs/compare/v0.0.1...v0.1.0

Information - Updated Sep 05, 2022

Stars: 29
Forks: 2
Issues: 11

Repositories & Extras

A fantasy deathcrawl in Rust

To run, with Rust compiler and Cargo package manager installed:

A fantasy deathcrawl in Rust

MIRAI is an abstract interpreter for the Rust compiler's mid-level intermediate

MIRAI is an abstract interpreter for the mid-level intermediate

MIRAI is an abstract interpreter for the Rust compiler's mid-level intermediate

Rust compiler toolkit for WebAssembly apps in the WasmEdge Runtime

Developers: Getting started with the Tencent Serverless Functions for AI inference, or WasmEdge Runtime

Rust compiler toolkit for WebAssembly apps in the WasmEdge Runtime

guessing_game_rust

A repo used to learn rust using the Rust compiler

guessing_game_rust

owner-thing-rust

A repo used to learn rust using the Rust compiler

owner-thing-rust

enums_thing_rust

A repo used to learn rust using the Rust compiler

enums_thing_rust

collections-rust

A repo used to learn rust using the Rust compiler

collections-rust

A snake game written in Rust

Download Rust compiler from

A snake game written in Rust

C Compiler in Rust

A basic C compiler written in Rust, roughly following the tutorial official Rust compiler was taken as inspiration

C Compiler in Rust

It is rust bindings and wrapper around libconfig library

It is rust bindings and wrapper around Rust Compiler

It is rust bindings and wrapper around libconfig library

Toy Rust Compiler

A compiler can be broken down into 4 parts

Toy Rust Compiler
Facebook Instagram Twitter GitHub Dribbble
Privacy