Description
Types and prettyprinter for the IL of the QBE compiler backend.
Description
This library provides types representing the intermediate language of the QBE compiler backend. It also provides pretty-printing instances based on the @prettyprinter@ library, that emit the textual representation of the IL.
README.md
qbe-hs
Haskell types and prettyprinter for the IL of the QBE compiler backend
Example
helloWorld :: Program
helloWorld = Program [] [helloString] [helloMain]
where
helloString = DataDef [] "str" Nothing
[ FieldExtTy Byte $ String "hello world" :| []
, FieldExtTy Byte $ Const (CInt False 0) :| []
]
helloMain = FuncDef [Export] (Just $ AbiBaseTy Word) "main"
Nothing [] NoVariadic $
Block "start"
[]
[ Call (Just ("r", AbiBaseTy Word)) (ValGlobal "puts")
Nothing
[Arg (AbiBaseTy Long) $ ValGlobal "str"]
[]
]
(Ret $ Just $ ValConst $ CInt False 0)
:| []
Gets rendered to
data $str =
{b "hello world", b 0}
export
function w $main () {
@start
%r =w call $puts (l $str)
ret 0
}
Contributing
You can send patches to my public-inbox mailing list or to any of the contacts listed at fgaz.me/about. Or you can send a pull request to the GitHub mirror.
Issues are tracked at https://todo.sr.ht/~fgaz/qbe-hs.