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/CBuiltins.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'powerpc/CBuiltins.ml') diff --git a/powerpc/CBuiltins.ml b/powerpc/CBuiltins.ml index e219a175..1c7a3086 100644 --- a/powerpc/CBuiltins.ml +++ b/powerpc/CBuiltins.ml @@ -118,7 +118,10 @@ let builtins = { (TPtr (TVoid [],[]),[],false); (* isel *) "__builtin_isel", - (TInt (IInt, []),[TInt(IInt, []);TInt(IInt, []);TInt(IInt, [])],false) + (TInt (IInt, []),[TInt(IInt, []);TInt(IInt, []);TInt(IInt, [])],false); + (* atomic operations *) + "__builtin_atomic_exchange", + (TVoid [], [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false) ] } -- cgit From 2dce91b8e2cae0b49c8870df6c727e25aaa180d8 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 9 Sep 2015 15:36:34 +0200 Subject: Add builtin for atomic load. Implement the new __builtin_atomic_load(int *a, int *b); which stores *a in *b. This differs from the atomic_load of the GCC, since the PPC ISA manual states that you must jump before the load again if it fails. --- powerpc/CBuiltins.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'powerpc/CBuiltins.ml') diff --git a/powerpc/CBuiltins.ml b/powerpc/CBuiltins.ml index 1c7a3086..2013c9cf 100644 --- a/powerpc/CBuiltins.ml +++ b/powerpc/CBuiltins.ml @@ -121,7 +121,10 @@ let builtins = { (TInt (IInt, []),[TInt(IInt, []);TInt(IInt, []);TInt(IInt, [])],false); (* atomic operations *) "__builtin_atomic_exchange", - (TVoid [], [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false) + (TVoid [], [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false); + "__builtin_atomic_load", + (TVoid [], [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false) + ] } -- 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/CBuiltins.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'powerpc/CBuiltins.ml') diff --git a/powerpc/CBuiltins.ml b/powerpc/CBuiltins.ml index b61028d3..5409e9ef 100644 --- a/powerpc/CBuiltins.ml +++ b/powerpc/CBuiltins.ml @@ -123,7 +123,10 @@ let builtins = { "__builtin_atomic_exchange", (TVoid [], [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false); "__builtin_atomic_load", - (TVoid [], [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false) + (TVoid [], [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false); + "__builtin_atomic_compare_exchange", + (TInt (IBool, []), [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false); + ] } -- 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/CBuiltins.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'powerpc/CBuiltins.ml') diff --git a/powerpc/CBuiltins.ml b/powerpc/CBuiltins.ml index 5409e9ef..a9e4f5e3 100644 --- a/powerpc/CBuiltins.ml +++ b/powerpc/CBuiltins.ml @@ -126,7 +126,8 @@ let builtins = { (TVoid [], [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false); "__builtin_atomic_compare_exchange", (TInt (IBool, []), [TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[]);TPtr (TInt(IInt, []),[])],false); - + "__builtin_sync_fetch_and_add", + (TInt (IInt, []), [TPtr (TInt(IInt, []),[]);TInt(IInt, [])],false); ] } -- cgit