| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef BINOP_SIMPLIFICATION_H |
| 12 |
#define BINOP_SIMPLIFICATION_H |
| 13 |
|
| 14 |
#include <string> |
| 15 |
#include "llvm/ADT/SmallVector.h" |
| 16 |
#include "Transformation.h" |
| 17 |
|
| 18 |
namespace clang { |
| 19 |
class DeclGroupRef; |
| 20 |
class ASTContext; |
| 21 |
class FunctionDecl; |
| 22 |
class Stmt; |
| 23 |
class BinaryOperator; |
| 24 |
} |
| 25 |
|
| 26 |
class BSCollectionVisitor; |
| 27 |
class BSStatementVisitor; |
| 28 |
|
| 29 |
class BinOpSimplification : public Transformation { |
| 30 |
friend class BSCollectionVisitor; |
| 31 |
friend class BSStatementVisitor; |
| 32 |
|
| 33 |
public: |
| 34 |
|
| 35 |
BinOpSimplification(const char *TransName, const char *Desc) |
| 36 |
: Transformation(TransName, Desc), |
| 37 |
BinOpCollectionVisitor(NULL), |
| 38 |
StmtVisitor(NULL), |
| 39 |
NameQueryWrap(NULL), |
| 40 |
TheFuncDecl(NULL), |
| 41 |
TheStmt(NULL), |
| 42 |
TheBinOp(NULL), |
| 43 |
TmpVarName(""), |
| 44 |
NeedParen(false) |
| 45 |
{ } |
| 46 |
|
| 47 |
~BinOpSimplification(void); |
| 48 |
|
| 49 |
private: |
| 50 |
|
| 51 |
virtual void Initialize(clang::ASTContext &context); |
| 52 |
|
| 53 |
virtual bool HandleTopLevelDecl(clang::DeclGroupRef D); |
| 54 |
|
| 55 |
virtual void HandleTranslationUnit(clang::ASTContext &Ctx); |
| 56 |
|
| 57 |
bool addNewTmpVariable(void); |
| 58 |
|
| 59 |
bool addNewAssignStmt(void); |
| 60 |
|
| 61 |
bool replaceBinOp(void); |
| 62 |
|
| 63 |
void setTmpVarName(std::string &Name) { |
| 64 |
TmpVarName = Name; |
| 65 |
} |
| 66 |
|
| 67 |
std::string getTmpVarName(void) { |
| 68 |
return TmpVarName; |
| 69 |
} |
| 70 |
|
| 71 |
clang::SmallVector<clang::BinaryOperator *, 10> ValidBinOps; |
| 72 |
|
| 73 |
BSCollectionVisitor *BinOpCollectionVisitor; |
| 74 |
|
| 75 |
BSStatementVisitor *StmtVisitor; |
| 76 |
|
| 77 |
TransNameQueryWrap *NameQueryWrap; |
| 78 |
|
| 79 |
clang::FunctionDecl *TheFuncDecl; |
| 80 |
|
| 81 |
clang::Stmt *TheStmt; |
| 82 |
|
| 83 |
clang::BinaryOperator *TheBinOp; |
| 84 |
|
| 85 |
std::string TmpVarName; |
| 86 |
|
| 87 |
bool NeedParen; |
| 88 |
|
| 89 |
|
| 90 |
BinOpSimplification(void); |
| 91 |
|
| 92 |
BinOpSimplification(const BinOpSimplification &); |
| 93 |
|
| 94 |
void operator=(const BinOpSimplification &); |
| 95 |
}; |
| 96 |
#endif |