Flutter Engine
The Flutter Engine
object_riscv_test.cc
Go to the documentation of this file.
1// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "platform/assert.h"
6#include "vm/globals.h"
7#if defined(TARGET_ARCH_RISCV32) || defined(TARGET_ARCH_RISCV64)
8
10#include "vm/object.h"
11#include "vm/unit_test.h"
12
13namespace dart {
14
15#define __ assembler->
16
17// Generate a simple dart code sequence.
18// This is used to test Code and Instruction object creation.
19void GenerateIncrement(compiler::Assembler* assembler) {
20 __ EnterFrame(1 * kWordSize);
21 __ li(A0, 0);
22 __ PushRegister(A0);
23 __ addi(A0, A0, 1);
24 __ sx(A0, compiler::Address(SP));
25 __ lx(A1, compiler::Address(SP));
26 __ addi(A1, A1, 1);
27 __ PopRegister(A0);
28 __ mv(A0, A1);
29 __ LeaveFrame();
30 __ ret();
31}
32
33// Generate a dart code sequence that embeds a string object in it.
34// This is used to test Embedded String objects in the instructions.
35void GenerateEmbedStringInCode(compiler::Assembler* assembler,
36 const char* str) {
37 const String& string_object =
39 __ EnterStubFrame();
40 __ LoadObject(A0, string_object);
41 __ LeaveStubFrame();
42 __ ret();
43}
44
45// Generate a dart code sequence that embeds a smi object in it.
46// This is used to test Embedded Smi objects in the instructions.
47void GenerateEmbedSmiInCode(compiler::Assembler* assembler, intptr_t value) {
48 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value));
49 const intx_t val = static_cast<intx_t>(smi_object.ptr());
50 __ LoadImmediate(A0, val);
51 __ ret();
52}
53
54} // namespace dart
55
56#endif // defined TARGET_ARCH_RISCV
#define __
@ kOld
Definition: heap.h:39
static Object & ZoneHandle()
Definition: object.h:419
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
uint8_t value
Definition: dart_vm.cc:33
constexpr intptr_t kWordSize
Definition: globals.h:509