[ABI] Refactored AsmJit to use strong-typed enums, this breaks both API and ABI

[ABI] Added ABI version as an inline namespace, which forms asmjit::_abi_MAJOR_MINOR
[ABI] Added support for AVX512_FP16, 16-bit broadcast, and AVX512_FP16 tests
[ABI] Added initial support for consecutive registers into instruction database and register allocator
[ABI] Added a possibility to use temporary memory in CodeHolder's zone
[ABI] Compiler::setArg() is now deprecated, use FuncNode::setArg()
[Bug] Fixed correct RW information of instructions that only support implicit zeroing with {k}
[Bug] Fixed broadcast to be able to broadcast bcst16 operands
This commit is contained in:
kobalicek
2021-12-13 09:11:58 +01:00
parent 4ec760a3d1
commit 996deae327
154 changed files with 29537 additions and 21190 deletions

View File

@@ -1,25 +1,7 @@
// AsmJit - Machine code generation for C++
// This file is part of AsmJit project <https://asmjit.com>
//
// * Official AsmJit Home Page: https://asmjit.com
// * Official Github Repository: https://github.com/asmjit/asmjit
//
// Copyright (c) 2008-2020 The AsmJit Authors
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// See asmjit.h or LICENSE.md for license and copyright information
// SPDX-License-Identifier: Zlib
#include <asmjit/core.h>
@@ -32,6 +14,7 @@
#include <chrono>
#include "cmdline.h"
#include "asmjitutils.h"
#include "performancetimer.h"
#include "asmjit_test_compiler.h"
@@ -56,21 +39,6 @@ void compiler_add_a64_tests(TestApp& app);
using namespace asmjit;
// ============================================================================
// [TestApp]
// ============================================================================
static const char* archAsString(uint32_t arch) {
switch (arch) {
case Environment::kArchX86: return "X86";
case Environment::kArchX64: return "X64";
case Environment::kArchARM: return "A32";
case Environment::kArchThumb: return "T32";
case Environment::kArchAArch64: return "A64";
default: return "Unknown";
}
}
int TestApp::handleArgs(int argc, const char* const* argv) {
CmdLine cmd(argc, argv);
@@ -86,7 +54,7 @@ void TestApp::showInfo() {
unsigned((ASMJIT_LIBRARY_VERSION >> 16) ),
unsigned((ASMJIT_LIBRARY_VERSION >> 8) & 0xFF),
unsigned((ASMJIT_LIBRARY_VERSION ) & 0xFF),
archAsString(Environment::kArchHost));
asmjitArchAsString(Arch::kHost));
printf(" [%s] Verbose (use --verbose to turn verbose output ON)\n", _verbose ? "x" : " ");
printf(" [%s] DumpAsm (use --dump-asm to turn assembler dumps ON)\n", _dumpAsm ? "x" : " ");
printf(" [%s] DumpHex (use --dump-hex to dump binary in hexadecimal)\n", _dumpHex ? "x" : " ");
@@ -98,133 +66,156 @@ int TestApp::run() {
return 0;
#else
#ifndef ASMJIT_NO_LOGGING
uint32_t kFormatFlags = FormatOptions::kFlagMachineCode |
FormatOptions::kFlagExplainImms |
FormatOptions::kFlagRegCasts |
FormatOptions::kFlagAnnotations |
FormatOptions::kFlagDebugPasses |
FormatOptions::kFlagDebugRA ;
FormatOptions formatOptions;
formatOptions.addFlags(
FormatFlags::kMachineCode |
FormatFlags::kExplainImms |
FormatFlags::kRegCasts );
FileLogger fileLogger(stdout);
fileLogger.addFlags(kFormatFlags);
fileLogger.setOptions(formatOptions);
StringLogger stringLogger;
stringLogger.addFlags(kFormatFlags);
stringLogger.setOptions(formatOptions);
#endif
JitRuntime runtime;
PerformanceTimer compileTimer;
PerformanceTimer finalizeTimer;
double compileTime = 0;
double finalizeTime = 0;
for (std::unique_ptr<TestCase>& test : _tests) {
JitRuntime runtime;
CodeHolder code;
SimpleErrorHandler errorHandler;
for (uint32_t pass = 0; pass < 2; pass++) {
CodeHolder code;
SimpleErrorHandler errorHandler;
PerformanceTimer perfTimer;
code.init(runtime.environment());
code.setErrorHandler(&errorHandler);
code.init(runtime.environment());
code.setErrorHandler(&errorHandler);
if (pass != 0) {
#ifndef ASMJIT_NO_LOGGING
if (_verbose) {
code.setLogger(&fileLogger);
}
else {
stringLogger.clear();
code.setLogger(&stringLogger);
}
if (_verbose) {
code.setLogger(&fileLogger);
}
else {
stringLogger.clear();
code.setLogger(&stringLogger);
}
#endif
printf("[Test] %s", test->name());
printf("[Test] %s", test->name());
#ifndef ASMJIT_NO_LOGGING
if (_verbose) printf("\n");
if (_verbose)
printf("\n");
#endif
}
#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86
x86::Compiler cc(&code);
x86::Compiler cc(&code);
#endif
#if defined(ASMJIT_BUILD_ARM) && ASMJIT_ARCH_ARM == 64
arm::Compiler cc(&code);
arm::Compiler cc(&code);
#endif
perfTimer.start();
test->compile(cc);
perfTimer.stop();
compileTime += perfTimer.duration();
void* func = nullptr;
Error err = errorHandler._err;
if (!err) {
perfTimer.start();
err = cc.finalize();
perfTimer.stop();
finalizeTime += perfTimer.duration();
}
#ifndef ASMJIT_NO_LOGGING
if (_dumpAsm) {
if (!_verbose) printf("\n");
String sb;
Formatter::formatNodeList(sb, kFormatFlags, &cc);
printf("%s", sb.data());
}
cc.addDiagnosticOptions(DiagnosticOptions::kRAAnnotate | DiagnosticOptions::kRADebugAll);
#endif
if (err == kErrorOk)
err = runtime.add(&func, &code);
compileTimer.start();
test->compile(cc);
compileTimer.stop();
if (err == kErrorOk && _dumpHex) {
String sb;
sb.appendHex((void*)func, code.codeSize());
printf("\n (HEX: %s)\n", sb.data());
}
void* func = nullptr;
Error err = errorHandler._err;
if (_verbose)
fflush(stdout);
if (!err) {
finalizeTimer.start();
err = cc.finalize();
finalizeTimer.stop();
}
if (err == kErrorOk) {
_outputSize += code.codeSize();
// The first pass is only for timing serialization and compilation, because otherwise it would be biased by
// logging, which takes much more time than finalize() does. We want to benchmark Compiler the way it would
// be used in production.
if (pass == 0) {
compileTime += compileTimer.duration();
finalizeTime += finalizeTimer.duration();
continue;
}
StringTmp<128> result;
StringTmp<128> expect;
#ifndef ASMJIT_NO_LOGGING
if (_dumpAsm) {
if (!_verbose)
printf("\n");
if (test->run(func, result, expect)) {
if (!_verbose) printf(" [OK]\n");
String sb;
Formatter::formatNodeList(sb, formatOptions, &cc);
printf("%s", sb.data());
}
#endif
if (err == kErrorOk)
err = runtime.add(&func, &code);
if (err == kErrorOk && _dumpHex) {
String sb;
sb.appendHex((void*)func, code.codeSize());
printf("\n (HEX: %s)\n", sb.data());
}
if (_verbose)
fflush(stdout);
if (err == kErrorOk) {
_outputSize += code.codeSize();
StringTmp<128> result;
StringTmp<128> expect;
if (test->run(func, result, expect)) {
if (!_verbose)
printf(" [OK]\n");
}
else {
if (!_verbose)
printf(" [FAILED]\n");
#ifndef ASMJIT_NO_LOGGING
if (!_verbose)
printf("%s", stringLogger.data());
#endif
printf("[Status]\n");
printf(" Returned: %s\n", result.data());
printf(" Expected: %s\n", expect.data());
_nFailed++;
}
if (_dumpAsm)
printf("\n");
runtime.release(func);
}
else {
if (!_verbose) printf(" [FAILED]\n");
if (!_verbose)
printf(" [FAILED]\n");
#ifndef ASMJIT_NO_LOGGING
if (!_verbose) printf("%s", stringLogger.data());
if (!_verbose)
printf("%s", stringLogger.data());
#endif
printf("[Status]\n");
printf(" Returned: %s\n", result.data());
printf(" Expected: %s\n", expect.data());
printf(" ERROR 0x%08X: %s\n", unsigned(err), errorHandler._message.data());
_nFailed++;
}
if (_dumpAsm)
printf("\n");
runtime.release(func);
}
else {
if (!_verbose) printf(" [FAILED]\n");
#ifndef ASMJIT_NO_LOGGING
if (!_verbose) printf("%s", stringLogger.data());
#endif
printf("[Status]\n");
printf(" ERROR 0x%08X: %s\n", unsigned(err), errorHandler._message.data());
_nFailed++;
}
}
@@ -244,10 +235,6 @@ int TestApp::run() {
#endif
}
// ============================================================================
// [Main]
// ============================================================================
int main(int argc, char* argv[]) {
TestApp app;