All Projects → llvm-hs → llvm-hs-typed

llvm-hs / llvm-hs-typed

Licence: other
Type Safe LLVM IR ( Experimental )

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to llvm-hs-typed

bl
Simple imperative programming language created for fun.
Stars: ✭ 57 (+21.28%)
Mutual labels:  llvm, llvm-ir
Mcsema
Framework for lifting x86, amd64, aarch64, sparc32, and sparc64 program binaries to LLVM bitcode
Stars: ✭ 2,198 (+4576.6%)
Mutual labels:  llvm, llvm-ir
Llvm Hs
Haskell bindings for LLVM
Stars: ✭ 370 (+687.23%)
Mutual labels:  llvm, code-generation
Llvm
Project moved to: https://github.com/llvm/llvm-project
Stars: ✭ 4,461 (+9391.49%)
Mutual labels:  llvm, code-generation
doc
Design documents related to the decompilation pipeline.
Stars: ✭ 23 (-51.06%)
Mutual labels:  llvm, llvm-ir
llvm-brainfuck
Brainfuck compiler based on LLVM API
Stars: ✭ 27 (-42.55%)
Mutual labels:  llvm, llvm-ir
Zion
A statically-typed strictly-evaluated garbage-collected readable programming language.
Stars: ✭ 33 (-29.79%)
Mutual labels:  llvm, type-safety
llvm-kaleidoscope
LLVM Tutorial: Kaleidoscope (Implementing a Language with LLVM)
Stars: ✭ 124 (+163.83%)
Mutual labels:  llvm, llvm-ir
llvm-semantics
Formal semantics of LLVM IR in K
Stars: ✭ 42 (-10.64%)
Mutual labels:  llvm, llvm-ir
LLAST
A high level LLVM IR AST provider for GraphEngine JIT.
Stars: ✭ 21 (-55.32%)
Mutual labels:  llvm, llvm-ir
Weld
High-performance runtime for data analytics applications
Stars: ✭ 2,709 (+5663.83%)
Mutual labels:  llvm, code-generation
TinyCompiler
c compiler based on flex(lex), bison(yacc) and LLVM, supports LLVM IR and obj code generation. 基于flex,bison以及LLVM,使用c++11实现的类C语法编译器, 支持生成中间代码及可执行文件.
Stars: ✭ 162 (+244.68%)
Mutual labels:  llvm, llvm-ir
Compiler-written-in-Haskell
A Turing complete language 😉
Stars: ✭ 31 (-34.04%)
Mutual labels:  llvm, llvm-hs
LLVM-Metadata-Visualizer
LLVM Metadata Visualizer
Stars: ✭ 20 (-57.45%)
Mutual labels:  llvm, llvm-ir
sum types.dart
A code generator enabling sum-types in Dart
Stars: ✭ 39 (-17.02%)
Mutual labels:  code-generation
php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (-23.4%)
Mutual labels:  code-generation
stack-guard
A toy implementation of 'Stack Guard' on top of the LLVM compiler toolchain
Stars: ✭ 21 (-55.32%)
Mutual labels:  llvm
jitmap
LLVM-jitted bitmaps
Stars: ✭ 25 (-46.81%)
Mutual labels:  llvm
malgo
A statically typed functional programming language.
Stars: ✭ 37 (-21.28%)
Mutual labels:  llvm
wasm-toolchain
WebAssembly toolchain
Stars: ✭ 34 (-27.66%)
Mutual labels:  llvm

llvm-hs-typed

Build Status

An experimental branch of llvm-hs-pure AST that enforces the semantics of correct AST construction using the Haskell type system to prevent malformed ASTs.

Usage

Typed AST

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}

module Example where

-- AST
import GHC.TypeLits
import LLVM.Prelude
import LLVM.AST.Tagged
import LLVM.AST.Constant
import LLVM.AST.Tagged.Global
import LLVM.AST.Tagged.Constant
import LLVM.AST.Tagged.Tag
import LLVM.AST.TypeLevel.Type

import qualified LLVM.AST as AST
import qualified LLVM.AST.Global as AST

c0 :: Constant ::: IntegerType' 32
c0 = int 42

named :: forall (t :: Type'). ShortByteString -> Name ::: t
named s = assertLLVMType $ AST.Name s

type ArgTys = [(IntegerType' 32), (IntegerType' 32)]
type RetTy = IntegerType' 32

defAdd :: Global
defAdd = function nm (params, False) [body, body]
  where
    nm :: Name ::: (PointerType' (FunctionType' (IntegerType' 32) ArgTys) ('AddrSpace' 0))
    nm = named "add"

    -- Types of subexpression are inferred from toplevel LLVM function signature

    {-p1 :: Parameter ::: (IntegerType' 32)-}
    p1 = parameter (named "a") []

    {-p2 :: Parameter ::: (IntegerType' 32)-}
    p2 = parameter (named "b") []

    {-body :: BasicBlock ::: IntegerType' 32-}
    body = basicBlock "entry" [] (ret (constantOperand c0) [])

    {-params :: Parameter :::* ArgTys-}
    params = p1 :* p2 :* tnil

module_ :: AST.Module
module_ = defaultModule
  { moduleName = "basic"
  , moduleDefinitions = [GlobalDefinition defAdd]
  }

Typed IRBuilder

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}

module Example2 where

import GHC.TypeLits
import LLVM.Prelude
import LLVM.AST.Constant
import LLVM.AST.Tagged.Global
import LLVM.AST.Tagged.Tag
import LLVM.AST.TypeLevel.Type
import qualified LLVM.AST as AST
import qualified LLVM.AST.Type as AST
import qualified LLVM.AST.Global as AST
import qualified LLVM.AST.Tagged as AST

import LLVM.AST.Tagged.IRBuilder as TBuilder
import qualified LLVM.IRBuilder as Builder

import Data.Coerce

simple :: AST.Module
simple = Builder.buildModule "exampleModule" $ do
    func
  where
  func :: Builder.ModuleBuilder (AST.Operand ::: IntegerType' 32)
  func =
    TBuilder.function "add" [(AST.i32, "a"), (AST.i32, "b")] $ \[a, b] -> do
      entry <- block `named` "entry"; do
        c <- add (coerce a) (coerce b)
        ret c

License

Copyright (c) 2017, Joachim Breitner

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].