OSDN Git Service

Merge from transactional-memory branch.
[pf3gnuchains/gcc-fork.git] / libitm / config / x86 / target.h
1 /* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
2    Contributed by Richard Henderson <rth@redhat.com>.
3
4    This file is part of the GNU Transactional Memory Library (libitm).
5
6    Libitm is free software; you can redistribute it and/or modify it
7    under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
12    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14    more details.
15
16    Under Section 7 of GPL version 3, you are granted additional
17    permissions described in the GCC Runtime Library Exception, version
18    3.1, as published by the Free Software Foundation.
19
20    You should have received a copy of the GNU General Public License and
21    a copy of the GCC Runtime Library Exception along with this program;
22    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23    <http://www.gnu.org/licenses/>.  */
24
25 namespace GTM HIDDEN {
26
27 #ifdef __x86_64__
28 /* ??? This doesn't work for Win64.  */
29 typedef struct gtm_jmpbuf
30 {
31   void *cfa;
32   unsigned long rip;
33   unsigned long rbx;
34   unsigned long rbp;
35   unsigned long r12;
36   unsigned long r13;
37   unsigned long r14;
38   unsigned long r15;
39 } gtm_jmpbuf;
40 #else
41 typedef struct gtm_jmpbuf
42 {
43   void *cfa;
44   unsigned long ebx;
45   unsigned long esi;
46   unsigned long edi;
47   unsigned long ebp;
48   unsigned long eip;
49 } gtm_jmpbuf;
50 #endif
51
52 /* x86 doesn't require strict alignment for the basic types.  */
53 #define STRICT_ALIGNMENT 0
54
55 /* x86 uses a fixed page size of 4K.  */
56 #define PAGE_SIZE       4096
57 #define FIXED_PAGE_SIZE 1
58
59 /* The size of one line in hardware caches (in bytes). */
60 #define HW_CACHELINE_SIZE 64
61
62
63 static inline void
64 cpu_relax (void)
65 {
66   __asm volatile ("rep; nop" : : : "memory");
67 }
68
69 static inline void
70 atomic_read_barrier (void)
71 {
72   /* x86 is a strong memory ordering machine.  */
73   __asm volatile ("" : : : "memory");
74 }
75
76 static inline void
77 atomic_write_barrier (void)
78 {
79   /* x86 is a strong memory ordering machine.  */
80   __asm volatile ("" : : : "memory");
81 }
82
83 } // namespace GTM
84
85 // We'll be using some of the cpu builtins, and their associated types.
86 #ifndef __cplusplus
87 /* ??? It's broken for C++. */
88 #include <x86intrin.h>
89 #else
90 # ifdef __SSE2__
91 #  include <emmintrin.h>
92 # elif defined(__SSE__)
93 #  include <xmmintrin.h>
94 # endif
95 # ifdef __AVX__
96 #  include <immintrin.h>
97 # endif
98 #endif