mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miles Bader <miles@lsi.nec.co.jp>
To: Muli Ben-Yehuda <mulix@mulix.org>
Cc: Jamie Lokier <jamie@shareable.org>, Andrew Morton <akpm@osdl.org>,
	Linux-Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] document optimizing macro for translating PROT_ to VM_ bits
Date: 30 Sep 2003 19:00:53 +0900	[thread overview]
Message-ID: <buon0cm1tpm.fsf@mcspd15.ucom.lsi.nec.co.jp> (raw)
In-Reply-To: <20030930092403.GR29313@actcom.co.il>

Muli Ben-Yehuda <mulix@mulix.org> writes:
> I like code that is "future proof", especially when it doesn't cost
> anything.

Sure, it's not always worth the trouble/pain to do so unless you've
actually got some reason to think it will be mis-used.

This is seeming more and more like such a case: it's a very special
purpose macro which is only used by two other small functions, both of
which are located immediately adjacent to the macro's definition.

If it _really_ makes you nervous, give it a big warning comment with
capital letters or something; that's almost certainly enough.

> How does it fare on your arch?

Quite grotesquely:

   int test3_0 (unsigned val)
   {
     return _calc_vm_trans_3 (val,0x20,0x80);
   }

   int test3_1 (unsigned val)
   {
     return _calc_vm_trans_3 (val,0x80,0x20);
   }

==>

   __calc_vm_trans_3:
           addi -20,sp,sp	#,,
           addi -1,r7,r5	#, bit1, tmp46
           addi -1,r8,r11	#, bit2, tmp51
           mov r6,r12	# x, tmp53
           st.w r31,16[sp]	#,
           and r7,r12	# bit1, tmp53
           and r7,r5	# bit1, tmp46
           and r8,r11	# bit2, tmp51
           cmp r0,r5	# tmp46
           be .L24	#,
           cmp r0,r11	# tmp51
           be .L24	#,
           cmp r8,r7	# bit2, bit1
           bnh .L26	#,
           mov r6,r12	# x, tmp53
           and r7,r12	# bit1, tmp53
           divu r8,r7,r10	# bit2, bit1, tmp61
           ld.w 16[sp],r31	#,
           divu r7,r12,r11	# bit1, tmp53, tmp63
           mov r12,r10	# tmp53, <result>
           addi 20,sp,sp	#,,
           jmp [r31]
   .L26:
           divu r7,r8,r10	# bit1, bit2, tmp57
           mul r8,r12,r0	# bit2, tmp53
           ld.w 16[sp],r31	#,
           mov r12,r10	# tmp53, <result>
           addi 20,sp,sp	#,,
           jmp [r31]
   .L24:
           jarl ___bug,r31	#
   _test3_1:
           addi -20,sp,sp	#,,
           st.w r31,16[sp]	#,
           movea lo(128),r0,r7	#,
           movea lo(32),r0,r8	#,
           jarl __calc_vm_trans_3,r31	#
           ld.w 16[sp],r31	#,
           addi 20,sp,sp	#,,
           jmp [r31]
   _test3_0:
           addi -20,sp,sp	#,,
           st.w r31,16[sp]	#,
           movea lo(32),r0,r7	#,
           movea lo(128),r0,r8	#,
           jarl __calc_vm_trans_3,r31	#
           ld.w 16[sp],r31	#,
           addi 20,sp,sp	#,,
           jmp [r31]


If I only use one test function, gcc does a bit better, but still
generates various unnecessary function-call-related artifacts:

   int test3_0 (unsigned val)
   {
     return _calc_vm_trans_3 (val,0x20,0x80);
   }

==>

   _test3_0:
           add -16,sp	#,
           andi 32,r6,r10	#, val, tmp56
           shl 2,r10	#, <result>
           addi 16,sp,sp	#,,
           jmp [r31]

-Miles
-- 
Freedom's just another word, for nothing left to lose   --Janis Joplin

  reply	other threads:[~2003-09-30 10:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-29  9:06 Muli Ben-Yehuda
2003-09-29 15:34 ` Jamie Lokier
2003-09-29 15:51   ` Valdis.Kletnieks
2003-09-29 17:11     ` Jamie Lokier
2003-09-29 17:25     ` Maciej Zenczykowski
2003-09-30  2:15       ` Miles Bader
2003-09-30  7:10   ` Muli Ben-Yehuda
2003-09-30  7:34     ` Miles Bader
2003-09-30  7:41       ` Muli Ben-Yehuda
2003-09-30  7:59         ` Miles Bader
2003-09-30  9:24           ` Muli Ben-Yehuda
2003-09-30 10:00             ` Miles Bader [this message]
2003-09-30 10:06               ` Miles Bader
2003-10-02 11:37               ` Muli Ben-Yehuda
2003-09-30 10:35             ` Thomas Schlichter
2003-09-30  8:02   ` Frédéric St-Martin

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=buon0cm1tpm.fsf@mcspd15.ucom.lsi.nec.co.jp \
    --to=miles@lsi.nec.co.jp \
    --cc=akpm@osdl.org \
    --cc=jamie@shareable.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miles@gnu.org \
    --cc=mulix@mulix.org \
    /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

all inboxes | Powered by JetHome®