Add readme
This commit is contained in:
53
README.md
Normal file
53
README.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# qbe-hs
|
||||||
|
|
||||||
|
[](https://hackage.haskell.org/package/qbe)
|
||||||
|
[](https://builds.sr.ht/~fgaz/qbe-hs/commits/master?)
|
||||||
|
|
||||||
|
Haskell types and prettyprinter for the [IL](https://c9x.me/compile/doc/il.html)
|
||||||
|
of the [QBE](https://c9x.me/compile/) compiler backend
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```haskell
|
||||||
|
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](https://lists.sr.ht/~fgaz/public-inbox)
|
||||||
|
or to any of the contacts listed at [fgaz.me/about](https://fgaz.me/about).
|
||||||
|
Or you can send a pull request to the
|
||||||
|
[GitHub mirror](https://github.com/fgaz/qbe-hs).
|
||||||
|
|
||||||
|
Issues are tracked at https://todo.sr.ht/~fgaz/qbe-hs
|
||||||
@@ -19,7 +19,7 @@ copyright: 2022 Francesco Gazzetta
|
|||||||
category: Language
|
category: Language
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
extra-doc-files: CHANGELOG.md
|
extra-doc-files: CHANGELOG.md
|
||||||
extra-source-files: golden/*.qbe
|
extra-source-files: README.md golden/*.qbe
|
||||||
tested-with:
|
tested-with:
|
||||||
, GHC == 8.10.7
|
, GHC == 8.10.7
|
||||||
, GHC == 9.0.2
|
, GHC == 9.0.2
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ helloWorld = Program [] [helloString] [helloMain]
|
|||||||
Nothing [] NoVariadic $
|
Nothing [] NoVariadic $
|
||||||
Block "start"
|
Block "start"
|
||||||
[]
|
[]
|
||||||
[Call (Just ("r", AbiBaseTy Word)) (ValGlobal "puts") Nothing [Arg (AbiBaseTy Long) $ ValGlobal "str"] []]
|
[ Call (Just ("r", AbiBaseTy Word)) (ValGlobal "puts")
|
||||||
|
Nothing
|
||||||
|
[Arg (AbiBaseTy Long) $ ValGlobal "str"]
|
||||||
|
[]
|
||||||
|
]
|
||||||
(Ret $ Just $ ValConst $ CInt False 0)
|
(Ret $ Just $ ValConst $ CInt False 0)
|
||||||
:| []
|
:| []
|
||||||
|
|||||||
Reference in New Issue
Block a user