ROSE 0.11.145.147
Unparser/Aarch64.h
1#ifndef ROSE_BinaryAnalysis_Unparser_Aarch64_H
2#define ROSE_BinaryAnalysis_Unparser_Aarch64_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_ASM_AARCH64
5
6#include <Rose/BinaryAnalysis/BasicTypes.h>
7#include <Rose/BinaryAnalysis/InstructionEnumsAarch64.h>
8#include <Rose/BinaryAnalysis/Unparser/Base.h>
9
10namespace Rose {
11namespace BinaryAnalysis {
12namespace Unparser {
13
14std::string unparseAarch64Mnemonic(SgAsmAarch64Instruction*);
15std::string unparseAarch64Expression(SgAsmExpression*, const LabelMap*);
16
18struct Aarch64Settings: public Settings {};
19
23class Aarch64: public Base {
24 Aarch64Settings settings_;
25
26protected:
27 explicit Aarch64(const Architecture::BaseConstPtr&, const Aarch64Settings&);
28
29public:
30 ~Aarch64();
31
32 static Ptr instance(const Architecture::BaseConstPtr&, const Aarch64Settings& = Aarch64Settings());
33
34 Ptr copy() const override;
35
36 const Aarch64Settings& settings() const override { return settings_; }
37 Aarch64Settings& settings() override { return settings_; }
38
39protected:
40 void emitInstructionMnemonic(std::ostream&, SgAsmInstruction*, State&) const override;
41 void emitOperandBody(std::ostream&, SgAsmExpression*, State&) const override;
42
43protected:
44 static std::string unparseArmCondition(Aarch64InstructionCondition);
45 void outputExpr(std::ostream&, SgAsmExpression*, State&) const;
46 void outputRegister(std::ostream&, SgAsmRegisterReferenceExpression*, State&) const;
47
48private:
49 // Precedence for the sake of emitting expressions. Higher return value is higher precedence.
50 static int operatorPrecedence(SgAsmExpression*);
51
52 // Parentheses for emitting expressions with inverted precedences
53 struct Parens {
54 std::string left, right;
55 Parens() {}
56 Parens(const std::string &left, const std::string &right)
57 : left(left), right(right) {}
58 };
59
60 // What parens to use when the operator has rootPrec and the left or right operand is as specified.
61 static Parens parensForPrecedence(int rootPrec, SgAsmExpression*);
62};
63
64} // namespace
65} // namespace
66} // namespace
67
68#endif
69#endif
Base class for expressions.
Base class for machine instructions.
Base class for references to a machine register.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
std::map< uint64_t, std::string > LabelMap
Map from address to label.
The ROSE library.
Settings settings
Command-line settings for the rosebud tool.
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.