History

m68k: put read-only arrays of computed gotos to its own text section (#275) (#276)

Sigrid Solveig Haflínudóttir committed 1 year ago

Commit 17d7e2b1 parent 017f80a1 file · +32 −0Browse files

Unified · Split

gcc/gcc/config/m68k/m68k.cc+32−0
@@ -208,6 +208,35 @@ static bool m68k_modes_tieable_p (machine_mode, machine_mode); · 207 unmodified lines
208208 static machine_mode m68k_promote_function_mode (const_tree, machine_mode,
209209 int *, const_tree, int);
210210 static void m68k_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx [], int);
211+
212+static void
213+m68k_unique_section (tree decl, int reloc)
214+{
215+ const char *name;
216+ char *section = NULL;
217+ tree type, chain;
218+
219+ /* Detect arrays pointing at labels - computed gotos. */
220+ if (categorize_decl_for_section (decl, reloc) == SECCAT_RODATA
221+ && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
222+ {
223+ type = TREE_TYPE (TREE_TYPE (decl));
224+ chain = TREE_CHAIN (decl);
225+
226+ if (type && chain && TREE_CODE (type) == POINTER_TYPE
227+ && TREE_CODE (chain) == LABEL_DECL)
228+ {
229+ name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
230+ name = targetm.strip_name_encoding (name);
231+ section
232+ = ACONCAT ((".text.", current_function_name (), ".", name, NULL));
233+ set_decl_section_name (decl, section);
234+ return;
235+ }
236+ }
237+
238+ default_unique_section (decl, reloc);
239+}
211240
212241 /* Initialize the GCC target structure. */
213242
@@ -216,6 +245,9 @@ static void m68k_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx [], int); · 2 unmodified lines
216245 #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
217246 #endif
218247
248+#undef TARGET_ASM_UNIQUE_SECTION
249+#define TARGET_ASM_UNIQUE_SECTION m68k_unique_section
250+
219251 #if INT_OP_GROUP == INT_OP_NO_DOT
220252 #undef TARGET_ASM_BYTE_OP
221253 #define TARGET_ASM_BYTE_OP "\tbyte\t"

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t