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..93517af40367a82854217810e03fab96b83169cc |
--- /dev/null |
+++ b/include/llvm/IR/NaClIntrinsics.h |
@@ -0,0 +1,129 @@ |
+//===-- 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. |
+// |
+//===----------------------------------------------------------------------===// |
+ |
+#ifndef LLVM_IR_NACL_H |
jvoung (off chromium)
2013/07/03 17:50:26
ifdef guard should be NACL_INTRINSICS something in
JF
2013/07/03 22:28:30
Done in the renaming I did for dschuff's review.
|
+#define LLVM_IR_NACL_H |
+ |
+#include "llvm/IR/Intrinsics.h" |
+#include "llvm/Support/Compiler.h" |
+#include <cstddef> |
+ |
+namespace llvm { |
+ |
+namespace NaCl { |
jvoung (off chromium)
2013/07/03 17:50:26
perhaps use allow lower case: namespace "nacl"
We
JF
2013/07/03 22:28:30
mseaborn had the same suggestion: using uppercase
jvoung (off chromium)
2013/07/03 23:10:38
Well like a lot of LLVM conventions, it's not cons
JF
2013/07/03 23:43:18
git grep -e "namespace [a-zA-Z0-9_][a-zA-Z0-9_]* *
|
+ |
+static const size_t NumAtomicIntrinsics = 5; |
+static const size_t NumAtomicIntrinsicTypes = 4; |
jvoung (off chromium)
2013/07/03 17:50:26
Could call this "NumAtomicIntrinsicOverloadTypes",
JF
2013/07/03 22:28:30
Done.
|
+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 { |
+ Type *OverloadedType; |
+ Intrinsic::ID ID : 16; |
+ uint8_t Overloaded : 1; |
+ uint8_t NumParams : 7; |
+ uint8_t ParamType[MaxAtomicIntrinsicsParameters]; |
+ |
+ Function *getDeclaration(Module *M) const { |
+ return Intrinsic::getDeclaration( |
+ M, ID, ArrayRef<Type *>(&OverloadedType, Overloaded ? 1 : 0)); |
+ } |
+ }; |
+ |
+ AtomicIntrinsics(LLVMContext &C); |
+ ~AtomicIntrinsics() {} |
+ |
+ class const_iterator { |
eliben
2013/07/03 16:06:05
Please get rid of this iterator. I found it very c
JF
2013/07/03 20:58:35
Awesome, ArrayRef is indeed much nicer. I changed
|
+ 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; |
jvoung (off chromium)
2013/07/03 17:50:26
Interesting that they didn't make llvm/Support/sup
JF
2013/07/03 22:28:30
Seems like an oversight that should get fixed upst
|
+ 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 |