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

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: 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
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 // This file declares the kinds of intrinsics supported by PNaCl.
(...skipping 13 matching lines...) Expand all
24 static const size_t kMaxIntrinsicParameters = 6; 24 static const size_t kMaxIntrinsicParameters = 6;
25 25
26 class Intrinsics { 26 class Intrinsics {
27 Intrinsics(const Intrinsics &) = delete; 27 Intrinsics(const Intrinsics &) = delete;
28 Intrinsics &operator=(const Intrinsics &) = delete; 28 Intrinsics &operator=(const Intrinsics &) = delete;
29 29
30 public: 30 public:
31 Intrinsics(); 31 Intrinsics();
32 ~Intrinsics(); 32 ~Intrinsics();
33 33
34 // Some intrinsics allow overloading by type. This enum collapses all 34 /// 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 35 /// 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. 36 /// type of the intrinsic function call's return value and parameters.
37 enum IntrinsicID { 37 enum IntrinsicID {
38 UnknownIntrinsic = 0, 38 UnknownIntrinsic = 0,
39 // Arbitrary (alphabetical) order. 39 // Arbitrary (alphabetical) order.
40 AtomicCmpxchg, 40 AtomicCmpxchg,
41 AtomicFence, 41 AtomicFence,
42 AtomicFenceAll, 42 AtomicFenceAll,
43 AtomicIsLockFree, 43 AtomicIsLockFree,
44 AtomicLoad, 44 AtomicLoad,
45 AtomicRMW, 45 AtomicRMW,
46 AtomicStore, 46 AtomicStore,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 MemoryOrderInvalid = 0, // Invalid, keep first. 85 MemoryOrderInvalid = 0, // Invalid, keep first.
86 MemoryOrderRelaxed, 86 MemoryOrderRelaxed,
87 MemoryOrderConsume, 87 MemoryOrderConsume,
88 MemoryOrderAcquire, 88 MemoryOrderAcquire,
89 MemoryOrderRelease, 89 MemoryOrderRelease,
90 MemoryOrderAcquireRelease, 90 MemoryOrderAcquireRelease,
91 MemoryOrderSequentiallyConsistent, 91 MemoryOrderSequentiallyConsistent,
92 MemoryOrderNum // Invalid, keep last. 92 MemoryOrderNum // Invalid, keep last.
93 }; 93 };
94 94
95 // Verify memory ordering rules for atomic intrinsics. For 95 /// Verify memory ordering rules for atomic intrinsics. For
96 // AtomicCmpxchg, Order is the "success" ordering and OrderOther is 96 /// AtomicCmpxchg, Order is the "success" ordering and OrderOther is
97 // the "failure" ordering. Returns true if valid, false if invalid. 97 /// the "failure" ordering. Returns true if valid, false if invalid.
98 // TODO(stichnot,kschimpf): Perform memory order validation in the 98 // TODO(stichnot,kschimpf): Perform memory order validation in the
99 // bitcode reader/parser, allowing LLVM and Subzero to share. See 99 // bitcode reader/parser, allowing LLVM and Subzero to share. See
100 // https://code.google.com/p/nativeclient/issues/detail?id=4126 . 100 // https://code.google.com/p/nativeclient/issues/detail?id=4126 .
101 static bool isMemoryOrderValid(IntrinsicID ID, uint64_t Order, 101 static bool isMemoryOrderValid(IntrinsicID ID, uint64_t Order,
102 uint64_t OrderOther = MemoryOrderInvalid); 102 uint64_t OrderOther = MemoryOrderInvalid);
103 103
104 enum SideEffects { SideEffects_F = 0, SideEffects_T = 1 }; 104 enum SideEffects { SideEffects_F = 0, SideEffects_T = 1 };
105 105
106 enum ReturnsTwice { ReturnsTwice_F = 0, ReturnsTwice_T = 1 }; 106 enum ReturnsTwice { ReturnsTwice_F = 0, ReturnsTwice_T = 1 };
107 107
108 // Basic attributes related to each intrinsic, that are relevant to 108 // Basic attributes related to each intrinsic, that are relevant to
jvoung (off chromium) 2015/06/30 22:05:48 Useful to /// ?
ascull 2015/07/06 19:29:09 Done.
109 // code generation. Perhaps the attributes representation can be shared 109 // code generation. Perhaps the attributes representation can be shared
110 // with general function calls, but PNaCl currently strips all 110 // with general function calls, but PNaCl currently strips all
111 // attributes from functions. 111 // attributes from functions.
112 struct IntrinsicInfo { 112 struct IntrinsicInfo {
113 enum IntrinsicID ID : 30; 113 enum IntrinsicID ID : 30;
114 enum SideEffects HasSideEffects : 1; 114 enum SideEffects HasSideEffects : 1;
115 enum ReturnsTwice ReturnsTwice : 1; 115 enum ReturnsTwice ReturnsTwice : 1;
116 }; 116 };
117 117
118 // The types of validation values for FullIntrinsicInfo.validateCall. 118 /// The types of validation values for FullIntrinsicInfo.validateCall.
119 enum ValidateCallValue { 119 enum ValidateCallValue {
120 IsValidCall, // Valid use of instrinsic call. 120 IsValidCall, // Valid use of instrinsic call.
Karl 2015/07/06 18:08:48 Maybe add /// here to? These comments appear to be
ascull 2015/07/06 19:29:09 Done.
121 BadReturnType, // Return type invalid for intrinsic. 121 BadReturnType, // Return type invalid for intrinsic.
122 WrongNumOfArgs, // Wrong number of arguments for intrinsic. 122 WrongNumOfArgs, // Wrong number of arguments for intrinsic.
123 WrongCallArgType, // Argument of wrong type. 123 WrongCallArgType, // Argument of wrong type.
124 }; 124 };
125 125
126 // The complete set of information about an intrinsic. 126 /// The complete set of information about an intrinsic.
127 struct FullIntrinsicInfo { 127 struct FullIntrinsicInfo {
128 struct IntrinsicInfo Info; // Information that CodeGen would care about. 128 struct IntrinsicInfo Info; /// Information that CodeGen would care about.
129 129
130 // Sanity check during parsing. 130 // Sanity check during parsing.
131 Type Signature[kMaxIntrinsicParameters]; 131 Type Signature[kMaxIntrinsicParameters];
132 uint8_t NumTypes; 132 uint8_t NumTypes;
133 133
134 // Validates that type signature of call matches intrinsic. 134 /// Validates that type signature of call matches intrinsic.
135 // If WrongArgumentType is returned, ArgIndex is set to corresponding 135 /// If WrongArgumentType is returned, ArgIndex is set to corresponding
136 // argument index. 136 /// argument index.
137 ValidateCallValue validateCall(const Ice::InstCall *Call, 137 ValidateCallValue validateCall(const Ice::InstCall *Call,
138 SizeT &ArgIndex) const; 138 SizeT &ArgIndex) const;
139 139
140 // Returns the return type of the intrinsic. 140 /// Returns the return type of the intrinsic.
141 Type getReturnType() const { 141 Type getReturnType() const {
142 assert(NumTypes > 1); 142 assert(NumTypes > 1);
143 return Signature[0]; 143 return Signature[0];
144 } 144 }
145 145
146 // Returns number of arguments expected. 146 /// Returns number of arguments expected.
147 SizeT getNumArgs() const { 147 SizeT getNumArgs() const {
148 assert(NumTypes > 1); 148 assert(NumTypes > 1);
149 return NumTypes - 1; 149 return NumTypes - 1;
150 } 150 }
151 151
152 // Returns type of Index-th argument. 152 /// Returns type of Index-th argument.
153 Type getArgType(SizeT Index) const; 153 Type getArgType(SizeT Index) const;
154 }; 154 };
155 155
156 // Find the information about a given intrinsic, based on function name. If 156 /// 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 157 /// 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 158 /// 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 159 /// 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 160 /// 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" 161 /// Error to true and returns nullptr (indicating an unknown "llvm.foo"
162 // intrinsic). 162 /// intrinsic).
163 const FullIntrinsicInfo *find(const IceString &Name, bool &Error) const; 163 const FullIntrinsicInfo *find(const IceString &Name, bool &Error) const;
164 164
165 private: 165 private:
166 // TODO(jvoung): May want to switch to something like LLVM's StringMap. 166 // TODO(jvoung): May want to switch to something like LLVM's StringMap.
167 typedef std::map<IceString, FullIntrinsicInfo> IntrinsicMap; 167 typedef std::map<IceString, FullIntrinsicInfo> IntrinsicMap;
168 IntrinsicMap Map; 168 IntrinsicMap Map;
169 }; 169 };
170 170
171 } // end of namespace Ice 171 } // end of namespace Ice
172 172
173 #endif // SUBZERO_SRC_ICEINTRINSICS_H 173 #endif // SUBZERO_SRC_ICEINTRINSICS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698