00001 #ifndef ROSE_SAGE_INTERFACE_ASM
00002 #define ROSE_SAGE_INTERFACE_ASM
00003
00004
00005
00006
00007 namespace SageInterface
00008 {
00009
00010
00011 void addComment(SgAsmStatement* stmt, const std::string & input_string );
00012
00013 SgAsmElfSection* getSection ( SgProject* project, const std::string & name );
00014
00015
00016 SgAsmElfSection* getSection ( SgProject* project, size_t ptr );
00017
00019 SgAsmFunction* getAsmFunction ( SgAsmInstruction* asmInstruction );
00020
00022 SgAsmBlock* getAsmBlock ( SgAsmInstruction* asmInstruction );
00023
00025 SgAsmInterpretation* getAsmInterpretation ( SgAsmNode* asmNode );
00026
00027 std::string generateUniqueName ( size_t value, std::map<size_t,int> & usedOffsets, size_t & counter );
00028
00029 size_t get_value ( SgAsmValueExpression* asmValueExpression );
00030 std::string get_valueString( SgAsmValueExpression* asmValueExpression );
00031
00032 bool isMovInstruction ( SgAsmInstruction* asmInstruction );
00033
00034 bool isInstructionKind ( SgAsmInstruction* asmInstruction, X86InstructionKind instuctionKind );
00035
00036 typedef bool (*EquivalenceTestFunctionType) (SgNode* x, SgNode* y);
00037
00038
00039 bool equivalenceTest(SgNode* x, SgNode* y);
00040
00041
00042 std::vector<SgNode*> flattenAST ( SgNode* node );
00043 std::vector<SgNode*> matchAST ( SgNode* node, std::vector<SgNode*> & listOfNodes, EquivalenceTestFunctionType equivalenceTest );
00044
00045
00046
00047 std::vector<SgNode*> find ( SgNode* astNode, SgNode* target, EquivalenceTestFunctionType equivalenceTest );
00048
00049
00051
00052 bool isNOP ( SgAsmInstruction* asmInstruction );
00054 bool isNOP ( const std::vector<SgAsmInstruction*> & asmInstructionList );
00056 std::vector<std::vector<SgAsmInstruction*> > find_NOP_sequences ( SgAsmBlock* asmBlock );
00057
00058
00060 void insertInstruction(SgAsmInstruction* targetInstruction, SgAsmInstruction* newInstruction, bool insertBefore);
00061
00063 void insertInstructionBefore(SgAsmInstruction* targetInstruction, SgAsmInstruction* newInstruction);
00064
00066 void removeInstruction(SgAsmStatement* instruction);
00067
00068 }
00069
00070
00071 #endif