@hackage qbe1.1.0.0

Types and prettyprinter for the IL of the QBE compiler backend

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