This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Emulating cps call using LLVM Coroutines | |
; RUN: opt coro-cps.ll -O2 -enable-coroutines -S | |
define void @f(i32 %arg) { | |
entry: | |
%bar.ret.addr = alloca i32 | |
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null) | |
%size = call i32 @llvm.coro.size.i32() | |
%alloc = call i8* @malloc(i32 %size) | |
%hdl = call noalias i8* @llvm.coro.begin(token %id, i8* %alloc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is my short-ish tutorial on how to implement closures in | |
a simple functional language: Foo. | |
First, some boilerplate. | |
> {-# LANGUAGE DeriveFunctor, TypeFamilies #-} | |
> import Control.Applicative | |
> import Control.Monad.Gen | |
> import Control.Monad.Writer | |
> import Data.Functor.Foldable |