mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-26 07:29:55 +00:00
Re-apply 100265 but instead disable building of ARM disassembly for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100379 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1b0194d646
commit
f6232cf8bb
@ -8,8 +8,8 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// This file is part of the ARM Disassembler.
|
// This file is part of the ARM Disassembler.
|
||||||
// It contains code to represent the core concepts of Builder, Builder Factory,
|
// It contains code to represent the core concepts of Builder and DisassembleFP
|
||||||
// as well as the Algorithm to solve the problem of disassembling an ARM instr.
|
// to solve the problem of disassembling an ARM instr.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
@ -3127,40 +3127,12 @@ static const DisassembleFP FuncPtrs[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Algorithms - Algorithms stores a map from Format to ARMAlgorithm*.
|
|
||||||
static std::vector<ARMAlgorithm*> Algorithms;
|
|
||||||
|
|
||||||
/// DoCleanup - Do cleanup of Algorithms upon exit.
|
|
||||||
void ARMAlgorithm::DoCleanup() {
|
|
||||||
for (unsigned i = 0; i < array_lengthof(FuncPtrs); ++i)
|
|
||||||
if (Algorithms[i])
|
|
||||||
delete Algorithms[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// GetInstance - GetInstance returns an instance of ARMAlgorithm given the
|
|
||||||
/// encoding Format. API clients should not free up the returned instance.
|
|
||||||
ARMAlgorithm *ARMAlgorithm::GetInstance(ARMFormat Format) {
|
|
||||||
/// Init the first time.
|
|
||||||
if (Algorithms.size() == 0) {
|
|
||||||
Algorithms.resize(array_lengthof(FuncPtrs));
|
|
||||||
for (unsigned i = 0, num = array_lengthof(FuncPtrs); i < num; ++i)
|
|
||||||
if (FuncPtrs[i])
|
|
||||||
Algorithms[i] = new ARMAlgorithm(FuncPtrs[i]);
|
|
||||||
else
|
|
||||||
Algorithms[i] = NULL;
|
|
||||||
|
|
||||||
// Register cleanup routine.
|
|
||||||
atexit(DoCleanup);
|
|
||||||
}
|
|
||||||
return Algorithms[Format];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// BuildIt - BuildIt performs the build step for this ARM Basic MC Builder.
|
/// BuildIt - BuildIt performs the build step for this ARM Basic MC Builder.
|
||||||
/// The general idea is to set the Opcode for the MCInst, followed by adding
|
/// The general idea is to set the Opcode for the MCInst, followed by adding
|
||||||
/// the appropriate MCOperands to the MCInst. ARM Basic MC Builder delegates
|
/// the appropriate MCOperands to the MCInst. ARM Basic MC Builder delegates
|
||||||
/// to the Algo (ARM Disassemble Algorithm) object to perform Format-specific
|
/// to the Format-specific disassemble function for disassembly, followed by
|
||||||
/// disassembly, followed by TryPredicateAndSBitModifier() to do
|
/// TryPredicateAndSBitModifier() to do PredicateOperand and OptionalDefOperand
|
||||||
/// PredicateOperand and OptionalDefOperand which follow the Dst/Src Operands.
|
/// which follow the Dst/Src Operands.
|
||||||
bool ARMBasicMCBuilder::BuildIt(MCInst &MI, uint32_t insn) {
|
bool ARMBasicMCBuilder::BuildIt(MCInst &MI, uint32_t insn) {
|
||||||
// Stage 1 sets the Opcode.
|
// Stage 1 sets the Opcode.
|
||||||
MI.setOpcode(Opcode);
|
MI.setOpcode(Opcode);
|
||||||
@ -3168,9 +3140,12 @@ bool ARMBasicMCBuilder::BuildIt(MCInst &MI, uint32_t insn) {
|
|||||||
if (NumOps == 0)
|
if (NumOps == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Stage 2 calls the ARM Disassembly Algorithm to build the operand list.
|
// Stage 2 calls the format-specific disassemble function to build the operand
|
||||||
|
// list.
|
||||||
|
if (Disasm == NULL)
|
||||||
|
return false;
|
||||||
unsigned NumOpsAdded = 0;
|
unsigned NumOpsAdded = 0;
|
||||||
bool OK = Algo.Solve(MI, Opcode, insn, NumOps, NumOpsAdded, this);
|
bool OK = (*Disasm)(MI, Opcode, insn, NumOps, NumOpsAdded, this);
|
||||||
|
|
||||||
if (!OK) return false;
|
if (!OK) return false;
|
||||||
if (NumOpsAdded >= NumOps)
|
if (NumOpsAdded >= NumOps)
|
||||||
@ -3256,6 +3231,15 @@ bool ARMBasicMCBuilder::RunBuildAfterHook(bool Status, MCInst &MI,
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Opcode, Format, and NumOperands make up an ARM Basic MCBuilder.
|
||||||
|
ARMBasicMCBuilder::ARMBasicMCBuilder(unsigned opc, ARMFormat format,
|
||||||
|
unsigned short num)
|
||||||
|
: Opcode(opc), Format(format), NumOps(num), SP(0) {
|
||||||
|
unsigned Idx = (unsigned)format;
|
||||||
|
assert(Idx < (array_lengthof(FuncPtrs) - 1) && "Unknown format");
|
||||||
|
Disasm = FuncPtrs[Idx];
|
||||||
|
}
|
||||||
|
|
||||||
/// CreateMCBuilder - Return an ARMBasicMCBuilder that can build up the MC
|
/// CreateMCBuilder - Return an ARMBasicMCBuilder that can build up the MC
|
||||||
/// infrastructure of an MCInst given the Opcode and Format of the instr.
|
/// infrastructure of an MCInst given the Opcode and Format of the instr.
|
||||||
/// Return NULL if it fails to create/return a proper builder. API clients
|
/// Return NULL if it fails to create/return a proper builder. API clients
|
||||||
@ -3263,10 +3247,6 @@ bool ARMBasicMCBuilder::RunBuildAfterHook(bool Status, MCInst &MI,
|
|||||||
/// performed by the API clients to improve performance.
|
/// performed by the API clients to improve performance.
|
||||||
ARMBasicMCBuilder *llvm::CreateMCBuilder(unsigned Opcode, ARMFormat Format) {
|
ARMBasicMCBuilder *llvm::CreateMCBuilder(unsigned Opcode, ARMFormat Format) {
|
||||||
|
|
||||||
ARMAlgorithm *Algo = ARMAlgorithm::GetInstance(Format);
|
|
||||||
if (!Algo)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return new ARMBasicMCBuilder(Opcode, Format,
|
return new ARMBasicMCBuilder(Opcode, Format,
|
||||||
ARMInsts[Opcode].getNumOperands(), *Algo);
|
ARMInsts[Opcode].getNumOperands());
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
// specifies the encoding used by the instruction, as well as a helper function
|
// specifies the encoding used by the instruction, as well as a helper function
|
||||||
// to convert the enums to printable char strings.
|
// to convert the enums to printable char strings.
|
||||||
//
|
//
|
||||||
// It also contains code to represent the concepts of Builder, Builder Factory,
|
// It also contains code to represent the concepts of Builder and DisassembleFP
|
||||||
// as well as the Algorithm to solve the problem of disassembling an ARM instr.
|
// to solve the problem of disassembling an ARM instr.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
@ -171,60 +171,23 @@ typedef ARMBasicMCBuilder *BO;
|
|||||||
typedef bool (*DisassembleFP)(MCInst &MI, unsigned Opcode, uint32_t insn,
|
typedef bool (*DisassembleFP)(MCInst &MI, unsigned Opcode, uint32_t insn,
|
||||||
unsigned short NumOps, unsigned &NumOpsAdded, BO Builder);
|
unsigned short NumOps, unsigned &NumOpsAdded, BO Builder);
|
||||||
|
|
||||||
/// ARMAlgorithm - ARMAlgorithm implements the ARM/Thumb disassembly by solving
|
|
||||||
/// the problem of building the MCOperands of an MCInst. Construction of
|
|
||||||
/// ARMAlgorithm requires passing in a function pointer with the DisassembleFP
|
|
||||||
/// data type.
|
|
||||||
class ARMAlgorithm {
|
|
||||||
public:
|
|
||||||
/// GetInstance - GetInstance returns an instance of ARMAlgorithm given the
|
|
||||||
/// encoding Format. API clients should not free up the returned instance.
|
|
||||||
static ARMAlgorithm *GetInstance(ARMFormat Format);
|
|
||||||
|
|
||||||
/// DoCleanup - DoCleanup is meant to be called upon exit as an exit handler.
|
|
||||||
static void DoCleanup();
|
|
||||||
|
|
||||||
/// Return true if this algorithm successfully disassembles the instruction.
|
|
||||||
/// NumOpsAdded is updated to reflect the number of operands added by the
|
|
||||||
/// algorithm. NumOpsAdded may be less than NumOps, in which case, there are
|
|
||||||
/// operands unaccounted for which need to be dealt with by the API client.
|
|
||||||
bool Solve(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned short NumOps,
|
|
||||||
unsigned &NumOpsAdded, BO Builder) const {
|
|
||||||
if (Disassemble == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return (*Disassemble)(MI, Opcode, insn, NumOps, NumOpsAdded, Builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ARMAlgorithm(DisassembleFP fp) : Disassemble(fp) {}
|
|
||||||
ARMAlgorithm(ARMAlgorithm &AA) : Disassemble(AA.Disassemble) {}
|
|
||||||
|
|
||||||
virtual ~ARMAlgorithm() {}
|
|
||||||
|
|
||||||
DisassembleFP Disassemble;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// ARMBasicMCBuilder - ARMBasicMCBuilder represents an ARM MCInst builder that
|
/// ARMBasicMCBuilder - ARMBasicMCBuilder represents an ARM MCInst builder that
|
||||||
/// knows how to build up the MCOperand list.
|
/// knows how to build up the MCOperand list.
|
||||||
class ARMBasicMCBuilder {
|
class ARMBasicMCBuilder {
|
||||||
unsigned Opcode;
|
unsigned Opcode;
|
||||||
ARMFormat Format;
|
ARMFormat Format;
|
||||||
unsigned short NumOps;
|
unsigned short NumOps;
|
||||||
const ARMAlgorithm &Algo;
|
DisassembleFP Disasm;
|
||||||
Session *SP;
|
Session *SP;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ARMBasicMCBuilder(ARMBasicMCBuilder &B)
|
ARMBasicMCBuilder(ARMBasicMCBuilder &B)
|
||||||
: Opcode(B.Opcode), Format(B.Format), NumOps(B.NumOps), Algo(B.Algo),
|
: Opcode(B.Opcode), Format(B.Format), NumOps(B.NumOps), Disasm(B.Disasm),
|
||||||
SP(B.SP)
|
SP(B.SP)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Opcode, Format, NumOperands, and Algo make an ARM Basic MCBuilder.
|
/// Opcode, Format, and NumOperands make up an ARM Basic MCBuilder.
|
||||||
ARMBasicMCBuilder(unsigned opc, ARMFormat format, unsigned short num,
|
ARMBasicMCBuilder(unsigned opc, ARMFormat format, unsigned short num);
|
||||||
const ARMAlgorithm &algo)
|
|
||||||
: Opcode(opc), Format(format), NumOps(num), Algo(algo), SP(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual ~ARMBasicMCBuilder() {}
|
virtual ~ARMBasicMCBuilder() {}
|
||||||
|
|
||||||
@ -256,9 +219,9 @@ public:
|
|||||||
/// BuildIt - BuildIt performs the build step for this ARM Basic MC Builder.
|
/// BuildIt - BuildIt performs the build step for this ARM Basic MC Builder.
|
||||||
/// The general idea is to set the Opcode for the MCInst, followed by adding
|
/// The general idea is to set the Opcode for the MCInst, followed by adding
|
||||||
/// the appropriate MCOperands to the MCInst. ARM Basic MC Builder delegates
|
/// the appropriate MCOperands to the MCInst. ARM Basic MC Builder delegates
|
||||||
/// to the Algo (ARM Disassemble Algorithm) object to perform Format-specific
|
/// to the Format-specific disassemble function for disassembly, followed by
|
||||||
/// disassembly, followed by class method TryPredicateAndSBitModifier() to do
|
/// TryPredicateAndSBitModifier() for PredicateOperand and OptionalDefOperand
|
||||||
/// PredicateOperand and OptionalDefOperand which follow the Dst/Src Operands.
|
/// which follow the Dst/Src Operands.
|
||||||
virtual bool BuildIt(MCInst &MI, uint32_t insn);
|
virtual bool BuildIt(MCInst &MI, uint32_t insn);
|
||||||
|
|
||||||
/// RunBuildAfterHook - RunBuildAfterHook performs operations deemed necessary
|
/// RunBuildAfterHook - RunBuildAfterHook performs operations deemed necessary
|
||||||
|
@ -16,9 +16,8 @@ BUILT_SOURCES = ARMGenRegisterInfo.h.inc ARMGenRegisterNames.inc \
|
|||||||
ARMGenRegisterInfo.inc ARMGenInstrNames.inc \
|
ARMGenRegisterInfo.inc ARMGenInstrNames.inc \
|
||||||
ARMGenInstrInfo.inc ARMGenAsmWriter.inc \
|
ARMGenInstrInfo.inc ARMGenAsmWriter.inc \
|
||||||
ARMGenDAGISel.inc ARMGenSubtarget.inc \
|
ARMGenDAGISel.inc ARMGenSubtarget.inc \
|
||||||
ARMGenCodeEmitter.inc ARMGenCallingConv.inc \
|
ARMGenCodeEmitter.inc ARMGenCallingConv.inc
|
||||||
ARMGenDecoderTables.inc
|
|
||||||
|
|
||||||
DIRS = AsmPrinter AsmParser Disassembler TargetInfo
|
DIRS = AsmPrinter AsmParser TargetInfo
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
Loading…
Reference in New Issue
Block a user