Last active
October 1, 2015 03:56
-
-
Save ajalab/9957fad7fbb685ac901c to your computer and use it in GitHub Desktop.
(CPU実験用)レイトレ PPCアセンブリ命令内訳
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
min-caml付属のレイトレ(min-rt.ml)をppc向けにコンパイルして吐き出された命令の内訳です。 | |
libmincaml.Sはmin-caml付属のライブラリで、平方根とか三角関数の実装があります。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instructions | |
IR description equivalent form doc(page) | |
lwz : load word and zero - D 47 | |
addi : add immediate - D 61 | |
lfd : load floating-point double - D 105 | |
lis : load immediate shifted addis Rx,0,v D 61 | |
stw : store word - D 52 | |
li : load immediate addi Rx,0,v D 61 | |
cmpwi : compare word immediate cmpi 0,1,Rx,v D 70 | |
bne : branch if not equal bc 4,10,tgt B 34 | |
b : branch - I 34 | |
mflr : move from LR mfspr Rx,8 XFX 92 | |
mtlr : move to LR mtspr 8,Rx XFX 91 | |
subi : subtract immediate addi Rx,0,-v D 61 | |
bl : branch (and set LR) - I 34 | |
fmul : floating multiply - A 122 | |
mr : move register or Rx,Ry,Ry X 77 | |
stfd : store floating-point double - D 118 | |
slwi : shift left immediate rlwinm ~~~ M 86 | |
fadd : floating add - A 121 | |
lwzx : load word and zero indexed - X 47 | |
fcmpu : floating compare unordered - X 129 | |
fsub : floating subtract A 121 | |
bgt : branch if greater than bc ~~~ B 34 | |
fdiv : floating divide - A 122 | |
fmr : floating move register - X 120 | |
fneg : floating negate - X 120 | |
stwx : store word indexed - X 52 | |
blt : branch if less than bc ~~~ B 34 | |
cmpw : compare word cmp 3,0,Rx,Ry X 70 | |
stwu : store word w/ update D 52 | |
stmw : store multiple word - D 56 | |
lmw : load multiple word - D 56 | |
bcl : branch conditional (set LR) - I 34 | |
addis : add immediate shifted - D 61 | |
lwzu : load word and 0 w/ update - D 47 | |
mtctr : move to CR mfspr 9,Rx XFX 91 | |
la : load address addi Rx,Ry,D D 61 | |
fctiwz: floating cvt 2 int word - X 127 | |
fabs : floating absolute value - X 120 | |
xoris : xor immediate shifted - D 76 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
import re | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
sys.exit(-1) | |
print(sys.argv[1], end="\n\n") | |
regexp = re.compile(r"^\s+(\w+)\s+.+$") | |
dic = {} | |
for line in open(sys.argv[1]): | |
m = regexp.match(line) | |
if m != None: | |
inst = m.group(1) | |
c = dic.get(inst) | |
if c == None: | |
c = 1 | |
else: | |
c = c + 1 | |
dic[inst] = c | |
lst = sorted(dic.items(), key=lambda x:-x[1]) | |
m = lst[0][1] | |
total = 0 | |
for k, v in lst: | |
total += v | |
print("{0:6s}: {1:50s} {2}".format(k, "*" * int(v / m * 50), v)) | |
print("\n{0} instructions".format(total)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libmincaml.S | |
lwz : ************************************************** 64 | |
stw : ************************************* 48 | |
mflr : *********************************** 45 | |
mr : ************************* 33 | |
mtlr : ****************** 24 | |
bcl : **************** 21 | |
addis : ************** 19 | |
stwu : *********** 15 | |
lmw : *********** 15 | |
stmw : *********** 15 | |
bl : ********** 13 | |
fmr : ******** 11 | |
mtctr : ******* 10 | |
lwzu : ******* 10 | |
addi : ***** 7 | |
lfd : **** 6 | |
stfd : *** 5 | |
la : *** 5 | |
b : ** 3 | |
cmpwi : * 2 | |
bne : * 2 | |
subi : * 2 | |
xoris : 1 | |
lis : 1 | |
fsub : 1 | |
fabs : 1 | |
li : 1 | |
fctiwz: 1 | |
381 instructions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
min-rt.s | |
lwz : ************************************************** 1299 | |
addi : ********************************************** 1198 | |
lfd : ******************************* 829 | |
lis : *************************** 705 | |
stw : *************************** 703 | |
li : *********************** 623 | |
cmpwi : ***************** 444 | |
bne : **************** 441 | |
b : **************** 431 | |
mflr : *************** 413 | |
mtlr : *************** 413 | |
subi : *************** 412 | |
bl : *************** 412 | |
fmul : ************ 325 | |
mr : ********** 263 | |
stfd : ******** 232 | |
slwi : ****** 157 | |
fadd : ***** 146 | |
lwzx : ***** 140 | |
fcmpu : ** 76 | |
fsub : ** 74 | |
bgt : ** 73 | |
fdiv : * 35 | |
fmr : * 34 | |
fneg : * 26 | |
stwx : 17 | |
blt : 8 | |
cmpw : 2 | |
stwu : 1 | |
stmw : 1 | |
lmw : 1 | |
9934 instructions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
KaMi