blob: c26f2cd0033ca76de27a20a3e6fa42e02e2da879 [file] [log] [blame]
Ian Rogers6f3dbba2014-10-14 17:41:57 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "asm_support_arm.S"
18
19.section .text
20// This function is used to check for the CPU's support for the sdiv
21// instruction at runtime. It will either return the value 1 or
22// will cause an invalid instruction trap (SIGILL signal). The
23// caller must arrange for the signal handler to set the r0
24// register to 0 and move the pc forward by 4 bytes (to skip
25// the invalid instruction).
26ENTRY artCheckForARMSDIVInstruction
27 mov r1,#1
28 // depending on the architecture, the assembler will not allow an
29 // sdiv instruction, so we will have to output the bytes directly.
30
31 // sdiv r0,r1,r1 is two words: 0xfb91 0xf1f0. We need little endian.
32 .byte 0x91,0xfb,0xf1,0xf0
33
34 // if the divide worked, r0 will have the value #1 (result of sdiv).
35 // It will have 0 otherwise (set by the signal handler)
36 // the value is just returned from this function.
37 bx lr
38END artCheckForARMSDIVInstruction