summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asmjit/src/asmjit/core/operand.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asmjit/src/asmjit/core/operand.cpp')
-rw-r--r--3rdparty/asmjit/src/asmjit/core/operand.cpp62
1 files changed, 29 insertions, 33 deletions
diff --git a/3rdparty/asmjit/src/asmjit/core/operand.cpp b/3rdparty/asmjit/src/asmjit/core/operand.cpp
index 46bb23a289c..ee026817f8e 100644
--- a/3rdparty/asmjit/src/asmjit/core/operand.cpp
+++ b/3rdparty/asmjit/src/asmjit/core/operand.cpp
@@ -1,36 +1,22 @@
-// 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 "../core/api-build_p.h"
#include "../core/operand.h"
ASMJIT_BEGIN_NAMESPACE
-// ============================================================================
-// [asmjit::Operand - Unit]
-// ============================================================================
+// Operand - Tests
+// ===============
#if defined(ASMJIT_TEST)
+enum class StrongEnumForImmTests : uint32_t {
+ kValue0,
+ kValue0xFFFFFFFF = 0xFFFFFFFFu
+};
+
UNIT(operand) {
INFO("Checking operand sizes");
EXPECT(sizeof(Operand) == 16);
@@ -65,22 +51,23 @@ UNIT(operand) {
EXPECT(dummy.as<BaseReg>().isValid() == false);
// Create some register (not specific to any architecture).
- uint32_t rSig = Operand::kOpReg | (1 << Operand::kSignatureRegTypeShift ) |
- (2 << Operand::kSignatureRegGroupShift) |
- (8 << Operand::kSignatureSizeShift ) ;
+ OperandSignature rSig = OperandSignature::fromOpType(OperandType::kReg) |
+ OperandSignature::fromRegType(RegType::kVec128) |
+ OperandSignature::fromRegGroup(RegGroup::kVec) |
+ OperandSignature::fromSize(8);
BaseReg r1(rSig, 5);
EXPECT(r1.isValid() == true);
EXPECT(r1.isReg() == true);
- EXPECT(r1.isReg(1) == true);
+ EXPECT(r1.isReg(RegType::kVec128) == true);
EXPECT(r1.isPhysReg() == true);
EXPECT(r1.isVirtReg() == false);
EXPECT(r1.signature() == rSig);
- EXPECT(r1.type() == 1);
- EXPECT(r1.group() == 2);
+ EXPECT(r1.type() == RegType::kVec128);
+ EXPECT(r1.group() == RegGroup::kVec);
EXPECT(r1.size() == 8);
EXPECT(r1.id() == 5);
- EXPECT(r1.isReg(1, 5) == true); // RegType and Id.
+ EXPECT(r1.isReg(RegType::kVec128, 5) == true); // RegType and Id.
EXPECT(r1._data[0] == 0);
EXPECT(r1._data[1] == 0);
@@ -88,7 +75,7 @@ UNIT(operand) {
BaseReg r2(r1, 6);
EXPECT(r2.isValid() == true);
EXPECT(r2.isReg() == true);
- EXPECT(r2.isReg(1) == true);
+ EXPECT(r2.isReg(RegType::kVec128) == true);
EXPECT(r2.isPhysReg() == true);
EXPECT(r2.isVirtReg() == false);
EXPECT(r2.signature() == rSig);
@@ -96,7 +83,7 @@ UNIT(operand) {
EXPECT(r2.group() == r1.group());
EXPECT(r2.size() == r1.size());
EXPECT(r2.id() == 6);
- EXPECT(r2.isReg(1, 6) == true);
+ EXPECT(r2.isReg(RegType::kVec128, 6) == true);
r1.reset();
EXPECT(!r1.isReg());
@@ -126,10 +113,19 @@ UNIT(operand) {
INFO("Checking basic functionality of Imm");
Imm immValue(-42);
+ EXPECT(immValue.type() == ImmType::kInt);
EXPECT(Imm(-1).value() == -1);
EXPECT(imm(-1).value() == -1);
EXPECT(immValue.value() == -42);
EXPECT(imm(0xFFFFFFFF).value() == int64_t(0xFFFFFFFF));
+
+ Imm immDouble(0.4);
+ EXPECT(immDouble.type() == ImmType::kDouble);
+ EXPECT(immDouble.valueAs<double>() == 0.4);
+ EXPECT(immDouble == imm(0.4));
+
+ EXPECT(Imm(StrongEnumForImmTests::kValue0).value() == 0);
+ EXPECT(Imm(StrongEnumForImmTests::kValue0xFFFFFFFF).value() == 0xFFFFFFFFu);
}
#endif