Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-ssa-address.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Memory address lowering and addressing mode selection. | 1 /* Memory address lowering and addressing mode selection. |
2 Copyright (C) 2004-2018 Free Software Foundation, Inc. | 2 Copyright (C) 2004-2020 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 | 6 GCC is free software; you can redistribute it and/or modify it |
7 under the terms of the GNU General Public License as published by the | 7 under the terms of the GNU General Public License as published by the |
257 : NULL_RTX); | 257 : NULL_RTX); |
258 idx = (addr->index | 258 idx = (addr->index |
259 ? expand_expr (addr->index, NULL_RTX, pointer_mode, EXPAND_NORMAL) | 259 ? expand_expr (addr->index, NULL_RTX, pointer_mode, EXPAND_NORMAL) |
260 : NULL_RTX); | 260 : NULL_RTX); |
261 | 261 |
262 /* addr->base could be an SSA_NAME that was set to a constant value. The | |
263 call to expand_expr may expose that constant. If so, fold the value | |
264 into OFF and clear BSE. Otherwise we may later try to pull a mode from | |
265 BSE to generate a REG, which won't work with constants because they | |
266 are modeless. */ | |
267 if (bse && GET_CODE (bse) == CONST_INT) | |
268 { | |
269 if (off) | |
270 off = simplify_gen_binary (PLUS, pointer_mode, bse, off); | |
271 else | |
272 off = bse; | |
273 gcc_assert (GET_CODE (off) == CONST_INT); | |
274 bse = NULL_RTX; | |
275 } | |
262 gen_addr_rtx (pointer_mode, sym, bse, idx, st, off, &address, NULL, NULL); | 276 gen_addr_rtx (pointer_mode, sym, bse, idx, st, off, &address, NULL, NULL); |
263 if (pointer_mode != address_mode) | 277 if (pointer_mode != address_mode) |
264 address = convert_memory_address (address_mode, address); | 278 address = convert_memory_address (address_mode, address); |
265 return address; | 279 return address; |
266 } | 280 } |
1125 TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (ref); | 1139 TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (ref); |
1126 TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (ref); | 1140 TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (ref); |
1127 return new_ref; | 1141 return new_ref; |
1128 } | 1142 } |
1129 | 1143 |
1144 /* Return the preferred index scale factor for accessing memory of mode | |
1145 MEM_MODE in the address space of pointer BASE. Assume that we're | |
1146 optimizing for speed if SPEED is true and for size otherwise. */ | |
1147 unsigned int | |
1148 preferred_mem_scale_factor (tree base, machine_mode mem_mode, | |
1149 bool speed) | |
1150 { | |
1151 /* For BLKmode, we can't do anything so return 1. */ | |
1152 if (mem_mode == BLKmode) | |
1153 return 1; | |
1154 | |
1155 struct mem_address parts = {}; | |
1156 addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (base)); | |
1157 unsigned int fact = GET_MODE_UNIT_SIZE (mem_mode); | |
1158 | |
1159 /* Addressing mode "base + index". */ | |
1160 parts.index = integer_one_node; | |
1161 parts.base = integer_one_node; | |
1162 rtx addr = addr_for_mem_ref (&parts, as, false); | |
1163 unsigned cost = address_cost (addr, mem_mode, as, speed); | |
1164 | |
1165 /* Addressing mode "base + index << scale". */ | |
1166 parts.step = wide_int_to_tree (sizetype, fact); | |
1167 addr = addr_for_mem_ref (&parts, as, false); | |
1168 unsigned new_cost = address_cost (addr, mem_mode, as, speed); | |
1169 | |
1170 /* Compare the cost of an address with an unscaled index with | |
1171 a scaled index and return factor if useful. */ | |
1172 if (new_cost < cost) | |
1173 return GET_MODE_UNIT_SIZE (mem_mode); | |
1174 return 1; | |
1175 } | |
1176 | |
1130 /* Dump PARTS to FILE. */ | 1177 /* Dump PARTS to FILE. */ |
1131 | 1178 |
1132 extern void dump_mem_address (FILE *, struct mem_address *); | 1179 extern void dump_mem_address (FILE *, struct mem_address *); |
1133 void | 1180 void |
1134 dump_mem_address (FILE *file, struct mem_address *parts) | 1181 dump_mem_address (FILE *file, struct mem_address *parts) |