8000 Dfa by s-nil · Pull Request #28 · llvm/llvm-project · GitHub
[go: up one dir, main page]

Skip to content

Dfa #28

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

Closed
wants to merge 3 commits into from
Closed

Dfa #28

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FlowSet abstract class is being created as a template that would be a
linkedlist to support different type of values(llvm). But there is some
issue in the push_back function declaration. After doing changes, llvm
is being built successfully but while using this in a pass an error is
being thrown when trying to run the pass. Pass is being built
successfully but while loading the pass using opt and running it with a
program symbol lookup error is being thrown.
  • Loading branch information
s-nil committed Sep 28, 2019
commit ef18c4029c01939e41c12000fc837c44428f9768
101 changes: 101 additions & 0 deletions llvm/include/llvm/DataFlowAnalysis/FlowSet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#ifndef LLVM_DFA_FLOWSET_H
#define LLVM_DFA_FLOWSET_H
#include <iostream>

using namespace std;
namespace llvm{

template <typename T>
class FlowSet
{
class Node;

public:
FlowSet<T>() noexcept
{
//m_spRoot = nullptr;
}

class Iterator;

Iterator begin()
{
return Iterator(m_spRoot);
}

Iterator end()
{
return Iterator(nullptr);
}

void push_back(T data);
//void traverse();

class Iterator
{
public:
Iterator() noexcept:
m_pCurrentNode(m_spRoot){ }

Iterator(const Node* pNode) noexcept:
m_pCurrentNode(pNode){ }

Iterator& operator=(Node* pNode)
{
this->m_pCurrentNode = pNode;
return *this;
}

Iterator& operator++()
{
if(m_pCurrentNode)
m_pCurrentNode = m_pCurrentNode->pNext;
return *this;
}

Iterator& operator++(int)
{
Iterator it = *this;
++*this;
return it;
}

Iterator& operator!=(const Iterator& it)
{
return m_pCurrentNode != it.m_pCurrentNode;
}

int operator*()
{
return m_pCurrentNode->data;
}
private:
const Node* m_pCurrentNode;
};

private:
class Node
{
T data;
Node* pNext;

friend class FlowSet;
};

Node* getNode(T d)
{
Node* pTmp = new Node;
pTmp->data = d;
pTmp->pNext = nullptr;
return pTmp;
}
Node*& getRoot()
{
return m_spRoot;
}
static Node* m_spRoot;
};

} // end namepspace llvm

#endif // LLVM_DFA_FLOWSET_H
25 changes: 25 additions & 0 deletions llvm/lib/DataFlowAnalysis/FlowSet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "llvm/DataFlowAnalysis/FlowSet.h"

using namespace llvm;

template <typename T>
typename FlowSet<T>::Node* FlowSet<T>::m_spRoot = nullptr;

template <typename T>
void FlowSet<T>::push_back(T data)
{
Node* pTemp = getNode(data);
if(!getRoot())
{
getRoot() = pTemp;
}
else
{
Node* pC = getRoot();
while(pC->pNext)
{
pC = pC->pNext;
}
pC->pNext = pTemp;
}
}
0