2#ifndef ROSE_SgAsmInstruction_H
3#define ROSE_SgAsmInstruction_H
5#include <Cxx_GrammarDeclarations.h>
6#include <SgAsmStatement.h>
27#include <Rose/BinaryAnalysis/Architecture/BasicTypes.h>
28#include <Rose/BinaryAnalysis/MemoryMap.h>
29#include <sageContainer.h>
30#include <Sawyer/Cached.h>
32#ifdef ROSE_SgAsmInstruction_IMPL
33#include <SgAsmExprListExp.h>
34#include <SgAsmOperandList.h>
42#if !defined(DOCUMENTATION)
57#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
59 friend class boost::serialization::access;
66 auto temp = architectureIdSerialize(p_architectureId);
67 s & boost::serialization::make_nvp(
"p_architectureId", temp);
68 p_architectureId = architectureIdDeserialize(temp);
70 s & BOOST_SERIALIZATION_NVP(p_rawBytes);
71 s & BOOST_SERIALIZATION_NVP(p_operandList);
72 s & BOOST_SERIALIZATION_NVP(p_delaySlot);
73 s & BOOST_SERIALIZATION_NVP(p_sources);
81 struct SemanticFailure {
83 SemanticFailure(): n(0) {}
85#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
87 friend class boost::serialization::access;
90 s & BOOST_SERIALIZATION_NVP(n);
106 uint8_t
const& get_architectureId()
const;
109 std::string architectureIdSerialize(uint8_t
id)
const;
110 uint8_t architectureIdDeserialize(
const std::string &name)
const;
117 SgUnsignedCharList
const& get_rawBytes()
const;
118 void set_rawBytes(SgUnsignedCharList
const&);
160 int64_t
const& get_stackDeltaIn()
const;
161 void set_stackDeltaIn(int64_t
const&);
179 SemanticFailure semanticFailure_;
186 static const int64_t INVALID_STACK_DELTA;
206 std::
string get_mnemonic() const;
209 virtual std::
string description() const final ROSE_DEPRECATED("use Architecture::Base::instructionDescription");
212 size_t nOperands() const;
220 virtual
bool terminatesBasicBlock() final ROSE_DEPRECATED("use Architecture::Base::terminatesBasicBlock");
221 virtual
bool isFunctionCallFast(const std::vector<
SgAsmInstruction*>&, rose_addr_t *target, rose_addr_t *ret) final
222 ROSE_DEPRECATED("use Architecture::Base::isFunctionCallFast");
223 virtual
bool isFunctionCallSlow(const std::vector<
SgAsmInstruction*>&, rose_addr_t *target, rose_addr_t *ret) final
224 ROSE_DEPRECATED("use Architecture::Base::isFunctionCallSlow");
225 virtual
bool isFunctionReturnFast(const std::vector<
SgAsmInstruction*>&) final
226 ROSE_DEPRECATED("use Architecture::Base::isFunctionReturnFast");
227 virtual
bool isFunctionReturnSlow(const std::vector<
SgAsmInstruction*>&) final
228 ROSE_DEPRECATED("use Architecture::Base::isFunctionReturnSlow");
229 virtual
Sawyer::Optional<rose_addr_t> branchTarget() final
230 ROSE_DEPRECATED("use Architecture::Base::branchTarget");
235 bool isFirstInBlock();
240 bool isLastInBlock();
376 virtual
bool hasEffect();
386 virtual
bool hasEffect(const std::vector<
SgAsmInstruction*>&,
bool allow_branch=false,
387 bool relax_stack_semantics=false);
398 virtual std::vector<std::pair<
size_t,
size_t> >
399 findNoopSubsequences(const std::vector<
SgAsmInstruction*>& insns,
bool allow_branch=false,
400 bool relax_stack_semantics=false);
403 virtual
Rose::BinaryAnalysis::AddressSet getSuccessors(
bool &complete)
404 ROSE_DEPRECATED("use Architecture::Base::getSuccessors");
405 virtual
Rose::BinaryAnalysis::AddressSet getSuccessors(const std::vector<
SgAsmInstruction*> &basicBlock,
407 const
Rose::BinaryAnalysis::MemoryMap::Ptr &initial_memory =
408 Rose::BinaryAnalysis::MemoryMap::Ptr())
409 ROSE_DEPRECATED("use Architecture::Base::getSuccessors");
416 virtual
size_t get_size() const;
419 virtual
bool isUnknown() const final ROSE_DEPRECATED("use Architecture::Base::isUnknown");
454 virtual
unsigned get_anyKind() const;
459 virtual std::
string toString() const;
464 virtual std::
string toStringNoAddr() const;
470 virtual std::set<rose_addr_t> explicitConstants() const;
481 size_t semanticFailure() const;
482 void semanticFailure(
size_t);
483 void incrementSemanticFailure();
494 bool normalizeOperands();
500 const SgUnsignedCharList& get_raw_bytes() const ROSE_DEPRECATED("use get_rawBytes");
501 void set_raw_bytes(const SgUnsignedCharList&) ROSE_DEPRECATED("use set_rawBytes");
513 uint8_t const& architectureId);
522 void initializeProperties();
541 virtual std::
string class_name() const override;
544 virtual VariantT variantT() const override;
549 enum { static_variant = V_SgAsmInstruction };
564 static const unsigned pool_size;
566 static std::vector<unsigned char *> pools;
571 static unsigned long initializeStorageClassArray(SgAsmInstructionStorageClass *);
574 static void clearMemoryPool();
575 static void deleteMemoryPool();
578 static void extendMemoryPoolForFileIO();
583 static SgAsmInstruction * getPointerFromGlobalIndex(AstSpecificDataManagingClass *,
unsigned long);
586 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long);
588 static void resetValidFreepointers();
590 static unsigned long getNumberOfLastValidPointer();
593#if defined(INLINE_FUNCTIONS)
595 inline void *
operator new (
size_t size);
598 void *
operator new (
size_t size);
601 void operator delete (
void* pointer,
size_t size);
604 void operator delete (
void* pointer)
650#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
653 virtual RTIReturnType
roseRTI()
override;
667 virtual const char*
sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
673 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
855 friend class SgAsmInstructionStorageClass;
858 friend class AstSpecificDataManagingClass;
861 friend class AstSpecificDataManagingClassStorageClass;
893#define BUILD_ATERM_SUPPORT 0
894 #if BUILD_ATERM_SUPPORT
895 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
907 virtual ATerm generate_ATerm()
override;
910 virtual void generate_ATerm_Annotation(ATerm & term)
override;
942uint8_t p_architectureId;
946SgUnsignedCharList p_rawBytes;
958SgAsmStatementPtrList p_sources;
962int64_t p_stackDeltaIn;
Class holding static data and functions supporting File I/O.
Attribute containing a regex expression as a string.
List of expression nodes.
Base class for expressions.
Base class for machine instructions.
List of operands for an instruction.
Base class for statement-like subclasses.
Supporting class from copy mechanism within ROSE.
This class represents the base class for all IR nodes within Sage III.
virtual size_t get_numberOfTraversalSuccessors()
return number of children in the traversal successor list
virtual RTIReturnType roseRTI()
return C++ Runtime-Time-Information
virtual std::vector< std::string > get_traversalSuccessorNamesContainer()
container of names of variables or container indices used used in the traversal to access AST success...
virtual void debugSerializationEnd(const char *className)
Called by generated serializers.
static std::string getNodeIdString(SgNode *sgnode)
compute the NodeId for a particular SgNode*.
virtual bool isInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
int variant() const
Older version function returns enum value "NODE".
virtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler *)
FOR INTERNAL USE Processes pairs of references to SgNode* and strings for use in AST tools
virtual long getChildIndex(SgNode *childNode) const
FOR INTERNAL USE Returns a unique index value for the childNode in the list of children at this IR no...
virtual size_t get_childIndex(SgNode *child)
index-based access to traversal successors by child node
virtual void debugSerializationBegin(const char *className)
Called by generated serializers.
virtual std::vector< SgNode * > get_traversalSuccessorContainer()
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
static void visitRepresentativeNode(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for type-based traversal.
virtual void checkDataMemberPointersIfInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
static size_t numberOfNodes()
Returns the total number of IR nodes of this type.
virtual void accept(ROSE_VisitorPattern &visitor)
support for the classic visitor pattern done in GoF
virtual SgNode * get_traversalSuccessorByIndex(size_t idx)
index-based access to traversal successors by index number
static void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
void executeVisitorMemberFunction(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
static SgNode * getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx)
Find a node by its variant type, pool index, and item index.
static size_t memoryUsage()
Returns the size in bytes of the total memory allocated for all IR nodes of this type.
static void traverseMemoryPoolNodes(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
virtual const char * sage_class_name() const
generates string representing the class name: (e.g. for SgNode returns "SgNode").
virtual std::vector< std::pair< SgNode *, std::string > > returnDataMemberPointers() const
FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools
static SgNode * getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx)
FOR INTERNAL USE Find an SgNode from its memory pool and location therin.
SgNode * addRegExpAttribute(std::string s, AstRegExAttribute *a)
Support for AST matching using regular expression.
std::shared_ptr< const Base > BaseConstPtr
Reference counted pointer for Architecture::Base.
void serialize(std::ostream &output, Graph &graph)
Serialize a graph into a stream of bytes.
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.