mirror of
https://github.com/asmjit/asmjit.git
synced 2025-12-16 20:17:05 +03:00
Minor C++17 modernization
* Inspired by the one of the pull requests (#483) * Use std::make_unique to make a unique pointer (tests only) * Use override instead of virtual to override a virtual member function
This commit is contained in:
@@ -24,7 +24,7 @@ public:
|
||||
ASMJIT_INLINE_NODEBUG explicit EmitHelper(BaseEmitter* emitter = nullptr) noexcept
|
||||
: BaseEmitHelper(emitter) {}
|
||||
|
||||
ASMJIT_INLINE_NODEBUG virtual ~EmitHelper() noexcept = default;
|
||||
ASMJIT_INLINE_NODEBUG ~EmitHelper() noexcept override = default;
|
||||
|
||||
ASMJIT_INLINE void reset(BaseEmitter* emitter) noexcept {
|
||||
_emitter = emitter;
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
ASMJIT_INLINE_NODEBUG explicit EmitHelper(BaseEmitter* emitter = nullptr, bool avx_enabled = false, bool avx512_enabled = false) noexcept
|
||||
: BaseEmitHelper(emitter) { reset(emitter, avx_enabled, avx512_enabled); }
|
||||
|
||||
ASMJIT_INLINE_NODEBUG virtual ~EmitHelper() noexcept = default;
|
||||
ASMJIT_INLINE_NODEBUG ~EmitHelper() noexcept override = default;
|
||||
|
||||
ASMJIT_INLINE_NODEBUG bool is_avx_enabled() const noexcept { return _avx_enabled; }
|
||||
ASMJIT_INLINE_NODEBUG bool is_avx512_enabled() const noexcept { return _avx512_enabled; }
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace asmjit_perf_utils {
|
||||
|
||||
class TestErrorHandler : public asmjit::ErrorHandler {
|
||||
void handle_error(asmjit::Error err, const char* message, asmjit::BaseEmitter* origin) {
|
||||
void handle_error(asmjit::Error err, const char* message, asmjit::BaseEmitter* origin) override {
|
||||
(void)err;
|
||||
(void)origin;
|
||||
printf("ERROR: %s\n", message);
|
||||
|
||||
@@ -398,13 +398,13 @@ bool BenchRegAllocApp::run_arch(Arch arch) {
|
||||
|
||||
#ifndef ASMJIT_NO_X86
|
||||
if (code.arch() == Arch::kX86 || code.arch() == Arch::kX64) {
|
||||
cc = std::unique_ptr<x86::Compiler>(new x86::Compiler());
|
||||
cc = std::make_unique<x86::Compiler>();
|
||||
}
|
||||
#endif // !ASMJIT_NO_X86
|
||||
|
||||
#ifndef ASMJIT_NO_AARCH64
|
||||
if (code.arch() == Arch::kAArch64) {
|
||||
cc = std::unique_ptr<a64::Compiler>(new a64::Compiler());
|
||||
cc = std::make_unique<a64::Compiler>();
|
||||
}
|
||||
#endif // !ASMJIT_NO_AARCH64
|
||||
|
||||
|
||||
@@ -246,12 +246,12 @@ int TestApp::run() {
|
||||
|
||||
#ifndef ASMJIT_NO_X86
|
||||
if (code.arch() == Arch::kX86 || code.arch() == Arch::kX64)
|
||||
cc = std::unique_ptr<x86::Compiler>(new x86::Compiler(&code));
|
||||
cc = std::make_unique<x86::Compiler>(&code);
|
||||
#endif // !ASMJIT_NO_X86
|
||||
|
||||
#ifndef ASMJIT_NO_AARCH64
|
||||
if (code.arch() == Arch::kAArch64)
|
||||
cc = std::unique_ptr<a64::Compiler>(new a64::Compiler(&code));
|
||||
cc = std::make_unique<a64::Compiler>(&code);
|
||||
#endif // !ASMJIT_NO_AARCH64
|
||||
|
||||
if (!cc)
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
SimpleErrorHandler()
|
||||
: _err(asmjit::Error::kOk) {}
|
||||
|
||||
virtual void handle_error(asmjit::Error err, const char* message, asmjit::BaseEmitter* origin) {
|
||||
void handle_error(asmjit::Error err, const char* message, asmjit::BaseEmitter* origin) override {
|
||||
asmjit::Support::maybe_unused(origin);
|
||||
_err = err;
|
||||
_message.assign(message);
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
A64TestCase(const char* name = nullptr)
|
||||
: TestCase(name, Arch::kAArch64) {}
|
||||
|
||||
virtual void compile(BaseCompiler& cc) override {
|
||||
void compile(BaseCompiler& cc) override {
|
||||
compile(static_cast<a64::Compiler&>(cc));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
uint32_t arg_count = _arg_count;
|
||||
FuncSignature signature;
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
cc.end_func();
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using U = unsigned int;
|
||||
|
||||
using Func0 = U (*)();
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
app.add(new A64Test_Simd1());
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
FuncNode* func_node = cc.add_func(FuncSignature::build<void, void*, const void*, const void*>());
|
||||
|
||||
a64::Gp dst = cc.new_gp_ptr("dst");
|
||||
@@ -223,7 +223,7 @@ public:
|
||||
cc.end_func();
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using Func = void (*)(void*, const void*, const void*);
|
||||
|
||||
uint32_t dst[4];
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
app.add(new A64Test_ManyRegs(i));
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
cc.add_func(FuncSignature::build<int>());
|
||||
|
||||
a64::Gp* regs = static_cast<a64::Gp*>(malloc(_reg_count * sizeof(a64::Gp)));
|
||||
@@ -283,7 +283,7 @@ public:
|
||||
free(regs);
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using Func = int (*)(void);
|
||||
Func func = ptr_as_func<Func>(_func);
|
||||
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
app.add(new A64Test_Adr());
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
cc.add_func(FuncSignature::build<int>());
|
||||
|
||||
a64::Gp addr = cc.new_gp_ptr("addr");
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
cc.embed_int32(5);
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using Func = int (*)(void);
|
||||
Func func = ptr_as_func<Func>(_func);
|
||||
|
||||
@@ -354,7 +354,7 @@ public:
|
||||
app.add(new A64Test_Branch1());
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
FuncNode* func_node = cc.add_func(FuncSignature::build<void, void*, size_t>());
|
||||
|
||||
a64::Gp p = cc.new_gp_ptr("p");
|
||||
@@ -376,7 +376,7 @@ public:
|
||||
cc.end_func();
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using Func = void (*)(void* p, size_t n);
|
||||
Func func = ptr_as_func<Func>(_func);
|
||||
|
||||
@@ -409,7 +409,7 @@ public:
|
||||
app.add(new A64Test_Invoke1());
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
FuncNode* func_node = cc.add_func(FuncSignature::build<uint32_t, uint32_t, uint32_t>());
|
||||
|
||||
a64::Gp x = cc.new_gp32("x");
|
||||
@@ -432,7 +432,7 @@ public:
|
||||
cc.end_func();
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using Func = uint32_t (*)(uint32_t, uint32_t);
|
||||
Func func = ptr_as_func<Func>(_func);
|
||||
|
||||
@@ -462,7 +462,7 @@ public:
|
||||
app.add(new A64Test_Invoke2());
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
FuncNode* func_node = cc.add_func(FuncSignature::build<double, double, double>());
|
||||
|
||||
a64::Vec x = cc.new_vec_d("x");
|
||||
@@ -484,7 +484,7 @@ public:
|
||||
cc.end_func();
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using Func = double (*)(double, double);
|
||||
Func func = ptr_as_func<Func>(_func);
|
||||
|
||||
@@ -514,7 +514,7 @@ public:
|
||||
app.add(new A64Test_Invoke3());
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
FuncNode* func_node = cc.add_func(FuncSignature::build<double, double, double>());
|
||||
|
||||
a64::Vec x = cc.new_vec_d("x");
|
||||
@@ -536,7 +536,7 @@ public:
|
||||
cc.end_func();
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using Func = double (*)(double, double);
|
||||
Func func = ptr_as_func<Func>(_func);
|
||||
|
||||
@@ -579,7 +579,7 @@ public:
|
||||
app.add(new A64Test_JumpTable(true));
|
||||
}
|
||||
|
||||
virtual void compile(a64::Compiler& cc) {
|
||||
void compile(a64::Compiler& cc) override {
|
||||
FuncNode* func_node = cc.add_func(FuncSignature::build<float, float, float, uint32_t>());
|
||||
|
||||
a64::Vec a = cc.new_vec_s("a");
|
||||
@@ -645,7 +645,7 @@ public:
|
||||
cc.embed_label_delta(L_Div, L_Table, 4);
|
||||
}
|
||||
|
||||
virtual bool run(void* _func, String& result, String& expect) {
|
||||
bool run(void* _func, String& result, String& expect) override {
|
||||
using Func = float (*)(float, float, uint32_t);
|
||||
Func func = ptr_as_func<Func>(_func);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user