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

Side by Side 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: Missed one cleanup file. Created 7 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 //===-- llvm/IR/NaClIntrinsics.h - NaCl Intrinsics --------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes intrinsic functions that are specific to NaCl.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #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.
15 #define LLVM_IR_NACL_H
16
17 #include "llvm/IR/Intrinsics.h"
18 #include "llvm/Support/Compiler.h"
19 #include <cstddef>
20
21 namespace llvm {
22
23 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_]* *
24
25 static const size_t NumAtomicIntrinsics = 5;
26 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.
27 static const size_t MaxAtomicIntrinsicsParameters = 5;
28
29 // Describe all the atomic intrinsics and their type signature. Most can
30 // be overloaded on a type.
31 class AtomicIntrinsics {
32 public:
33 enum ParamType {
34 NoP, // No parameter.
35 Int, // Overloaded.
36 Ptr, // Overloaded.
37 RMW, // Atomic RMW operation type.
38 Mem // Memory order.
39 };
40
41 struct AtomicIntrinsic {
42 Type *OverloadedType;
43 Intrinsic::ID ID : 16;
44 uint8_t Overloaded : 1;
45 uint8_t NumParams : 7;
46 uint8_t ParamType[MaxAtomicIntrinsicsParameters];
47
48 Function *getDeclaration(Module *M) const {
49 return Intrinsic::getDeclaration(
50 M, ID, ArrayRef<Type *>(&OverloadedType, Overloaded ? 1 : 0));
51 }
52 };
53
54 AtomicIntrinsics(LLVMContext &C);
55 ~AtomicIntrinsics() {}
56
57 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
58 public:
59 const_iterator(const AtomicIntrinsic *I) : I(I) {}
60 ~const_iterator() {}
61 const_iterator(const const_iterator &rhs) : I(rhs.I) {}
62 const_iterator &operator=(const const_iterator &rhs) {
63 I = rhs.I;
64 return *this;
65 }
66 void operator++() { ++I; }
67 bool operator!=(const const_iterator &rhs) { return I != rhs.I; }
68 const AtomicIntrinsic *operator->() const { return I; }
69
70 private:
71 const AtomicIntrinsic *I;
72 const_iterator() LLVM_DELETED_FUNCTION;
73 friend class AtomicIntrinsics;
74 };
75
76 // Iterator through all ID+Type overloads.
77 const_iterator begin() const;
78 const_iterator end() const;
79
80 // Iterator through all Type overloads for a single ID.
81 const_iterator begin(Intrinsic::ID ID) const;
82 const_iterator end(Intrinsic::ID ID) const;
83
84 const_iterator find(Intrinsic::ID ID, Type *OverloadedType) const;
85
86 private:
87 AtomicIntrinsic I[NumAtomicIntrinsics][NumAtomicIntrinsicTypes];
88
89 AtomicIntrinsics() LLVM_DELETED_FUNCTION;
90 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
91 AtomicIntrinsics &operator=(const AtomicIntrinsics &) LLVM_DELETED_FUNCTION;
92 };
93
94 // Operations that can be represented by the @llvm.nacl.atomic.rmw
95 // intrinsic.
96 //
97 // Do not reorder these values: their order offers forward compatibility
98 // of bitcode targeted to NaCl.
99 enum AtomicRMWOperation {
100 AtomicInvalid = 0, // Invalid, keep first.
101 AtomicAdd,
102 AtomicSub,
103 AtomicOr,
104 AtomicAnd,
105 AtomicXor,
106 AtomicExchange,
107 AtomicNum // Invalid, keep last.
108 };
109
110 // Memory orderings supported by C11/C++11.
111 //
112 // Do not reorder these values: their order offers forward compatibility
113 // of bitcode targeted to NaCl.
114 enum MemoryOrder {
115 MemoryOrderInvalid = 0, // Invalid, keep first.
116 MemoryOrderRelaxed,
117 MemoryOrderConsume,
118 MemoryOrderAcquire,
119 MemoryOrderRelease,
120 MemoryOrderAcquireRelease,
121 MemoryOrderSequentiallyConsistent,
122 MemoryOrderNum // Invalid, keep last.
123 };
124
125 } // End NaCl namespace
126
127 } // End llvm namespace
128
129 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698