1/*
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#ifndef ART_RUNTIME_ARCH_MIPS64_MEMCMP16_MIPS64_S_
18#define ART_RUNTIME_ARCH_MIPS64_MEMCMP16_MIPS64_S_
19
20#include "asm_support_mips64.S"
21
22.set noreorder
23
24// u4 __memcmp16(const u2*, const u2*, size_t);
25ENTRY_NO_GP __memcmp16
26  move  $t0, $zero
27  move  $t1, $zero
28  beqz  $a2, done       /* 0 length string */
29  nop
30  beq   $a0, $a1, done  /* addresses are identical */
31  nop
32
331:
34  lhu   $t0, 0($a0)
35  lhu   $t1, 0($a1)
36  bne   $t0, $t1, done
37  nop
38  daddu $a0, 2
39  daddu $a1, 2
40  dsubu $a2, 1
41  bnez  $a2, 1b
42  nop
43
44done:
45  dsubu $v0, $t0, $t1
46  j     $ra
47  nop
48END __memcmp16
49
50#endif  // ART_RUNTIME_ARCH_MIPS64_MEMCMP16_MIPS64_S_
51