llvm.org GIT mirror llvm / 5c332db
Add ArrayRef constructor from None, and do the cleanups that this constructor enables Patch by Robert Wilhelm. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181138 91177308-0d34-0410-b5e6-96231b3b80d8 Dmitri Gribenko 7 years ago
21 changed file(s) with 48 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
99 #ifndef LLVM_ADT_ARRAYREF_H
1010 #define LLVM_ADT_ARRAYREF_H
1111
12 #include "llvm/ADT/None.h"
1213 #include "llvm/ADT/SmallVector.h"
1314 #include
1415
4748
4849 /// Construct an empty ArrayRef.
4950 /*implicit*/ ArrayRef() : Data(0), Length(0) {}
51
52 /// Construct an empty ArrayRef from None.
53 /*implicit*/ ArrayRef(NoneType) : Data(0), Length(0) {}
5054
5155 /// Construct an ArrayRef from a single element.
5256 /*implicit*/ ArrayRef(const T &OneElt)
173177 public:
174178 typedef T *iterator;
175179
176 /// Construct an empty ArrayRef.
180 /// Construct an empty MutableArrayRef.
177181 /*implicit*/ MutableArrayRef() : ArrayRef() {}
182
183 /// Construct an empty MutableArrayRef from None.
184 /*implicit*/ MutableArrayRef(NoneType) : ArrayRef() {}
178185
179186 /// Construct an MutableArrayRef from a single element.
180187 /*implicit*/ MutableArrayRef(T &OneElt) : ArrayRef(OneElt) {}
195195 /// allocator. These registers should not be split into new intervals
196196 /// as currently those new intervals are not guaranteed to spill.
197197 void eliminateDeadDefs(SmallVectorImpl &Dead,
198 ArrayRef RegsBeingSpilled
199 = ArrayRef());
198 ArrayRef RegsBeingSpilled = None);
200199
201200 /// calculateRegClassAndHint - Recompute register class and hint for each new
202201 /// register.
262262 /// trace. Likewise, extra resources required by the specified scheduling
263263 /// classes are included. For the caller to account for extra machine
264264 /// instructions, it must first resolve each instruction's scheduling class.
265 unsigned getResourceLength(ArrayRef Extrablocks =
266 ArrayRef(),
267 ArrayRef ExtraInstrs =
268 ArrayRef()) const;
265 unsigned getResourceLength(
266 ArrayRef Extrablocks = None,
267 ArrayRef ExtraInstrs = None) const;
269268
270269 /// Return the length of the (data dependency) critical path through the
271270 /// trace.
4444
4545 /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as
4646 /// "llvm.ppc.altivec.lvx".
47 std::string getName(ID id, ArrayRef Tys = ArrayRef());
48
47 std::string getName(ID id, ArrayRef Tys = None);
48
4949 /// Intrinsic::getType(ID) - Return the function type for an intrinsic.
5050 ///
5151 FunctionType *getType(LLVMContext &Context, ID id,
52 ArrayRef Tys = ArrayRef());
52 ArrayRef Tys = None);
5353
5454 /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be
5555 /// overloaded.
6666 /// using iAny, fAny, vAny, or iPTRAny). For a declaration of an overloaded
6767 /// intrinsic, Tys must provide exactly one type for each overloaded type in
6868 /// the intrinsic.
69 Function *getDeclaration(Module *M, ID id,
70 ArrayRef Tys = ArrayRef());
69 Function *getDeclaration(Module *M, ID id, ArrayRef Tys = None);
7170
7271 /// Map a GCC builtin name to an intrinsic ID.
7372 ID getIntrinsicForGCCBuiltin(const char *Prefix, const char *BuiltinName);
121121 ///
122122 /// \return The return value is true, if warnings are fatal.
123123 virtual bool Warning(SMLoc L, const Twine &Msg,
124 ArrayRef Ranges = ArrayRef()) = 0;
124 ArrayRef Ranges = None) = 0;
125125
126126 /// Error - Emit an error at the location \p L, with the message \p Msg.
127127 ///
128128 /// \return The return value is always true, as an idiomatic convenience to
129129 /// clients.
130130 virtual bool Error(SMLoc L, const Twine &Msg,
131 ArrayRef Ranges = ArrayRef()) = 0;
131 ArrayRef Ranges = None) = 0;
132132
133133 /// Lex - Get the next AsmToken in the stream, possibly handling file
134134 /// inclusion first.
138138 const AsmToken &getTok();
139139
140140 /// \brief Report an error at the current lexer location.
141 bool TokError(const Twine &Msg,
142 ArrayRef Ranges = ArrayRef());
141 bool TokError(const Twine &Msg, ArrayRef Ranges = None);
143142
144143 /// parseIdentifier - Parse an identifier or string (as a quoted identifier)
145144 /// and set \p Res to the identifier contents.
144144 /// @param ShowColors - Display colored messages if output is a terminal and
145145 /// the default error handler is used.
146146 void PrintMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg,
147 ArrayRef Ranges = ArrayRef(),
148 ArrayRefFixIt> FixIts = ArrayRef(),
147 ArrayRefRange> Ranges = None,
148 ArrayRef FixIts = None,
149149 bool ShowColors = true) const;
150150
151151
154154 ///
155155 /// @param Msg If non-null, the kind of message (e.g., "error") which is
156156 /// prefixed to the message.
157 SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg,
158 ArrayRef Ranges = ArrayRef(),
159 ArrayRef FixIts = ArrayRef()) const;
157 SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg,
158 ArrayRef Ranges = None,
159 ArrayRef FixIts = None) const;
160160
161161 /// PrintIncludeStack - Prints the names of included files and the line of the
162162 /// file they were included from. A diagnostic handler can use this before
226226 int Line, int Col, SourceMgr::DiagKind Kind,
227227 StringRef Msg, StringRef LineStr,
228228 ArrayRef > Ranges,
229 ArrayRef FixIts = ArrayRef());
229 ArrayRef FixIts = None);
230230
231231 const SourceMgr *getSourceMgr() const { return SM; }
232232 SMLoc getLoc() const { return Loc; }
527527 if (Result) return false;
528528
529529 // Otherwise, create MDNode forward reference.
530 MDNode *FwdNode = MDNode::getTemporary(Context, ArrayRef());
530 MDNode *FwdNode = MDNode::getTemporary(Context, None);
531531 ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc());
532532
533533 if (NumberedMetadata.size() <= MID)
404404 }
405405
406406 // Create and return a placeholder, which will later be RAUW'd.
407 Value *V = MDNode::getTemporary(Context, ArrayRef());
407 Value *V = MDNode::getTemporary(Context, None);
408408 MDValuePtrs[Idx] = V;
409409 return V;
410410 }
52515251 MachineSDNode *
52525252 SelectionDAG::getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT) {
52535253 SDVTList VTs = getVTList(VT);
5254 return getMachineNode(Opcode, dl, VTs, ArrayRef());
5254 return getMachineNode(Opcode, dl, VTs, None);
52555255 }
52565256
52575257 MachineSDNode *
52875287 MachineSDNode *
52885288 SelectionDAG::getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2) {
52895289 SDVTList VTs = getVTList(VT1, VT2);
5290 return getMachineNode(Opcode, dl, VTs, ArrayRef());
5290 return getMachineNode(Opcode, dl, VTs, None);
52915291 }
52925292
52935293 MachineSDNode *
6969
7070 // Debugging level for shrink wrapping.
7171 enum ShrinkWrapDebugLevel {
72 None, BasicInfo, Iterations, Details
72 Disabled, BasicInfo, Iterations, Details
7373 };
7474
7575 static cl::opt
7676 ShrinkWrapDebugging("shrink-wrap-dbg", cl::Hidden,
7777 cl::desc("Print shrink wrapping debugging information"),
7878 cl::values(
79 clEnumVal(None , "disable debug output"),
79 clEnumVal(Disabled , "disable debug output"),
8080 clEnumVal(BasicInfo , "print basic DF sets"),
8181 clEnumVal(Iterations, "print SR sets for each iteration"),
8282 clEnumVal(Details , "print all DF sets"),
317317 ArrayRef ops,
318318 unsigned short flags = 0,
319319 unsigned short optionalflags = 0,
320 ArrayRef inds = ArrayRef())
320 ArrayRef inds = None)
321321 : opcode(opc), subclassoptionaldata(optionalflags), subclassdata(flags),
322322 operands(ops.begin(), ops.end()), indices(inds.begin(), inds.end()) {}
323323 uint8_t opcode;
4141
4242 // Different debug levels that can be enabled...
4343 enum PassDebugLevel {
44 None, Arguments, Structure, Executions, Details
44 Disabled, Arguments, Structure, Executions, Details
4545 };
4646
4747 static cl::opt
4848 PassDebugging("debug-pass", cl::Hidden,
4949 cl::desc("Print PassManager debugging information"),
5050 cl::values(
51 clEnumVal(None , "disable debug output"),
51 clEnumVal(Disabled , "disable debug output"),
5252 clEnumVal(Arguments , "print pass arguments to pass to 'opt'"),
5353 clEnumVal(Structure , "print pass structure before run()"),
5454 clEnumVal(Executions, "print pass name before it is executed"),
379379 }
380380
381381 FunctionType *FunctionType::get(Type *Result, bool isVarArg) {
382 return get(Result, ArrayRef(), isVarArg);
382 return get(Result, None, isVarArg);
383383 }
384384
385385 /// isValidReturnType - Return true if the specified type is valid as a return
498498 }
499499
500500 StructType *StructType::get(LLVMContext &Context, bool isPacked) {
501 return get(Context, llvm::ArrayRef(), isPacked);
501 return get(Context, None, isPacked);
502502 }
503503
504504 StructType *StructType::get(Type *type, ...) {
200200 }
201201
202202 virtual bool Warning(SMLoc L, const Twine &Msg,
203 ArrayRef Ranges = ArrayRef());
203 ArrayRef Ranges = None);
204204 virtual bool Error(SMLoc L, const Twine &Msg,
205 ArrayRef Ranges = ArrayRef());
205 ArrayRef Ranges = None);
206206
207207 virtual const AsmToken &Lex();
208208
285285
286286 void PrintMacroInstantiations();
287287 void PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Msg,
288 ArrayRef Ranges = ArrayRef()) const {
288 ArrayRef Ranges = None) const {
289289 SrcMgr.PrintMessage(Loc, Kind, Msg, Ranges);
290290 }
291291 static void DiagHandler(const SMDiagnostic &Diag, void *Context);
259259 Token getNext();
260260
261261 void printError(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Message,
262 ArrayRef Ranges = ArrayRef()) {
262 ArrayRef Ranges = None) {
263263 SM.PrintMessage(Loc, Kind, Message, Ranges);
264264 }
265265
8585 MCAsmLexer &getLexer() const { return Parser.getLexer(); }
8686
8787 bool Warning(SMLoc L, const Twine &Msg,
88 ArrayRef Ranges = ArrayRef()) {
88 ArrayRef Ranges = None) {
8989 return Parser.Warning(L, Msg, Ranges);
9090 }
9191 bool Error(SMLoc L, const Twine &Msg,
92 ArrayRef Ranges = ArrayRef()) {
92 ArrayRef Ranges = None) {
9393 return Parser.Error(L, Msg, Ranges);
9494 }
9595
476476 MCAsmLexer &getLexer() const { return Parser.getLexer(); }
477477
478478 bool Error(SMLoc L, const Twine &Msg,
479 ArrayRef Ranges = ArrayRef(),
479 ArrayRef Ranges = None,
480480 bool MatchingInlineAsm = false) {
481481 if (MatchingInlineAsm) return true;
482482 return Parser.Error(L, Msg, Ranges);
22032203 assert(!Operands.empty() && "Unexpect empty operand list!");
22042204 X86Operand *Op = static_cast(Operands[0]);
22052205 assert(Op->isToken() && "Leading operand should always be a mnemonic!");
2206 ArrayRef EmptyRanges = ArrayRef();
2206 ArrayRef EmptyRanges = None;
22072207
22082208 // First, handle aliases that expand to multiple instructions.
22092209 // FIXME: This should be replaced with a real .td file alias mechanism.
14821482 Module *M = II->getParent()->getParent()->getParent();
14831483 Function *F = Intrinsic::getDeclaration(M, Intrinsic::donothing);
14841484 InvokeInst::Create(F, II->getNormalDest(), II->getUnwindDest(),
1485 ArrayRef(), "", II->getParent());
1485 None, "", II->getParent());
14861486 }
14871487 return EraseInstFromFunction(MI);
14881488 }
14711471 CallInst *NewCall =
14721472 CallInst::Create(getReleaseCallee(F.getParent()),
14731473 Call->getArgOperand(0), "", Call);
1474 NewCall->setMetadata(ImpreciseReleaseMDKind,
1475 MDNode::get(C, ArrayRef()));
1474 NewCall->setMetadata(ImpreciseReleaseMDKind, MDNode::get(C, None));
14761475
14771476 DEBUG(dbgs() << "Replacing autorelease{,RV}(x) with objc_release(x) "
14781477 "since x is otherwise unused.\nOld: " << *Call << "\nNew: "
5656 return VM[V] = const_cast(V);
5757
5858 // Create a dummy node in case we have a metadata cycle.
59 MDNode *Dummy = MDNode::getTemporary(V->getContext(), ArrayRef());
59 MDNode *Dummy = MDNode::getTemporary(V->getContext(), None);
6060 VM[V] = Dummy;
6161
6262 // Check all operands to see if any need to be remapped.
12301230
12311231 // Mark the old scalar loop with metadata that tells us not to vectorize this
12321232 // loop again if we run into it.
1233 MDNode *MD = MDNode::get(OldBasicBlock->getContext(), ArrayRef());
1233 MDNode *MD = MDNode::get(OldBasicBlock->getContext(), None);
12341234 OldBasicBlock->getTerminator()->setMetadata(AlreadyVectorizedMDName, MD);
12351235
12361236 // Some loops have a single integer induction variable, while other loops