OLD | NEW |
---|---|
(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 | |
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 { | |
24 | |
25 static const size_t NumAtomicIntrinsics = 5; | |
26 static const size_t NumAtomicIntrinsicTypes = 4; | |
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 // 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 View allIntrinsicsAndOverloads() const; | |
eliben
2013/07/03 21:31:05
Add comments that explain what each of these metho
| |
62 View overloadsFor(Intrinsic::ID ID) const; | |
63 const AtomicIntrinsic *find(Intrinsic::ID ID, Type *OverloadedType) const; | |
64 | |
65 private: | |
66 AtomicIntrinsic I[NumAtomicIntrinsics][NumAtomicIntrinsicTypes]; | |
67 | |
68 AtomicIntrinsics() LLVM_DELETED_FUNCTION; | |
69 AtomicIntrinsics(const AtomicIntrinsics &) LLVM_DELETED_FUNCTION; | |
70 AtomicIntrinsics &operator=(const AtomicIntrinsics &) LLVM_DELETED_FUNCTION; | |
71 }; | |
72 | |
73 // Operations that can be represented by the @llvm.nacl.atomic.rmw | |
74 // intrinsic. | |
75 // | |
76 // Do not reorder these values: their order offers forward compatibility | |
77 // of bitcode targeted to NaCl. | |
78 enum AtomicRMWOperation { | |
79 AtomicInvalid = 0, // Invalid, keep first. | |
80 AtomicAdd, | |
81 AtomicSub, | |
82 AtomicOr, | |
83 AtomicAnd, | |
84 AtomicXor, | |
85 AtomicExchange, | |
86 AtomicNum // Invalid, keep last. | |
87 }; | |
88 | |
89 // Memory orderings supported by C11/C++11. | |
90 // | |
91 // Do not reorder these values: their order offers forward compatibility | |
92 // of bitcode targeted to NaCl. | |
93 enum MemoryOrder { | |
94 MemoryOrderInvalid = 0, // Invalid, keep first. | |
95 MemoryOrderRelaxed, | |
96 MemoryOrderConsume, | |
97 MemoryOrderAcquire, | |
98 MemoryOrderRelease, | |
99 MemoryOrderAcquireRelease, | |
100 MemoryOrderSequentiallyConsistent, | |
101 MemoryOrderNum // Invalid, keep last. | |
102 }; | |
103 | |
104 } // End NaCl namespace | |
105 | |
106 } // End llvm namespace | |
107 | |
108 #endif | |
OLD | NEW |