Path: blob/master/test/hotspot/gtest/aarch64/test_assembler_aarch64.cpp
41145 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2020, Red Hat Inc. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324#include "precompiled.hpp"2526#if defined(AARCH64) && !defined(ZERO)2728#include "asm/assembler.hpp"29#include "asm/assembler.inline.hpp"30#include "compiler/disassembler.hpp"31#include "memory/resourceArea.hpp"32#include "unittest.hpp"3334#define __ _masm.3536static void asm_check(const unsigned int *insns, const unsigned int *insns1, size_t len) {37bool ok = true;38for (unsigned int i = 0; i < len; i++) {39if (insns[i] != insns1[i]) {40ResourceMark rm;41stringStream ss;42ss.print_cr("Ours:");43Disassembler::decode((address)&insns1[i], (address)&insns1[i+1], &ss);44ss.print_cr("Theirs:");45Disassembler::decode((address)&insns[i], (address)&insns[i+1], &ss);4647EXPECT_EQ(insns[i], insns1[i]) << ss.as_string();48}49}50}5152TEST_VM(AssemblerAArch64, validate) {53// Smoke test for assembler54BufferBlob* b = BufferBlob::create("aarch64Test", 500000);55CodeBuffer code(b);56Assembler _masm(&code);57address entry = __ pc();5859// python aarch64-asmtest.py | expand > asmtest.out.h60#include "asmtest.out.h"6162asm_check((unsigned int *)entry, insns, sizeof insns / sizeof insns[0]);6364{65address PC = __ pc();66__ ld1(v0, __ T16B, Address(r16)); // No offset67__ ld1(v0, __ T8H, __ post(r16, 16)); // Post-index68__ ld2(v0, v1, __ T8H, __ post(r24, 16 * 2)); // Post-index69__ ld1(v0, __ T16B, __ post(r16, r17)); // Register post-index70static const unsigned int vector_insns[] = {710x4c407200, // ld1 {v0.16b}, [x16]720x4cdf7600, // ld1 {v0.8h}, [x16], #16730x4cdf8700, // ld2 {v0.8h, v1.8h}, [x24], #32740x4cd17200, // ld1 {v0.16b}, [x16], x1775};76asm_check((unsigned int *)PC, vector_insns,77sizeof vector_insns / sizeof vector_insns[0]);78}7980BufferBlob::free(b);81}8283#endif // AARCH64848586