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