LLVM: lib/Target/AVR/Disassembler/AVRDisassembler.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

15

18

26

28

29using namespace llvm;

31

32#define DEBUG_TYPE "avr-disassembler"

33

35

36namespace {

37

38

40public:

43 ~AVRDisassembler() override = default;

44

48};

49}

50

54 return new AVRDisassembler(STI, Ctx);

55}

56

63

65 AVR::R0, AVR::R1, AVR::R2, AVR::R3, AVR::R4, AVR::R5, AVR::R6,

66 AVR::R7, AVR::R8, AVR::R9, AVR::R10, AVR::R11, AVR::R12, AVR::R13,

67 AVR::R14, AVR::R15, AVR::R16, AVR::R17, AVR::R18, AVR::R19, AVR::R20,

68 AVR::R21, AVR::R22, AVR::R23, AVR::R24, AVR::R25, AVR::R26, AVR::R27,

69 AVR::R28, AVR::R29, AVR::R30, AVR::R31,

70};

71

73 AVR::R1R0, AVR::R3R2, AVR::R5R4, AVR::R7R6,

74 AVR::R9R8, AVR::R11R10, AVR::R13R12, AVR::R15R14,

75 AVR::R17R16, AVR::R19R18, AVR::R21R20, AVR::R23R22,

76 AVR::R25R24, AVR::R27R26, AVR::R29R28, AVR::R31R30,

77};

78

82 if (RegNo > 31)

84

88}

89

98

107

115

124

130

139

147

155

158

159

160

161 if (Insn > 127)

163

164

167

169

171}

172

176

178

179

180 if ((Insn & 0xf000) == 0x8000) {

181 unsigned RegBase = (Insn & 0x8) ? AVR::R29R28 : AVR::R31R30;

182 unsigned Offset = Insn & 7;

183 if ((Insn & 0x200) == 0) {

188 } else {

193 }

195 }

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215 if ((Insn & 0xfc00) != 0x9000 || (Insn & 0xf) == 0)

217

218

219 unsigned RegBase;

220 switch (Insn & 0xc) {

221 case 0xc:

222 RegBase = AVR::R27R26;

223 break;

224 case 0x8:

225 RegBase = AVR::R29R28;

226 break;

227 case 0x0:

228 RegBase = AVR::R31R30;

229 break;

230 default:

232 }

233

234

235 switch (Insn & 0x203) {

236 case 0x200:

241 case 0x201:

243 break;

244 case 0x202:

246 break;

247 case 0:

252 case 1:

254 break;

255 case 2:

257 break;

258 default:

260 }

261

262

263 if ((Insn & 0x200) == 0) {

267 } else {

271

273 }

274

276}

277

278#include "AVRGenDisassemblerTables.inc"

279

282 if (Bytes.size() < 2) {

285 }

286

288 Insn = (Bytes[0] << 0) | (Bytes[1] << 8);

289

291}

292

295

296 if (Bytes.size() < 4) {

299 }

300

302 Insn =

303 (Bytes[0] << 16) | (Bytes[1] << 24) | (Bytes[2] << 0) | (Bytes[3] << 8);

304

306}

307

309

310 switch (Size) {

311 case 2:

312 return DecoderTable16;

313 case 4:

314 return DecoderTable32;

315 default:

317 }

318}

319

324 uint32_t Insn;

325

327

328

329 {

331

334

335

336 if (STI.hasFeature(AVR::FeatureTinyEncoding)) {

337 Result = decodeInstruction(DecoderTableAVRTiny16, Instr, Insn, Address,

338 this, STI);

341 }

342

343

345 this, STI);

348

349

350

354 }

355

356

357 {

359

362

364 this, STI);

365

368 }

369

371 }

372}

373

MCDisassembler::DecodeStatus DecodeStatus

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static bool readInstruction16(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn)

static bool readInstruction32(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn)

static const uint16_t GPRPairDecoderTable[]

static const uint16_t GPRDecoderTable[]

LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRDisassembler()

Definition AVRDisassembler.cpp:58

static DecodeStatus DecodeZREGRegisterClass(MCInst &Inst, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:125

static DecodeStatus decodeLoadStore(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:173

static DecodeStatus DecodeIWREGSRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:116

static DecodeStatus DecodeGPR8RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:79

static DecodeStatus decodeRelCondBrTarget7(MCInst &Inst, unsigned Field, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:140

static DecodeStatus DecodeLD8RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:90

DecodeStatus(* DecodeFunc)(MCInst &MI, unsigned insn, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:374

static DecodeStatus DecodeDREGSRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:108

static DecodeStatus decodeRelCondBrTarget13(MCInst &Inst, unsigned Field, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:148

static DecodeStatus readInstruction16(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn)

Definition AVRDisassembler.cpp:280

static MCDisassembler * createAVRDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)

Definition AVRDisassembler.cpp:51

static DecodeStatus decodeMemri(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:156

static DecodeStatus readInstruction32(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn)

Definition AVRDisassembler.cpp:293

static DecodeStatus DecodeLD8loRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:99

static const uint8_t * getDecoderTable(uint64_t Size)

Definition AVRDisassembler.cpp:308

static DecodeStatus decodeCallTarget(MCInst &Inst, unsigned Field, uint64_t Address, const MCDisassembler *Decoder)

Definition AVRDisassembler.cpp:131

#define LLVM_EXTERNAL_VISIBILITY

This file defines the DenseMap class.

OptimizedStructLayoutField Field

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

size_t size() const

size - Get the array size.

Context object for machine code objects.

Superclass for all disassemblers.

DecodeStatus

Ternary decode status.

Instances of this class represent a single low-level machine instruction.

void addOperand(const MCOperand Op)

void setOpcode(unsigned Op)

static MCOperand createReg(MCRegister Reg)

static MCOperand createImm(int64_t Val)

Wrapper class representing physical registers. Should be passed by value.

Generic base class for all target subtargets.

Wrapper class representing virtual and physical registers.

Target - Wrapper for Target specific information.

This class implements an extremely fast bulk output stream that can only output to a stream.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

This is an optimization pass for GlobalISel generic memory operations.

Target & getTheAVRTarget()

constexpr bool isUInt(uint64_t x)

Checks if an unsigned integer fits into the given bit width.

constexpr int32_t SignExtend32(uint32_t X)

Sign-extend the number in the bottom B bits of X to a 32-bit integer.

static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)

RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.