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

Unified Diff: include/llvm/IR/NaClIntrinsics.h

Issue 17777004: Concurrency support for PNaCl ABI (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Address dschuff's comments (2). 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
« no previous file with comments | « include/llvm/IR/Intrinsics.td ('k') | include/llvm/InitializePasses.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/llvm/IR/NaClIntrinsics.h
diff --git a/include/llvm/IR/NaClIntrinsics.h b/include/llvm/IR/NaClIntrinsics.h
new file mode 100644
index 0000000000000000000000000000000000000000..2196c7fa9259a6047330e6bf545ca136128af910
--- /dev/null
+++ b/include/llvm/IR/NaClIntrinsics.h
@@ -0,0 +1,132 @@
+//===-- llvm/IR/NaClIntrinsics.h - 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.
Derek Schuff 2013/07/03 16:08:55 since these files are really only for atomic intri
JF 2013/07/03 21:28:12 Done in a single change.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_IR_NACL_H
+#define LLVM_IR_NACL_H
+
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/Support/Compiler.h"
+#include <cstddef>
+
+namespace llvm {
+
+namespace NaCl {
+
+static const size_t NumAtomicIntrinsics = 5;
+static const size_t NumAtomicIntrinsicTypes = 4;
+static const size_t MaxAtomicIntrinsicsParameters = 5;
+
+// Describe all the atomic intrinsics and their type signature. Most can
+// be overloaded on a type.
+class AtomicIntrinsics {
+public:
+ enum ParamType {
+ NoP, // No parameter.
+ Int, // Overloaded.
+ Ptr, // Overloaded.
+ RMW, // Atomic RMW operation type.
+ Mem // Memory order.
+ };
+
+ struct AtomicIntrinsic {
+ Intrinsic::ID ID : 16;
+ uint8_t NumParams;
+ bool Overloaded;
+ Type *OverloadedType;
+ // Full function signature, excluding return type.
+ Type *Signature[MaxAtomicIntrinsicsParameters];
+ uint8_t ParamType[MaxAtomicIntrinsicsParameters];
+
+ Type *Parameter(size_t P) const { return Signature[P]; }
+ Function *getDeclaration(Module *M) const {
+ return Intrinsic::getDeclaration(
+ M, ID, ArrayRef<Type *>(&OverloadedType, Overloaded ? 1 : 0));
+ }
+ };
+
+ AtomicIntrinsics(LLVMContext &C);
+ ~AtomicIntrinsics() {}
+
+ class const_iterator {
+ public:
+ const_iterator(const AtomicIntrinsic *I) : I(I) {}
+ ~const_iterator() {}
+ const_iterator(const const_iterator &rhs) : I(rhs.I) {}
+ const_iterator &operator=(const const_iterator &rhs) {
+ I = rhs.I;
+ return *this;
+ }
+ void operator++() { ++I; }
+ bool operator!=(const const_iterator &rhs) { return I != rhs.I; }
+ const AtomicIntrinsic *operator->() const { return I; }
+
+ private:
+ const AtomicIntrinsic *I;
+ const_iterator() LLVM_DELETED_FUNCTION;
+ friend class AtomicIntrinsics;
+ };
+
+ // Iterator through all ID+Type overloads.
+ const_iterator begin() const;
+ const_iterator end() const;
+
+ // Iterator through all Type overloads for a single ID.
+ const_iterator begin(Intrinsic::ID ID) const;
+ const_iterator end(Intrinsic::ID ID) const;
+
+ const_iterator find(Intrinsic::ID ID, Type *OverloadedType) const;
+
+private:
+ AtomicIntrinsic I[NumAtomicIntrinsics][NumAtomicIntrinsicTypes];
+
+ AtomicIntrinsics() LLVM_DELETED_FUNCTION;
+ AtomicIntrinsics(const AtomicIntrinsics &) LLVM_DELETED_FUNCTION;
+ AtomicIntrinsics &operator=(const AtomicIntrinsics &) LLVM_DELETED_FUNCTION;
+};
+
+// Operations that can be represented by the @llvm.nacl.atomic.rmw
+// intrinsic.
+//
+// Do not reorder these values: their order offers forward compatibility
+// of bitcode targeted to NaCl.
+enum AtomicRMWOperation {
+ AtomicInvalid = 0, // Invalid, keep first.
+ AtomicAdd,
+ AtomicSub,
+ AtomicOr,
+ AtomicAnd,
+ AtomicXor,
+ AtomicExchange,
+ AtomicNum // Invalid, keep last.
+};
+
+// Memory orderings supported by C11/C++11.
+//
+// Do not reorder these values: their order offers forward compatibility
+// of bitcode targeted to NaCl.
+enum MemoryOrder {
+ MemoryOrderInvalid = 0, // Invalid, keep first.
+ MemoryOrderRelaxed,
+ MemoryOrderConsume,
+ MemoryOrderAcquire,
+ MemoryOrderRelease,
+ MemoryOrderAcquireRelease,
+ MemoryOrderSequentiallyConsistent,
+ MemoryOrderNum // Invalid, keep last.
+};
+
+} // End NaCl namespace
+
+} // End llvm namespace
+
+#endif
« no previous file with comments | « include/llvm/IR/Intrinsics.td ('k') | include/llvm/InitializePasses.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698