static int finalize_imm (void);
static int process_operands (void);
static const reg_entry *build_modrm_byte (void);
-static void output_insn (void);
+static void output_insn (const struct last_insn *);
static void output_imm (fragS *, offsetT);
static void output_disp (fragS *, offsetT);
#ifndef I386COFF
}
lfence_before_ret;
-/* Types of previous instruction is .byte or prefix. */
-static struct
- {
- segT seg;
- const char *file;
- const char *name;
- unsigned int line;
- enum last_insn_kind
- {
- last_insn_other = 0,
- last_insn_directive,
- last_insn_prefix
- } kind;
- } last_insn;
-
/* 1 if the assembler should generate relax relocations. */
static int generate_relax_relocations
/* Output lfence, 0xfaee8, before instruction. */
static void
-insert_lfence_before (void)
+insert_lfence_before (const struct last_insn *last_insn)
{
char *p;
else
return;
- if (last_insn.kind != last_insn_other
- && last_insn.seg == now_seg)
+ if (last_insn->kind != last_insn_other)
{
- as_warn_where (last_insn.file, last_insn.line,
+ as_warn_where (last_insn->file, last_insn->line,
_("`%s` skips -mlfence-before-indirect-branch on `%s`"),
- last_insn.name, insn_name (&i.tm));
+ last_insn->name, insn_name (&i.tm));
return;
}
if (lfence_before_ret != lfence_before_ret_none
&& (i.tm.base_opcode | 1) == 0xc3)
{
- if (last_insn.kind != last_insn_other
- && last_insn.seg == now_seg)
+ if (last_insn->kind != last_insn_other)
{
- as_warn_where (last_insn.file, last_insn.line,
+ as_warn_where (last_insn->file, last_insn->line,
_("`%s` skips -mlfence-before-ret on `%s`"),
- last_insn.name, insn_name (&i.tm));
+ last_insn->name, insn_name (&i.tm));
return;
}
const char *end, *pass1_mnem = NULL;
enum i386_error pass1_err = 0;
const insn_template *t;
+ struct last_insn *last_insn
+ = &seg_info(now_seg)->tc_segment_info_data.last_insn;
/* Initialize globals. */
current_templates.end = current_templates.start = NULL;
if (i.rex != 0)
add_prefix (REX_OPCODE | i.rex);
- insert_lfence_before ();
+ insert_lfence_before (last_insn);
/* We are ready to output the insn. */
- output_insn ();
+ output_insn (last_insn);
insert_lfence_after ();
- last_insn.seg = now_seg;
-
if (i.tm.opcode_modifier.isprefix)
{
- last_insn.kind = last_insn_prefix;
- last_insn.name = insn_name (&i.tm);
- last_insn.file = as_where (&last_insn.line);
+ last_insn->kind = last_insn_prefix;
+ last_insn->name = insn_name (&i.tm);
+ last_insn->file = as_where (&last_insn->line);
}
else
- last_insn.kind = last_insn_other;
+ last_insn->kind = last_insn_other;
}
/* The Q suffix is generally valid only in 64-bit mode, with very few
/* Return 1 if a FUSED_JCC_PADDING frag should be generated. */
static int
-add_fused_jcc_padding_frag_p (enum mf_cmp_kind* mf_cmp_p)
+add_fused_jcc_padding_frag_p (enum mf_cmp_kind *mf_cmp_p,
+ const struct last_insn *last_insn)
{
/* NB: Don't work with COND_JUMP86 without i386. */
if (!align_branch_power
if (maybe_fused_with_jcc_p (mf_cmp_p))
{
- if (last_insn.kind == last_insn_other
- || last_insn.seg != now_seg)
+ if (last_insn->kind == last_insn_other)
return 1;
if (flag_debug)
- as_warn_where (last_insn.file, last_insn.line,
+ as_warn_where (last_insn->file, last_insn->line,
_("`%s` skips -malign-branch-boundary on `%s`"),
- last_insn.name, insn_name (&i.tm));
+ last_insn->name, insn_name (&i.tm));
}
return 0;
/* Return 1 if a BRANCH_PREFIX frag should be generated. */
static int
-add_branch_prefix_frag_p (void)
+add_branch_prefix_frag_p (const struct last_insn *last_insn)
{
/* NB: Don't work with COND_JUMP86 without i386. Don't add prefix
to PadLock instructions since they include prefixes in opcode. */
if (!i.operands || i.tm.opcode_modifier.isprefix)
return 0;
- if (last_insn.kind == last_insn_other
- || last_insn.seg != now_seg)
+ if (last_insn->kind == last_insn_other)
return 1;
if (flag_debug)
- as_warn_where (last_insn.file, last_insn.line,
+ as_warn_where (last_insn->file, last_insn->line,
_("`%s` skips -malign-branch-boundary on `%s`"),
- last_insn.name, insn_name (&i.tm));
+ last_insn->name, insn_name (&i.tm));
return 0;
}
static int
add_branch_padding_frag_p (enum align_branch_kind *branch_p,
- enum mf_jcc_kind *mf_jcc_p)
+ enum mf_jcc_kind *mf_jcc_p,
+ const struct last_insn *last_insn)
{
int add_padding;
}
if (add_padding
- && last_insn.kind != last_insn_other
- && last_insn.seg == now_seg)
+ && last_insn->kind != last_insn_other)
{
if (flag_debug)
- as_warn_where (last_insn.file, last_insn.line,
+ as_warn_where (last_insn->file, last_insn->line,
_("`%s` skips -malign-branch-boundary on `%s`"),
- last_insn.name, insn_name (&i.tm));
+ last_insn->name, insn_name (&i.tm));
return 0;
}
}
static void
-output_insn (void)
+output_insn (const struct last_insn *last_insn)
{
fragS *insn_start_frag;
offsetT insn_start_off;
insn_start_frag = frag_now;
insn_start_off = frag_now_fix ();
- if (add_branch_padding_frag_p (&branch, &mf_jcc))
+ if (add_branch_padding_frag_p (&branch, &mf_jcc, last_insn))
{
char *p;
/* Branch can be 8 bytes. Leave some room for prefixes. */
if (branch)
/* Skip if this is a branch. */
;
- else if (add_fused_jcc_padding_frag_p (&mf_cmp))
+ else if (add_fused_jcc_padding_frag_p (&mf_cmp, last_insn))
{
/* Make room for padding. */
frag_grow (MAX_FUSED_JCC_PADDING_SIZE);
fragP->tc_frag_data.branch_type = align_branch_fused;
fragP->tc_frag_data.max_bytes = MAX_FUSED_JCC_PADDING_SIZE;
}
- else if (add_branch_prefix_frag_p ())
+ else if (add_branch_prefix_frag_p (last_insn))
{
unsigned int max_prefix_size = align_branch_prefix_size;
unsigned int j;
valueT val;
bool vex = false, xop = false, evex = false;
+ struct last_insn *last_insn;
init_globals ();
else if (i.rex != 0)
add_prefix (REX_OPCODE | i.rex);
- output_insn ();
+ last_insn = &seg_info(now_seg)->tc_segment_info_data.last_insn;
+ output_insn (last_insn);
+ last_insn->kind = last_insn_directive;
+ last_insn->name = ".insn directive";
+ last_insn->file = as_where (&last_insn->line);
done:
*saved_ilp = saved_char;
void
i386_cons_align (int ignore ATTRIBUTE_UNUSED)
{
- if (last_insn.kind != last_insn_directive
+ struct last_insn *last_insn
+ = &seg_info(now_seg)->tc_segment_info_data.last_insn;
+
+ if (last_insn->kind != last_insn_directive
&& (bfd_section_flags (now_seg) & SEC_CODE))
{
- last_insn.seg = now_seg;
- last_insn.kind = last_insn_directive;
- last_insn.name = "constant directive";
- last_insn.file = as_where (&last_insn.line);
+ last_insn->kind = last_insn_directive;
+ last_insn->name = "constant directive";
+ last_insn->file = as_where (&last_insn->line);
if (lfence_before_ret != lfence_before_ret_none)
{
if (lfence_before_indirect_branch != lfence_branch_none)