Skip to content

Commit

Permalink
hoist_enters + importer cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kurtenacker committed Jan 4, 2023
1 parent 72d2dee commit 9eaba5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/thorin/transform/hoist_enters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace thorin {

std::stack<const Def*> todo;
static std::stack<const Def*> hoist_enters_todo;

static void find_enters(std::deque<const Enter*>& enters, const Def* def) {
if (auto enter = def->isa<Enter>())
Expand All @@ -19,15 +19,15 @@ static void find_enters(std::deque<const Enter*>& enters, const Def* def) {

for (auto use : def->uses()) {
if (auto memop = use->isa<MemOp>())
todo.push(memop);
hoist_enters_todo.push(memop);
}
}

static void find_enters(std::deque<const Enter*>& enters, Continuation* continuation) {
if (auto mem_param = continuation->mem_param()) {
todo.push(mem_param);
while (!todo.empty()) {
auto next_item = pop(todo);
hoist_enters_todo.push(mem_param);
while (!hoist_enters_todo.empty()) {
auto next_item = pop(hoist_enters_todo);

find_enters(enters, next_item);
}
Expand Down
9 changes: 1 addition & 8 deletions src/thorin/transform/importer.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "thorin/transform/importer.h"

#include <set>
#include <stack>
#include <utility>

namespace thorin {

const Type* Importer::import_type(const Type* otype) {
Expand Down Expand Up @@ -32,10 +28,7 @@ const Type* Importer::import_type(const Type* otype) {
return ntype;
}

std::stack<std::pair<const Def*, bool>> required_defs;
std::set<const Def *> analyzed_conts;

void enqueue(const Def* elem) {
void Importer::enqueue(const Def* elem) {
if (elem->isa_nom<Continuation>()) {
if (analyzed_conts.find(elem) != analyzed_conts.end()) {
required_defs.push(std::pair(elem, false));
Expand Down
8 changes: 8 additions & 0 deletions src/thorin/transform/importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include "thorin/world.h"
#include "thorin/config.h"

#include <set>
#include <stack>
#include <utility>

namespace thorin {

class Importer {
Expand All @@ -26,6 +30,10 @@ class Importer {

private:
const Def* import_nonrecursive();
void enqueue(const Def* elem);

std::stack<std::pair<const Def*, bool>> required_defs;
std::set<const Def*> analyzed_conts;

public:
Type2Type type_old2new_;
Expand Down

0 comments on commit 9eaba5d

Please sign in to comment.