Messages in this thread | ![/](/images/icornerl.gif) | | Subject | Re: [PATCH] document optimizing macro for translating PROT_ to VM_ bits | From | Miles Bader <> | Date | 30 Sep 2003 19:00:53 +0900 |
| |
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 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| ![\](/images/icornerr.gif) |