Skip to contentSkip to conversation

ppc32 use simplified mmenonics

PATCH Albert Cahalan 4 participants 10 messages Aug 22, 2004 – Aug 23, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines

This patch substitutes complex rlwinm instruction
to the simplied instruction clrrwi when possible.

This has the same meaning as the ppc knows only about rlwinm; clrrwi is just a language simplification.

basicly it's a : s/rlwinm R1,R2,0,0,31-N/clrrwi R1,R2,N/

Please apply or comments,

I'd rather you went the other way, replacing these barely-documented instructions with ones that are easy to look up. Motorola has about a zillion of these "simplified" instructions. I guess Motorola and IBM were jealous of Intel's CISC instructions.

The big problem is this:
THESE ARE NOT IN THE INDEX!!!!!!

So, if I forget what one of these many instructions does, I'll have quite the time paging through the manual trying to find it.

If it's not in the index, please avoid it.

#1 lore raw
Quoted 6 lines · Albert Cahalan

I'd rather you went the other way, replacing these barely-documented instructions with ones that are easy to look up. Motorola has about a zillion of these "simplified" instructions. I guess Motorola and IBM were jealous of Intel's CISC instructions.

Quoted 8 lines

The big problem is this:
THESE ARE NOT IN THE INDEX!!!!!!

So, if I forget what one of these many instructions does, I'll have quite the time paging through the manual trying to find it.

If it's not in the index, please avoid it.

Well,

let's analyse 'mr R1,R2'. Which is simplified instruction for moving register, which represent the following instruction 'or R2,0,R1'

when you read 'mr' you obviously know what the source want to do. However seeing 'or', for my part, I see logicial or operation. In spite of the fact, there's some case when 'or' could simply move a register, I guess that's not as obvious as 'mr' instruction.

I guess that's the same for multiple other simplified instruction

bne target = bc 4,2,target

When I see first form, I know exactly what the program do, whereas on the second form : What the hell is 4,2 ?

So I'ld rather go with simplified instruction, even if that index doesn't contain them (which I agree with you, is very bad). There are still in Appendix F of my pdf and you can search with the find utility include in your reader (xpdf does)

Signature · 1 line
Tab
#2 lore raw
Quoted 14 lines · Vincent Hanquez
Quoted 13 lines · Albert Cahalan

I'd rather you went the other way, replacing these barely-documented instructions with ones that are easy to look up. Motorola has about a zillion of these "simplified" instructions. I guess Motorola and IBM were jealous of Intel's CISC instructions.

The big problem is this:
THESE ARE NOT IN THE INDEX!!!!!!

So, if I forget what one of these many instructions does, I'll have quite the time paging through the manual trying to find it.

Quoted 6 lines
Quoted 1 line

If it's not in the index, please avoid it.

Well,

let's analyse 'mr R1,R2'. Which is simplified instruction for moving register, which represent the following instruction 'or R2,0,R1'

The "or" is much easier, because it follows the standard 3-register pattern. With "mr", which way does it go? That's one more thing to remember. In fact I don't know, but the "or" is obvious.

The 0 is your hint that the "or" isn't a plain "or".

Quoted 4 lines

bne target = bc 4,2,target

When I see first form, I know exactly what the program do, whereas on the second form : What the hell is 4,2 ?

This is a slightly better example, but still, it's lots easier to look up "bc" to see the selection of options that are available.

Plus, yeah, "what the hell is 4,2", but those numbers replace a _lot_ of other things you'd need to remember. There are 456 of these "simplified" branch instructions. If you use those, you'll tend to restrict your code to those few common ones you remember. There's bdnzltrl, bdnzfla, bunla... That's madness.

That's 114 opcodes to 1.

Quoted 4 lines

So I'ld rather go with simplified instruction, even if that index doesn't contain them (which I agree with you, is very bad). There are still in Appendix F of my pdf and you can search with the find utility include in your reader (xpdf does)

I have the physical book. Other than being unsearchable, it's much nicer than the pdf. It's easy on the eyes, doesn't occupy screen space, and I can read it on the can.

#3 lore raw
Quoted 6 lines · Albert Cahalan

The "or" is much easier, because it follows the standard 3-register pattern. With "mr", which way does it go? That's one more thing to remember. In fact I don't know, but the "or" is obvious.

The 0 is your hint that the "or" isn't a plain "or".

Sure, but this is about mmenonic. When I see 'or', my mind doesn't make any link with 'move register' but only with 'or'. I have to process another term of the line (the 0) to see that the program want to move a register.

Quoted 9 lines
Quoted 4 lines

bne target = bc 4,2,target

When I see first form, I know exactly what the program do, whereas on the second form : What the hell is 4,2 ?

This is a slightly better example, but still, it's lots easier to look up "bc" to see the selection of options that are available.

Quoted 6 lines

Plus, yeah, "what the hell is 4,2", but those numbers replace a _lot_ of other things you'd need to remember. There are 456 of these "simplified" branch instructions. If you use those, you'll tend to restrict your code to those few common ones you remember. There's bdnzltrl, bdnzfla, bunla... That's madness.

