• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- ARMDisassembler.h - Disassembler for ARM/Thumb ISA -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is part of the ARM Disassembler.
11 // It contains the header for ARMDisassembler and ThumbDisassembler, both are
12 // subclasses of MCDisassembler.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef ARMDISASSEMBLER_H
17 #define ARMDISASSEMBLER_H
18 
19 #include "llvm/MC/MCDisassembler.h"
20 
21 namespace llvm {
22 
23 class MCInst;
24 class MemoryObject;
25 class raw_ostream;
26 
27 struct EDInstInfo;
28 
29 /// ARMDisassembler - ARM disassembler for all ARM platforms.
30 class ARMDisassembler : public MCDisassembler {
31 public:
32   /// Constructor     - Initializes the disassembler.
33   ///
ARMDisassembler()34   ARMDisassembler() :
35     MCDisassembler() {
36   }
37 
~ARMDisassembler()38   ~ARMDisassembler() {
39   }
40 
41   /// getInstruction - See MCDisassembler.
42   bool getInstruction(MCInst &instr,
43                       uint64_t &size,
44                       const MemoryObject &region,
45                       uint64_t address,
46                       raw_ostream &vStream) const;
47 
48   /// getEDInfo - See MCDisassembler.
49   EDInstInfo *getEDInfo() const;
50 private:
51 };
52 
53 // Forward declaration.
54 class ARMBasicMCBuilder;
55 
56 /// Session - Keep track of the IT Block progression.
57 class Session {
58   friend class ARMBasicMCBuilder;
59 public:
Session()60   Session() : ITCounter(0), ITState(0) {}
~Session()61   ~Session() {}
62   /// InitIT - Initializes ITCounter/ITState.
63   bool InitIT(unsigned short bits7_0);
64   /// UpdateIT - Updates ITCounter/ITState as IT Block progresses.
65   void UpdateIT();
66 
67 private:
68   unsigned ITCounter; // Possible values: 0, 1, 2, 3, 4.
69   unsigned ITState;   // A2.5.2 Consists of IT[7:5] and IT[4:0] initially.
70 };
71 
72 /// ThumbDisassembler - Thumb disassembler for all ARM platforms.
73 class ThumbDisassembler : public MCDisassembler {
74 public:
75   /// Constructor     - Initializes the disassembler.
76   ///
ThumbDisassembler()77   ThumbDisassembler() :
78     MCDisassembler(), SO() {
79   }
80 
~ThumbDisassembler()81   ~ThumbDisassembler() {
82   }
83 
84   /// getInstruction - See MCDisassembler.
85   bool getInstruction(MCInst &instr,
86                       uint64_t &size,
87                       const MemoryObject &region,
88                       uint64_t address,
89                       raw_ostream &vStream) const;
90 
91   /// getEDInfo - See MCDisassembler.
92   EDInstInfo *getEDInfo() const;
93 private:
94   Session SO;
95 };
96 
97 } // namespace llvm
98 
99 #endif
100