aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-04-09 18:17:11 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-04-09 18:17:11 -0700
commit022873c12ec07fab6fbd72d04f7a2616b8f0abc9 (patch)
tree5817cdf545fe55dff9858cd39af425a6226e16f5 /src
parente2811fed826db20a10af7f70ac44f1aad9f06aa5 (diff)
__atomic funcs
Diffstat (limited to 'src')
-rw-r--r--src/library.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js
index b000c7f4..1d5a9140 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4436,6 +4436,83 @@ LibraryManager.library = {
return size <= 4 && (ptr&(size-1)) == 0;
},
+ __atomic_load_8: function(ptr, memmodel) {
+ {{{ makeStructuralReturn([makeGetValue('ptr', 0, 'i32'), makeGetValue('ptr', 4, 'i32')]) }}};
+ },
+
+ __atomic_store_8: function(ptr, vall, valh, memmodel) {
+ {{{ makeSetValue('ptr', 0, 'vall', 'i32') }}};
+ {{{ makeSetValue('ptr', 4, 'valh', 'i32') }}};
+ },
+
+ __atomic_exchange_8: function(ptr, vall, valh, memmodel) {
+ var l = {{{ makeGetValue('ptr', 0, 'i32') }}};
+ var h = {{{ makeGetValue('ptr', 4, 'i32') }}};
+ {{{ makeSetValue('ptr', 0, 'vall', 'i32') }}};
+ {{{ makeSetValue('ptr', 4, 'valh', 'i32') }}};
+ {{{ makeStructuralReturn(['l', 'h']) }}};
+ },
+
+ __atomic_compare_exchange_8: function(ptr, expected, desiredl, desiredh, weak, success_memmodel, failure_memmodel) {
+ var pl = {{{ makeGetValue('ptr', 0, 'i32') }}};
+ var ph = {{{ makeGetValue('ptr', 4, 'i32') }}};
+ var el = {{{ makeGetValue('expected', 0, 'i32') }}};
+ var eh = {{{ makeGetValue('expected', 4, 'i32') }}};
+ if (pl === el && ph === eh) {
+ {{{ makeSetValue('ptr', 0, 'desiredl', 'i32') }}};
+ {{{ makeSetValue('ptr', 4, 'desiredh', 'i32') }}};
+ return 1;
+ } else {
+ {{{ makeSetValue('expected', 0, 'pl', 'i32') }}};
+ {{{ makeSetValue('expected', 4, 'ph', 'i32') }}};
+ return 0;
+ }
+ },
+
+ __atomic_fetch_add_8__deps: ['llvm_uadd_with_overflow_i64'],
+ __atomic_fetch_add_8: function(ptr, vall, valh, memmodel) {
+ var l = {{{ makeGetValue('ptr', 0, 'i32') }}};
+ var h = {{{ makeGetValue('ptr', 4, 'i32') }}};
+ {{{ makeSetValue('ptr', 0, '_llvm_uadd_with_overflow_i64(l, h, vall, valh)', 'i32') }}};
+ {{{ makeSetValue('ptr', 4, 'tempRet0', 'i32') }}};
+ {{{ makeStructuralReturn(['l', 'h']) }}};
+ },
+
+ __atomic_fetch_sub_8__deps: ['i64Subtract'],
+ __atomic_fetch_sub_8: function(ptr, vall, valh, memmodel) {
+ var l = {{{ makeGetValue('ptr', 0, 'i32') }}};
+ var h = {{{ makeGetValue('ptr', 4, 'i32') }}};
+ {{{ makeSetValue('ptr', 0, '_i64Subtract(l, h, vall, valh)', 'i32') }}};
+ {{{ makeSetValue('ptr', 4, 'tempRet0', 'i32') }}};
+ {{{ makeStructuralReturn(['l', 'h']) }}};
+ },
+
+ __atomic_fetch_and_8__deps: ['i64Subtract'],
+ __atomic_fetch_and_8: function(ptr, vall, valh, memmodel) {
+ var l = {{{ makeGetValue('ptr', 0, 'i32') }}};
+ var h = {{{ makeGetValue('ptr', 4, 'i32') }}};
+ {{{ makeSetValue('ptr', 0, 'l&vall', 'i32') }}};
+ {{{ makeSetValue('ptr', 4, 'h&valh', 'i32') }}};
+ {{{ makeStructuralReturn(['l', 'h']) }}};
+ },
+
+ __atomic_fetch_or_8: function(ptr, vall, valh, memmodel) {
+ var l = {{{ makeGetValue('ptr', 0, 'i32') }}};
+ var h = {{{ makeGetValue('ptr', 4, 'i32') }}};
+ {{{ makeSetValue('ptr', 0, 'l|vall', 'i32') }}};
+ {{{ makeSetValue('ptr', 4, 'h|valh', 'i32') }}};
+ {{{ makeStructuralReturn(['l', 'h']) }}};
+ },
+
+ __atomic_fetch_xor_8: function(ptr, vall, valh, memmodel) {
+ var l = {{{ makeGetValue('ptr', 0, 'i32') }}};
+ var h = {{{ makeGetValue('ptr', 4, 'i32') }}};
+ {{{ makeSetValue('ptr', 0, 'l^vall', 'i32') }}};
+ {{{ makeSetValue('ptr', 4, 'h^valh', 'i32') }}};
+ {{{ makeStructuralReturn(['l', 'h']) }}};
+ },
+
+
// ==========================================================================
// llvm-mono integration
// ==========================================================================