So you writing assembly ppc code with your book on your side ? because I don't see any reason to associate easily '4,2' with 'not equal'

mmenonics is about associating instruction with what they do. 'bc 4,2' doesn't make me associate that with 'branch not equal' but with 'branch conditional something'. Without knowing the something, that won't help me figure what the program want to do.

if you're able to decode '4,2' in real time you're very strong, but you're probably a computer ;)

bdnzltrl kinds of mmenonics are actually not fair, they are not really used :). But even that I would prefer bdnztlrl which I would have to lookup, than bclr with cryptics numbers which I would had to lookup too.

Quoted 1 line

That's 114 opcodes to 1.

There's not 1 opcode for conditional branching. There are more on ppc basis:

bc, bca, bclr, bcctr, bcl, bcla, bclrl, bcctrl

Thus if you count bnea, bnelr, bnectl, bnel, as new different instructions compared to bne, then maybe you need to understand why thoses are called mmenomics.

So as soon as you know those 8 basis opcodes, thoses are actually very easy to understand. You just need to append the following (which all bourne script peoples use)

ne = not equal
eq = equal
lt = less than
le = less equal
ge = greater equal
gt = greater than
....

ex :
bc = Branch Conditional
bca = Branch Conditional Absolute
bne = Branch Not Equal
bnea = Branch Not Equal Absolute

thus from (8 basis mmenonics) + (12 kind of modifiers) I'm able to decode in real time those 8 * 12 = 96 simplified instructions.

Quoted 8 lines
Quoted 4 lines

So I'ld rather go with simplified instruction, even if that index doesn't contain them (which I agree with you, is very bad). There are still in Appendix F of my pdf and you can search with the find utility include in your reader (xpdf does)

I have the physical book. Other than being unsearchable, it's much nicer than the pdf. It's easy on the eyes, doesn't occupy screen space, and I can read it on the can.

You would better learn few of them and decode them the way it meant to be, than lookup them all in your book.

That would save your time, your eyes and your desk space ;)

Signature · 1 line
Tab
#4 lore raw
Quoted 13 lines · Vincent Hanquez
Quoted 10 lines · Albert Cahalan

This is a slightly better example, but still, it's lots easier to look up "bc" to see the selection of options that are available.

Plus, yeah, "what the hell is 4,2", but those numbers replace a _lot_ of other things you'd need to remember. There are 456 of these "simplified" branch instructions. If you use those, you'll tend to restrict your code to those few common ones you remember. There's bdnzltrl, bdnzfla, bunla... That's madness.

Quoted 2 lines

So you writing assembly ppc code with your book on your side ? because I don't see any reason to associate easily '4,2' with 'not equal'

As I said, it's a slightly better example.
(it's also NOT what the patch was changing)

Quoted 3 lines

bdnzltrl kinds of mmenonics are actually not fair, they are not really used :). But even that I would prefer bdnztlrl which I would have to lookup, than bclr with cryptics numbers which I would had to lookup too.

See, that's a problem. You're limiting yourself to just 96 of the 456 listed operations, which are only 1/5 of the 2304 available operations.

I do admit to using bne at times. The bit manipulation stuff is different though. It's not so cryptic in the raw form. The same goes for using "or" to copy a register.

If you don't use the full bit manipulation notation all the time, you might forget what it can do. Then you'll end up using 2 instructions where one would do.

Quoted 5 lines
Quoted 1 line

That's 114 opcodes to 1.

There's not 1 opcode for conditional branching. There are more on ppc basis:

bc, bca, bclr, bcctr, bcl, bcla, bclrl, bcctrl

OK, that's 8. Dividing 456 by that, I still see a 57:1 ratio.

There's also that matter of the 1848 operations you can't access via the "simplified" instruction names.

#5 lore raw
Quoted 2 lines · Albert Cahalan

