V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
disasm-arm64.h
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_ARM64_DISASM_ARM64_H_
6 #define V8_ARM64_DISASM_ARM64_H_
7 
8 #include "src/arm64/assembler-arm64.h"
9 #include "src/arm64/decoder-arm64.h"
10 #include "src/arm64/instructions-arm64.h"
11 #include "src/globals.h"
12 #include "src/utils.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 
19  public:
21  DisassemblingDecoder(char* text_buffer, int buffer_size);
22  virtual ~DisassemblingDecoder();
23  char* GetOutput();
24 
25  // Declare all Visitor functions.
26  #define DECLARE(A) void Visit##A(Instruction* instr);
27  VISITOR_LIST(DECLARE)
28  #undef DECLARE
29 
30  protected:
31  virtual void ProcessOutput(Instruction* instr);
32 
33  // Default output functions. The functions below implement a default way of
34  // printing elements in the disassembly. A sub-class can override these to
35  // customize the disassembly output.
36 
37  // Prints the name of a register.
38  virtual void AppendRegisterNameToOutput(const CPURegister& reg);
39 
40  void Format(Instruction* instr, const char* mnemonic, const char* format);
41  void Substitute(Instruction* instr, const char* string);
42  int SubstituteField(Instruction* instr, const char* format);
43  int SubstituteRegisterField(Instruction* instr, const char* format);
44  int SubstituteImmediateField(Instruction* instr, const char* format);
45  int SubstituteLiteralField(Instruction* instr, const char* format);
46  int SubstituteBitfieldImmediateField(Instruction* instr, const char* format);
47  int SubstituteShiftField(Instruction* instr, const char* format);
48  int SubstituteExtendField(Instruction* instr, const char* format);
49  int SubstituteConditionField(Instruction* instr, const char* format);
50  int SubstitutePCRelAddressField(Instruction* instr, const char* format);
51  int SubstituteBranchTargetField(Instruction* instr, const char* format);
52  int SubstituteLSRegOffsetField(Instruction* instr, const char* format);
53  int SubstitutePrefetchField(Instruction* instr, const char* format);
54  int SubstituteBarrierField(Instruction* instr, const char* format);
55 
56  bool RdIsZROrSP(Instruction* instr) const {
57  return (instr->Rd() == kZeroRegCode);
58  }
59 
60  bool RnIsZROrSP(Instruction* instr) const {
61  return (instr->Rn() == kZeroRegCode);
62  }
63 
64  bool RmIsZROrSP(Instruction* instr) const {
65  return (instr->Rm() == kZeroRegCode);
66  }
67 
68  bool RaIsZROrSP(Instruction* instr) const {
69  return (instr->Ra() == kZeroRegCode);
70  }
71 
72  bool IsMovzMovnImm(unsigned reg_size, uint64_t value);
73 
74  void ResetOutput();
75  void AppendToOutput(const char* string, ...);
76 
77  char* buffer_;
78  uint32_t buffer_pos_;
79  uint32_t buffer_size_;
80  bool own_buffer_;
81 };
82 
83 
85  public:
86  explicit PrintDisassembler(FILE* stream) : stream_(stream) { }
87  ~PrintDisassembler() { }
88 
89  virtual void ProcessOutput(Instruction* instr);
90 
91  private:
92  FILE *stream_;
93 };
94 
95 
96 } // namespace internal
97 } // namespace v8
98 
99 #endif // V8_ARM64_DISASM_ARM64_H_
Definition: libplatform.h:13