Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 8 additions & 11 deletions include/Token/Token.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@

namespace spatial {

enum opTokenTy {
isArray,
isAlloca,
isOpBitcast,
isPhiGEPOpd,
isIcmpGEPOpd,
isOneGEPIndx,
isFunArg
};

enum opTokenTy {isArray, isAlloca, isOpBitcast, isPhiGEPOpd, isIcmpGEPOpd, isOneGEPIndx, isFunPtr, isFunArg};

class Token {
private:
Expand Down Expand Up @@ -102,6 +95,8 @@ class Token {
bool getIsIcmpGEPOpd();
void setIsOneGEPIndx();
bool getIsOneGEPIndx();
void setIsFunPtr();
bool getIsFunPtr();
void setIsFunArg();
bool getIsFunArg();

Expand All @@ -110,8 +105,10 @@ class Token {

bool isNullToken();
void setNullToken();
llvm::Type *getTy();
void setTy(llvm::Type *);
llvm::Type* getTy();
void setTy(llvm::Type*);
void setFunction(llvm::Function*);
llvm::Function* getFunction();
};
} // namespace spatial

Expand Down
56 changes: 34 additions & 22 deletions lib/Token/Token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace spatial {

Token::Token() {
this->TyLength = 7;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
this->TyLength = 8;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
}

void Token::set(llvm::Value *Val, unsigned int Kind, std::string Index,
Expand Down Expand Up @@ -48,13 +48,16 @@ void Token::set(std::string S, unsigned int Kind, std::string Index,
this->Func = Func;
}

Token::Token(llvm::Value *Val, std::string Index) {
this->TyLength = 7;

Token::Token(llvm::Value *Val, std::string Index) {
this->TyLength = 8;
this->opTokenTy = llvm::BitVector(this->TyLength, false);

if (llvm::Argument *Arg = llvm::dyn_cast<llvm::Argument>(Val)) {
set(Arg, /* Kind = */ 2, Index, Arg->getParent());
} else {
this->setIsGlobal();
this->setIsFunArg();
} else {
// If Val is GEPOperator, it must be coming from load/store
if (llvm::GEPOperator *GOP = llvm::dyn_cast<llvm::GEPOperator>(Val)) {
// We handle GEPInst separately
Expand All @@ -78,35 +81,36 @@ Token::Token(llvm::Value *Val, std::string Index) {
}
}

Token::Token(llvm::GEPOperator *GOP, llvm::Function *Func, std::string Index) {
this->TyLength = 7;
this->opTokenTy = llvm::BitVector(this->TyLength, false);

Token::Token(llvm::GEPOperator *GOP, llvm::Function *Func, std::string Index) {
this->TyLength = 8;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
llvm::Value *Val = GOP->getPointerOperand();
Index = this->getIndex(GOP);
set(Val, /* Kind = */ 0, Index, Func);
}

Token::Token(llvm::Argument *Arg, std::string Index) {
this->TyLength = 7;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
set(Arg, /* Kind = */ 2, Index, Arg->getParent());

Token::Token(llvm::Argument *Arg, std::string Index) {
this->TyLength = 8;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
set(Arg, /* Kind = */ 2, Index, Arg->getParent());
}

Token::Token(llvm::Type *Ty, std::string Index) {
this->TyLength = 7;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
set(Ty, /* Kind = */ 1, Index);
this->TyLength = 8;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
set(Ty, /* Kind = */ 1, Index);
}

Token::Token(std::string S, llvm::Function *Func, std::string Index) {
this->TyLength = 7;
Token::Token(std::string S, llvm::Function *Func, std::string Index) {
this->TyLength = 8;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
set(S, /* Kind = */ 3, Index, Func);
}

Token::Token(Token *A) {
this->TyLength = 7;
this->TyLength = 8;
this->opTokenTy = llvm::BitVector(this->TyLength, false);
unsigned int Kind = A->Kind;
if (Kind == 0) {
Expand Down Expand Up @@ -355,13 +359,16 @@ bool Token::getIsPhiGEPOpd() { return opTokenTy.test(isPhiGEPOpd); }

void Token::setIsIcmpGEPOpd() { this->opTokenTy.set(isIcmpGEPOpd); }

bool Token::getIsIcmpGEPOpd() { return opTokenTy.test(isIcmpGEPOpd); }

void Token::setIsOneGEPIndx() { this->opTokenTy.set(isOneGEPIndx); }
void Token::setIsFunPtr() { this->opTokenTy.set(isFunPtr); }

bool Token::getIsFunPtr() { return opTokenTy.test(isFunPtr); }

void Token::setIsFunArg() { this->opTokenTy.set(isFunArg); }

bool Token::getIsFunArg() { return opTokenTy.test(isFunArg); }
void Token::setIsOneGEPIndx() { this->opTokenTy.set(isOneGEPIndx); }

void Token::setIsFunArg() { this->opTokenTy.set(isFunArg); }

template <typename GOP> std::vector<int> Token::getGEPArrayIndex(GOP *G) {
std::vector<int> Idx;
Expand All @@ -386,5 +393,10 @@ bool Token::isNullToken() {

llvm::Type *Token::getTy() { return this->Ty; }

void Token::setTy(llvm::Type *type) { this->Ty = type; }
void Token::setTy(llvm::Type* type) { this->Ty = type;}

void Token::setFunction(llvm::Function* F) { this->Func = F; }

llvm::Function* Token::getFunction() { return this->Func; }

} // namespace spatial