From 62277541b0ea1c687c64df79a543f776b9f58f29 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 9 Sep 2015 09:47:57 +0200 Subject: Added an builtin for the atomic exchange operation. The new builtin __builtin_atomic_exchange(int *a, int *b, int *c) stores *b in *a and sets *c to the old value of *a. --- powerpc/Machregs.v | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'powerpc/Machregs.v') diff --git a/powerpc/Machregs.v b/powerpc/Machregs.v index a2017dca..f07d488b 100644 --- a/powerpc/Machregs.v +++ b/powerpc/Machregs.v @@ -160,9 +160,14 @@ Fixpoint destroyed_by_clobber (cl: list string): list mreg := end end. +Definition builtin_atomic_exchange := ident_of_string "__builtin_atomic_exchange". + Definition destroyed_by_builtin (ef: external_function): list mreg := match ef with - | EF_builtin _ _ => F13 :: nil + | EF_builtin id sg => + if ident_eq id builtin_atomic_exchange then R10::R11::F13:: nil + else + F13 :: nil | EF_vload _ => R11 :: nil | EF_vstore Mint64 => R10 :: R11 :: R12 :: nil | EF_vstore _ => R11 :: R12 :: nil @@ -183,6 +188,7 @@ Definition temp_for_parent_frame: mreg := Definition mregs_for_operation (op: operation): list (option mreg) * option mreg := (nil, None). + Definition mregs_for_builtin (ef: external_function): list (option mreg) * list (option mreg) := (nil, nil). -- cgit From 41655f6c8d38270cc50407b0141b443f6ee90100 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 10 Sep 2015 10:20:15 +0200 Subject: Added builtin for atomic compare and exchange. The new __builtin_atomic_compare_exchange(int *ptr,int *exp,int *dsr); writes dsr into ptr if ptr is equal to exp and returns true if ptr is not equal to exp it writes ptr into exp and returns false. --- powerpc/Machregs.v | 2 ++ 1 file changed, 2 insertions(+) (limited to 'powerpc/Machregs.v') diff --git a/powerpc/Machregs.v b/powerpc/Machregs.v index 4391d5a8..1699211d 100644 --- a/powerpc/Machregs.v +++ b/powerpc/Machregs.v @@ -162,12 +162,14 @@ Fixpoint destroyed_by_clobber (cl: list string): list mreg := Definition builtin_atomic_exchange := ident_of_string "__builtin_atomic_exchange". Definition builtin_sync_and_fetch := ident_of_string "__builtin_sync_and_fetch". +Definition builtin_atomic_compare_exchange := ident_of_string "__builtin_atomic_compare_exchange". Definition destroyed_by_builtin (ef: external_function): list mreg := match ef with | EF_builtin id sg => if ident_eq id builtin_atomic_exchange then R10::R11::F13:: nil else if ident_eq id builtin_sync_and_fetch then R11::F13::nil + else if ident_eq id builtin_atomic_compare_exchange then R10::R11::R12::F13:: nil else F13 :: nil | EF_vload _ => R11 :: nil | EF_vstore Mint64 => R10 :: R11 :: R12 :: nil -- cgit From 9dc0dd73f75875b301c886df40087192d0fad386 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 14 Sep 2015 19:41:39 +0200 Subject: Use fix registers for atomic builtins. In order to avoid clashes during register allocation etc. The builtins now use fixed registers and mark additional registers as destroyed for temporaries. --- powerpc/Machregs.v | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'powerpc/Machregs.v') diff --git a/powerpc/Machregs.v b/powerpc/Machregs.v index 1699211d..c464ddd6 100644 --- a/powerpc/Machregs.v +++ b/powerpc/Machregs.v @@ -161,15 +161,15 @@ Fixpoint destroyed_by_clobber (cl: list string): list mreg := end. Definition builtin_atomic_exchange := ident_of_string "__builtin_atomic_exchange". -Definition builtin_sync_and_fetch := ident_of_string "__builtin_sync_and_fetch". +Definition builtin_sync_and_fetch := ident_of_string "__builtin_sync_fetch_and_add". Definition builtin_atomic_compare_exchange := ident_of_string "__builtin_atomic_compare_exchange". Definition destroyed_by_builtin (ef: external_function): list mreg := match ef with | EF_builtin id sg => - if ident_eq id builtin_atomic_exchange then R10::R11::F13:: nil - else if ident_eq id builtin_sync_and_fetch then R11::F13::nil - else if ident_eq id builtin_atomic_compare_exchange then R10::R11::R12::F13:: nil + if ident_eq id builtin_atomic_exchange then R10::R11:: nil + else if ident_eq id builtin_atomic_compare_exchange then R10::R11::R12:: nil + else if ident_eq id builtin_sync_and_fetch then R3::R10::nil else F13 :: nil | EF_vload _ => R11 :: nil | EF_vstore Mint64 => R10 :: R11 :: R12 :: nil @@ -193,7 +193,14 @@ Definition mregs_for_operation (op: operation): list (option mreg) * option mreg Definition mregs_for_builtin (ef: external_function): list (option mreg) * list (option mreg) := - (nil, nil). + match ef with + | EF_builtin id sg => + if ident_eq id builtin_atomic_exchange then ((Some R3)::(Some R4)::(Some R5)::nil,nil) + else if ident_eq id builtin_sync_and_fetch then ((Some R4)::(Some R5)::nil,(Some R3)::nil) + else if ident_eq id builtin_atomic_compare_exchange then ((Some R4)::(Some R5)::(Some R6)::nil, (Some R3):: nil) + else (nil, nil) + | _ => (nil, nil) + end. Global Opaque destroyed_by_op destroyed_by_load destroyed_by_store -- cgit From bc1fbdd0baaab41aa048b3214ec71bb0cc04dfcc Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 21 Sep 2015 16:17:44 +0200 Subject: Applied a few simplification for temporary registers. --- powerpc/Machregs.v | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'powerpc/Machregs.v') diff --git a/powerpc/Machregs.v b/powerpc/Machregs.v index c464ddd6..f94c3b64 100644 --- a/powerpc/Machregs.v +++ b/powerpc/Machregs.v @@ -167,9 +167,8 @@ Definition builtin_atomic_compare_exchange := ident_of_string "__builtin_atomic_ Definition destroyed_by_builtin (ef: external_function): list mreg := match ef with | EF_builtin id sg => - if ident_eq id builtin_atomic_exchange then R10::R11:: nil - else if ident_eq id builtin_atomic_compare_exchange then R10::R11::R12:: nil - else if ident_eq id builtin_sync_and_fetch then R3::R10::nil + if ident_eq id builtin_atomic_exchange then R10::nil + else if ident_eq id builtin_atomic_compare_exchange then R10::R11::nil else F13 :: nil | EF_vload _ => R11 :: nil | EF_vstore Mint64 => R10 :: R11 :: R12 :: nil -- cgit