An open API service indexing awesome lists of open source software.

https://github.com/bollu/musquared

Demand-agnostic managed language compiler using MLIR
https://github.com/bollu/musquared

Last synced: 4 days ago
JSON representation

Demand-agnostic managed language compiler using MLIR

Awesome Lists containing this project

README

          

# λ ∈ MLIR | ![mu-squared](https://wikimedia.org/api/rest_v1/media/math/render/svg/68b31ff8082976980ee460521d36b8a30f9603a2)
- [Lioville function](https://en.wikipedia.org/wiki/Liouville_function)

### Good resources:

- [SPIR-V dialect spec](https://github.com/bollu/mlir/blob/master/orig_docs/Dialects/SPIR-V.md)
- [SPIR-V dialect base tablegen](https://github.com/bollu/mlir/blob/master/include/mlir/Dialect/SPIRV/SPIRVBase.td)
- [SPIR-V dialect header](https://github.com/bollu/mlir/blob/master/include/mlir/Dialect/SPIRV/SPIRVDialect.h)
- [SPIR-V dialect cpp](https://github.com/bollu/mlir/blob/master/lib/Dialect/SPIRV/SPIRVDialect.cpp)
- [SPIR-V types header](https://github.com/bollu/mlir/blob/master/include/mlir/Dialect/SPIRV/SPIRVTypes.h)
- [SPIR-V types cpp](https://github.com/bollu/mlir/blob/master/lib/Dialect/SPIRV/SPIRVTypes.cpp)

### Round tripping

- What stops someone from defining a printer that is completely different
from what the parser wants?

### GHC Core

- [`CoreSyn` data type in GHC](https://downloads.haskell.org/~ghc/8.8.3/docs/html/libraries/ghc-8.8.3/CoreSyn.html)
- [`CoreSyn` wiki commentary](https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/core-syn-type)
- [Stephen Diehl on targetting Core](https://www.stephendiehl.com/posts/ghc_03.html)

```hs
data Expr b
= Var Id
| Lit Literal
| App (Expr b) (Arg b)
| Lam b (Expr b)
| Let (Bind b) (Expr b)
| Case (Expr b) b Type [Alt b] -- See #case_invariants#
| Cast (Expr b) Coercion
| Tick (Tickish Id) (Expr b)
| Type Type
| Coercion Coercion
deriving Data

type Arg b = Expr b
type Alt b = (AltCon, [b], Expr b)

data AltCon = DataAlt DataCon | LitAlt Literal | DEFAULT

data Bind b = NonRec b (Expr b) | Rec [(b, (Expr b))]

```

### `hask-programs/`

To run these, first install the GHC plugin from `ghc-dump`. This installs
both the plugin that is loaded with `-fplugin GhcDump.Plugin` [The package `ghc-dump-core`]
as well as the utility tool for dumping these called `ghc-dump` [The package `ghc-dump-util`].

```
# install tool and compiler plugin
$ cd ghc-dump && cabal install --lib all && cabal install all
```

Then run the makefile:

```
# run the makefile, generate the dump, pretty print the dump
$ cd hask-programs && make && ghc-dump --show fib.pass-0000.cbor
```

### TODO

- [ ] Parse `case x of { ... }` style input.
- [ ] Parse `let var = val in ...` input.
- [ ] Add `PrimInt` type.
- [ ] Get factorial up and running.
- [ ] Get a notion of explicit GC.