[binutils-gdb] x86: make TC_FRAG_INIT() resolve to a function call
Jan Beulich
jbeulich@sourceware.org
Mon Sep 8 09:13:09 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=149e0b44f3d1d4b6a55e63bb4631ed7b66861ed0
commit 149e0b44f3d1d4b6a55e63bb4631ed7b66861ed0
Author: Jan Beulich <jbeulich@suse.com>
Date: Mon Sep 8 11:10:55 2025 +0200
x86: make TC_FRAG_INIT() resolve to a function call
This way we can avoid making various global variables non-static. Their
set is to only ever grow, really.
Diff:
---
gas/config/tc-i386.c | 26 +++++++++++++++++++++-----
gas/config/tc-i386.h | 36 ++++--------------------------------
2 files changed, 25 insertions(+), 37 deletions(-)
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index fefd587ac7f..6afbd0e2103 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -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. */
}
+/* 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. */
diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h
index 3e348d63f05..1cdf8fc39e7 100644
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -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
More information about the Binutils-cvs
mailing list