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

Side by Side Diff: include/llvm/IR/NaClAtomicIntrinsics.h

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 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
« no previous file with comments | « include/llvm/IR/Intrinsics.td ('k') | include/llvm/IRReader/IRReader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===-- llvm/IR/NaClAtomicIntrinsics.h - NaCl Atomic 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 atomic intrinsic functions that are specific to NaCl.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_IR_NACL_ATOMIC_INTRINSICS_H
15 #define LLVM_IR_NACL_ATOMIC_INTRINSICS_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 {
24
25 static const size_t NumAtomicIntrinsics = 6;
26 static const size_t NumAtomicIntrinsicOverloadTypes = 4;
27 static const size_t MaxAtomicIntrinsicsParameters = 5;
28
29 /// Describe all the atomic intrinsics and their type signature. Most
30 /// can 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 // The atomic intrinsic can be overloaded on zero or one type,
50 // which is needed to create the function's declaration.
51 return Intrinsic::getDeclaration(
52 M, ID, ArrayRef<Type *>(&OverloadedType, Overloaded ? 1 : 0));
53 }
54 };
55
56 AtomicIntrinsics(LLVMContext &C);
57 ~AtomicIntrinsics() {}
58
59 typedef ArrayRef<AtomicIntrinsic> View;
60
61 /// Access all atomic intrinsics, which can then be iterated over.
62 View allIntrinsicsAndOverloads() const;
63 /// Access a particular atomic intrinsic.
64 /// \returns 0 if no intrinsic was found.
65 const AtomicIntrinsic *find(Intrinsic::ID ID, Type *OverloadedType) const;
66
67 private:
68 AtomicIntrinsic I[NumAtomicIntrinsics][NumAtomicIntrinsicOverloadTypes];
69
70 AtomicIntrinsics() LLVM_DELETED_FUNCTION;
71 AtomicIntrinsics(const AtomicIntrinsics &) LLVM_DELETED_FUNCTION;
72 AtomicIntrinsics &operator=(const AtomicIntrinsics &) LLVM_DELETED_FUNCTION;
73 };
74
75 /// Operations that can be represented by the @llvm.nacl.atomic.rmw
76 /// intrinsic.
77 ///
78 /// Do not reorder these values: their order offers forward
79 /// compatibility of bitcode targeted to NaCl.
80 enum AtomicRMWOperation {
81 AtomicInvalid = 0, // Invalid, keep first.
82 AtomicAdd,
83 AtomicSub,
84 AtomicOr,
85 AtomicAnd,
86 AtomicXor,
87 AtomicExchange,
88 AtomicNum // Invalid, keep last.
89 };
90
91 /// Memory orderings supported by C11/C++11.
92 ///
93 /// Do not reorder these values: their order offers forward
94 /// compatibility of bitcode targeted to NaCl.
95 enum MemoryOrder {
96 MemoryOrderInvalid = 0, // Invalid, keep first.
97 MemoryOrderRelaxed,
98 MemoryOrderConsume,
99 MemoryOrderAcquire,
100 MemoryOrderRelease,
101 MemoryOrderAcquireRelease,
102 MemoryOrderSequentiallyConsistent,
103 MemoryOrderNum // Invalid, keep last.
104 };
105
106 } // End NaCl namespace
107
108 } // End llvm namespace
109
110 #endif
OLDNEW
« no previous file with comments | « include/llvm/IR/Intrinsics.td ('k') | include/llvm/IRReader/IRReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698