1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sw=4 et tw=79:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Copyright (C) 2009 University of Szeged
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * ***** END LICENSE BLOCK ***** */
31 #include "assembler/wtf/Platform.h"
33 #if ENABLE_ASSEMBLER && WTF_CPU_ARM_TRADITIONAL
35 #include "MacroAssemblerARM.h"
37 #if WTF_PLATFORM_LINUX || WTF_PLATFORM_ANDROID
38 #include <sys/types.h>
44 // lame check for kernel version
46 #include <linux/version.h>
47 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
48 #include <asm/procinfo.h>
50 #include <asm/hwcap.h>
57 static bool isVFPPresent()
59 #if WTF_PLATFORM_LINUX
60 int fd = open("/proc/self/auxv", O_RDONLY);
63 while (read(fd, &aux, sizeof(Elf32_auxv_t))) {
64 if (aux.a_type == AT_HWCAP) {
66 return aux.a_un.a_val & HWCAP_VFP;
76 const bool MacroAssemblerARM::s_isVFPPresent = isVFPPresent();
78 #if WTF_CPU_ARMV5_OR_LOWER
79 /* On ARMv5 and below, natural alignment is required. */
80 void MacroAssemblerARM::load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest)
84 ASSERT(address.scale >= 0 && address.scale <= 3);
85 op2 = m_assembler.lsl(address.index, static_cast<int>(address.scale));
87 if (address.offset >= 0 && address.offset + 0x2 <= 0xff) {
88 m_assembler.add_r(ARMRegisters::S0, address.base, op2);
89 m_assembler.ldrh_u(dest, ARMRegisters::S0, ARMAssembler::getOp2Byte(address.offset));
90 m_assembler.ldrh_u(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(address.offset + 0x2));
91 } else if (address.offset < 0 && address.offset >= -0xff) {
92 m_assembler.add_r(ARMRegisters::S0, address.base, op2);
93 m_assembler.ldrh_d(dest, ARMRegisters::S0, ARMAssembler::getOp2Byte(-address.offset));
94 m_assembler.ldrh_d(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(-address.offset - 0x2));
96 m_assembler.ldr_un_imm(ARMRegisters::S0, address.offset);
97 m_assembler.add_r(ARMRegisters::S0, ARMRegisters::S0, op2);
98 m_assembler.ldrh_r(dest, address.base, ARMRegisters::S0);
99 m_assembler.add_r(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::OP2_IMM | 0x2);
100 m_assembler.ldrh_r(ARMRegisters::S0, address.base, ARMRegisters::S0);
102 m_assembler.orr_r(dest, dest, m_assembler.lsl(ARMRegisters::S0, 16));
108 #endif // ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)