public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: Indu Bhagat <indu.bhagat@oracle.com>, binutils@sourceware.org
Subject: Re: [PATCH,RFC 8/9] gas: synthesize CFI for hand-written asm
Date: Thu, 28 Sep 2023 15:58:57 +0100	[thread overview]
Message-ID: <15cba71f-0308-03b8-776d-53e0b2c4b982@redhat.com> (raw)
In-Reply-To: <20230920230401.1739139-9-indu.bhagat@oracle.com>

Hi Indu,

> A ginsn is a target-independent representation of the machine
> instructions.  One machine instruction may need one or more ginsn.

Is there a way to display the ginins as they are created, maybe in the
listing output ?

I think that this might be a useful feature when it comes to debugging the
ginsn generation code in the future...

>     - Hand-written asm block must begin with a .type   foo, @function
>     - Hand-written asm block must end with a .size foo, .-foo

Must it ?  Can't you assume that all the assembler instructions
between one ".type <name>,@function" and the next ".type <name>,@function"
must belong to a single function ?

The reason for my hesitation is that I imagine that there is hand written
assembler out there that does not bother to set the size of function
symbols.  Probably on the (mistaken) grounds that nothing really needs to
know the size of functions.  So relying on a .size directive might not
be that safe.


> +bool
> +x86_scfi_callee_saved_p (uint32_t dw2reg_num)
> +{
> +  if (dw2reg_num == 3 /* rbx.  */
> +      || dw2reg_num == REG_FP /* rbp.  */
> +      || dw2reg_num == REG_SP /* rsp.  */
> +      || (dw2reg_num >= 12 && dw2reg_num <= 15) /* r12 - r15.  */)
> +    return true;

Why do you have defines for REG_FP and REG_SP but not the other registers ?
(Answer: because REG_SP and REG_FP are in part generic and used by ginsns,
whereas the other register numbers are totally specific to the x86
architecture.  But, my nerd brain replies, that is no reason why those registers
cannot have defines of their own).


> +  if (opcode == 0x8b)

I dislike magic numbers.  It would be much better, IMHO, if the code read as:

   if (opcode == MOV_INSN)

This is not a criticism of your code, since these hard coded instruction values
are used throughout the i386 backend of the assembler.  But one fine day I would
love to see a patch replacing magic constants with descriptive names.

Cheers
   Nick


  reply	other threads:[~2023-09-28 14:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20 23:03 [PATCH,RFC 0/9] SCFI implementation in GNU assembler Indu Bhagat
2023-09-20 23:03 ` [PATCH,RFC 1/9] gas: dw2gencfi: minor rejig for cfi_sections_set and all_cfi_sections Indu Bhagat
2023-09-20 23:03 ` [PATCH,RFC 2/9] gas: dw2gencfi: use all_cfi_sections instead of cfi_sections Indu Bhagat
2023-09-20 23:03 ` [PATCH,RFC 3/9] gas: dw2gencfi: expose a new cfi_set_last_fde API Indu Bhagat
2023-09-20 23:03 ` [PATCH,RFC 4/9] gas: dw2gencfi: move some tc_* defines to the header file Indu Bhagat
2023-09-20 23:03 ` [PATCH,RFC 5/9] gas: add new command line option --scfi[=all,none] Indu Bhagat
2023-09-28 14:04   ` Nick Clifton
2023-09-30  6:13     ` Indu Bhagat
2023-09-20 23:03 ` [PATCH,RFC 6/9] gas: dw2gencfi: ignore all .cfi_* directives with --scfi=all Indu Bhagat
2023-09-28 14:10   ` [PATCH, RFC " Nick Clifton
2023-09-30  6:20     ` Indu Bhagat
2023-09-20 23:03 ` [PATCH,RFC 7/9] gas: scfidw2gen: new functionality to prepapre for SCFI Indu Bhagat
2023-09-20 23:04 ` [PATCH,RFC 8/9] gas: synthesize CFI for hand-written asm Indu Bhagat
2023-09-28 14:58   ` Nick Clifton [this message]
2023-09-30  6:43     ` Indu Bhagat
2023-09-20 23:04 ` [PATCH,RFC 9/9] gas: testsuite: add a x86_64 testsuite for SCFI Indu Bhagat
2023-09-28 15:01 ` [PATCH,RFC 0/9] SCFI implementation in GNU assembler Nick Clifton
2023-09-30  6:44   ` Indu Bhagat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15cba71f-0308-03b8-776d-53e0b2c4b982@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=indu.bhagat@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).