1 --- gcc/config/i386/i386.c.sse3 2005-11-15 17:33:02.000000000 -0800
2 +++ gcc/config/i386/i386.c 2005-11-17 09:44:47.000000000 -0800
3 @@ -14347,10 +14347,20 @@ ix86_init_mmx_sse_builtins (void)
4 tree void_ftype_unsigned_unsigned
5 = build_function_type_list (void_type_node, unsigned_type_node,
6 unsigned_type_node, NULL_TREE);
7 + tree void_ftype_di_di
8 + = build_function_type_list (void_type_node,
9 + long_long_unsigned_type_node,
10 + long_long_unsigned_type_node,
12 tree void_ftype_pcvoid_unsigned_unsigned
13 = build_function_type_list (void_type_node, const_ptr_type_node,
14 unsigned_type_node, unsigned_type_node,
16 + tree void_ftype_pcvoid_di_di
17 + = build_function_type_list (void_type_node, const_ptr_type_node,
18 + long_long_unsigned_type_node,
19 + long_long_unsigned_type_node,
21 tree unsigned_ftype_void
22 = build_function_type (unsigned_type_node, void_list_node);
24 @@ -14811,12 +14821,24 @@ ix86_init_mmx_sse_builtins (void)
25 def_builtin (MASK_SSE2, "__builtin_ia32_pmaddwd128", v4si_ftype_v8hi_v8hi, IX86_BUILTIN_PMADDWD128);
27 /* Prescott New Instructions. */
28 - def_builtin (MASK_SSE3, "__builtin_ia32_monitor",
29 - void_ftype_pcvoid_unsigned_unsigned,
30 - IX86_BUILTIN_MONITOR);
31 - def_builtin (MASK_SSE3, "__builtin_ia32_mwait",
32 - void_ftype_unsigned_unsigned,
33 - IX86_BUILTIN_MWAIT);
36 + def_builtin (MASK_SSE3, "__builtin_ia32_monitor",
37 + void_ftype_pcvoid_di_di,
38 + IX86_BUILTIN_MONITOR);
39 + def_builtin (MASK_SSE3, "__builtin_ia32_mwait",
41 + IX86_BUILTIN_MWAIT);
45 + def_builtin (MASK_SSE3, "__builtin_ia32_monitor",
46 + void_ftype_pcvoid_unsigned_unsigned,
47 + IX86_BUILTIN_MONITOR);
48 + def_builtin (MASK_SSE3, "__builtin_ia32_mwait",
49 + void_ftype_unsigned_unsigned,
50 + IX86_BUILTIN_MWAIT);
52 def_builtin (MASK_SSE3, "__builtin_ia32_movshdup",
54 IX86_BUILTIN_MOVSHDUP);
55 @@ -15660,13 +15682,17 @@ ix86_expand_builtin (tree exp, rtx targe
56 op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
57 op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
58 op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
59 + mode = TARGET_64BIT ? DImode : SImode;
61 - op0 = copy_to_mode_reg (SImode, op0);
62 + op0 = copy_to_mode_reg (mode, op0);
64 - op1 = copy_to_mode_reg (SImode, op1);
65 + op1 = copy_to_mode_reg (mode, op1);
67 - op2 = copy_to_mode_reg (SImode, op2);
68 - emit_insn (gen_sse3_monitor (op0, op1, op2));
69 + op2 = copy_to_mode_reg (mode, op2);
71 + emit_insn (gen_sse3_monitor64 (op0, op1, op2));
73 + emit_insn (gen_sse3_monitor (op0, op1, op2));
76 case IX86_BUILTIN_MWAIT:
77 @@ -15674,11 +15700,15 @@ ix86_expand_builtin (tree exp, rtx targe
78 arg1 = TREE_VALUE (TREE_CHAIN (arglist));
79 op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
80 op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
81 + mode = TARGET_64BIT ? DImode : SImode;
83 - op0 = copy_to_mode_reg (SImode, op0);
84 + op0 = copy_to_mode_reg (mode, op0);
86 - op1 = copy_to_mode_reg (SImode, op1);
87 - emit_insn (gen_sse3_mwait (op0, op1));
88 + op1 = copy_to_mode_reg (mode, op1);
90 + emit_insn (gen_sse3_mwait64 (op0, op1));
92 + emit_insn (gen_sse3_mwait (op0, op1));
95 case IX86_BUILTIN_LDDQU:
96 --- gcc/config/i386/pmmintrin.h.sse3 2005-11-04 14:13:48.000000000 -0800
97 +++ gcc/config/i386/pmmintrin.h 2005-11-15 22:44:02.000000000 -0800
98 @@ -110,7 +110,6 @@ _mm_lddqu_si128 (__m128i const *__P)
99 return (__m128i) __builtin_ia32_lddqu ((char const *)__P);
103 static __inline void __attribute__((__always_inline__))
104 _mm_monitor (void const * __P, unsigned int __E, unsigned int __H)
106 @@ -122,10 +121,6 @@ _mm_mwait (unsigned int __E, unsigned in
108 __builtin_ia32_mwait (__E, __H);
111 -#define _mm_monitor(P, E, H) __builtin_ia32_monitor ((P), (E), (H))
112 -#define _mm_mwait(E, H) __builtin_ia32_mwait ((E), (H))
115 #endif /* __SSE3__ */
117 --- gcc/config/i386/sse.md.sse3 2005-11-04 14:13:48.000000000 -0800
118 +++ gcc/config/i386/sse.md 2005-11-17 09:25:31.000000000 -0800
119 @@ -3890,15 +3890,36 @@
120 [(unspec_volatile [(match_operand:SI 0 "register_operand" "a")
121 (match_operand:SI 1 "register_operand" "c")]
124 + "TARGET_SSE3 && !TARGET_64BIT"
126 [(set_attr "length" "3")])
128 +(define_insn "sse3_mwait64"
129 + [(unspec_volatile [(match_operand:DI 0 "register_operand" "a")
130 + (match_operand:DI 1 "register_operand" "c")]
132 + "TARGET_SSE3 && TARGET_64BIT"
133 +;; Older assembler doesn't support "mwait %rax,%rcx".
136 + [(set_attr "length" "3")])
138 (define_insn "sse3_monitor"
139 [(unspec_volatile [(match_operand:SI 0 "register_operand" "a")
140 (match_operand:SI 1 "register_operand" "c")
141 (match_operand:SI 2 "register_operand" "d")]
144 + "TARGET_SSE3 && !TARGET_64BIT"
145 "monitor\t%0, %1, %2"
146 [(set_attr "length" "3")])
148 +(define_insn "sse3_monitor64"
149 + [(unspec_volatile [(match_operand:DI 0 "register_operand" "a")
150 + (match_operand:DI 1 "register_operand" "c")
151 + (match_operand:DI 2 "register_operand" "d")]
153 + "TARGET_SSE3 && TARGET_64BIT"
154 +;; Older assembler doesn't support "monitor %rax,%rcx,%rdx".
155 +;; "monitor\t%0, %1, %2"
157 + [(set_attr "length" "3")])
158 --- gcc/testsuite/gcc.target/i386/monitor.c.sse3 2005-11-15 22:59:54.000000000 -0800
159 +++ gcc/testsuite/gcc.target/i386/monitor.c 2005-11-15 23:25:23.000000000 -0800
161 +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
162 +/* { dg-options "-O2 -msse3" } */
164 +/* Verify that they work in both 32bit and 64bit. */
166 +#include <pmmintrin.h>
169 +foo (char *p, int x, int y, int z)
171 + _mm_monitor (p, y, x);
176 +bar (char *p, long x, long y, long z)
178 + _mm_monitor (p, y, x);
185 + _mm_monitor (p, 0, 0);