Files
sdk/runtime/vm/compiler/assembler/assembler_test.h
Tess Strickland b23584eaa0 [vm/compiler] Add reg, reg, imm forms for lsl/asr/and assembler macros.
For non-x86 architectures, these forms directly translate to a
single instruction when possible. On x86 architectures,
XImmediate(dst, src, imm) where X is in {Lsl, ArithmeticShiftRight, And}
can be translated to:

  MoveRegister(dst, src);
  XImmediate(dst, imm);

in the general case since MoveRegister(dst, src) is a no-op if dst and
src are the same.

Also add versions of these assembler macros that take an OperandSize
and handle 32-bit OperandSizes appropriately on 64-bit architectures.

Ensure the implementation for LslImmediate and
ArithmeticShiftRightImmediate emits no instructions if shift == 0,
dst == src, and OperandSizeInBits(sz) == kBitsPerWord on all
architectures.

-----

Other changes:

Fix ConstantExpression::EmitMoveToLocation on ARM64 to match
other architectures, which allow any word-sized or less unboxed
integer representation.

Fill out ExtendValue on RISCV for previously unimplemented
OperandSizes, using the Zba and Zbb extensions when possible.

-----

TEST=vm/cc/Assembler_AndImmediate vm/cc/Assembler_LslImmediate
     vm/cc/Assembler_ArithmeticShiftRightImmediate

Separated out of https://dart-review.googlesource.com/c/sdk/+/378706
for easier debugging/reviewing.

Change-Id: I721f1334784f7011a958ea8af29f0e56c620726c
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-linux-product-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-aot-linux-debug-simarm_x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-mac-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-android-release-arm64c-try,vm-ffi-android-debug-arm64c-try,vm-aot-linux-debug-x64c-try,vm-linux-debug-x64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386180
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-10-04 10:07:51 +00:00

71 lines
1.9 KiB
C++

// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_COMPILER_ASSEMBLER_ASSEMBLER_TEST_H_
#define RUNTIME_VM_COMPILER_ASSEMBLER_ASSEMBLER_TEST_H_
#include "vm/compiler/runtime_api.h"
#if defined(DART_PRECOMPILED_RUNTIME)
#error "AOT runtime should not use compiler sources (including header files)"
#endif // defined(DART_PRECOMPILED_RUNTIME)
#include "vm/compiler/assembler/assembler_base.h"
namespace dart {
namespace compiler {
void EnterTestFrame(Assembler* assembler);
void LeaveTestFrame(Assembler* assembler);
// Used in AndImmediate, LslImmediate, and ArithmeticRightShiftImmediate tests.
struct RegRegImmTests : AllStatic {
static const Register kInputReg;
static const Register kReturnReg;
static intptr_t And(intptr_t lhs, intptr_t rhs, OperandSize sz);
static intptr_t Lsl(intptr_t value, intptr_t shift, OperandSize sz);
static intptr_t Asr(intptr_t value, intptr_t shift, OperandSize sz);
static intptr_t ExtendValue(intptr_t value, OperandSize sz);
static intptr_t ZeroExtendValue(intptr_t value, OperandSize sz);
static intptr_t SignExtendValue(intptr_t value, OperandSize sz);
};
const uintptr_t kRegRegImmInputs[] = {
0,
1,
0x5A,
kMaxInt8,
static_cast<uintptr_t>(kMinInt8),
kMaxUint8,
kMaxUint8 + 1,
0x5BDF,
kMaxInt16,
static_cast<uintptr_t>(kMinInt16),
kMaxUint16,
kMaxUint16 + 1,
0x12345,
0x579BDF13,
kMaxInt32,
static_cast<uintptr_t>(kMinInt32),
kMaxUint32,
#if !defined(TARGET_ARCH_IS_32_BIT)
kMaxUint32 + 1,
0x123456789ABC,
0x579BDF13579BDF13,
kMaxInt64,
static_cast<uintptr_t>(kMinInt64),
kMaxUint64,
#endif
};
} // namespace compiler
} // namespace dart
#endif // RUNTIME_VM_COMPILER_ASSEMBLER_ASSEMBLER_TEST_H_