Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend Preparation: Nested Extract Splitting #187

Open
NeuralCoder3 opened this issue Mar 13, 2023 · 0 comments
Open

Backend Preparation: Nested Extract Splitting #187

NeuralCoder3 opened this issue Mar 13, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@NeuralCoder3
Copy link
Collaborator

NeuralCoder3 commented Mar 13, 2023

We need a phase that splits nested extracts into basic blocks to move this burden away from the backends.
Issue raised in regard to #181

Related code snippet:

// A call to an extract like constructed for conditionals (else,then)#cond (args)
// TODO: we can not rely on the structure of the extract (it might be a nested extract)
for (auto callee_def : ex->tuple()->projs()) {
    // dissect the tuple of lambdas
    auto callee = callee_def->isa_nom<Lam>();
    assert(callee);
    // each callees type should agree with the argument type (should be checked by type checking).
    // Especially, the number of vars should be the number of arguments.
    // TODO: does not hold for complex arguments that are not tuples.
    assert(callee->num_vars() == app->num_args());
    for (size_t i = 0, e = callee->num_vars(); i != e; ++i) {
        // emits the arguments one by one (TODO: handle together like before)
        if (auto arg = emit_unsafe(app->arg(i)); !arg.empty()) {
            auto phi = callee->var(i);
            assert(!match<mem::M>(phi->type()));
            lam2bb_[callee].phis[phi].emplace_back(arg, id(lam, true));
            locals_[phi] = id(phi);
        }
    }
}

instead of emit_unsafe(app->arg()); in the case

auto ex = app->callee()->isa<Extract>(); ex && app->callee_type()->is_basicblock()

The corresponding tests in affine are marked as *.disabled_extract.

@leissa leissa added the enhancement New feature or request label Mar 13, 2023
NeuralCoder3 added a commit to NeuralCoder3/thorin2 that referenced this issue Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants