#Glove - A gleam library for creating QBE IR

1 messages · Page 1 of 1 (latest)

finite compass
next hedge
#

!!!

#

that's is so cool

#

Oh I like the logo a lot

finite compass
finite compass
#

this is a working example. Needs some polish but compiles: ```rs
import gleam/io
import gleam/option.{None, Some}
import glove

pub fn main() {
let data_def =
glove.DataDef(
linkage: glove.Linkage(exported: False, section: None, secflags: None),
name: "str",
align: None,
items: [
#(glove.Byte, glove.Str("hello world")),
#(glove.Byte, glove.Constant(0)),
],
)

let main_func =
glove.Function(
linkage: glove.public(),
name: "main",
arguments: [],
return_ty: Some(glove.Word),
blocks: [
glove.Block(
label: "@start",
statements: [
glove.Assign(
glove.Temporary("r"),
glove.Word,
glove.Call(
glove.Global("puts"),
[#(glove.Long, glove.Global("str"))],
),
),
glove.Volatile(glove.Ret(Some(glove.Const(0)))),
],
),
],
)

let empty_module = glove.Module(functions: [], types: [], data: [])
empty_module
|> glove.add_data(data_def)
|> glove.add_function(main_func)
|> glove.display_module
|> io.print
}
// Expectable result:
//export function w $main() {
//@start
// # Call the puts function with $str as argument.
// %r =w call $puts(l $str)
// ret 0
//}
//
//data $str = { b "hello world", b 0 }

elfin sequoia
#

How are y’all making these awesome repo logos

finite compass
#

it is the best for quick logos

elfin sequoia
#

Oh derp im dumb you answered the same question above 😂

#

This looks cool!

#

What’s QBE

#

🙃

finite compass
#

It is a compiler backend

elfin sequoia
#

Oooooo

finite compass
#

the library creates qbe ir code that compiles with the qbe to assembly

elfin sequoia
#

That’s so cool 😮

finite compass
#

The code example i provided creates the QBE code to create a executable to say: hello world 😛

finite compass
elfin sequoia
finite compass
#

I am thinking if I have to add export file with the code or let users to do it.

next hedge
#

I'd just let them do it

finite compass
#

Next steps: 1. Cover more qbe instructions. 2. Write a small AST to QBE IR example.

finite compass
#

@next hedge and @cunning sierra i hope you don't mind I added your names in special thanks section

next hedge
#

I did nothing! 😄

cunning sierra
#

Yeah that's fine with me! Thanks 😄

finite compass
#

You create gleam! 😜

elfin sequoia
#

@next hedge as dr frankenstein talking to his creation: “what the hell what kind of moron made you”

finite compass
#

I will add @simple hawk too, if she use it for yak 😛

cunning sierra
#

I just wish qbe had windows support

#

I did end up testing it on windows and it didn't work

next hedge
#

Yeah me too

finite compass
#

This is why I want to make another library.

elfin sequoia
#

qwindows

finite compass
#

If qbe supported windows I wouldn't bother

balmy ether
#

maybe just like try to add support instead of starting from scratch then

next hedge
#

I think he wanted to make a C generation library rather than a qbe alternative

next hedge
#

Globe! Great name @finite compass

finite compass
balmy ether
#

based

finite compass
#

There was an answer on adding windows support to another user: "choose a better OS" 🤣🤣

balmy ether
#

id say the same thing tbh but I wouldnt complain if someone implements it for me

finite compass
#

Well I am not a windows user so I don't want to spend time to implement it.

#

Also programming is a hobby for me so I prefer to contribute something to gleam community.

cunning sierra
finite compass
#

I will take a look after work. Thank you!

finite compass
#

Just released v2.0.0 . I think it covers at least of 95% of QBE spec now.