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