As I said, it's a slightly better example.
(it's also NOT what the patch was changing)

I was just commenting of the fact you prefer using bc than simplified instructions.

Quoted 3 lines

See, that's a problem. You're limiting yourself to just 96 of the 456 listed operations, which are only 1/5 of the 2304 available operations.

That was an example to show that your figures were totally silly. I'm not limiting myself in anyway, and I could do the same stuff for (most of) all others simplified instructions, but I think that's not the goal of this list, neither of this thread.

Quoted 7 lines

I do admit to using bne at times. The bit manipulation stuff is different though. It's not so cryptic in the raw form. The same goes for using "or" to copy a register.

If you don't use the full bit manipulation notation all the time, you might forget what it can do. Then you'll end up using 2 instructions where one would do.

Mis-using theses instructions is not actually the point here. I agree that a person which do that is not right.

However each person that has read some documentations about ppc assembly know that a 'clrrwi' is a macro to a more complex instruction 'rlwinm'.

Any documentation that wouldn't mention that is just plain wrong.

Quoted 4 lines

OK, that's 8. Dividing 456 by that, I still see a 57:1 ratio.

There's also that matter of the 1848 operations you can't access via the "simplified" instruction names.

Are you counting one operations for 'rlwinm' and one for 'rlwinm.' to have so much (1848) operations ? or is your figures totally random ?

But anyway it seems, we could discuss the benefit or not, of using simplified instructions the whole night. I think this is a good idea (obviously) and it seems Benjamin thinks it too. Thoses simplified instructions are mentioned in all officials ppc assembly documentation because they are simple and help.

But if kernel people do not want to apply this patch for the reasons you said that's ok, but I'm not gonna discuss that for 10 hours :p

Signature · 1 line
Tab
#6 lore raw
Quoted 4 lines · Vincent Hanquez

However each person that has read some documentations about ppc assembly know that a 'clrrwi' is a macro to a more complex instruction 'rlwinm'.

Any documentation that wouldn't mention that is just plain wrong.

It's buried in Appendix F.

Quoted 7 lines
Quoted 4 lines

OK, that's 8. Dividing 456 by that, I still see a 57:1 ratio.

There's also that matter of the 1848 operations you can't access via the "simplified" instruction names.

Are you counting one operations for 'rlwinm' and one for 'rlwinm.' to have so much (1848) operations ? or is your figures totally random ?

That's just for branches.

There are 32 condition register bits.
There are 9 values for the BO field. (so far)
There are 8 of these: bc,bca,bcl,bcla,bcctr,bcctrl,bclr,bclrl

That comes to 2304. Subtract the 456 "simplified" instruction names you have. That leaves 1848 that you are unable to access.

Take a look at the crand instruction. It uses numbers. Now, just imagine mixing that with branch instructions that hide the numbers. I hope you see the problem.

Quoted 4 lines

But anyway it seems, we could discuss the benefit or not, of using simplified instructions the whole night. I think this is a good idea (obviously) and it seems Benjamin thinks it too. Thoses simplified instructions are mentioned in all officials ppc assembly documentation because they are simple and help.

It doesn't appear to be so. He wrote:

: Oh well.. I've got quite used to tweaking rlwinm directly : but I suppose it's more clear for others to go to clrrwi.

So I'd like him to know that others like rlwinm directly too. Using instructions that are in the index makes sense. Using a zillion poorly documented alternatives is madness.

#7 lore raw
Quoted 7 lines · Albert Cahalan

That comes to 2304. Subtract the 456 "simplified" instruction names you have. That leaves 1848 that you are unable to access.

Take a look at the crand instruction. It uses numbers. Now, just imagine mixing that with branch instructions that hide the numbers. I hope you see the problem.

I never said we should use simplified instructions everywhere there are instructions. Hence I don't see why we care here about 1848 instructions not beeing accessible. Most of thoses 1848 instructions probably fit in the 'not so much' used, and thus doesn't need a simplified mmenonic.

Quoted 6 lines

It doesn't appear to be so. He wrote:

: Oh well.. I've got quite used to tweaking rlwinm directly : but I suppose it's more clear for others to go to clrrwi.

So I'd like him to know that others like rlwinm directly too.

sure.

and some other prefer simplified instructions. I guess we're hitting a wall here :)

But as clrrwi is already use in the kernel (as a lot of others simplified instructions), either send a patch to remove them or don't say that this is madness.

Quoted 2 lines

Using instructions that are in the index makes sense. Using a zillion poorly documented alternatives is madness.

Maybe then you should rewrite all part of kernels, gcc, objdump and gdb that use/disassemble the code with simplified instructions (mr, li, b*, etc...) too. (clrrwi is as documented as mr)

Signature · 1 line
Tab
#8 lore raw
In reply to Vincent Hanquez
Quoted 6 lines · Vincent Hanquez
Quoted 5 lines · Albert Cahalan

The "or" is much easier, because it follows the standard 3-register pattern. With "mr", which way does it go? That's one more thing to remember. In fact I don't know, but the "or" is obvious.

Quoted 6 lines
Quoted 1 line

The 0 is your hint that the "or" isn't a plain "or".

Sure, but this is about mmenonic. When I see 'or', my mind doesn't make any link with 'move register' but only with 'or'. I have to process another term of the line (the 0) to see that the program want to move a register.

I'd assume somebody familiar with the architecture reads this as a matter of course.

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#9 lore raw
In reply to Albert Cahalan
Quoted 6 lines

I'd rather you went the other way, replacing these barely-documented instructions with ones that are easy to look up. Motorola has about a zillion of these "simplified" instructions. I guess Motorola and IBM were jealous of Intel's CISC instructions.

It's just simplified mnemonics, not instructions ;)

Quoted 2 lines

The big problem is this:
THESE ARE NOT IN THE INDEX!!!!!!

Yah, that sucks, I tend to agree... I've had a hard time in the "early days" finding some of them in the manuals

Quoted 5 lines

So, if I forget what one of these many instructions does, I'll have quite the time paging through the manual trying to find it.

If it's not in the index, please avoid it.

Signature · 1 line
Benjamin Herrenschmidt <[email protected]>