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);
80 struct SemanticFailure {
82 SemanticFailure(): n(0) {}
84#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
86 friend class boost::serialization::access;
89 s & BOOST_SERIALIZATION_NVP(n);
110 uint8_t
const& get_architectureId()
const;
114 std::string architectureIdSerialize(uint8_t
id)
const;
115 uint8_t architectureIdDeserialize(
const std::string &name)
const;
122 SgUnsignedCharList
const& get_rawBytes()
const;
123 void set_rawBytes(SgUnsignedCharList
const&);
161 int64_t
const& get_stackDeltaIn()
const;
162 void set_stackDeltaIn(int64_t
const&);
180 SemanticFailure semanticFailure_;
187 static const int64_t INVALID_STACK_DELTA;
208 std::
string get_mnemonic() const;
211 virtual std::
string description() const final ROSE_DEPRECATED("use Architecture::Base::instructionDescription");
214 size_t nOperands() const;
222 virtual
bool terminatesBasicBlock() final ROSE_DEPRECATED("use Architecture::Base::terminatesBasicBlock");
223 virtual
bool isFunctionCallFast(const std::vector<
SgAsmInstruction*>&, rose_addr_t *target, rose_addr_t *ret) final
224 ROSE_DEPRECATED("use Architecture::Base::isFunctionCallFast");
225 virtual
bool isFunctionCallSlow(const std::vector<
SgAsmInstruction*>&, rose_addr_t *target, rose_addr_t *ret) final
226 ROSE_DEPRECATED("use Architecture::Base::isFunctionCallSlow");
227 virtual
bool isFunctionReturnFast(const std::vector<
SgAsmInstruction*>&) final
228 ROSE_DEPRECATED("use Architecture::Base::isFunctionReturnFast");
229 virtual
bool isFunctionReturnSlow(const std::vector<
SgAsmInstruction*>&) final
230 ROSE_DEPRECATED("use Architecture::Base::isFunctionReturnSlow");
231 virtual
Sawyer::Optional<rose_addr_t> branchTarget() final
232 ROSE_DEPRECATED("use Architecture::Base::branchTarget");
237 bool isFirstInBlock();
242 bool isLastInBlock();
378 virtual
bool hasEffect();
388 virtual
bool hasEffect(const std::vector<
SgAsmInstruction*>&,
bool allow_branch=false,
389 bool relax_stack_semantics=false);
400 virtual std::vector<std::pair<
size_t,
size_t> >
401 findNoopSubsequences(const std::vector<
SgAsmInstruction*>& insns,
bool allow_branch=false,
402 bool relax_stack_semantics=false);
405 virtual
Rose::BinaryAnalysis::AddressSet getSuccessors(
bool &complete)
406 ROSE_DEPRECATED("use Architecture::Base::getSuccessors");
407 virtual
Rose::BinaryAnalysis::AddressSet getSuccessors(const std::vector<
SgAsmInstruction*> &basicBlock,
409 const
Rose::BinaryAnalysis::MemoryMap::Ptr &initial_memory =
410 Rose::BinaryAnalysis::MemoryMap::Ptr())
411 ROSE_DEPRECATED("use Architecture::Base::getSuccessors");
418 virtual
size_t get_size() const;
421 virtual
bool isUnknown() const final ROSE_DEPRECATED("use Architecture::Base::isUnknown");
456 virtual
unsigned get_anyKind() const;
461 virtual std::
string toString() const;
466 virtual std::
string toStringNoAddr() const;
472 virtual std::set<rose_addr_t> explicitConstants() const;
483 size_t semanticFailure() const;
484 void semanticFailure(
size_t);
485 void incrementSemanticFailure();
496 bool normalizeOperands();
502 const SgUnsignedCharList& get_raw_bytes() const ROSE_DEPRECATED("use get_rawBytes");
503 void set_raw_bytes(const SgUnsignedCharList&) ROSE_DEPRECATED("use set_rawBytes");
515 uint8_t const& architectureId);
524 void initializeProperties();
543 virtual std::
string class_name() const override;
546 virtual VariantT variantT() const override;
551 enum { static_variant = V_SgAsmInstruction };
566 static const unsigned pool_size;
568 static std::vector<unsigned char *> pools;
573 static unsigned long initializeStorageClassArray(SgAsmInstructionStorageClass *);
576 static void clearMemoryPool();
577 static void deleteMemoryPool();
580 static void extendMemoryPoolForFileIO();
585 static SgAsmInstruction * getPointerFromGlobalIndex(AstSpecificDataManagingClass *,
unsigned long);
588 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long);
590 static void resetValidFreepointers();
592 static unsigned long getNumberOfLastValidPointer();
595#if defined(INLINE_FUNCTIONS)
597 inline void *
operator new (
size_t size);
600 void *
operator new (
size_t size);
603 void operator delete (
void* pointer,
size_t size);
606 void operator delete (
void* pointer)
652#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
655 virtual RTIReturnType
roseRTI()
override;
669 virtual const char*
sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
675 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
857 friend class SgAsmInstructionStorageClass;
860 friend class AstSpecificDataManagingClass;
863 friend class AstSpecificDataManagingClassStorageClass;
895#define BUILD_ATERM_SUPPORT 0
896 #if BUILD_ATERM_SUPPORT
897 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
909 virtual ATerm generate_ATerm()
override;
912 virtual void generate_ATerm_Annotation(ATerm & term)
override;
943uint8_t p_architectureId;
947SgUnsignedCharList p_rawBytes;
959int64_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.