Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: src/IceIntrinsics.cpp

Issue 321993002: Add a few Subzero intrinsics (not the atomic ones yet). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: doesn't matter if eax or not Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceIntrinsics.cpp
diff --git a/src/IceIntrinsics.cpp b/src/IceIntrinsics.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f07fd0add5f87d3e165bb101ad89c6f8bad704a5
--- /dev/null
+++ b/src/IceIntrinsics.cpp
@@ -0,0 +1,87 @@
+//===- subzero/src/IceIntrinsics.cpp - Functions related to intrinsics ----===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the Intrinsics utilities for matching and
+// then dispatching by name.
+//
+//===----------------------------------------------------------------------===//
+
+#include "IceCfg.h"
+#include "IceCfgNode.h"
+#include "IceIntrinsics.h"
+#include "IceLiveness.h"
+#include "IceOperand.h"
+
+#include <utility>
+
+namespace Ice {
+
+const IntrinsicInfo UnknownIntrinsicInfo = { UnknownIntrinsic, false };
+
+bool operator==(const IntrinsicInfo &A, const IntrinsicInfo &B) {
+ return A.ID == B.ID && A.HasSideEffects == B.HasSideEffects;
+}
+
+// TODO(jvoung): vet and test the HasSideEffects attributes.
+// Reduce the amount of duplication for overloaded intrinsics.
+const struct IceIntrinsicsEntry_ {
JF 2014/06/10 03:50:41 This should be in an anonymous namespace.
jvoung (off chromium) 2014/06/12 05:48:30 Done.
+ IntrinsicInfo Info;
+ const char *IntrinsicName;
+} IceIntrinsicsTable [] = {
+ { {AtomicCmpxchg, true}, "nacl.atomic.cmpxchg.i8" },
+ { {AtomicCmpxchg, true}, "nacl.atomic.cmpxchg.i16" },
+ { {AtomicCmpxchg, true}, "nacl.atomic.cmpxchg.i32" },
+ { {AtomicCmpxchg, true}, "nacl.atomic.cmpxchg.i64" },
+ { {AtomicFence, true}, "nacl.atomic.fence"},
+ { {AtomicFenceAll, true}, "nacl.atomic.fence.all" },
+ { {AtomicIsLockFree, true}, "nacl.atomic.is.lock.free" },
+ { {AtomicLoad, true}, "nacl.atomic.load.i8" },
+ { {AtomicLoad, true}, "nacl.atomic.load.i16" },
+ { {AtomicLoad, true}, "nacl.atomic.load.i32" },
+ { {AtomicLoad, true}, "nacl.atomic.load.i64" },
+ { {AtomicRMW, true}, "nacl.atomic.rmw.i8" },
+ { {AtomicRMW, true}, "nacl.atomic.rmw.i16" },
+ { {AtomicRMW, true}, "nacl.atomic.rmw.i32" },
+ { {AtomicRMW, true}, "nacl.atomic.rmw.i64" },
+ { {AtomicStore, true}, "nacl.atomic.store.i8" },
+ { {AtomicStore, true}, "nacl.atomic.store.i16" },
+ { {AtomicStore, true}, "nacl.atomic.store.i32" },
+ { {AtomicStore, true}, "nacl.atomic.store.i64" },
+ { {Bswap, false}, "bswap.i16" },
+ { {Bswap, false}, "bswap.i32" },
+ { {Bswap, false}, "bswap.i64" },
+ { {Ctlz, false}, "ctlz.i32" },
+ { {Ctlz, false}, "ctlz.i64" },
+ { {Ctpop, false}, "ctpop.i32" },
+ { {Ctpop, false}, "ctpop.i64" },
+ { {Cttz, false}, "cttz.i32" },
+ { {Cttz, false}, "cttz.i64" },
+ { {Longjmp, true}, "nacl.longjmp" },
+ { {Memcpy, true}, "memcpy.p0i8.p0i8.i32" },
+ { {Memmove, true}, "memmove.p0i8.p0i8.i32" },
+ { {Memset, true}, "memset.p0i8.i32" },
+ { {NaClReadTP, false}, "nacl.read.tp" },
+ { {Setjmp, true}, "nacl.setjmp" },
+ { {Sqrt, false}, "sqrt.f32" },
+ { {Sqrt, false}, "sqrt.f64" },
+ { {Stacksave, true}, "stacksave" },
+ { {Stackrestore, true}, "stackrestore" },
+ { {Trap, true}, "trap" }
JF 2014/06/10 03:50:41 Do you need the function signatures too? The lower
Jim Stichnoth 2014/06/10 22:58:28 I'm not sure what in particular the lowering code
jvoung (off chromium) 2014/06/12 05:48:30 Yeah, I think type signatures would be most useful
JF 2014/06/12 15:43:02 I was thinking of something similar to llvm/IR/NaC
+};
+
+const size_t IceIntrinsicsTableSize = llvm::array_lengthof(IceIntrinsicsTable);
+
+void BuildIntrinsicMap(IntrinsicMap *OutMap) {
+ for (size_t I = 0; I < IceIntrinsicsTableSize; ++I) {
+ const struct IceIntrinsicsEntry_ &Entry = IceIntrinsicsTable[I];
+ OutMap->insert(std::make_pair(IceString(Entry.IntrinsicName), Entry.Info));
+ }
+}
+
+} // end of namespace Ice

Powered by Google App Engine
This is Rietveld 408576698