~fgaz/qbe-hs

Haskell types and prettyprinter for the intermediate language of the QBE compiler backend

clone

read-only
https://git.sr.ht/~fgaz/qbe-hs
read/write
git@git.sr.ht:~fgaz/qbe-hs

You can also use your local clone with git send-email.

#qbe-hs

Hackage builds.sr.ht status

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