summaryrefslogtreecommitdiffstats
path: root/src/ppe
diff options
context:
space:
mode:
authorWael El-Essawy <welessa@us.ibm.com>2015-11-06 11:59:08 -0600
committerWilliam A. Bryan <wilbryan@us.ibm.com>2015-11-10 10:53:02 -0600
commit86d4c8b7e8bda9cd7eb2b59491fb712aeac0235a (patch)
tree92c59fc9922c36d7122b023df6e45c9011846920 /src/ppe
parentb71686c6d906da0dd4a935b22a2ad10f5c17208a (diff)
downloadtalos-occ-86d4c8b7e8bda9cd7eb2b59491fb712aeac0235a.tar.gz
talos-occ-86d4c8b7e8bda9cd7eb2b59491fb712aeac0235a.zip
Fix Powerpc to PPE tool for multiply
This is a hw/ppe reviewed and merged fix that eleminates a bug in the multiplication call glue code. Change-Id: Ia563a6410042b328dd79d4b1c183aeed08781725 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21878 Tested-by: FSP CI Jenkins Reviewed-by: Fadi Kassem <fmkassem@us.ibm.com> Reviewed-by: William A. Bryan <wilbryan@us.ibm.com>
Diffstat (limited to 'src/ppe')
-rwxr-xr-xsrc/ppe/tools/PowerPCtoPPE/ppc-ppe-pcp.py39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/ppe/tools/PowerPCtoPPE/ppc-ppe-pcp.py b/src/ppe/tools/PowerPCtoPPE/ppc-ppe-pcp.py
index 1d6635f..e3bd089 100755
--- a/src/ppe/tools/PowerPCtoPPE/ppc-ppe-pcp.py
+++ b/src/ppe/tools/PowerPCtoPPE/ppc-ppe-pcp.py
@@ -419,9 +419,15 @@ def p2p_replace(line, ppc_op):
print newline
# construct and write "mr R3, RA" to copy the operand RA to R3
- newline = inst.group(1) + 'mr' + inst.group(3) + '3' +\
- inst.group(5) + inst.group(6)
- print newline
+ # if RA == R3 then R3 was clobbered, restore R3 from stack
+ if inst.group(6) == '3':
+ newline = inst.group(1) + 'lwz' + inst.group(3) + '3' +\
+ inst.group(5) + '8(1)'
+ print newline
+ else:
+ newline = inst.group(1) + 'mr' + inst.group(3) + '3' +\
+ inst.group(5) + inst.group(6)
+ print newline
# if 'mulli' is detected, using 'li' instead of 'mr' for second operand
if ppc_op == 'mulli':
@@ -429,11 +435,13 @@ def p2p_replace(line, ppc_op):
else:
temp_op = 'mr'
- # construct and write "mr R4, RB" to copy the operand RB to R4
- # or in 'mulli' case, "li R4, IM" to copy the operand IM to R4
- newline = inst.group(1) + temp_op + inst.group(3) + '4' +\
- inst.group(5) + inst.group(8)
- print newline
+ # Set R4 if R4 is not already RB
+ if temp_op == 'li' or inst.group(8) != '4':
+ # construct and write "mr R4, RB" to copy the operand RB to R4
+ # or in 'mulli' case, "li R4, IM" to copy the operand IM to R4
+ newline = inst.group(1) + temp_op + inst.group(3) + '4' +\
+ inst.group(5) + inst.group(8)
+ print newline
# using branch and link(bl) to branch to subroutine
# later subroutine can branch back using branch link register(blr)
@@ -442,10 +450,17 @@ def p2p_replace(line, ppc_op):
newline = inst.group(1) + 'bl' + inst.group(3) + ppe_op
print newline
- # construct and write "mr RT, R3" to copy the result in R3 to RT
- newline = inst.group(1) + 'mr' + inst.group(3) + inst.group(4) +\
- inst.group(5) + '3'
- print newline
+ # if RT is not already R3 then copy R3 to RT
+ if inst.group(4) != '3':
+ # construct and write "mr RT, R3" to copy the result in R3 to RT
+ newline = inst.group(1) + 'mr' + inst.group(3) + inst.group(4) +\
+ inst.group(5) + '3'
+ print newline
+ else:
+ # save return on stack
+ newline = inst.group(1) + 'stw' + inst.group(3) + '3' +\
+ inst.group(5) + '8(1)'
+ print newline
# construct and write "lwz R3, 16(R1)" to fetch the LR value from stack
newline = inst.group(1) + 'lwz' + inst.group(3) + '3' +\
OpenPOWER on IntegriCloud