PowerPC: Enable POWER8 platform sans hwcap bits.
[glibc.git] / sysdeps / powerpc / powerpc32 / bp-asm.h
blob16afbb22510e257b62c092379de9175e0c8cec8e
1 /* Bounded-pointer definitions for PowerPC assembler.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 Contributed by Greg McGary <greg@mcgary.org>
4 This file is part of the GNU C Library. Its master source is NOT part of
5 the C library, however. The master source lives in the GNU MP Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
21 #if __BOUNDED_POINTERS__
23 /* Byte offsets of BP components. */
24 # define oVALUE 0
25 # define oLOW 4
26 # define oHIGH 8
28 /* Don't check bounds, just convert the BP register to its simple
29 pointer value. */
31 # define DISCARD_BOUNDS(rBP) \
32 lwz rBP, oVALUE(rBP)
34 /* Check low bound, with the side effect that the BP register is converted
35 its simple pointer value. Move the high bound into a register for
36 later use. */
38 # define CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH) \
39 lwz rHIGH, oHIGH(rBP); \
40 lwz rLOW, oLOW(rBP); \
41 lwz rBP, oVALUE(rBP); \
42 twllt rBP, rLOW
44 /* Check the high bound, which is in a register, using the given
45 conditional trap instruction. */
47 # define CHECK_BOUNDS_HIGH(rVALUE, rHIGH, TWLcc) \
48 TWLcc rVALUE, rHIGH
50 /* Check the high bound, which is stored at the return-value's high
51 bound slot, using the given conditional trap instruction. */
53 # define CHECK_BOUNDS_HIGH_RTN(rVALUE, rHIGH, TWLcc) \
54 lwz rHIGH, oHIGH(rRTN); \
55 TWLcc rVALUE, rHIGH
57 /* Check both bounds, with the side effect that the BP register is
58 converted to its simple pointer value. */
60 # define CHECK_BOUNDS_BOTH(rBP, rLOW, rHIGH) \
61 CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH); \
62 twlge rBP, rHIGH
64 /* Check bounds on a memory region of given length, with the side
65 effect that the BP register is converted to its simple pointer
66 value. */
68 # define CHECK_BOUNDS_BOTH_WIDE(rBP, rLOW, rHIGH, rLENGTH) \
69 CHECK_BOUNDS_LOW (rBP, rLOW, rHIGH); \
70 sub rHIGH, rHIGH, rLENGTH; \
71 twlgt rBP, rHIGH
73 # define CHECK_BOUNDS_BOTH_WIDE_LIT(rBP, rLOW, rHIGH, LENGTH) \
74 CHECK_BOUNDS_LOW (rBP, rLOW, rHIGH); \
75 subi rHIGH, rHIGH, LENGTH; \
76 twlgt rBP, rHIGH
78 /* Store a pointer value register into the return-value's pointer
79 value slot. */
81 # define STORE_RETURN_VALUE(rVALUE) \
82 stw rVALUE, oVALUE(rRTN)
84 /* Store a low and high bounds into the return-value's pointer bounds
85 slots. */
87 # define STORE_RETURN_BOUNDS(rLOW, rHIGH) \
88 stw rLOW, oLOW(rRTN); \
89 stw rHIGH, oHIGH(rRTN)
91 /* Stuff zero value/low/high into the BP addressed by rRTN. */
93 # define RETURN_NULL_BOUNDED_POINTER \
94 li r4, 0; \
95 STORE_RETURN_VALUE (r4); \
96 STORE_RETURN_BOUNDS (r4, r4)
98 #else
100 # define DISCARD_BOUNDS(rBP)
101 # define CHECK_BOUNDS_LOW(rBP, rLOW, rHIGH)
102 # define CHECK_BOUNDS_HIGH(rVALUE, rHIGH, TWLcc)
103 # define CHECK_BOUNDS_HIGH_RTN(rVALUE, rHIGH, TWLcc)
104 # define CHECK_BOUNDS_BOTH(rBP, rLOW, rHIGH)
105 # define CHECK_BOUNDS_BOTH_WIDE(rBP, rLOW, rHIGH, rLENGTH)
106 # define CHECK_BOUNDS_BOTH_WIDE_LIT(rBP, rLOW, rHIGH, LENGTH)
107 # define STORE_RETURN_VALUE(rVALUE)
108 # define STORE_RETURN_BOUNDS(rLOW, rHIGH)
110 # define RETURN_NULL_BOUNDED_POINTER li rRTN, 0
112 #endif