summaryrefslogtreecommitdiffstats
path: root/tools/PowerPCtoPPE/p2p-test-gen.py
diff options
context:
space:
mode:
authorGlenn Miles <milesg@us.ibm.com>2015-02-23 14:34:25 -0600
committerDavid Young <davidy@us.ibm.com>2015-02-23 14:53:56 -0600
commita28f852be2197680c6864a8b66b8cb0743893471 (patch)
treec5ecb43caba4c86a6de39727d7765c4bdc8c6804 /tools/PowerPCtoPPE/p2p-test-gen.py
parentf7a56090b73768f8fec063e41aba12662ee59a45 (diff)
downloadtalos-sbe-a28f852be2197680c6864a8b66b8cb0743893471.tar.gz
talos-sbe-a28f852be2197680c6864a8b66b8cb0743893471.zip
Added ppe tools directory with contents
Change-Id: I9da1e93f2624a8da121548b7af67002a98d61fe2 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/15907 Reviewed-by: Glenn R. Miles <milesg@us.ibm.com> Reviewed-by: David Young <davidy@us.ibm.com> Tested-by: David Young <davidy@us.ibm.com>
Diffstat (limited to 'tools/PowerPCtoPPE/p2p-test-gen.py')
-rwxr-xr-xtools/PowerPCtoPPE/p2p-test-gen.py147
1 files changed, 147 insertions, 0 deletions
diff --git a/tools/PowerPCtoPPE/p2p-test-gen.py b/tools/PowerPCtoPPE/p2p-test-gen.py
new file mode 100755
index 00000000..983cec03
--- /dev/null
+++ b/tools/PowerPCtoPPE/p2p-test-gen.py
@@ -0,0 +1,147 @@
+#!/usr/bin/python2.6
+
+# \file p2p-test-gen.py
+# \brief this program generates random constructed test cases
+# in the form of input file consumed by ppc-ppe-pcp.py
+# \usage create a file named 'test.s' and make sure it has at
+# least one blank line before executing this program.
+
+import fileinput
+import random
+
+DotLabel = ['', 'Label:', '.Label']
+
+Comments = ['', '// Comments', '/* Comments */']
+
+TabSpace = ['', '\t', ' ', '\t ', ' \t', ' \t ']
+
+RegLabel = ['', '%r']
+
+Register = [0,1,2,3,4,5,6,7,8,9,10,13,28,29,30,31]
+
+TestEnable = [0,1,2,3]
+
+TestBook = {'eieio' : 0,
+ 'isync' : 0,
+ 'icbi' : 0,
+ 'icbt' : 0,
+ 'stbux' : 3,
+ 'sthux' : 3,
+ 'stwux' : 3,
+ 'lbzux' : 3,
+ 'lhzux' : 3,
+ 'lwzux' : 3,
+ 'lha' : 2,
+ 'lhau' : 2,
+ 'lhax' : 3,
+ 'lhaux' : 3,
+ 'mulhhw' : 3,
+ 'mulhhwu' : 3,
+ 'mulhw' : 3,
+ 'mulhwu' : 3,
+ 'mullw' : 3,
+ 'mulli' : 1,
+ 'divw' : 3,
+ 'divwu' : 3,
+ 'lmw' : 2,
+ 'stmw' : 2,
+ 'lwz' : 4,
+ 'stw' : 4,
+ 'cmplw' : 5,
+ 'cmpw' : 5,
+ 'cmpwi' : 5}
+
+BranchList = ['bc', 'bcl', 'blt', 'bltl', 'ble', 'blel', 'bgt', 'bgtl', 'bge',
+ 'bgel', 'beq', 'beql', 'bne', 'bnel']
+
+def p2p_test():
+ for line in fileinput.input('test.s', inplace=1):
+ print '// start generating test cases:',
+ for opcode,format in TestBook.iteritems():
+ opcode += ' '
+ if random.randint(1, 10) > 5:
+ print random.sample(TabSpace,1)[0] + random.sample(Comments,1)[0] +\
+ random.sample(TabSpace,1)[0]
+ else:
+ print random.sample(TabSpace,1)[0] + random.sample(DotLabel,1)[0] +\
+ random.sample(TabSpace,1)[0]
+ if format == 0 in TestEnable:
+ print random.sample(TabSpace,1)[0] + opcode +\
+ random.sample(TabSpace,1)[0] + random.sample(Comments,1)[0]
+ if format == 3 in TestEnable:
+ regs = random.sample(Register, 3)
+ reg_field = random.sample(RegLabel,1)[0] + str(regs[0]) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ random.sample(RegLabel,1)[0] + str(regs[1]) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ random.sample(RegLabel,1)[0] + str(regs[2])
+ print random.sample(TabSpace,1)[0] + opcode +\
+ random.sample(TabSpace,1)[0] + reg_field +\
+ random.sample(TabSpace,1)[0] + random.sample(Comments,1)[0]
+ if format == 1 in TestEnable:
+ regs = random.sample(Register, 2)
+ reg_field = random.sample(RegLabel,1)[0] + str(regs[0]) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ random.sample(RegLabel,1)[0] + str(regs[1]) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ str(random.randint(-128, 128))
+ print random.sample(TabSpace,1)[0] + opcode +\
+ random.sample(TabSpace,1)[0] + reg_field +\
+ random.sample(TabSpace,1)[0] + random.sample(Comments,1)[0]
+ if format == 2 in TestEnable:
+ regs = random.sample(Register, 2)
+ reg_field = random.sample(RegLabel,1)[0] + str(regs[0]) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ str(random.randint(-128, 128)) +\
+ '(' + random.sample(RegLabel,1)[0] + str(regs[1]) + ')'
+ print random.sample(TabSpace,1)[0] + opcode +\
+ random.sample(TabSpace,1)[0] + reg_field +\
+ random.sample(TabSpace,1)[0] + random.sample(Comments,1)[0]
+ if format == 4 in TestEnable:
+ for i in [1,2]:
+ regs = random.sample(Register, 2)
+ reg_field = random.sample(RegLabel,1)[0] + str(regs[0]) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ str(random.randint(-128, 128)) +\
+ '(' + random.sample(RegLabel,1)[0] + str(regs[1]) + ')'
+ print random.sample(TabSpace,1)[0] + opcode +\
+ random.sample(TabSpace,1)[0] + reg_field +\
+ random.sample(TabSpace,1)[0] + random.sample(Comments,1)[0]
+ if format == 5 in TestEnable:
+ if 'i' in opcode:
+ regs = random.sample(Register, 1)
+ reg_field = random.sample(RegLabel,1)[0] + str(regs[0]) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ random.sample(RegLabel,1)[0] +\
+ str(random.randint(-128, 128))
+ else:
+ regs = random.sample(Register, 2)
+ reg_field = random.sample(RegLabel,1)[0] + str(regs[0]) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ random.sample(RegLabel,1)[0] + str(regs[1])
+ print random.sample(TabSpace,1)[0] + opcode +\
+ random.sample(TabSpace,1)[0] + reg_field +\
+ random.sample(TabSpace,1)[0] + random.sample(Comments,1)[0]
+ branch = random.sample(BranchList, 1)[0] + ' '
+ if 'bc' in branch:
+ reg_field = random.sample(TabSpace,1)[0] +\
+ str(random.randint(0, 15)) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ str(random.randint(0, 7)) + ',' +\
+ random.sample(TabSpace,1)[0] +\
+ str(random.randint(-128, 128)) +\
+ random.sample(TabSpace,1)[0]
+ else:
+ reg_field = random.sample(TabSpace,1)[0] +\
+ str(random.randint(-128, 128)) +\
+ random.sample(TabSpace,1)[0]
+ print random.sample(TabSpace,1)[0] + branch +\
+ random.sample(TabSpace,1)[0] + reg_field +\
+ random.sample(TabSpace,1)[0] + random.sample(Comments,1)[0]
+ fileinput.close()
+
+if __name__ == '__main__':
+ p2p_test()
+
+
+
OpenPOWER on IntegriCloud