diff options
Diffstat (limited to 'meta/packages/gcc/gcc-4.3.1/debian/gcc-i386-emit-cld.dpatch')
-rw-r--r-- | meta/packages/gcc/gcc-4.3.1/debian/gcc-i386-emit-cld.dpatch | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/meta/packages/gcc/gcc-4.3.1/debian/gcc-i386-emit-cld.dpatch b/meta/packages/gcc/gcc-4.3.1/debian/gcc-i386-emit-cld.dpatch new file mode 100644 index 0000000000..1267b00e18 --- /dev/null +++ b/meta/packages/gcc/gcc-4.3.1/debian/gcc-i386-emit-cld.dpatch | |||
@@ -0,0 +1,179 @@ | |||
1 | #! /bin/sh -e | ||
2 | |||
3 | # DP: Emit cld instruction when stringops are used (i386). | ||
4 | |||
5 | dir= | ||
6 | if [ $# -eq 3 -a "$2" = '-d' ]; then | ||
7 | pdir="-d $3" | ||
8 | dir="$3/" | ||
9 | elif [ $# -ne 1 ]; then | ||
10 | echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" | ||
11 | exit 1 | ||
12 | fi | ||
13 | case "$1" in | ||
14 | -patch) | ||
15 | patch $pdir -f --no-backup-if-mismatch -p0 < $0 | ||
16 | ;; | ||
17 | -unpatch) | ||
18 | patch $pdir -f --no-backup-if-mismatch -R -p0 < $0 | ||
19 | ;; | ||
20 | *) | ||
21 | echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" | ||
22 | exit 1 | ||
23 | esac | ||
24 | exit 0 | ||
25 | |||
26 | 2008-03-06 Uros Bizjak <ubizjak@gmail.com> | ||
27 | |||
28 | * config/i386/i386.h (TARGET_CLD): New define. | ||
29 | (struct machine_function): Add needs_cld field. | ||
30 | (ix86_current_function_needs_cld): New define. | ||
31 | * config/i386/i386.md (UNSPEC_CLD): New unspec volatile constant. | ||
32 | ("cld"): New isns pattern. | ||
33 | ("strmov_singleop"): Set ix86_current_function_needs_cld flag. | ||
34 | ("rep_mov"): Ditto. | ||
35 | ("strset_singleop"): Ditto. | ||
36 | ("rep_stos"): Ditto. | ||
37 | ("cmpstrnqi_nz_1"): Ditto. | ||
38 | ("cmpstrnqi_1"): Ditto. | ||
39 | ("strlenqi_1"): Ditto. | ||
40 | * config/i386/i386.c (ix86_expand_prologue): Emit cld insn for | ||
41 | TARGET_CLD when ix86_current_function_needs_cld is set. | ||
42 | |||
43 | Index: gcc/config/i386/i386.h | ||
44 | =================================================================== | ||
45 | --- gcc/config/i386/i386.h (revision 132966) | ||
46 | +++ gcc/config/i386/i386.h (working copy) | ||
47 | @@ -388,6 +388,7 @@ extern unsigned int ix86_arch_features[X | ||
48 | |||
49 | extern int x86_prefetch_sse; | ||
50 | |||
51 | +#define TARGET_CLD 1 | ||
52 | #define TARGET_ABM x86_abm | ||
53 | #define TARGET_CMPXCHG16B x86_cmpxchg16b | ||
54 | #define TARGET_POPCNT x86_popcnt | ||
55 | @@ -2446,8 +2447,9 @@ struct machine_function GTY(()) | ||
56 | int save_varrargs_registers; | ||
57 | int accesses_prev_frame; | ||
58 | int optimize_mode_switching[MAX_386_ENTITIES]; | ||
59 | - /* Set by ix86_compute_frame_layout and used by prologue/epilogue expander to | ||
60 | - determine the style used. */ | ||
61 | + int needs_cld; | ||
62 | + /* Set by ix86_compute_frame_layout and used by prologue/epilogue | ||
63 | + expander to determine the style used. */ | ||
64 | int use_fast_prologue_epilogue; | ||
65 | /* Number of saved registers USE_FAST_PROLOGUE_EPILOGUE has been computed | ||
66 | for. */ | ||
67 | @@ -2467,6 +2469,7 @@ struct machine_function GTY(()) | ||
68 | #define ix86_stack_locals (cfun->machine->stack_locals) | ||
69 | #define ix86_save_varrargs_registers (cfun->machine->save_varrargs_registers) | ||
70 | #define ix86_optimize_mode_switching (cfun->machine->optimize_mode_switching) | ||
71 | +#define ix86_current_function_needs_cld (cfun->machine->needs_cld) | ||
72 | #define ix86_tls_descriptor_calls_expanded_in_cfun \ | ||
73 | (cfun->machine->tls_descriptor_call_expanded_p) | ||
74 | /* Since tls_descriptor_call_expanded is not cleared, even if all TLS | ||
75 | Index: gcc/config/i386/i386.md | ||
76 | =================================================================== | ||
77 | --- gcc/config/i386/i386.md (revision 132966) | ||
78 | +++ gcc/config/i386/i386.md (working copy) | ||
79 | @@ -205,6 +205,7 @@ | ||
80 | (UNSPECV_XCHG 12) | ||
81 | (UNSPECV_LOCK 13) | ||
82 | (UNSPECV_PROLOGUE_USE 14) | ||
83 | + (UNSPECV_CLD 15) | ||
84 | ]) | ||
85 | |||
86 | ;; Constants to represent pcomtrue/pcomfalse variants | ||
87 | @@ -18519,6 +18520,14 @@ | ||
88 | |||
89 | ;; Block operation instructions | ||
90 | |||
91 | +(define_insn "cld" | ||
92 | + [(unspec_volatile [(const_int 0)] UNSPECV_CLD)] | ||
93 | + "" | ||
94 | + "cld" | ||
95 | + [(set_attr "length" "1") | ||
96 | + (set_attr "length_immediate" "0") | ||
97 | + (set_attr "modrm" "0")]) | ||
98 | + | ||
99 | (define_expand "movmemsi" | ||
100 | [(use (match_operand:BLK 0 "memory_operand" "")) | ||
101 | (use (match_operand:BLK 1 "memory_operand" "")) | ||
102 | @@ -18591,7 +18600,7 @@ | ||
103 | (set (match_operand 2 "register_operand" "") | ||
104 | (match_operand 5 "" ""))])] | ||
105 | "TARGET_SINGLE_STRINGOP || optimize_size" | ||
106 | - "") | ||
107 | + "ix86_current_function_needs_cld = 1;") | ||
108 | |||
109 | (define_insn "*strmovdi_rex_1" | ||
110 | [(set (mem:DI (match_operand:DI 2 "register_operand" "0")) | ||
111 | @@ -18708,7 +18717,7 @@ | ||
112 | (match_operand 3 "memory_operand" "")) | ||
113 | (use (match_dup 4))])] | ||
114 | "" | ||
115 | - "") | ||
116 | + "ix86_current_function_needs_cld = 1;") | ||
117 | |||
118 | (define_insn "*rep_movdi_rex64" | ||
119 | [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0)) | ||
120 | @@ -18868,7 +18877,7 @@ | ||
121 | (set (match_operand 0 "register_operand" "") | ||
122 | (match_operand 3 "" ""))])] | ||
123 | "TARGET_SINGLE_STRINGOP || optimize_size" | ||
124 | - "") | ||
125 | + "ix86_current_function_needs_cld = 1;") | ||
126 | |||
127 | (define_insn "*strsetdi_rex_1" | ||
128 | [(set (mem:DI (match_operand:DI 1 "register_operand" "0")) | ||
129 | @@ -18962,7 +18971,7 @@ | ||
130 | (use (match_operand 3 "register_operand" "")) | ||
131 | (use (match_dup 1))])] | ||
132 | "" | ||
133 | - "") | ||
134 | + "ix86_current_function_needs_cld = 1;") | ||
135 | |||
136 | (define_insn "*rep_stosdi_rex64" | ||
137 | [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0)) | ||
138 | @@ -19138,7 +19147,7 @@ | ||
139 | (clobber (match_operand 1 "register_operand" "")) | ||
140 | (clobber (match_dup 2))])] | ||
141 | "" | ||
142 | - "") | ||
143 | + "ix86_current_function_needs_cld = 1;") | ||
144 | |||
145 | (define_insn "*cmpstrnqi_nz_1" | ||
146 | [(set (reg:CC FLAGS_REG) | ||
147 | @@ -19185,7 +19194,7 @@ | ||
148 | (clobber (match_operand 1 "register_operand" "")) | ||
149 | (clobber (match_dup 2))])] | ||
150 | "" | ||
151 | - "") | ||
152 | + "ix86_current_function_needs_cld = 1;") | ||
153 | |||
154 | (define_insn "*cmpstrnqi_1" | ||
155 | [(set (reg:CC FLAGS_REG) | ||
156 | @@ -19254,7 +19263,7 @@ | ||
157 | (clobber (match_operand 1 "register_operand" "")) | ||
158 | (clobber (reg:CC FLAGS_REG))])] | ||
159 | "" | ||
160 | - "") | ||
161 | + "ix86_current_function_needs_cld = 1;") | ||
162 | |||
163 | (define_insn "*strlenqi_1" | ||
164 | [(set (match_operand:SI 0 "register_operand" "=&c") | ||
165 | Index: gcc/config/i386/i386.c | ||
166 | =================================================================== | ||
167 | --- gcc/config/i386/i386.c (revision 132966) | ||
168 | +++ gcc/config/i386/i386.c (working copy) | ||
169 | @@ -6498,6 +6498,10 @@ ix86_expand_prologue (void) | ||
170 | emit_insn (gen_prologue_use (pic_offset_table_rtx)); | ||
171 | emit_insn (gen_blockage ()); | ||
172 | } | ||
173 | + | ||
174 | + /* Emit cld instruction if stringops are used in the function. */ | ||
175 | + if (TARGET_CLD && ix86_current_function_needs_cld) | ||
176 | + emit_insn (gen_cld ()); | ||
177 | } | ||
178 | |||
179 | /* Emit code to restore saved registers using MOV insns. First register | ||