Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ compiler.developPackage {

modifier = drv: pkgs.haskell.lib.compose.addBuildTools [
pkgs.haskellPackages.cabal-install
pkgs.haskell-language-server
# LLVM CLI tools for local testing purposes.
pkgs.llvm_9
# For viewing heap profiles (mainly ps2pdf).
Expand Down
7 changes: 7 additions & 0 deletions elemental.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ common shared
, bytestring ^>= 0.10
, containers ^>= 0.6
, data-fix ^>= 0.3
, dlist ^>= 1.0
, fused-effects ^>= 1.1
, integer-logarithms ^>= 1.0
, lens ^>= 4.19
, llvm-hs == 9.0.1
, llvm-hs-pure ^>= 9.0
, megaparsec ^>= 9.0
, prettyprinter ^>= 1.7
, tagged ^>= 0.8
, text ^>= 1.2
, text-short ^>= 0.1
, transformers ^>= 0.5
default-language: Haskell2010
ghc-options:
-Wall
Expand Down Expand Up @@ -70,9 +73,12 @@ library
, Language.Elemental.AST.Program
, Language.Elemental.AST.Type
, Language.Elemental.AST.Unchecked
, Language.Elemental.Backend
, Language.Elemental.Backend.LLVM
, Language.Elemental.Diagnostic
, Language.Elemental.Emit
, Language.Elemental.Location
, Language.Elemental.InteractionNet
, Language.Elemental.Parser
, Language.Elemental.Pretty
, Language.Elemental.Primitive
Expand Down Expand Up @@ -116,5 +122,6 @@ test-suite test
, tasty ^>= 1.4
, tasty-golden ^>= 2.3
, tasty-hedgehog ^>= 1.1
, tasty-hunit ^>= 0.10
ghc-options:
-threaded
5 changes: 4 additions & 1 deletion src/Control/Effect/ModuleBuilder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ function
-- ^ The types of the function arguments.
-> Type
-- ^ The return type of the function.
-> Linkage
-- ^ The linkage of the function.
-> ([Operand] -> IRBuilderC m ())
-- ^ A function that builds the function's basic blocks from its arguments.
-> m Operand
function nm argTys retTy body = do
function nm argTys retTy link body = do
(blocks, paramNames) <- runIRBuilder emptyIRBuilder $ do
paramNames <- traverse (const fresh) argTys
body $ zipWith LocalReference argTys paramNames
Expand All @@ -71,6 +73,7 @@ function nm argTys retTy body = do
= (($ []) <$> zipWith Parameter argTys paramNames, False)
, returnType = retTy
, basicBlocks = blocks
, linkage = link
}
funTy = ptr $ FunctionType retTy argTys False
ConstantOperand (GlobalReference funTy nm) <$ emitDefn def
Expand Down
8 changes: 7 additions & 1 deletion src/Language/Elemental.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module Language.Elemental
-- * Emitting
-- $emitting
, module Language.Elemental.Emit
, module Language.Elemental.InteractionNet
) where

import Data.Version (Version)
Expand All @@ -45,6 +46,7 @@ import Language.Elemental.AST.Type
import Language.Elemental.AST.Unchecked
import Language.Elemental.Diagnostic
import Language.Elemental.Emit
import Language.Elemental.InteractionNet
import Language.Elemental.Location
import Language.Elemental.Parser
import Language.Elemental.Pretty
Expand Down Expand Up @@ -116,7 +118,11 @@ version = Paths.version
-}

{- $emitting
Programs can be emitted as LLVM using 'emitProgram'.
Programs can be emitted as interaction nets using 'emitProgram'. These can
then be compiled with 'compileINet'. This will output a generic backend
representation, which can finally be converted into LLVM using
"Language.Elemental.Backend.LLVM" or into some other target language by
manually folding the representation.

The compiler also exposes its other emitting functions, however their
interface may be more volatile as there's no clear use case for them.
Expand Down
Loading