chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / sysdeps / powerpc / powerpc64 / bp-asm.h
1 /* Bounded-pointer definitions for PowerPC64 assembler.
2    Copyright (C) 2000, 2002 Free Software Foundation, Inc.
3    Contributed by Greg McGary <greg@mcgary.org>
4
5    This file is part of the GNU C Library.  Its master source is NOT part of
6    the C library, however.  The master source lives in the GNU MP Library.
7
8    The GNU C Library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Library General Public License as
10    published by the Free Software Foundation; either version 2 of the
11    License, or (at your option) any later version.
12
13    The GNU C Library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Library General Public License for more details.
17
18    You should have received a copy of the GNU Library General Public
19    License along with the GNU C Library; see the file COPYING.LIB.  If not,
20    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21    Boston, MA 02111-1307, USA.  */
22
23 #if __BOUNDED_POINTERS__
24
25 /* Byte offsets of BP components.  */
26 # define oVALUE 0
27 # define oLOW   4
28 # define oHIGH  8
29
30 /* Don't check bounds, just convert the BP register to its simple
31    pointer value.  */
32
33 # define DISCARD_BOUNDS(rBP)                    \
34         ld      rBP, oVALUE(rBP)
35
36 /* Check low bound, with the side effect that the BP register is converted
37    its simple pointer value.  Move the high bound into a register for
38    later use.  */
39
40 # define CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH)     \
41         ld      rHIGH, oHIGH(rBP);              \
42         ld      rLOW, oLOW(rBP);                \
43         ld      rBP, oVALUE(rBP);               \
44         tdllt   rBP, rLOW
45
46 /* Check the high bound, which is in a register, using the given
47    conditional trap instruction.  */
48
49 # define CHECK_BOUNDS_HIGH(rVALUE, rHIGH, TWLcc) \
50         TWLcc   rVALUE, rHIGH
51
52 /* Check the high bound, which is stored at the return-value's high
53    bound slot, using the given conditional trap instruction.  */
54
55 # define CHECK_BOUNDS_HIGH_RTN(rVALUE, rHIGH, TWLcc)    \
56         ld      rHIGH, oHIGH(rRTN);                     \
57         TWLcc   rVALUE, rHIGH
58
59 /* Check both bounds, with the side effect that the BP register is
60    converted to its simple pointer value.  */
61
62 # define CHECK_BOUNDS_BOTH(rBP, rLOW, rHIGH)    \
63         CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH);     \
64         tdlge   rBP, rHIGH
65
66 /* Check bounds on a memory region of given length, with the side
67    effect that the BP register is converted to its simple pointer
68    value.  */
69
70 # define CHECK_BOUNDS_BOTH_WIDE(rBP, rLOW, rHIGH, rLENGTH)      \
71         CHECK_BOUNDS_LOW (rBP, rLOW, rHIGH);                    \
72         sub     rHIGH, rHIGH, rLENGTH;                          \
73         tdlgt   rBP, rHIGH
74
75 # define CHECK_BOUNDS_BOTH_WIDE_LIT(rBP, rLOW, rHIGH, LENGTH)   \
76         CHECK_BOUNDS_LOW (rBP, rLOW, rHIGH);                    \
77         subi    rHIGH, rHIGH, LENGTH;                           \
78         tdlgt   rBP, rHIGH
79
80 /* Store a pointer value register into the return-value's pointer
81    value slot.  */
82
83 # define STORE_RETURN_VALUE(rVALUE)             \
84         std     rVALUE, oVALUE(rRTN)
85
86 /* Store a low and high bounds into the return-value's pointer bounds
87    slots.  */
88
89 # define STORE_RETURN_BOUNDS(rLOW, rHIGH)       \
90         std     rLOW, oLOW(rRTN);               \
91         std     rHIGH, oHIGH(rRTN)
92
93 /* Stuff zero value/low/high into the BP addressed by rRTN.  */
94
95 # define RETURN_NULL_BOUNDED_POINTER            \
96         li      r4, 0;                          \
97         STORE_RETURN_VALUE (r4);                \
98         STORE_RETURN_BOUNDS (r4, r4)
99
100 #else
101
102 # define DISCARD_BOUNDS(rBP)
103 # define CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH)
104 # define CHECK_BOUNDS_HIGH(rVALUE, rHIGH, TWLcc)
105 # define CHECK_BOUNDS_HIGH_RTN(rVALUE, rHIGH, TWLcc)
106 # define CHECK_BOUNDS_BOTH(rBP, rLOW, rHIGH)
107 # define CHECK_BOUNDS_BOTH_WIDE(rBP, rLOW, rHIGH, rLENGTH)
108 # define CHECK_BOUNDS_BOTH_WIDE_LIT(rBP, rLOW, rHIGH, LENGTH)
109 # define STORE_RETURN_VALUE(rVALUE)
110 # define STORE_RETURN_BOUNDS(rLOW, rHIGH)
111
112 # define RETURN_NULL_BOUNDED_POINTER li rRTN, 0
113
114 #endif
115