diff --git a/include/Token/Token.h b/include/Token/Token.h index 60591a9..bc627a0 100644 --- a/include/Token/Token.h +++ b/include/Token/Token.h @@ -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: @@ -102,6 +95,8 @@ class Token { bool getIsIcmpGEPOpd(); void setIsOneGEPIndx(); bool getIsOneGEPIndx(); + void setIsFunPtr(); + bool getIsFunPtr(); void setIsFunArg(); bool getIsFunArg(); @@ -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 diff --git a/lib/Token/Token.cpp b/lib/Token/Token.cpp index 84bd220..9a62dbd 100644 --- a/lib/Token/Token.cpp +++ b/lib/Token/Token.cpp @@ -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, @@ -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(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(Val)) { // We handle GEPInst separately @@ -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) { @@ -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 std::vector Token::getGEPArrayIndex(GOP *G) { std::vector Idx; @@ -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