11cb0ef41Sopenharmony_ci// Copyright 2009 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_ARM 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci#include "src/codegen/arm/constants-arm.h" 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_cinamespace v8 { 101cb0ef41Sopenharmony_cinamespace internal { 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciFloat64 Instruction::DoubleImmedVmov() const { 131cb0ef41Sopenharmony_ci // Reconstruct a double from the immediate encoded in the vmov instruction. 141cb0ef41Sopenharmony_ci // 151cb0ef41Sopenharmony_ci // instruction: [xxxxxxxx,xxxxabcd,xxxxxxxx,xxxxefgh] 161cb0ef41Sopenharmony_ci // double: [aBbbbbbb,bbcdefgh,00000000,00000000, 171cb0ef41Sopenharmony_ci // 00000000,00000000,00000000,00000000] 181cb0ef41Sopenharmony_ci // 191cb0ef41Sopenharmony_ci // where B = ~b. Only the high 16 bits are affected. 201cb0ef41Sopenharmony_ci uint64_t high16; 211cb0ef41Sopenharmony_ci high16 = (Bits(17, 16) << 4) | Bits(3, 0); // xxxxxxxx,xxcdefgh. 221cb0ef41Sopenharmony_ci high16 |= (0xFF * Bit(18)) << 6; // xxbbbbbb,bbxxxxxx. 231cb0ef41Sopenharmony_ci high16 |= (Bit(18) ^ 1) << 14; // xBxxxxxx,xxxxxxxx. 241cb0ef41Sopenharmony_ci high16 |= Bit(19) << 15; // axxxxxxx,xxxxxxxx. 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci uint64_t imm = high16 << 48; 271cb0ef41Sopenharmony_ci return Float64::FromBits(imm); 281cb0ef41Sopenharmony_ci} 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci// These register names are defined in a way to match the native disassembler 311cb0ef41Sopenharmony_ci// formatting. See for example the command "objdump -d <binary file>". 321cb0ef41Sopenharmony_ciconst char* Registers::names_[kNumRegisters] = { 331cb0ef41Sopenharmony_ci "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", 341cb0ef41Sopenharmony_ci "r8", "r9", "r10", "fp", "ip", "sp", "lr", "pc", 351cb0ef41Sopenharmony_ci}; 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci// List of alias names which can be used when referring to ARM registers. 381cb0ef41Sopenharmony_ciconst Registers::RegisterAlias Registers::aliases_[] = { 391cb0ef41Sopenharmony_ci {10, "sl"}, {11, "r11"}, {12, "r12"}, {13, "r13"}, 401cb0ef41Sopenharmony_ci {14, "r14"}, {15, "r15"}, {kNoRegister, nullptr}}; 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci// Support for VFP registers s0 to s31 (d0 to d15) and d16-d31. 431cb0ef41Sopenharmony_ci// Note that "sN:sM" is the same as "dN/2" up to d15. 441cb0ef41Sopenharmony_ci// These register names are defined in a way to match the native disassembler 451cb0ef41Sopenharmony_ci// formatting. See for example the command "objdump -d <binary file>". 461cb0ef41Sopenharmony_ciconst char* VFPRegisters::names_[kNumVFPRegisters] = { 471cb0ef41Sopenharmony_ci "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", 481cb0ef41Sopenharmony_ci "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", 491cb0ef41Sopenharmony_ci "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31", "d0", 501cb0ef41Sopenharmony_ci "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11", 511cb0ef41Sopenharmony_ci "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", "d22", 521cb0ef41Sopenharmony_ci "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31"}; 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ciconst char* VFPRegisters::Name(int reg, bool is_double) { 551cb0ef41Sopenharmony_ci DCHECK((0 <= reg) && (reg < kNumVFPRegisters)); 561cb0ef41Sopenharmony_ci return names_[reg + (is_double ? kNumVFPSingleRegisters : 0)]; 571cb0ef41Sopenharmony_ci} 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ciint VFPRegisters::Number(const char* name, bool* is_double) { 601cb0ef41Sopenharmony_ci for (int i = 0; i < kNumVFPRegisters; i++) { 611cb0ef41Sopenharmony_ci if (strcmp(names_[i], name) == 0) { 621cb0ef41Sopenharmony_ci if (i < kNumVFPSingleRegisters) { 631cb0ef41Sopenharmony_ci *is_double = false; 641cb0ef41Sopenharmony_ci return i; 651cb0ef41Sopenharmony_ci } else { 661cb0ef41Sopenharmony_ci *is_double = true; 671cb0ef41Sopenharmony_ci return i - kNumVFPSingleRegisters; 681cb0ef41Sopenharmony_ci } 691cb0ef41Sopenharmony_ci } 701cb0ef41Sopenharmony_ci } 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci // No register with the requested name found. 731cb0ef41Sopenharmony_ci return kNoRegister; 741cb0ef41Sopenharmony_ci} 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ciint Registers::Number(const char* name) { 771cb0ef41Sopenharmony_ci // Look through the canonical names. 781cb0ef41Sopenharmony_ci for (int i = 0; i < kNumRegisters; i++) { 791cb0ef41Sopenharmony_ci if (strcmp(names_[i], name) == 0) { 801cb0ef41Sopenharmony_ci return i; 811cb0ef41Sopenharmony_ci } 821cb0ef41Sopenharmony_ci } 831cb0ef41Sopenharmony_ci 841cb0ef41Sopenharmony_ci // Look through the alias names. 851cb0ef41Sopenharmony_ci int i = 0; 861cb0ef41Sopenharmony_ci while (aliases_[i].reg != kNoRegister) { 871cb0ef41Sopenharmony_ci if (strcmp(aliases_[i].name, name) == 0) { 881cb0ef41Sopenharmony_ci return aliases_[i].reg; 891cb0ef41Sopenharmony_ci } 901cb0ef41Sopenharmony_ci i++; 911cb0ef41Sopenharmony_ci } 921cb0ef41Sopenharmony_ci 931cb0ef41Sopenharmony_ci // No register with the requested name found. 941cb0ef41Sopenharmony_ci return kNoRegister; 951cb0ef41Sopenharmony_ci} 961cb0ef41Sopenharmony_ci 971cb0ef41Sopenharmony_ci} // namespace internal 981cb0ef41Sopenharmony_ci} // namespace v8 991cb0ef41Sopenharmony_ci 1001cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_ARM 101