ROSE  0.11.145.0
Unparser/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/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/Unparser/Base.h>
8 
9 namespace Rose {
10 namespace BinaryAnalysis {
11 namespace Unparser {
12 
13 std::string unparseAarch32Mnemonic(SgAsmAarch32Instruction*);
14 std::string unparseAarch32Expression(SgAsmExpression*, const LabelMap*, RegisterDictionaryPtr);
15 
17 struct Aarch32Settings: public Settings {};
18 
22 class Aarch32: public Base {
23  Aarch32Settings settings_;
24 
25 protected:
26  explicit Aarch32(const Aarch32Settings &settings)
27  : settings_(settings) {}
28 
29 public:
30  ~Aarch32() {}
31 
32  static Ptr instance(const Aarch32Settings &settings = Aarch32Settings()) {
33  return Ptr(new Aarch32(settings));
34  }
35 
36  Ptr copy() const override {
37  return instance(settings());
38  }
39 
40  const Aarch32Settings& settings() const override { return settings_; }
41  Aarch32Settings& 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  void outputExpr(std::ostream&, SgAsmExpression*, State &) const;
49  void outputRegister(std::ostream&, SgAsmRegisterReferenceExpression*, State&) const;
50 
51 private:
52  // Precedence for the sake of emitting expressions. Higher return value is higher precedence.
53  static int operatorPrecedence(SgAsmExpression*);
54 
55  // Parentheses for emitting expressions with inverted precedences
56  struct Parens {
57  std::string left, right;
58  Parens() {}
59  Parens(const std::string &left, const std::string &right)
60  : left(left), right(right) {}
61  };
62 
63  // What parens to use when the operator has rootPrec and the left or right operand is as specified.
64  static Parens parensForPrecedence(int rootPrec, SgAsmExpression*);
65 };
66 
67 } // namespace
68 } // namespace
69 } // namespace
70 
71 #endif
72 #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.