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

Unified Diff: lib/IR/NaClIntrinsics.cpp

Issue 17777004: Concurrency support for PNaCl ABI (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Clean up suggested by mseaborn. Created 7 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: lib/IR/NaClIntrinsics.cpp
diff --git a/lib/IR/NaClIntrinsics.cpp b/lib/IR/NaClIntrinsics.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4614e222c341e5aff83a8950d3fc304db5fcac93
--- /dev/null
+++ b/lib/IR/NaClIntrinsics.cpp
@@ -0,0 +1,88 @@
+//===-- llvm/IR/NaClIntrinsics.cpp - NaCl Intrinsics ------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file describes intrinsic functions that are specific to NaCl.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/NaClIntrinsics.h"
+#include "llvm/IR/Type.h"
+
+namespace llvm {
+
+namespace NaCl {
+
+AtomicIntrinsics::AtomicIntrinsics(LLVMContext &C) {
+ Type *IT[NumAtomicIntrinsicTypes] = { Type::getInt8Ty(C), Type::getInt16Ty(C),
+ Type::getInt32Ty(C),
+ Type::getInt64Ty(C) };
+ size_t CurIntrin = 0;
+
+#define INIT(P0, P1, P2, P3, P4, INTRIN) \
eliben 2013/07/03 16:06:05 Comment to explain what's going on
JF 2013/07/03 20:58:35 Done.
+ do { \
+ for (size_t CurType = 0; CurType != NumAtomicIntrinsicTypes; ++CurType) { \
+ size_t Param = 0; \
+ I[CurIntrin][CurType].OverloadedType = IT[CurType]; \
+ I[CurIntrin][CurType].ID = Intrinsic::nacl_atomic_##INTRIN; \
+ I[CurIntrin][CurType].Overloaded = \
+ P0 == Int || P0 == Ptr || P1 == Int || P1 == Ptr || P2 == Int || \
+ P2 == Ptr || P3 == Int || P3 == Ptr || P4 == Int || P4 == Ptr; \
+ I[CurIntrin][CurType].NumParams = \
+ (P0 != NoP) + (P1 != NoP) + (P2 != NoP) + (P3 != NoP) + (P4 != NoP); \
+ I[CurIntrin][CurType].ParamType[Param++] = P0; \
+ I[CurIntrin][CurType].ParamType[Param++] = P1; \
+ I[CurIntrin][CurType].ParamType[Param++] = P2; \
+ I[CurIntrin][CurType].ParamType[Param++] = P3; \
+ I[CurIntrin][CurType].ParamType[Param++] = P4; \
+ } \
+ ++CurIntrin; \
+ } while (0)
+
+ INIT(Ptr, Mem, NoP, NoP, NoP, load);
+ INIT(Ptr, Int, Mem, NoP, NoP, store);
+ INIT(RMW, Ptr, Int, Mem, NoP, rmw);
+ INIT(Ptr, Int, Int, Mem, Mem, cmpxchg);
+ INIT(Mem, NoP, NoP, NoP, NoP, fence);
+}
+
+AtomicIntrinsics::const_iterator AtomicIntrinsics::begin() const {
+ return &I[0][0];
+}
+
+AtomicIntrinsics::const_iterator AtomicIntrinsics::end() const {
+ return begin().I + NumAtomicIntrinsics * NumAtomicIntrinsicTypes;
+}
+
+AtomicIntrinsics::const_iterator
+AtomicIntrinsics::begin(Intrinsic::ID ID) const {
+ for (const AtomicIntrinsic *AI = begin().I; AI != end().I; ++AI)
+ if (AI->ID == ID)
+ return const_iterator(AI);
+ llvm_unreachable("unhandled atomic intrinsic");
+}
+
+AtomicIntrinsics::const_iterator AtomicIntrinsics::end(Intrinsic::ID ID) const {
+ for (const AtomicIntrinsic *AI = end().I; AI != begin().I; --AI)
+ if ((AI - 1)->ID == ID)
+ return const_iterator(AI);
+ llvm_unreachable("unhandled atomic intrinsic");
+}
+
+AtomicIntrinsics::const_iterator
+AtomicIntrinsics::find(Intrinsic::ID ID, Type *OverloadedType) const {
+ for (const AtomicIntrinsic *AI = begin().I; AI != end().I; ++AI)
+ if (AI->ID == ID && AI->OverloadedType == OverloadedType)
+ return const_iterator(AI);
+ llvm_unreachable("unhandled atomic intrinsic");
+}
+
+} // End NaCl namespace
+
+} // End llvm namespace

Powered by Google App Engine
This is Rietveld 408576698