ROSE  0.11.50.0
Aarch32.h
1 #ifndef ROSE_BinaryAnalysis_Unparser_Aarch32_H
2 #define ROSE_BinaryAnalysis_Unparser_Aarch32_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_ASM_AARCH32
5 
6 #include <Rose/BinaryAnalysis/Unparser/Base.h>
7 
8 namespace Rose {
9 namespace BinaryAnalysis {
10 namespace Unparser {
11 
12 std::string unparseAarch32Mnemonic(SgAsmAarch32Instruction*);
13 std::string unparseAarch32Expression(SgAsmExpression*, const LabelMap*, const RegisterDictionary*);
14 
15 struct Aarch32Settings: public Settings {};
16 
20 class Aarch32: public Base {
21  Aarch32Settings settings_;
22 
23 protected:
24  explicit Aarch32(const Aarch32Settings &settings)
25  : settings_(settings) {}
26 
27 public:
28  ~Aarch32() {}
29 
30  static Ptr instance(const Aarch32Settings &settings = Aarch32Settings()) {
31  return Ptr(new Aarch32(settings));
32  }
33 
34  Ptr copy() const ROSE_OVERRIDE {
35  return instance(settings());
36  }
37 
38  const Aarch32Settings& settings() const ROSE_OVERRIDE { return settings_; }
39  Aarch32Settings& settings() ROSE_OVERRIDE { return settings_; }
40 
41 protected:
42  void emitInstructionMnemonic(std::ostream&, SgAsmInstruction*, State&) const override;
43  void emitOperandBody(std::ostream&, SgAsmExpression*, State&) const override;
44 
45 protected:
46  void outputExpr(std::ostream&, SgAsmExpression*, State &) const;
47  void outputRegister(std::ostream&, SgAsmRegisterReferenceExpression*, State&) const;
48 
49 private:
50  // Precedence for the sake of emitting expressions. Higher return value is higher precedence.
51  static int operatorPrecedence(SgAsmExpression*);
52 
53  // Parentheses for emitting expressions with inverted precedences
54  struct Parens {
55  std::string left, right;
56  Parens() {}
57  Parens(const std::string &left, const std::string &right)
58  : left(left), right(right) {}
59  };
60 
61  // What parens to use when the operator has rootPrec and the left or right operand is as specified.
62  static Parens parensForPrecedence(int rootPrec, SgAsmExpression*);
63 };
64 
65 } // namespace
66 } // namespace
67 } // namespace
68 
69 #endif
70 #endif
Sawyer::SharedPointer< Node > Ptr
Shared-ownership pointer to an expression Node.
Definition: SymbolicExpr.h:156
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.
Main namespace for the ROSE library.
Base class for expressions.