mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-04 21:30:49 +00:00
tidy some things up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131836 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1a55c419a6
commit
97ff42d51d
@ -6,11 +6,10 @@
|
|||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "Disassembler.h"
|
#include "Disassembler.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include "llvm-c/Disassembler.h"
|
#include "llvm-c/Disassembler.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCDisassembler.h"
|
#include "llvm/MC/MCDisassembler.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
@ -27,17 +26,12 @@ class Target;
|
|||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
//
|
|
||||||
// LLVMCreateDisasm() creates a disassembler for the TripleName. Symbolic
|
// LLVMCreateDisasm() creates a disassembler for the TripleName. Symbolic
|
||||||
// disassembly is supported by passing a block of information in the DisInfo
|
// disassembly is supported by passing a block of information in the DisInfo
|
||||||
// parameter and specifing the TagType and call back functions as described in
|
// parameter and specifying the TagType and callback functions as described in
|
||||||
// the header llvm-c/Disassembler.h . The pointer to the block and the
|
// the header llvm-c/Disassembler.h . The pointer to the block and the
|
||||||
// functions can all be passed as NULL. If successful this returns a
|
// functions can all be passed as NULL. If successful, this returns a
|
||||||
// disassembler context if not it returns NULL.
|
// disassembler context. If not, it returns NULL.
|
||||||
//
|
//
|
||||||
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
||||||
int TagType, LLVMOpInfoCallback GetOpInfo,
|
int TagType, LLVMOpInfoCallback GetOpInfo,
|
||||||
@ -108,7 +102,6 @@ namespace {
|
|||||||
// The memory object created by LLVMDisasmInstruction().
|
// The memory object created by LLVMDisasmInstruction().
|
||||||
//
|
//
|
||||||
class DisasmMemoryObject : public MemoryObject {
|
class DisasmMemoryObject : public MemoryObject {
|
||||||
private:
|
|
||||||
uint8_t *Bytes;
|
uint8_t *Bytes;
|
||||||
uint64_t Size;
|
uint64_t Size;
|
||||||
uint64_t BasePC;
|
uint64_t BasePC;
|
||||||
@ -126,7 +119,7 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
//
|
//
|
||||||
// LLVMDisasmInstruction() disassembles a single instruction using the
|
// LLVMDisasmInstruction() disassembles a single instruction using the
|
||||||
@ -159,13 +152,10 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
|
|||||||
IP->printInst(&Inst, OS);
|
IP->printInst(&Inst, OS);
|
||||||
OS.flush();
|
OS.flush();
|
||||||
|
|
||||||
|
assert(OutStringSize != 0 && "Output buffer cannot be zero size");
|
||||||
size_t OutputSize = std::min(OutStringSize-1, InsnStr.size());
|
size_t OutputSize = std::min(OutStringSize-1, InsnStr.size());
|
||||||
std::memcpy(OutString, InsnStr.data(), OutputSize);
|
std::memcpy(OutString, InsnStr.data(), OutputSize);
|
||||||
OutString[OutputSize] = '\0'; // Terminate string.
|
OutString[OutputSize] = '\0'; // Terminate string.
|
||||||
|
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
Loading…
Reference in New Issue
Block a user