14d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe/*
24d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * Copyright (C) 2014 The Android Open Source Project
34d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe *
44d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * Licensed under the Apache License, Version 2.0 (the "License");
54d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * you may not use this file except in compliance with the License.
64d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * You may obtain a copy of the License at
74d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe *
84d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe *      http://www.apache.org/licenses/LICENSE-2.0
94d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe *
104d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * Unless required by applicable law or agreed to in writing, software
114d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * distributed under the License is distributed on an "AS IS" BASIS,
124d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * See the License for the specific language governing permissions and
144d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe * limitations under the License.
154d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe */
164d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe
174d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe#ifndef ART_RUNTIME_ARCH_MIPS_MEMCMP16_MIPS_S_
184d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe#define ART_RUNTIME_ARCH_MIPS_MEMCMP16_MIPS_S_
194d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe
20624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe#include "asm_support_mips.S"
214d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe
224d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe// u4 __memcmp16(const u2*, const u2*, size_t);
23624010286eea15c0526c2ff75341ddfd906332b1Andreas GampeENTRY __memcmp16
24624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  li  $t0,0
25624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  li  $t1,0
26624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  beqz  $a2,done   /* 0 length string */
27624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  beq $a0,$a1,done    /* strings are identical */
284d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe
294d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe  /* Unoptimised... */
30624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe1:  lhu $t0,0($a0)
31624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  lhu $t1,0($a1)
32624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  addu  $a1,2
33624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  bne $t0,$t1,done
34624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  addu  $a0,2
35624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  subu  $a2,1
36624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  bnez  $a2,1b
374d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe
384d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampedone:
39624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  subu  $v0,$t0,$t1
40624010286eea15c0526c2ff75341ddfd906332b1Andreas Gampe  j $ra
41624010286eea15c0526c2ff75341ddfd906332b1Andreas GampeEND __memcmp16
424d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe
434d0589c90971e19c25894414ae7da579269e1fe2Andreas Gampe#endif  // ART_RUNTIME_ARCH_MIPS_MEMCMP16_MIPS_S_
44