]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: make TC_FRAG_INIT() resolve to a function call
authorJan Beulich <jbeulich@suse.com>
Mon, 8 Sep 2025 09:10:55 +0000 (11:10 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 8 Sep 2025 09:10:55 +0000 (11:10 +0200)
This way we can avoid making various global variables non-static. Their
set is to only ever grow, really.

gas/config/tc-i386.c
gas/config/tc-i386.h

index fefd587ac7fa38dfb5f833f3b5ee98bbb127af0e..6afbd0e2103a400993e781b3400fdb31b44331dd 100644 (file)
@@ -648,7 +648,7 @@ static int this_operand = -1;
 /* Are we processing a .insn directive?  */
 #define dot_insn() (i.tm.mnem_off == MN__insn)
 
-enum i386_flag_code i386_flag_code;
+static enum i386_flag_code i386_flag_code;
 #define flag_code i386_flag_code /* Permit to continue using original name.  */
 static unsigned int object_64bit;
 static unsigned int disallow_64bit_reloc;
@@ -861,7 +861,7 @@ static const char *cpu_arch_name = NULL;
 static char *cpu_sub_arch_name = NULL;
 
 /* CPU feature flags.  */
-i386_cpu_flags cpu_arch_flags = CPU_UNKNOWN_FLAGS;
+static i386_cpu_flags cpu_arch_flags = CPU_UNKNOWN_FLAGS;
 
 /* ISA extensions available in 64-bit mode only.  */
 static const i386_cpu_flags cpu_64_flags = CPU_ANY_64_FLAGS;
@@ -870,13 +870,13 @@ static const i386_cpu_flags cpu_64_flags = CPU_ANY_64_FLAGS;
 static int cpu_arch_tune_set = 0;
 
 /* Cpu we are generating instructions for.  */
-enum processor_type cpu_arch_tune = PROCESSOR_UNKNOWN;
+static enum processor_type cpu_arch_tune = PROCESSOR_UNKNOWN;
 
 /* CPU instruction set architecture used.  */
-enum processor_type cpu_arch_isa = PROCESSOR_UNKNOWN;
+static enum processor_type cpu_arch_isa = PROCESSOR_UNKNOWN;
 
 /* CPU feature flags of instruction set architecture used.  */
-i386_cpu_flags cpu_arch_isa_flags;
+static i386_cpu_flags cpu_arch_isa_flags;
 
 /* If set, conditional jumps are not automatically promoted to handle
    larger than a byte offset.  */
@@ -15667,6 +15667,22 @@ i386_att_operand (char *operand_string)
   return 1;                    /* Normal return.  */
 }
 \f
+/* Initialize the tc_frag_data field of a fragment.  */
+
+void i386_frag_init (fragS *fragP, size_t max_bytes)
+{
+  memset (&fragP->tc_frag_data, 0, sizeof (fragP->tc_frag_data));
+  fragP->tc_frag_data.isa = cpu_arch_isa;
+  fragP->tc_frag_data.tune = cpu_arch_tune;
+  fragP->tc_frag_data.cpunop = cpu_arch_flags.bitfield.cpunop;
+  fragP->tc_frag_data.isanop = cpu_arch_isa_flags.bitfield.cpunop;
+  fragP->tc_frag_data.code = i386_flag_code;
+  fragP->tc_frag_data.max_bytes = max_bytes;
+  fragP->tc_frag_data.last_insn_normal
+    = (seg_info(now_seg)->tc_segment_info_data.last_insn.kind
+       == last_insn_other);
+}
+
 /* Calculate the maximum variable size (i.e., excluding fr_fix)
    that an rs_machine_dependent frag may reach.  */
 
index 3e348d63f058ea6df2ffa805153e82f3a9b0acac..1cdf8fc39e7effcb4dc70ebf31bfa2b5770f9ba8 100644 (file)
@@ -277,19 +277,14 @@ enum processor_type
   PROCESSOR_NONE
 };
 
-extern i386_cpu_flags cpu_arch_flags;
-extern enum processor_type cpu_arch_tune;
-extern enum processor_type cpu_arch_isa;
-extern i386_cpu_flags cpu_arch_isa_flags;
-
 /* We support four different modes.  I386_FLAG_CODE variable is used to
    distinguish three of these.  */
 
-extern enum i386_flag_code {
+enum i386_flag_code {
        CODE_32BIT,
        CODE_16BIT,
        CODE_64BIT
-} i386_flag_code;
+};
 
 struct i386_segment_info {
   /* Type of previous "instruction", e.g. .byte or stand-alone prefix.  */
@@ -341,31 +336,8 @@ struct i386_tc_frag_data
    the isa/tune settings at the time the .align was assembled.  */
 #define TC_FRAG_TYPE struct i386_tc_frag_data
 
-#define TC_FRAG_INIT(FRAGP, MAX_BYTES)                         \
- do                                                            \
-   {                                                           \
-     (FRAGP)->tc_frag_data.u.padding_fragP = NULL;             \
-     (FRAGP)->tc_frag_data.padding_address = 0;                        \
-     (FRAGP)->tc_frag_data.isa = cpu_arch_isa;                 \
-     (FRAGP)->tc_frag_data.tune = cpu_arch_tune;               \
-     (FRAGP)->tc_frag_data.cpunop = cpu_arch_flags.bitfield.cpunop; \
-     (FRAGP)->tc_frag_data.isanop = cpu_arch_isa_flags.bitfield.cpunop; \
-     (FRAGP)->tc_frag_data.code = i386_flag_code;              \
-     (FRAGP)->tc_frag_data.max_bytes = (MAX_BYTES);            \
-     (FRAGP)->tc_frag_data.length = 0;                         \
-     (FRAGP)->tc_frag_data.last_length = 0;                    \
-     (FRAGP)->tc_frag_data.max_prefix_length = 0;              \
-     (FRAGP)->tc_frag_data.prefix_length = 0;                  \
-     (FRAGP)->tc_frag_data.default_prefix = 0;                 \
-     (FRAGP)->tc_frag_data.cmp_size = 0;                       \
-     (FRAGP)->tc_frag_data.classified = 0;                     \
-     (FRAGP)->tc_frag_data.branch_type = 0;                    \
-     (FRAGP)->tc_frag_data.mf_type = 0;                                \
-     (FRAGP)->tc_frag_data.last_insn_normal                    \
-       = (seg_info(now_seg)->tc_segment_info_data.last_insn.kind \
-          == last_insn_other);                                 \
-   }                                                           \
- while (0)
+void i386_frag_init (fragS *, size_t);
+#define TC_FRAG_INIT(fragP, max_bytes) i386_frag_init (fragP, max_bytes)
 
 #define WORKING_DOT_WORD 1