-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.cpp
90 lines (71 loc) · 1.71 KB
/
Test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <assert.h>
#include <iostream>
namespace llvm {
void llvm_unreachable(const char *msg) {
assert(0 && msg);
}
#define LLVM_DEBUG(x) x
std::ostream &errs() { return std::cerr; }
std::ostream &dbgs() { return std::cerr; }
namespace MCD {
enum {
OPC_ExtractField = 0,
OPC_FilterValue,
OPC_CheckField,
OPC_CheckPredicate,
OPC_TryDecode,
OPC_Decode,
OPC_SoftFail,
OPC_Fail,
};
}
class FeatureBitset {
};
class MCSubtargetInfo {
public:
const FeatureBitset getFeatureBits() const {
return FeatureBitset();
}
};
class MCDisassembler {
public:
enum DecodeStatus {
Success = 0,
SoftFail,
Fail
};
};
class MCOperand {
public:
static MCOperand &createReg(unsigned Reg) { }
static MCOperand &createImm(unsigned Imm) { }
};
class MCInst {
unsigned Opcode;
public:
void setOpcode(unsigned Opc) { Opcode = Opc; }
unsigned getOpcode() { return Opcode; }
void addOperand(const MCOperand &MO) { }
void clear() { }
};
} // namespace llvm
using namespace llvm;
typedef MCDisassembler::DecodeStatus DecodeStatus;
static DecodeStatus DecodeGPRexcl3RegisterClass(MCInst &MI, uint64_t RegNo,
uint64_t Address,
const void *Decoder) {
MI.addOperand(MCOperand::createReg(RegNo));
return DecodeStatus::Success;
}
#define GET_INSTRINFO_ENUM
#include "TestInstrInfo.inc"
#include "TestDisasm.inc"
int main() {
MCInst MI;
MCSubtargetInfo STI;
unsigned Insn = 0x430f; // mov #0, r3
DecodeStatus Res = decodeInstruction(DecoderTable16, MI, Insn, 0, 0, STI);
assert(Res == DecodeStatus::Success && "Decoding failed");
assert(MI.getOpcode() == Test::MOV16rc && "Expected MOV16rc");
return 0;
}