mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-20 10:24:12 +00:00
[Sparc] Really add sparcel architecture support.
Mostly copy-and-paste from Sparc v8 architecture. Differential Revision: http://reviews.llvm.org/D8741 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236146 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -16,6 +16,8 @@
|
||||
#include "SparcSubtarget.h"
|
||||
#include "llvm/MC/MCDisassembler.h"
|
||||
#include "llvm/MC/MCFixedLenDisassembler.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
|
||||
using namespace llvm;
|
||||
@ -38,17 +40,15 @@ public:
|
||||
raw_ostream &VStream,
|
||||
raw_ostream &CStream) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
extern Target TheSparcTarget, TheSparcV9Target;
|
||||
extern Target TheSparcTarget, TheSparcV9Target, TheSparcelTarget;
|
||||
}
|
||||
|
||||
static MCDisassembler *createSparcDisassembler(
|
||||
const Target &T,
|
||||
const MCSubtargetInfo &STI,
|
||||
MCContext &Ctx) {
|
||||
static MCDisassembler *createSparcDisassembler(const Target &T,
|
||||
const MCSubtargetInfo &STI,
|
||||
MCContext &Ctx) {
|
||||
return new SparcDisassembler(STI, Ctx);
|
||||
}
|
||||
|
||||
@ -59,10 +59,10 @@ extern "C" void LLVMInitializeSparcDisassembler() {
|
||||
createSparcDisassembler);
|
||||
TargetRegistry::RegisterMCDisassembler(TheSparcV9Target,
|
||||
createSparcDisassembler);
|
||||
TargetRegistry::RegisterMCDisassembler(TheSparcelTarget,
|
||||
createSparcDisassembler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const unsigned IntRegDecoderTable[] = {
|
||||
SP::G0, SP::G1, SP::G2, SP::G3,
|
||||
SP::G4, SP::G5, SP::G6, SP::G7,
|
||||
@ -208,16 +208,19 @@ static DecodeStatus DecodeSWAP(MCInst &Inst, unsigned insn, uint64_t Address,
|
||||
|
||||
/// Read four bytes from the ArrayRef and return 32 bit word.
|
||||
static DecodeStatus readInstruction32(ArrayRef<uint8_t> Bytes, uint64_t Address,
|
||||
uint64_t &Size, uint32_t &Insn) {
|
||||
uint64_t &Size, uint32_t &Insn,
|
||||
bool IsLittleEndian) {
|
||||
// We want to read exactly 4 Bytes of data.
|
||||
if (Bytes.size() < 4) {
|
||||
Size = 0;
|
||||
return MCDisassembler::Fail;
|
||||
}
|
||||
|
||||
// Encoded as a big-endian 32-bit word in the stream.
|
||||
Insn =
|
||||
(Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) | (Bytes[0] << 24);
|
||||
Insn = IsLittleEndian
|
||||
? (Bytes[0] << 0) | (Bytes[1] << 8) | (Bytes[2] << 16) |
|
||||
(Bytes[3] << 24)
|
||||
: (Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) |
|
||||
(Bytes[0] << 24);
|
||||
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
@ -228,12 +231,12 @@ DecodeStatus SparcDisassembler::getInstruction(MCInst &Instr, uint64_t &Size,
|
||||
raw_ostream &VStream,
|
||||
raw_ostream &CStream) const {
|
||||
uint32_t Insn;
|
||||
|
||||
DecodeStatus Result = readInstruction32(Bytes, Address, Size, Insn);
|
||||
bool isLittleEndian = getContext().getAsmInfo()->isLittleEndian();
|
||||
DecodeStatus Result =
|
||||
readInstruction32(Bytes, Address, Size, Insn, isLittleEndian);
|
||||
if (Result == MCDisassembler::Fail)
|
||||
return MCDisassembler::Fail;
|
||||
|
||||
|
||||
// Calling the auto-generated decoder function.
|
||||
Result =
|
||||
decodeInstruction(DecoderTableSparc32, Instr, Insn, Address, this, STI);
|
||||
|
Reference in New Issue
Block a user