Mercurial > hg > CbC > GCC_original
comparison gcc/rtlhooks.c @ 16:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | 77e2b8dfacca |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
15:561a7518be6b | 16:04ced10e8804 |
---|---|
1 /* Generic hooks for the RTL middle-end. | 1 /* Generic hooks for the RTL middle-end. |
2 Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. | 2 Copyright (C) 2004-2017 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GCC. | 4 This file is part of GCC. |
5 | 5 |
6 GCC is free software; you can redistribute it and/or modify it under | 6 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 #include "system.h" | 21 #include "system.h" |
22 #include "coretypes.h" | 22 #include "coretypes.h" |
23 #include "tm.h" | 23 #include "tm.h" |
24 #include "function.h" | |
24 #include "rtl.h" | 25 #include "rtl.h" |
26 #include "tree.h" | |
27 #include "insn-config.h" | |
28 #include "memmodel.h" | |
29 #include "emit-rtl.h" | |
30 #include "recog.h" | |
25 #include "rtlhooks-def.h" | 31 #include "rtlhooks-def.h" |
26 #include "expr.h" | 32 #include "explow.h" |
27 #include "recog.h" | 33 #include "target.h" |
28 | 34 |
29 | 35 |
30 /* For speed, we will copy the RTX hooks struct member-by-member | 36 /* For speed, we will copy the RTX hooks struct member-by-member |
31 instead of doing indirect calls. For these reason, we initialize | 37 instead of doing indirect calls. For these reason, we initialize |
32 *two* struct rtl_hooks globals: rtl_hooks is the one that is used | 38 *two* struct rtl_hooks globals: rtl_hooks is the one that is used |
35 | 41 |
36 const struct rtl_hooks general_rtl_hooks = RTL_HOOKS_INITIALIZER; | 42 const struct rtl_hooks general_rtl_hooks = RTL_HOOKS_INITIALIZER; |
37 struct rtl_hooks rtl_hooks = RTL_HOOKS_INITIALIZER; | 43 struct rtl_hooks rtl_hooks = RTL_HOOKS_INITIALIZER; |
38 | 44 |
39 rtx | 45 rtx |
40 gen_lowpart_general (enum machine_mode mode, rtx x) | 46 gen_lowpart_general (machine_mode mode, rtx x) |
41 { | 47 { |
42 rtx result = gen_lowpart_common (mode, x); | 48 rtx result = gen_lowpart_common (mode, x); |
43 | 49 |
44 if (result) | 50 if (result) |
45 return result; | 51 return result; |
51 gcc_assert (result != 0); | 57 gcc_assert (result != 0); |
52 return result; | 58 return result; |
53 } | 59 } |
54 else | 60 else |
55 { | 61 { |
56 int offset = 0; | |
57 | |
58 /* The only additional case we can do is MEM. */ | 62 /* The only additional case we can do is MEM. */ |
59 gcc_assert (MEM_P (x)); | 63 gcc_assert (MEM_P (x)); |
60 | 64 |
61 /* The following exposes the use of "x" to CSE. */ | 65 /* The following exposes the use of "x" to CSE. */ |
62 if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD | 66 scalar_int_mode xmode; |
63 && SCALAR_INT_MODE_P (GET_MODE (x)) | 67 if (is_a <scalar_int_mode> (GET_MODE (x), &xmode) |
64 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode), | 68 && GET_MODE_SIZE (xmode) <= UNITS_PER_WORD |
65 GET_MODE_BITSIZE (GET_MODE (x))) | 69 && TRULY_NOOP_TRUNCATION_MODES_P (mode, xmode) |
66 && !reload_completed) | 70 && !reload_completed) |
67 return gen_lowpart_general (mode, force_reg (GET_MODE (x), x)); | 71 return gen_lowpart_general (mode, force_reg (xmode, x)); |
68 | 72 |
69 if (WORDS_BIG_ENDIAN) | 73 HOST_WIDE_INT offset = byte_lowpart_offset (mode, GET_MODE (x)); |
70 offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) | |
71 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD)); | |
72 | |
73 if (BYTES_BIG_ENDIAN) | |
74 /* Adjust the address so that the address-after-the-data | |
75 is unchanged. */ | |
76 offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)) | |
77 - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))); | |
78 | |
79 return adjust_address (x, mode, offset); | 74 return adjust_address (x, mode, offset); |
80 } | 75 } |
81 } | 76 } |
82 | 77 |
83 /* Similar to gen_lowpart, but cannot emit any instruction via | |
84 copy_to_reg or force_reg. Mainly used in simplify-rtx.c. */ | |
85 rtx | 78 rtx |
86 gen_lowpart_no_emit_general (enum machine_mode mode, rtx x) | 79 reg_num_sign_bit_copies_general (const_rtx, scalar_int_mode, scalar_int_mode, |
87 { | 80 unsigned int *) |
88 rtx result = gen_lowpart_if_possible (mode, x); | |
89 if (result) | |
90 return result; | |
91 else | |
92 return x; | |
93 } | |
94 | |
95 rtx | |
96 reg_num_sign_bit_copies_general (const_rtx x ATTRIBUTE_UNUSED, | |
97 enum machine_mode mode ATTRIBUTE_UNUSED, | |
98 const_rtx known_x ATTRIBUTE_UNUSED, | |
99 enum machine_mode known_mode ATTRIBUTE_UNUSED, | |
100 unsigned int known_ret ATTRIBUTE_UNUSED, | |
101 unsigned int *result ATTRIBUTE_UNUSED) | |
102 { | 81 { |
103 return NULL; | 82 return NULL; |
104 } | 83 } |
105 | 84 |
106 rtx | 85 rtx |
107 reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED, | 86 reg_nonzero_bits_general (const_rtx, scalar_int_mode, scalar_int_mode, |
108 enum machine_mode mode ATTRIBUTE_UNUSED, | 87 unsigned HOST_WIDE_INT *) |
109 const_rtx known_x ATTRIBUTE_UNUSED, | |
110 enum machine_mode known_mode ATTRIBUTE_UNUSED, | |
111 unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED, | |
112 unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED) | |
113 { | 88 { |
114 return NULL; | 89 return NULL; |
115 } | 90 } |
116 | 91 |
117 bool | 92 bool |
118 reg_truncated_to_mode_general (enum machine_mode mode ATTRIBUTE_UNUSED, | 93 reg_truncated_to_mode_general (machine_mode mode ATTRIBUTE_UNUSED, |
119 const_rtx x ATTRIBUTE_UNUSED) | 94 const_rtx x ATTRIBUTE_UNUSED) |
120 { | 95 { |
121 return false; | 96 return false; |
122 } | 97 } |
123 | 98 |
129 If the requested operation cannot be done, 0 is returned. | 104 If the requested operation cannot be done, 0 is returned. |
130 | 105 |
131 This is similar to gen_lowpart_general. */ | 106 This is similar to gen_lowpart_general. */ |
132 | 107 |
133 rtx | 108 rtx |
134 gen_lowpart_if_possible (enum machine_mode mode, rtx x) | 109 gen_lowpart_if_possible (machine_mode mode, rtx x) |
135 { | 110 { |
136 rtx result = gen_lowpart_common (mode, x); | 111 rtx result = gen_lowpart_common (mode, x); |
137 | 112 |
138 if (result) | 113 if (result) |
139 return result; | 114 return result; |
140 else if (MEM_P (x)) | 115 else if (MEM_P (x)) |
141 { | 116 { |
142 /* This is the only other case we handle. */ | 117 /* This is the only other case we handle. */ |
143 int offset = 0; | 118 HOST_WIDE_INT offset = byte_lowpart_offset (mode, GET_MODE (x)); |
144 rtx new_rtx; | 119 rtx new_rtx = adjust_address_nv (x, mode, offset); |
145 | |
146 if (WORDS_BIG_ENDIAN) | |
147 offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) | |
148 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD)); | |
149 if (BYTES_BIG_ENDIAN) | |
150 /* Adjust the address so that the address-after-the-data is | |
151 unchanged. */ | |
152 offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)) | |
153 - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))); | |
154 | |
155 new_rtx = adjust_address_nv (x, mode, offset); | |
156 if (! memory_address_addr_space_p (mode, XEXP (new_rtx, 0), | 120 if (! memory_address_addr_space_p (mode, XEXP (new_rtx, 0), |
157 MEM_ADDR_SPACE (x))) | 121 MEM_ADDR_SPACE (x))) |
158 return 0; | 122 return 0; |
159 | 123 |
160 return new_rtx; | 124 return new_rtx; |