summaryrefslogtreecommitdiff
path: root/powerpc
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-04-17 07:01:18 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-04-17 07:01:18 +0000
commit59646439baa1b9cc6209b684e4ccf9aac908fdbc (patch)
tree55f0b7c0f82f9b0e32ba754dc129938ac1242cc9 /powerpc
parent9e9853b79e652036c2e5c7af01d8ac9add0b8962 (diff)
Support __builtin_memcpy; use it for struct assignment
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1319 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'powerpc')
-rw-r--r--powerpc/PrintAsm.ml25
1 files changed, 25 insertions, 0 deletions
diff --git a/powerpc/PrintAsm.ml b/powerpc/PrintAsm.ml
index f528335..4c89879 100644
--- a/powerpc/PrintAsm.ml
+++ b/powerpc/PrintAsm.ml
@@ -271,6 +271,31 @@ let print_builtin_function oc s =
fprintf oc " stfs %a, 0(%a)\n" freg FPR1 ireg GPR3
| "__builtin_volatile_write_float64" ->
fprintf oc " stfd %a, 0(%a)\n" freg FPR1 ireg GPR3
+ (* Block copy *)
+ | "__builtin_memcpy" ->
+ let lbl1 = new_label() in
+ let lbl2 = new_label() in
+ fprintf oc " cmplwi %a, %a, 0\n" creg CR0 ireg GPR5;
+ fprintf oc " beq %a, %a\n" creg CR0 label lbl1;
+ fprintf oc " mtctr %a\n" ireg GPR5;
+ fprintf oc " addi %a, %a, -1\n" ireg GPR6 ireg GPR3;
+ fprintf oc " addi %a, %a, -1\n" ireg GPR4 ireg GPR4;
+ fprintf oc "%a: lbzu %a, 1(%a)\n" label lbl2 ireg GPR0 ireg GPR4;
+ fprintf oc " stbu %a, 1(%a)\n" ireg GPR0 ireg GPR6;
+ fprintf oc " bdnz %a\n" label lbl2;
+ fprintf oc "%a:\n" label lbl1
+ | "__builtin_memcpy_word" ->
+ let lbl1 = new_label() in
+ let lbl2 = new_label() in
+ fprintf oc " rlwinm. %a, %a, 30, 2, 31\n" ireg GPR5 ireg GPR5;
+ fprintf oc " beq %a, %a\n" creg CR0 label lbl1;
+ fprintf oc " mtctr %a\n" ireg GPR5;
+ fprintf oc " addi %a, %a, -4\n" ireg GPR6 ireg GPR3;
+ fprintf oc " addi %a, %a, -4\n" ireg GPR4 ireg GPR4;
+ fprintf oc "%a: lwzu %a, 4(%a)\n" label lbl2 ireg GPR0 ireg GPR4;
+ fprintf oc " stwu %a, 4(%a)\n" ireg GPR0 ireg GPR6;
+ fprintf oc " bdnz %a\n" label lbl2;
+ fprintf oc "%a:\n" label lbl1
(* Integer arithmetic *)
| "__builtin_mulhw" ->
fprintf oc " mulhw %a, %a, %a\n" ireg GPR3 ireg GPR3 ireg GPR4