Skip to content

Commit

Permalink
better explanation, resistent against remaining ds calls (non-callee …
Browse files Browse the repository at this point in the history
…position)
  • Loading branch information
NeuralCoder3 committed May 26, 2023
1 parent 57593f2 commit b398b7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 6 additions & 8 deletions dialects/direct/direct.thorin
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
///
/// [TOC]
///
/// This plugin has three jobs:
/// 1. Convert inline direct style calls to CPS (and their functions).
/// 2. Wrap DS functions to CPS functions using an axiom.
/// 3. Convert CPS functions to DS functions using an axiom.
/// This plugin has two operating phases:
/// 1. ds2cps: Convert direct style functions to CPS functions.
/// This transformation changes the type signature and wraps the body in a return.
/// Replace all callee occurrences (call sites) with a wrapped call using the `cps2ds` axiom.
/// 2. cps2ds: Replace calls to the `cps2ds` axiom with cps style continuations.
/// For each call, a new continuation is created and the function call continues in the new function.
///
/// ## Dependencies
///
.import compile;
///
/// ## Operations
///
/// ### %direct.ds2cps
///
// .ax %direct.ds2cps: Π [T: *, U: *] -> (T -> U) -> .Cn [T, .Cn U];
///
/// ### %direct.cps2ds
///
/// This axiom lets the user call a cps function in direct style.
Expand Down
5 changes: 5 additions & 0 deletions dialects/direct/passes/cps2ds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iostream>

#include <thorin/lam.h>
#include "thorin/lattice.h"

#include "dialects/direct/autogen.h"
#include "dialects/direct/direct.h"
Expand All @@ -18,6 +19,10 @@ void CPS2DS::rewrite_lam(Lam* lam) {
lam->world().DLOG("skipped {}", lam);
return;
}
if(!lam->codom()->isa<Bot>()) {
world().WLOG("direct style lambda {} : {} skipped. This will likely cause problems during code generation.", lam, lam->type());
return;
}

lam->world().DLOG("Rewrite lam: {}", lam->sym());

Expand Down

0 comments on commit b398b7d

Please sign in to comment.