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

Side by Side Diff: src/IceIntrinsics.h

Issue 1216963007: Doxygenize the documentation comments (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase to master Created 5 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
« no previous file with comments | « src/IceInstX8632.cpp ('k') | src/IceIntrinsics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceIntrinsics.h - List of Ice Intrinsics -----*- C++ -*-===// 1 //===- subzero/src/IceIntrinsics.h - List of Ice Intrinsics -----*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 ///
10 // This file declares the kinds of intrinsics supported by PNaCl. 10 /// \file
11 // 11 /// This file declares the kinds of intrinsics supported by PNaCl.
12 ///
12 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
13 14
14 #ifndef SUBZERO_SRC_ICEINTRINSICS_H 15 #ifndef SUBZERO_SRC_ICEINTRINSICS_H
15 #define SUBZERO_SRC_ICEINTRINSICS_H 16 #define SUBZERO_SRC_ICEINTRINSICS_H
16 17
17 #include "IceDefs.h" 18 #include "IceDefs.h"
18 #include "IceTypes.h" 19 #include "IceTypes.h"
19 20
20 namespace Ice { 21 namespace Ice {
21 22
22 class InstCall; 23 class InstCall;
23 24
24 static const size_t kMaxIntrinsicParameters = 6; 25 static const size_t kMaxIntrinsicParameters = 6;
25 26
26 class Intrinsics { 27 class Intrinsics {
27 Intrinsics(const Intrinsics &) = delete; 28 Intrinsics(const Intrinsics &) = delete;
28 Intrinsics &operator=(const Intrinsics &) = delete; 29 Intrinsics &operator=(const Intrinsics &) = delete;
29 30
30 public: 31 public:
31 Intrinsics(); 32 Intrinsics();
32 ~Intrinsics(); 33 ~Intrinsics();
33 34
34 // Some intrinsics allow overloading by type. This enum collapses all 35 /// Some intrinsics allow overloading by type. This enum collapses all
35 // overloads into a single ID, but the type can still be recovered by the 36 /// overloads into a single ID, but the type can still be recovered by the
36 // type of the intrinsic function call's return value and parameters. 37 /// type of the intrinsic function call's return value and parameters.
37 enum IntrinsicID { 38 enum IntrinsicID {
38 UnknownIntrinsic = 0, 39 UnknownIntrinsic = 0,
39 // Arbitrary (alphabetical) order. 40 // Arbitrary (alphabetical) order.
40 AtomicCmpxchg, 41 AtomicCmpxchg,
41 AtomicFence, 42 AtomicFence,
42 AtomicFenceAll, 43 AtomicFenceAll,
43 AtomicIsLockFree, 44 AtomicIsLockFree,
44 AtomicLoad, 45 AtomicLoad,
45 AtomicRMW, 46 AtomicRMW,
46 AtomicStore, 47 AtomicStore,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 MemoryOrderInvalid = 0, // Invalid, keep first. 86 MemoryOrderInvalid = 0, // Invalid, keep first.
86 MemoryOrderRelaxed, 87 MemoryOrderRelaxed,
87 MemoryOrderConsume, 88 MemoryOrderConsume,
88 MemoryOrderAcquire, 89 MemoryOrderAcquire,
89 MemoryOrderRelease, 90 MemoryOrderRelease,
90 MemoryOrderAcquireRelease, 91 MemoryOrderAcquireRelease,
91 MemoryOrderSequentiallyConsistent, 92 MemoryOrderSequentiallyConsistent,
92 MemoryOrderNum // Invalid, keep last. 93 MemoryOrderNum // Invalid, keep last.
93 }; 94 };
94 95
95 // Verify memory ordering rules for atomic intrinsics. For 96 /// Verify memory ordering rules for atomic intrinsics. For
96 // AtomicCmpxchg, Order is the "success" ordering and OrderOther is 97 /// AtomicCmpxchg, Order is the "success" ordering and OrderOther is
97 // the "failure" ordering. Returns true if valid, false if invalid. 98 /// the "failure" ordering. Returns true if valid, false if invalid.
98 // TODO(stichnot,kschimpf): Perform memory order validation in the 99 // TODO(stichnot,kschimpf): Perform memory order validation in the
99 // bitcode reader/parser, allowing LLVM and Subzero to share. See 100 // bitcode reader/parser, allowing LLVM and Subzero to share. See
100 // https://code.google.com/p/nativeclient/issues/detail?id=4126 . 101 // https://code.google.com/p/nativeclient/issues/detail?id=4126 .
101 static bool isMemoryOrderValid(IntrinsicID ID, uint64_t Order, 102 static bool isMemoryOrderValid(IntrinsicID ID, uint64_t Order,
102 uint64_t OrderOther = MemoryOrderInvalid); 103 uint64_t OrderOther = MemoryOrderInvalid);
103 104
104 enum SideEffects { SideEffects_F = 0, SideEffects_T = 1 }; 105 enum SideEffects { SideEffects_F = 0, SideEffects_T = 1 };
105 106
106 enum ReturnsTwice { ReturnsTwice_F = 0, ReturnsTwice_T = 1 }; 107 enum ReturnsTwice { ReturnsTwice_F = 0, ReturnsTwice_T = 1 };
107 108
108 // Basic attributes related to each intrinsic, that are relevant to 109 /// Basic attributes related to each intrinsic, that are relevant to
109 // code generation. Perhaps the attributes representation can be shared 110 /// code generation. Perhaps the attributes representation can be shared
110 // with general function calls, but PNaCl currently strips all 111 /// with general function calls, but PNaCl currently strips all
111 // attributes from functions. 112 /// attributes from functions.
112 struct IntrinsicInfo { 113 struct IntrinsicInfo {
113 enum IntrinsicID ID : 30; 114 enum IntrinsicID ID : 30;
114 enum SideEffects HasSideEffects : 1; 115 enum SideEffects HasSideEffects : 1;
115 enum ReturnsTwice ReturnsTwice : 1; 116 enum ReturnsTwice ReturnsTwice : 1;
116 }; 117 };
117 118
118 // The types of validation values for FullIntrinsicInfo.validateCall. 119 /// The types of validation values for FullIntrinsicInfo.validateCall.
119 enum ValidateCallValue { 120 enum ValidateCallValue {
120 IsValidCall, // Valid use of instrinsic call. 121 IsValidCall, /// Valid use of instrinsic call.
121 BadReturnType, // Return type invalid for intrinsic. 122 BadReturnType, /// Return type invalid for intrinsic.
122 WrongNumOfArgs, // Wrong number of arguments for intrinsic. 123 WrongNumOfArgs, /// Wrong number of arguments for intrinsic.
123 WrongCallArgType, // Argument of wrong type. 124 WrongCallArgType, /// Argument of wrong type.
124 }; 125 };
125 126
126 // The complete set of information about an intrinsic. 127 /// The complete set of information about an intrinsic.
127 struct FullIntrinsicInfo { 128 struct FullIntrinsicInfo {
128 struct IntrinsicInfo Info; // Information that CodeGen would care about. 129 struct IntrinsicInfo Info; /// Information that CodeGen would care about.
129 130
130 // Sanity check during parsing. 131 // Sanity check during parsing.
131 Type Signature[kMaxIntrinsicParameters]; 132 Type Signature[kMaxIntrinsicParameters];
132 uint8_t NumTypes; 133 uint8_t NumTypes;
133 134
134 // Validates that type signature of call matches intrinsic. 135 /// Validates that type signature of call matches intrinsic.
135 // If WrongArgumentType is returned, ArgIndex is set to corresponding 136 /// If WrongArgumentType is returned, ArgIndex is set to corresponding
136 // argument index. 137 /// argument index.
137 ValidateCallValue validateCall(const Ice::InstCall *Call, 138 ValidateCallValue validateCall(const Ice::InstCall *Call,
138 SizeT &ArgIndex) const; 139 SizeT &ArgIndex) const;
139 140
140 // Returns the return type of the intrinsic. 141 /// Returns the return type of the intrinsic.
141 Type getReturnType() const { 142 Type getReturnType() const {
142 assert(NumTypes > 1); 143 assert(NumTypes > 1);
143 return Signature[0]; 144 return Signature[0];
144 } 145 }
145 146
146 // Returns number of arguments expected. 147 /// Returns number of arguments expected.
147 SizeT getNumArgs() const { 148 SizeT getNumArgs() const {
148 assert(NumTypes > 1); 149 assert(NumTypes > 1);
149 return NumTypes - 1; 150 return NumTypes - 1;
150 } 151 }
151 152
152 // Returns type of Index-th argument. 153 /// Returns type of Index-th argument.
153 Type getArgType(SizeT Index) const; 154 Type getArgType(SizeT Index) const;
154 }; 155 };
155 156
156 // Find the information about a given intrinsic, based on function name. If 157 /// Find the information about a given intrinsic, based on function name. If
157 // the function name does not have the common "llvm." prefix, nullptr is 158 /// the function name does not have the common "llvm." prefix, nullptr is
158 // returned and Error is set to false. Otherwise, tries to find a reference 159 /// returned and Error is set to false. Otherwise, tries to find a reference
159 // to a FullIntrinsicInfo entry (valid for the lifetime of the map). If 160 /// to a FullIntrinsicInfo entry (valid for the lifetime of the map). If
160 // found, sets Error to false and returns the reference. If not found, sets 161 /// found, sets Error to false and returns the reference. If not found, sets
161 // Error to true and returns nullptr (indicating an unknown "llvm.foo" 162 /// Error to true and returns nullptr (indicating an unknown "llvm.foo"
162 // intrinsic). 163 /// intrinsic).
163 const FullIntrinsicInfo *find(const IceString &Name, bool &Error) const; 164 const FullIntrinsicInfo *find(const IceString &Name, bool &Error) const;
164 165
165 private: 166 private:
166 // TODO(jvoung): May want to switch to something like LLVM's StringMap. 167 // TODO(jvoung): May want to switch to something like LLVM's StringMap.
167 typedef std::map<IceString, FullIntrinsicInfo> IntrinsicMap; 168 typedef std::map<IceString, FullIntrinsicInfo> IntrinsicMap;
168 IntrinsicMap Map; 169 IntrinsicMap Map;
169 }; 170 };
170 171
171 } // end of namespace Ice 172 } // end of namespace Ice
172 173
173 #endif // SUBZERO_SRC_ICEINTRINSICS_H 174 #endif // SUBZERO_SRC_ICEINTRINSICS_H
OLDNEW
« no previous file with comments | « src/IceInstX8632.cpp ('k') | src/IceIntrinsics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698