AsmJit cleanup and refactoring

This commit is contained in:
kobalicek
2020-05-31 23:38:22 +02:00
parent e78bba83da
commit f986f7fc44
121 changed files with 13790 additions and 10627 deletions

View File

@@ -21,9 +21,11 @@
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// ----------------------------------------------------------------------------
// This file is used to test opcodes generated by AsmJit. Output can be
// disassembled in your IDE or by your favorite disassembler. Instructions
// are grouped by category and then sorted alphabetically.
// ----------------------------------------------------------------------------
#include <asmjit/x86.h>
#include <stdio.h>
@@ -34,21 +36,21 @@
using namespace asmjit;
struct OpcodeDumpInfo {
uint32_t archId;
uint32_t arch;
bool useRex1;
bool useRex2;
};
static const char* archIdToString(uint32_t archId) {
switch (archId) {
case ArchInfo::kIdNone: return "None";
case ArchInfo::kIdX86 : return "X86";
case ArchInfo::kIdX64 : return "X64";
case ArchInfo::kIdA32 : return "A32";
case ArchInfo::kIdA64 : return "A64";
default:
return "<unknown>";
static const char* archToString(uint32_t arch) noexcept {
switch (arch & ~Environment::kArchBigEndianMask) {
case Environment::kArchX86 : return "X86";
case Environment::kArchX64 : return "X64";
case Environment::kArchARM : return "ARM";
case Environment::kArchThumb : return "Thumb";
case Environment::kArchAArch64 : return "AArch64";
case Environment::kArchMIPS_LE : return "MIPS";
case Environment::kArchMIPS64_LE: return "MIPS64";
default: return "Unknown";
}
}
@@ -65,23 +67,23 @@ int main() {
TestErrorHandler eh;
OpcodeDumpInfo infoList[] = {
{ ArchInfo::kIdX86, false, false },
{ ArchInfo::kIdX64, false, false },
{ ArchInfo::kIdX64, false, true },
{ ArchInfo::kIdX64, true , false },
{ ArchInfo::kIdX64, true , true }
{ Environment::kArchX86, false, false },
{ Environment::kArchX64, false, false },
{ Environment::kArchX64, false, true },
{ Environment::kArchX64, true , false },
{ Environment::kArchX64, true , true }
};
for (uint32_t i = 0; i < ASMJIT_ARRAY_SIZE(infoList); i++) {
const OpcodeDumpInfo& info = infoList[i];
printf("Opcodes [ARCH=%s REX1=%s REX2=%s]\n",
archIdToString(info.archId),
archToString(info.arch),
info.useRex1 ? "true" : "false",
info.useRex2 ? "true" : "false");
CodeHolder code;
code.init(CodeInfo(info.archId));
code.init(Environment(info.arch));
code.setErrorHandler(&eh);
#ifndef ASMJIT_NO_LOGGING
@@ -95,7 +97,7 @@ int main() {
// If this is the host architecture the code generated can be executed
// for debugging purposes (the first instruction is ret anyway).
if (code.archId() == ArchInfo::kIdHost) {
if (code.arch() == Environment::kArchHost) {
JitRuntime runtime;
VoidFunc p;