491de34bcc
This very large changeset adds support for RISCV32. Bug: v8:13025 Change-Id: Ieacc857131e6620f0fcfd7daa88a0f8d77056aa9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3736732 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Yahan Lu <yahan@iscas.ac.cn> Reviewed-by: ji qiu <qiuji@iscas.ac.cn> Reviewed-by: Andreas Haas <ahaas@chromium.org> Reviewed-by: Hannes Payer <hpayer@chromium.org> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> Cr-Commit-Position: refs/heads/main@{#82053}
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
// Copyright 2021 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "test/cctest/test-helper-riscv32.h"
|
|
|
|
#include "src/codegen/macro-assembler.h"
|
|
#include "src/execution/isolate-inl.h"
|
|
#include "src/init/v8.h"
|
|
#include "test/cctest/cctest.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
int32_t GenAndRunTest(Func test_generator) {
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
HandleScope scope(isolate);
|
|
|
|
MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes);
|
|
test_generator(assm);
|
|
assm.jr(ra);
|
|
|
|
CodeDesc desc;
|
|
assm.GetCode(isolate, &desc);
|
|
Handle<Code> code =
|
|
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
|
|
auto f = GeneratedCode<int32_t()>::FromCode(*code);
|
|
return f.Call();
|
|
}
|
|
|
|
Handle<Code> AssembleCodeImpl(Func assemble) {
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
MacroAssembler assm(isolate, CodeObjectRequired::kYes);
|
|
|
|
assemble(assm);
|
|
assm.jr(ra);
|
|
|
|
CodeDesc desc;
|
|
assm.GetCode(isolate, &desc);
|
|
Handle<Code> code =
|
|
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
|
|
if (FLAG_print_code) {
|
|
code->Print();
|
|
}
|
|
return code;
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|