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_ASM_SUPPORT_MIPS64_S_ 18#define ART_RUNTIME_ARCH_MIPS64_ASM_SUPPORT_MIPS64_S_ 19 20#include "asm_support_mips64.h" 21 22// Define special registers. 23 24// Register holding suspend check count down. 25#define rSUSPEND $s0 26// Register holding Thread::Current(). 27#define rSELF $s1 28 29 30 // Declare a function called name, sets up $gp. 31 // This macro modifies t8. 32.macro ENTRY name 33 .type \name, %function 34 .global \name 35 // Cache alignment for function entry. 36 .balign 16 37\name: 38 .cfi_startproc 39 // Set up $gp and store the previous $gp value to $t8. It will be pushed to the 40 // stack after the frame has been constructed. 41 .cpsetup $t9, $t8, \name 42 // Ensure we get a sane starting CFA. 43 .cfi_def_cfa $sp,0 44 // Declare a local convenience label to be branched to when $gp is already set up. 45.L\name\()_gp_set: 46.endm 47 48 // Declare a function called name, doesn't set up $gp. 49.macro ENTRY_NO_GP name 50 .type \name, %function 51 .global \name 52 // Cache alignment for function entry. 53 .balign 16 54\name: 55 .cfi_startproc 56 // Ensure we get a sane starting CFA. 57 .cfi_def_cfa $sp,0 58.endm 59 60.macro END name 61 .cfi_endproc 62 .size \name, .-\name 63.endm 64 65.macro UNIMPLEMENTED name 66 ENTRY \name 67 break 68 break 69 END \name 70.endm 71 72// Macros to poison (negate) the reference for heap poisoning. 73.macro POISON_HEAP_REF rRef 74#ifdef USE_HEAP_POISONING 75 subu \rRef, $zero, \rRef 76#endif // USE_HEAP_POISONING 77.endm 78 79// Macros to unpoison (negate) the reference for heap poisoning. 80.macro UNPOISON_HEAP_REF rRef 81#ifdef USE_HEAP_POISONING 82 subu \rRef, $zero, \rRef 83#endif // USE_HEAP_POISONING 84.endm 85 86// Based on contents of creg select the minimum integer 87// At the end of the macro the original value of creg is lost 88.macro MINint dreg,rreg,sreg,creg 89 .set push 90 .set noat 91 .ifc \dreg, \rreg 92 selnez \dreg, \rreg, \creg 93 seleqz \creg, \sreg, \creg 94 .else 95 seleqz \dreg, \sreg, \creg 96 selnez \creg, \rreg, \creg 97 .endif 98 or \dreg, \dreg, \creg 99 .set pop 100.endm 101 102// Find minimum of two signed registers 103.macro MINs dreg,rreg,sreg 104 .set push 105 .set noat 106 slt $at, \rreg, \sreg 107 MINint \dreg, \rreg, \sreg, $at 108 .set pop 109.endm 110 111// Find minimum of two unsigned registers 112.macro MINu dreg,rreg,sreg 113 .set push 114 .set noat 115 sltu $at, \rreg, \sreg 116 MINint \dreg, \rreg, \sreg, $at 117 .set pop 118.endm 119 120#endif // ART_RUNTIME_ARCH_MIPS64_ASM_SUPPORT_MIPS64_S_ 121