annotate gcc/config/rs6000/amo.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Power ISA 3.0 atomic memory operation include file.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2017-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Michael Meissner <meissner@linux.vnet.ibm.com>.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
8 under the terms of the GNU General Public License as published
kono
parents:
diff changeset
9 by the Free Software Foundation; either version 3, or (at your
kono
parents:
diff changeset
10 option) any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT
kono
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
kono
parents:
diff changeset
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
kono
parents:
diff changeset
15 License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
18 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
19 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
22 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
24 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 #ifndef _AMO_H
kono
parents:
diff changeset
27 #define _AMO_H
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 #if !defined(_ARCH_PWR9) || !defined(_ARCH_PPC64)
kono
parents:
diff changeset
30 #error "The atomic memory operations require Power 64-bit ISA 3.0"
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 #else
kono
parents:
diff changeset
33 #include <stdint.h>
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 /* Enumeration of the LWAT/LDAT sub-opcodes. */
kono
parents:
diff changeset
36 enum _AMO_LD {
kono
parents:
diff changeset
37 _AMO_LD_ADD = 0x00, /* Fetch and Add. */
kono
parents:
diff changeset
38 _AMO_LD_XOR = 0x01, /* Fetch and Xor. */
kono
parents:
diff changeset
39 _AMO_LD_IOR = 0x02, /* Fetch and Ior. */
kono
parents:
diff changeset
40 _AMO_LD_AND = 0x03, /* Fetch and And. */
kono
parents:
diff changeset
41 _AMO_LD_UMAX = 0x04, /* Fetch and Unsigned Maximum. */
kono
parents:
diff changeset
42 _AMO_LD_SMAX = 0x05, /* Fetch and Signed Maximum. */
kono
parents:
diff changeset
43 _AMO_LD_UMIN = 0x06, /* Fetch and Unsigned Minimum. */
kono
parents:
diff changeset
44 _AMO_LD_SMIN = 0x07, /* Fetch and Signed Minimum. */
kono
parents:
diff changeset
45 _AMO_LD_SWAP = 0x08, /* Swap. */
kono
parents:
diff changeset
46 _AMO_LD_CS_NE = 0x10, /* Compare and Swap Not Equal. */
kono
parents:
diff changeset
47 _AMO_LD_INC_BOUNDED = 0x18, /* Fetch and Increment Bounded. */
kono
parents:
diff changeset
48 _AMO_LD_INC_EQUAL = 0x19, /* Fetch and Increment Equal. */
kono
parents:
diff changeset
49 _AMO_LD_DEC_BOUNDED = 0x1A /* Fetch and Decrement Bounded. */
kono
parents:
diff changeset
50 };
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* Implementation of the simple LWAT/LDAT operations that take one register and
kono
parents:
diff changeset
53 modify one word or double-word of memory and return the value that was
kono
parents:
diff changeset
54 previously in the memory location.
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 The LWAT/LDAT opcode requires the address to be a single register, and that
kono
parents:
diff changeset
57 points to a suitably aligned memory location. Asm volatile is used to
kono
parents:
diff changeset
58 prevent the optimizer from moving the operation. */
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 #define _AMO_LD_SIMPLE(NAME, TYPE, OPCODE, FC) \
kono
parents:
diff changeset
61 static __inline__ TYPE \
kono
parents:
diff changeset
62 NAME (TYPE *_PTR, TYPE _VALUE) \
kono
parents:
diff changeset
63 { \
kono
parents:
diff changeset
64 unsigned __int128 _TMP; \
kono
parents:
diff changeset
65 TYPE _RET; \
kono
parents:
diff changeset
66 __asm__ volatile ("mr %L1,%3\n" \
kono
parents:
diff changeset
67 "\t" OPCODE " %1,%P0,%4\n" \
kono
parents:
diff changeset
68 "\tmr %2,%1\n" \
kono
parents:
diff changeset
69 : "+Q" (_PTR[0]), "=&r" (_TMP), "=r" (_RET) \
kono
parents:
diff changeset
70 : "r" (_VALUE), "n" (FC)); \
kono
parents:
diff changeset
71 return _RET; \
kono
parents:
diff changeset
72 }
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 _AMO_LD_SIMPLE (amo_lwat_add, uint32_t, "lwat", _AMO_LD_ADD)
kono
parents:
diff changeset
75 _AMO_LD_SIMPLE (amo_lwat_xor, uint32_t, "lwat", _AMO_LD_XOR)
kono
parents:
diff changeset
76 _AMO_LD_SIMPLE (amo_lwat_ior, uint32_t, "lwat", _AMO_LD_IOR)
kono
parents:
diff changeset
77 _AMO_LD_SIMPLE (amo_lwat_and, uint32_t, "lwat", _AMO_LD_AND)
kono
parents:
diff changeset
78 _AMO_LD_SIMPLE (amo_lwat_umax, uint32_t, "lwat", _AMO_LD_UMAX)
kono
parents:
diff changeset
79 _AMO_LD_SIMPLE (amo_lwat_umin, uint32_t, "lwat", _AMO_LD_UMIN)
kono
parents:
diff changeset
80 _AMO_LD_SIMPLE (amo_lwat_swap, uint32_t, "lwat", _AMO_LD_SWAP)
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 _AMO_LD_SIMPLE (amo_lwat_sadd, int32_t, "lwat", _AMO_LD_ADD)
kono
parents:
diff changeset
83 _AMO_LD_SIMPLE (amo_lwat_smax, int32_t, "lwat", _AMO_LD_SMAX)
kono
parents:
diff changeset
84 _AMO_LD_SIMPLE (amo_lwat_smin, int32_t, "lwat", _AMO_LD_SMIN)
kono
parents:
diff changeset
85 _AMO_LD_SIMPLE (amo_lwat_sswap, int32_t, "lwat", _AMO_LD_SWAP)
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 _AMO_LD_SIMPLE (amo_ldat_add, uint64_t, "ldat", _AMO_LD_ADD)
kono
parents:
diff changeset
88 _AMO_LD_SIMPLE (amo_ldat_xor, uint64_t, "ldat", _AMO_LD_XOR)
kono
parents:
diff changeset
89 _AMO_LD_SIMPLE (amo_ldat_ior, uint64_t, "ldat", _AMO_LD_IOR)
kono
parents:
diff changeset
90 _AMO_LD_SIMPLE (amo_ldat_and, uint64_t, "ldat", _AMO_LD_AND)
kono
parents:
diff changeset
91 _AMO_LD_SIMPLE (amo_ldat_umax, uint64_t, "ldat", _AMO_LD_UMAX)
kono
parents:
diff changeset
92 _AMO_LD_SIMPLE (amo_ldat_umin, uint64_t, "ldat", _AMO_LD_UMIN)
kono
parents:
diff changeset
93 _AMO_LD_SIMPLE (amo_ldat_swap, uint64_t, "ldat", _AMO_LD_SWAP)
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 _AMO_LD_SIMPLE (amo_ldat_sadd, int64_t, "ldat", _AMO_LD_ADD)
kono
parents:
diff changeset
96 _AMO_LD_SIMPLE (amo_ldat_smax, int64_t, "ldat", _AMO_LD_SMAX)
kono
parents:
diff changeset
97 _AMO_LD_SIMPLE (amo_ldat_smin, int64_t, "ldat", _AMO_LD_SMIN)
kono
parents:
diff changeset
98 _AMO_LD_SIMPLE (amo_ldat_sswap, int64_t, "ldat", _AMO_LD_SWAP)
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 /* Enumeration of the STWAT/STDAT sub-opcodes. */
kono
parents:
diff changeset
101 enum _AMO_ST {
kono
parents:
diff changeset
102 _AMO_ST_ADD = 0x00, /* Store Add. */
kono
parents:
diff changeset
103 _AMO_ST_XOR = 0x01, /* Store Xor. */
kono
parents:
diff changeset
104 _AMO_ST_IOR = 0x02, /* Store Ior. */
kono
parents:
diff changeset
105 _AMO_ST_AND = 0x03, /* Store And. */
kono
parents:
diff changeset
106 _AMO_ST_UMAX = 0x04, /* Store Unsigned Maximum. */
kono
parents:
diff changeset
107 _AMO_ST_SMAX = 0x05, /* Store Signed Maximum. */
kono
parents:
diff changeset
108 _AMO_ST_UMIN = 0x06, /* Store Unsigned Minimum. */
kono
parents:
diff changeset
109 _AMO_ST_SMIN = 0x07, /* Store Signed Minimum. */
kono
parents:
diff changeset
110 _AMO_ST_TWIN = 0x18 /* Store Twin. */
kono
parents:
diff changeset
111 };
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 /* Implementation of the simple STWAT/STDAT operations that take one register
kono
parents:
diff changeset
114 and modify one word or double-word of memory. No value is returned.
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 The STWAT/STDAT opcode requires the address to be a single register, and
kono
parents:
diff changeset
117 that points to a suitably aligned memory location. Asm volatile is used to
kono
parents:
diff changeset
118 prevent the optimizer from moving the operation. */
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 #define _AMO_ST_SIMPLE(NAME, TYPE, OPCODE, FC) \
kono
parents:
diff changeset
121 static __inline__ void \
kono
parents:
diff changeset
122 NAME (TYPE *_PTR, TYPE _VALUE) \
kono
parents:
diff changeset
123 { \
kono
parents:
diff changeset
124 __asm__ volatile (OPCODE " %1,%P0,%2" \
kono
parents:
diff changeset
125 : "+Q" (_PTR[0]) \
kono
parents:
diff changeset
126 : "r" (_VALUE), "n" (FC)); \
kono
parents:
diff changeset
127 return; \
kono
parents:
diff changeset
128 }
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 _AMO_ST_SIMPLE (amo_stwat_add, uint32_t, "stwat", _AMO_ST_ADD)
kono
parents:
diff changeset
131 _AMO_ST_SIMPLE (amo_stwat_xor, uint32_t, "stwat", _AMO_ST_XOR)
kono
parents:
diff changeset
132 _AMO_ST_SIMPLE (amo_stwat_ior, uint32_t, "stwat", _AMO_ST_IOR)
kono
parents:
diff changeset
133 _AMO_ST_SIMPLE (amo_stwat_and, uint32_t, "stwat", _AMO_ST_AND)
kono
parents:
diff changeset
134 _AMO_ST_SIMPLE (amo_stwat_umax, uint32_t, "stwat", _AMO_ST_UMAX)
kono
parents:
diff changeset
135 _AMO_ST_SIMPLE (amo_stwat_umin, uint32_t, "stwat", _AMO_ST_UMIN)
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 _AMO_ST_SIMPLE (amo_stwat_sadd, int32_t, "stwat", _AMO_ST_ADD)
kono
parents:
diff changeset
138 _AMO_ST_SIMPLE (amo_stwat_smax, int32_t, "stwat", _AMO_ST_SMAX)
kono
parents:
diff changeset
139 _AMO_ST_SIMPLE (amo_stwat_smin, int32_t, "stwat", _AMO_ST_SMIN)
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 _AMO_ST_SIMPLE (amo_stdat_add, uint64_t, "stdat", _AMO_ST_ADD)
kono
parents:
diff changeset
142 _AMO_ST_SIMPLE (amo_stdat_xor, uint64_t, "stdat", _AMO_ST_XOR)
kono
parents:
diff changeset
143 _AMO_ST_SIMPLE (amo_stdat_ior, uint64_t, "stdat", _AMO_ST_IOR)
kono
parents:
diff changeset
144 _AMO_ST_SIMPLE (amo_stdat_and, uint64_t, "stdat", _AMO_ST_AND)
kono
parents:
diff changeset
145 _AMO_ST_SIMPLE (amo_stdat_umax, uint64_t, "stdat", _AMO_ST_UMAX)
kono
parents:
diff changeset
146 _AMO_ST_SIMPLE (amo_stdat_umin, uint64_t, "stdat", _AMO_ST_UMIN)
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 _AMO_ST_SIMPLE (amo_stdat_sadd, int64_t, "stdat", _AMO_ST_ADD)
kono
parents:
diff changeset
149 _AMO_ST_SIMPLE (amo_stdat_smax, int64_t, "stdat", _AMO_ST_SMAX)
kono
parents:
diff changeset
150 _AMO_ST_SIMPLE (amo_stdat_smin, int64_t, "stdat", _AMO_ST_SMIN)
kono
parents:
diff changeset
151 #endif /* _ARCH_PWR9 && _ARCH_PPC64. */
kono
parents:
diff changeset
152 #endif /* _POWERPC_AMO_H. */