llvm.org GIT mirror llvm / 1d475d8
[BinaryFormat, Option, TableGen] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305537 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
16 changed file(s) with 268 addition(s) and 233 deletion(s). Raw diff Collapse all Expand all
None //===-- llvm/BinaryFormat/ELF.h - ELF constants and structures --*- C++ -*-===//
0 //===- llvm/BinaryFormat/ELF.h - ELF constants and structures ---*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1919 #ifndef LLVM_BINARYFORMAT_ELF_H
2020 #define LLVM_BINARYFORMAT_ELF_H
2121
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/DataTypes.h"
22 #include
2423 #include
2524
2625 namespace llvm {
27
2826 namespace ELF {
2927
30 typedef uint32_t Elf32_Addr; // Program address
31 typedef uint32_t Elf32_Off; // File offset
32 typedef uint16_t Elf32_Half;
33 typedef uint32_t Elf32_Word;
34 typedef int32_t Elf32_Sword;
35
36 typedef uint64_t Elf64_Addr;
37 typedef uint64_t Elf64_Off;
38 typedef uint16_t Elf64_Half;
39 typedef uint32_t Elf64_Word;
40 typedef int32_t Elf64_Sword;
41 typedef uint64_t Elf64_Xword;
42 typedef int64_t Elf64_Sxword;
28 using Elf32_Addr = uint32_t; // Program address
29 using Elf32_Off = uint32_t; // File offset
30 using Elf32_Half = uint16_t;
31 using Elf32_Word = uint32_t;
32 using Elf32_Sword = int32_t;
33
34 using Elf64_Addr = uint64_t;
35 using Elf64_Off = uint64_t;
36 using Elf64_Half = uint16_t;
37 using Elf64_Word = uint32_t;
38 using Elf64_Sword = int32_t;
39 using Elf64_Xword = uint64_t;
40 using Elf64_Sxword = int64_t;
4341
4442 // Object file magic string.
4543 static const char ElfMagic[] = {0x7f, 'E', 'L', 'F', '\0'};
7472 Elf32_Half e_shentsize; // Size of an entry in the section header table
7573 Elf32_Half e_shnum; // Number of entries in the section header table
7674 Elf32_Half e_shstrndx; // Sect hdr table index of sect name string table
75
7776 bool checkMagic() const {
7877 return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0;
7978 }
79
8080 unsigned char getFileClass() const { return e_ident[EI_CLASS]; }
8181 unsigned char getDataEncoding() const { return e_ident[EI_DATA]; }
8282 };
9898 Elf64_Half e_shentsize;
9999 Elf64_Half e_shnum;
100100 Elf64_Half e_shstrndx;
101
101102 bool checkMagic() const {
102103 return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0;
103104 }
105
104106 unsigned char getFileClass() const { return e_ident[EI_CLASS]; }
105107 unsigned char getDataEncoding() const { return e_ident[EI_DATA]; }
106108 };
13561358 };
13571359
13581360 } // end namespace ELF
1359
13601361 } // end namespace llvm
13611362
1362 #endif
1363 #endif // LLVM_BINARYFORMAT_ELF_H
None //===--- Arg.h - Parsed Argument Classes ------------------------*- C++ -*-===//
0 //===- Arg.h - Parsed Argument Classes --------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2020 #include
2121
2222 namespace llvm {
23
24 class raw_ostream;
25
2326 namespace opt {
27
2428 class ArgList;
2529
2630 /// \brief A concrete instance of a particular driver option.
2832 /// The Arg class encodes just enough information to be able to
2933 /// derive the argument values efficiently.
3034 class Arg {
31 Arg(const Arg &) = delete;
32 void operator=(const Arg &) = delete;
33
3435 private:
3536 /// \brief The option this argument is an instance of.
3637 const Option Opt;
6465 const char *Value0, const Arg *BaseArg = nullptr);
6566 Arg(const Option Opt, StringRef Spelling, unsigned Index,
6667 const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
68 Arg(const Arg &) = delete;
69 Arg &operator=(const Arg &) = delete;
6770 ~Arg();
6871
6972 const Option &getOption() const { return Opt; }
8891 void claim() const { getBaseArg().Claimed = true; }
8992
9093 unsigned getNumValues() const { return Values.size(); }
94
9195 const char *getValue(unsigned N = 0) const {
9296 return Values[N];
9397 }
121125 };
122126
123127 } // end namespace opt
128
124129 } // end namespace llvm
125130
126 #endif
131 #endif // LLVM_OPTION_ARG_H
None //===--- ArgList.h - Argument List Management -------------------*- C++ -*-===//
0 //===- ArgList.h - Argument List Management ---------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
99 #ifndef LLVM_OPTION_ARGLIST_H
1010 #define LLVM_OPTION_ARGLIST_H
1111
12 #include "llvm/ADT/ArrayRef.h"
1213 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/iterator_range.h"
1315 #include "llvm/ADT/SmallString.h"
1416 #include "llvm/ADT/SmallVector.h"
1517 #include "llvm/ADT/StringRef.h"
1719 #include "llvm/Option/Arg.h"
1820 #include "llvm/Option/OptSpecifier.h"
1921 #include "llvm/Option/Option.h"
22 #include
23 #include
24 #include
25 #include
2026 #include
2127 #include
2228 #include
29 #include
2330 #include
2431
2532 namespace llvm {
33
34 class raw_ostream;
35
2636 namespace opt {
27 class ArgList;
28 class Option;
2937
3038 /// arg_iterator - Iterates through arguments stored inside an ArgList.
3139 template
5866 }
5967 }
6068
61 typedef std::iterator_traits Traits;
69 using Traits = std::iterator_traits;
6270
6371 public:
64 typedef typename Traits::value_type value_type;
65 typedef typename Traits::reference reference;
66 typedef typename Traits::pointer pointer;
67 typedef std::forward_iterator_tag iterator_category;
68 typedef std::ptrdiff_t difference_type;
72 using value_type = typename Traits::value_type;
73 using reference = typename Traits::reference;
74 using pointer = typename Traits::pointer;
75 using iterator_category = std::forward_iterator_tag;
76 using difference_type = std::ptrdiff_t;
6977
7078 arg_iterator(
7179 BaseIter Current, BaseIter End,
110118 /// and to iterate over groups of arguments.
111119 class ArgList {
112120 public:
113 typedef SmallVector arglist_type;
114 typedef arg_iterator iterator;
115 typedef arg_iterator const_iterator;
116 typedef arg_iterator reverse_iterator;
117 typedef arg_iterator
118 const_reverse_iterator;
121 using arglist_type = SmallVector;
122 using iterator = arg_iterator;
123 using const_iterator = arg_iterator;
124 using reverse_iterator = arg_iterator;
125 using const_reverse_iterator =
126 arg_iterator;
119127
120128 template using filtered_iterator =
121129 arg_iterator;
126134 /// The internal list of arguments.
127135 arglist_type Args;
128136
129 typedef std::pair OptRange;
137 using OptRange = std::pair;
130138 static OptRange emptyRange() { return {-1u, 0u}; }
131139
132140 /// The first and last index of each different OptSpecifier ID.
141149 // derived objects, but can still be used by derived objects to implement
142150 // their own special members.
143151 ArgList() = default;
152
144153 // Explicit move operations to ensure the container is cleared post-move
145154 // otherwise it could lead to a double-delete in the case of moving of an
146155 // InputArgList which deletes the contents of the container. If we could fix
151160 RHS.Args.clear();
152161 RHS.OptRanges.clear();
153162 }
163
154164 ArgList &operator=(ArgList &&RHS) {
155165 Args = std::move(RHS.Args);
156166 RHS.Args.clear();
158168 RHS.OptRanges.clear();
159169 return *this;
160170 }
171
161172 // Protect the dtor to ensure this type is never destroyed polymorphically.
162173 ~ArgList() = default;
163174
379390
380391 public:
381392 InputArgList(const char* const *ArgBegin, const char* const *ArgEnd);
393
382394 InputArgList(InputArgList &&RHS)
383395 : ArgList(std::move(RHS)), ArgStrings(std::move(RHS.ArgStrings)),
384396 SynthesizedStrings(std::move(RHS.SynthesizedStrings)),
385397 NumInputArgStrings(RHS.NumInputArgStrings) {}
398
386399 InputArgList &operator=(InputArgList &&RHS) {
387400 releaseMemory();
388401 ArgList::operator=(std::move(RHS));
391404 NumInputArgStrings = RHS.NumInputArgStrings;
392405 return *this;
393406 }
407
394408 ~InputArgList() { releaseMemory(); }
395409
396410 const char *getArgString(unsigned Index) const override {
463477 append(MakePositionalArg(BaseArg, Opt, Value));
464478 }
465479
466
467480 /// AddSeparateArg - Construct a new Positional arg for the given option
468481 /// \p Id, with the provided \p Value and append it to the argument
469482 /// list.
472485 append(MakeSeparateArg(BaseArg, Opt, Value));
473486 }
474487
475
476488 /// AddJoinedArg - Construct a new Positional arg for the given option
477489 /// \p Id, with the provided \p Value and append it to the argument list.
478490 void AddJoinedArg(const Arg *BaseArg, const Option Opt,
480492 append(MakeJoinedArg(BaseArg, Opt, Value));
481493 }
482494
483
484495 /// MakeFlagArg - Construct a new FlagArg for the given option \p Id.
485496 Arg *MakeFlagArg(const Arg *BaseArg, const Option Opt) const;
486497
503514 };
504515
505516 } // end namespace opt
517
506518 } // end namespace llvm
507519
508 #endif
520 #endif // LLVM_OPTION_ARGLIST_H
None //===--- OptSpecifier.h - Option Specifiers ---------------------*- C++ -*-===//
0 //===- OptSpecifier.h - Option Specifiers -----------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
99 #ifndef LLVM_OPTION_OPTSPECIFIER_H
1010 #define LLVM_OPTION_OPTSPECIFIER_H
1111
12 #include "llvm/Support/Compiler.h"
13
1412 namespace llvm {
1513 namespace opt {
16 class Option;
1714
18 /// OptSpecifier - Wrapper class for abstracting references to option IDs.
19 class OptSpecifier {
20 unsigned ID;
15 class Option;
2116
22 private:
23 explicit OptSpecifier(bool) = delete;
17 /// OptSpecifier - Wrapper class for abstracting references to option IDs.
18 class OptSpecifier {
19 unsigned ID = 0;
2420
25 public:
26 OptSpecifier() : ID(0) {}
27 /*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
28 /*implicit*/ OptSpecifier(const Option *Opt);
21 public:
22 OptSpecifier() = default;
23 explicit OptSpecifier(bool) = delete;
24 /*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
25 /*implicit*/ OptSpecifier(const Option *Opt);
2926
30 bool isValid() const { return ID != 0; }
27 bool isValid() const { return ID != 0; }
3128
32 unsigned getID() const { return ID; }
29 unsigned getID() const { return ID; }
3330
34 bool operator==(OptSpecifier Opt) const { return ID == Opt.getID(); }
35 bool operator!=(OptSpecifier Opt) const { return !(*this == Opt); }
36 };
37 }
38 }
31 bool operator==(OptSpecifier Opt) const { return ID == Opt.getID(); }
32 bool operator!=(OptSpecifier Opt) const { return !(*this == Opt); }
33 };
3934
40 #endif
35 } // end namespace opt
36 } // end namespace llvm
37
38 #endif // LLVM_OPTION_OPTSPECIFIER_H
None //===--- OptTable.h - Option Table ------------------------------*- C++ -*-===//
0 //===- OptTable.h - Option Table --------------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1010 #define LLVM_OPTION_OPTTABLE_H
1111
1212 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringRef.h"
1314 #include "llvm/ADT/StringSet.h"
1415 #include "llvm/Option/OptSpecifier.h"
16 #include
17 #include
18 #include
1519
1620 namespace llvm {
21
1722 class raw_ostream;
23
1824 namespace opt {
25
1926 class Arg;
2027 class ArgList;
2128 class InputArgList;
5259 ArrayRef OptionInfos;
5360 bool IgnoreCase;
5461
55 unsigned TheInputOptionID;
56 unsigned TheUnknownOptionID;
62 unsigned TheInputOptionID = 0;
63 unsigned TheUnknownOptionID = 0;
5764
5865 /// The index of the first option which can be parsed (i.e., is not a
5966 /// special option like 'input' or 'unknown', and is not an option group).
60 unsigned FirstSearchableIndex;
67 unsigned FirstSearchableIndex = 0;
6168
6269 /// The union of all option prefixes. If an argument does not begin with
6370 /// one of these, it is an input.
175182 void PrintHelp(raw_ostream &OS, const char *Name,
176183 const char *Title, bool ShowHidden = false) const;
177184 };
185
178186 } // end namespace opt
187
179188 } // end namespace llvm
180189
181 #endif
190 #endif // LLVM_OPTION_OPTTABLE_H
None //===--- Option.h - Abstract Driver Options ---------------------*- C++ -*-===//
0 //===- Option.h - Abstract Driver Options -----------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1111
1212 #include "llvm/ADT/SmallVector.h"
1313 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Option/OptSpecifier.h"
1415 #include "llvm/Option/OptTable.h"
1516 #include "llvm/Support/ErrorHandling.h"
17 #include
18 #include
1619
1720 namespace llvm {
21
22 class raw_ostream;
23
1824 namespace opt {
25
1926 class Arg;
2027 class ArgList;
28
2129 /// ArgStringList - Type used for constructing argv lists for subprocesses.
22 typedef SmallVector ArgStringList;
30 using ArgStringList = SmallVector;
2331
2432 /// Base flags for all options. Custom flags may be added after.
2533 enum DriverFlag {
201209 };
202210
203211 } // end namespace opt
212
204213 } // end namespace llvm
205214
206 #endif
215 #endif // LLVM_OPTION_OPTION_H
1515
1616 namespace llvm {
1717
18 class raw_ostream;
1819 class RecordKeeper;
19 class raw_ostream;
20
2021 /// \brief Perform the action using Records, and write output to OS.
2122 /// \returns true on error, false otherwise
22 typedef bool TableGenMainFn(raw_ostream &OS, RecordKeeper &Records);
23 using TableGenMainFn = bool (raw_ostream &OS, RecordKeeper &Records);
2324
2425 int TableGenMain(char *argv0, TableGenMainFn *MainFn);
25 }
2626
27 #endif
27 } // end namespace llvm
28
29 #endif // LLVM_TABLEGEN_MAIN_H
3737 namespace llvm {
3838
3939 class ListRecTy;
40 struct MultiClass;
4041 class Record;
4142 class RecordKeeper;
4243 class RecordVal;
4344 class StringInit;
44 struct MultiClass;
4545
4646 //===----------------------------------------------------------------------===//
4747 // Type Classes
8989 }
9090
9191 /// 'bit' - Represent a single bit
92 ///
9392 class BitRecTy : public RecTy {
9493 static BitRecTy Shared;
9594
108107 };
109108
110109 /// 'bits' - Represent a fixed number of bits
111 ///
112110 class BitsRecTy : public RecTy {
113111 unsigned Size;
114112
129127 };
130128
131129 /// 'code' - Represent a code fragment
132 ///
133130 class CodeRecTy : public RecTy {
134131 static CodeRecTy Shared;
135132
146143 };
147144
148145 /// 'int' - Represent an integer value of no particular size
149 ///
150146 class IntRecTy : public RecTy {
151147 static IntRecTy Shared;
152148
165161 };
166162
167163 /// 'string' - Represent an string value
168 ///
169164 class StringRecTy : public RecTy {
170165 static StringRecTy Shared;
171166
184179
185180 /// 'list' - Represent a list of values, all of which must be of
186181 /// the specified type.
187 ///
188182 class ListRecTy : public RecTy {
183 friend ListRecTy *RecTy::getListTy();
184
189185 RecTy *Ty;
190186
191187 explicit ListRecTy(RecTy *T) : RecTy(ListRecTyKind), Ty(T) {}
192
193 friend ListRecTy *RecTy::getListTy();
194188
195189 public:
196190 static bool classof(const RecTy *RT) {
206200 };
207201
208202 /// 'dag' - Represent a dag fragment
209 ///
210203 class DagRecTy : public RecTy {
211204 static DagRecTy Shared;
212205
224217
225218 /// '[classname]' - Represent an instance of a class, such as:
226219 /// (R32 X = EAX).
227 ///
228220 class RecordRecTy : public RecTy {
221 friend class Record;
222
229223 Record *Rec;
230224
231225 explicit RecordRecTy(Record *R) : RecTy(RecordRecTyKind), Rec(R) {}
232
233 friend class Record;
234226
235227 public:
236228 static bool classof(const RecTy *RT) {
248240
249241 /// Find a common type that T1 and T2 convert to.
250242 /// Return 0 if no such type exists.
251 ///
252243 RecTy *resolveTypes(RecTy *T1, RecTy *T2);
253244
254245 //===----------------------------------------------------------------------===//
340331 /// selection operator. Given an initializer, it selects the specified bits
341332 /// out, returning them as a new init of bits type. If it is not legal to use
342333 /// the bit subscript operator on this initializer, return null.
343 ///
344334 virtual Init *convertInitializerBitRange(ArrayRef Bits) const {
345335 return nullptr;
346336 }
349339 /// selection operator. Given an initializer, it selects the specified list
350340 /// elements, returning them as a new init of list type. If it is not legal
351341 /// to take a slice of this, return null.
352 ///
353342 virtual Init *convertInitListSlice(ArrayRef Elements) const {
354343 return nullptr;
355344 }
357346 /// This method is used to implement the FieldInit class.
358347 /// Implementors of this method should return the type of the named field if
359348 /// they are of record type.
360 ///
361349 virtual RecTy *getFieldType(StringInit *FieldName) const {
362350 return nullptr;
363351 }
365353 /// This method complements getFieldType to return the
366354 /// initializer for the specified field. If getFieldType returns non-null
367355 /// this method should return non-null, otherwise it returns null.
368 ///
369356 virtual Init *getFieldInit(Record &R, const RecordVal *RV,
370357 StringInit *FieldName) const {
371358 return nullptr;
375362 /// variables which may not be defined at the time the expression is formed.
376363 /// If a value is set for the variable later, this method will be called on
377364 /// users of the value to allow the value to propagate out.
378 ///
379365 virtual Init *resolveReferences(Record &R, const RecordVal *RV) const {
380366 return const_cast(this);
381367 }
399385
400386 /// This is the common super-class of types that have a specific,
401387 /// explicit, type.
402 ///
403388 class TypedInit : public Init {
404389 RecTy *Ty;
405390
408393 : Init(K, Opc), Ty(T) {}
409394
410395 public:
411 TypedInit(const TypedInit &Other) = delete;
412 TypedInit &operator=(const TypedInit &Other) = delete;
396 TypedInit(const TypedInit &) = delete;
397 TypedInit &operator=(const TypedInit &) = delete;
413398
414399 static bool classof(const Init *I) {
415400 return I->getKind() >= IK_FirstTypedInit &&
437422 };
438423
439424 /// '?' - Represents an uninitialized value
440 ///
441425 class UnsetInit : public Init {
442426 UnsetInit() : Init(IK_UnsetInit) {}
443427
444428 public:
445429 UnsetInit(const UnsetInit &) = delete;
446 UnsetInit &operator=(const UnsetInit &Other) = delete;
430 UnsetInit &operator=(const UnsetInit &) = delete;
447431
448432 static bool classof(const Init *I) {
449433 return I->getKind() == IK_UnsetInit;
462446 };
463447
464448 /// 'true'/'false' - Represent a concrete initializer for a bit.
465 ///
466449 class BitInit : public Init {
467450 bool Value;
468451
469452 explicit BitInit(bool V) : Init(IK_BitInit), Value(V) {}
470453
471454 public:
472 BitInit(const BitInit &Other) = delete;
473 BitInit &operator=(BitInit &Other) = delete;
455 BitInit(const BitInit &) = delete;
456 BitInit &operator=(BitInit &) = delete;
474457
475458 static bool classof(const Init *I) {
476459 return I->getKind() == IK_BitInit;
492475
493476 /// '{ a, b, c }' - Represents an initializer for a BitsRecTy value.
494477 /// It contains a vector of bits, whose size is determined by the type.
495 ///
496478 class BitsInit final : public TypedInit, public FoldingSetNode,
497479 public TrailingObjects {
498480 unsigned NumBits;
501483 : TypedInit(IK_BitsInit, BitsRecTy::get(N)), NumBits(N) {}
502484
503485 public:
504 BitsInit(const BitsInit &Other) = delete;
505 BitsInit &operator=(const BitsInit &Other) = delete;
486 BitsInit(const BitsInit &) = delete;
487 BitsInit &operator=(const BitsInit &) = delete;
506488
507489 // Do not use sized deallocation due to trailing objects.
508490 void operator delete(void *p) { ::operator delete(p); }
551533 };
552534
553535 /// '7' - Represent an initialization by a literal integer value.
554 ///
555536 class IntInit : public TypedInit {
556537 int64_t Value;
557538
559540 : TypedInit(IK_IntInit, IntRecTy::get()), Value(V) {}
560541
561542 public:
562 IntInit(const IntInit &Other) = delete;
563 IntInit &operator=(const IntInit &Other) = delete;
543 IntInit(const IntInit &) = delete;
544 IntInit &operator=(const IntInit &) = delete;
564545
565546 static bool classof(const Init *I) {
566547 return I->getKind() == IK_IntInit;
589570 };
590571
591572 /// "foo" - Represent an initialization by a string value.
592 ///
593573 class StringInit : public TypedInit {
594574 StringRef Value;
595575
597577 : TypedInit(IK_StringInit, StringRecTy::get()), Value(V) {}
598578
599579 public:
600 StringInit(const StringInit &Other) = delete;
601 StringInit &operator=(const StringInit &Other) = delete;
580 StringInit(const StringInit &) = delete;
581 StringInit &operator=(const StringInit &) = delete;
602582
603583 static bool classof(const Init *I) {
604584 return I->getKind() == IK_StringInit;
635615 Value(V) {}
636616
637617 public:
638 CodeInit(const StringInit &Other) = delete;
639 CodeInit &operator=(const StringInit &Other) = delete;
618 CodeInit(const StringInit &) = delete;
619 CodeInit &operator=(const StringInit &) = delete;
640620
641621 static bool classof(const Init *I) {
642622 return I->getKind() == IK_CodeInit;
674654 unsigned NumValues;
675655
676656 public:
677 typedef Init *const *const_iterator;
657 using const_iterator = Init *const *;
678658
679659 private:
680660 explicit ListInit(unsigned N, RecTy *EltTy)
681661 : TypedInit(IK_ListInit, ListRecTy::get(EltTy)), NumValues(N) {}
682662
683663 public:
684 ListInit(const ListInit &Other) = delete;
685 ListInit &operator=(const ListInit &Other) = delete;
664 ListInit(const ListInit &) = delete;
665 ListInit &operator=(const ListInit &) = delete;
686666
687667 // Do not use sized deallocation due to trailing objects.
688668 void operator delete(void *p) { ::operator delete(p); }
743723 : TypedInit(K, Type, Opc) {}
744724
745725 public:
746 OpInit(const OpInit &Other) = delete;
747 OpInit &operator=(OpInit &Other) = delete;
726 OpInit(const OpInit &) = delete;
727 OpInit &operator=(OpInit &) = delete;
748728
749729 static bool classof(const Init *I) {
750730 return I->getKind() >= IK_FirstOpInit &&
780760 : OpInit(IK_UnOpInit, Type, opc), LHS(lhs) {}
781761
782762 public:
783 UnOpInit(const UnOpInit &Other) = delete;
784 UnOpInit &operator=(const UnOpInit &Other) = delete;
763 UnOpInit(const UnOpInit &) = delete;
764 UnOpInit &operator=(const UnOpInit &) = delete;
785765
786766 static bool classof(const Init *I) {
787767 return I->getKind() == IK_UnOpInit;
818798 };
819799
820800 /// !op (X, Y) - Combine two inits.
821 ///
822801 class BinOpInit : public OpInit, public FoldingSetNode {
823802 public:
824803 enum BinaryOp : uint8_t { ADD, AND, OR, SHL, SRA, SRL, LISTCONCAT,
831810 OpInit(IK_BinOpInit, Type, opc), LHS(lhs), RHS(rhs) {}
832811
833812 public:
834 BinOpInit(const BinOpInit &Other) = delete;
835 BinOpInit &operator=(const BinOpInit &Other) = delete;
813 BinOpInit(const BinOpInit &) = delete;
814 BinOpInit &operator=(const BinOpInit &) = delete;
836815
837816 static bool classof(const Init *I) {
838817 return I->getKind() == IK_BinOpInit;
873852 };
874853
875854 /// !op (X, Y, Z) - Combine two inits.
876 ///
877855 class TernOpInit : public OpInit, public FoldingSetNode {
878856 public:
879857 enum TernaryOp : uint8_t { SUBST, FOREACH, IF };
886864 OpInit(IK_TernOpInit, Type, opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
887865
888866 public:
889 TernOpInit(const TernOpInit &Other) = delete;
890 TernOpInit &operator=(const TernOpInit &Other) = delete;
867 TernOpInit(const TernOpInit &) = delete;
868 TernOpInit &operator=(const TernOpInit &) = delete;
891869
892870 static bool classof(const Init *I) {
893871 return I->getKind() == IK_TernOpInit;
934912 };
935913
936914 /// 'Opcode' - Represent a reference to an entire variable object.
937 ///
938915 class VarInit : public TypedInit {
939916 Init *VarName;
940917
942919 : TypedInit(IK_VarInit, T), VarName(VN) {}
943920
944921 public:
945 VarInit(const VarInit &Other) = delete;
946 VarInit &operator=(const VarInit &Other) = delete;
922 VarInit(const VarInit &) = delete;
923 VarInit &operator=(const VarInit &) = delete;
947924
948925 static bool classof(const Init *I) {
949926 return I->getKind() == IK_VarInit;
979956 };
980957
981958 /// Opcode{0} - Represent access to one bit of a variable or field.
982 ///
983959 class VarBitInit : public Init {
984960 TypedInit *TI;
985961 unsigned Bit;
993969 }
994970
995971 public:
996 VarBitInit(const VarBitInit &Other) = delete;
997 VarBitInit &operator=(const VarBitInit &Other) = delete;
972 VarBitInit(const VarBitInit &) = delete;
973 VarBitInit &operator=(const VarBitInit &) = delete;
998974
999975 static bool classof(const Init *I) {
1000976 return I->getKind() == IK_VarBitInit;
10311007 }
10321008
10331009 public:
1034 VarListElementInit(const VarListElementInit &Other) = delete;
1035 void operator=(const VarListElementInit &Other) = delete;
1010 VarListElementInit(const VarListElementInit &) = delete;
1011 VarListElementInit &operator=(const VarListElementInit &) = delete;
10361012
10371013 static bool classof(const Init *I) {
10381014 return I->getKind() == IK_VarListElementInit;
10561032 };
10571033
10581034 /// AL - Represent a reference to a 'def' in the description
1059 ///
10601035 class DefInit : public TypedInit {
1036 friend class Record;
1037
10611038 Record *Def;
10621039
10631040 DefInit(Record *D, RecordRecTy *T) : TypedInit(IK_DefInit, T), Def(D) {}
10641041
1065 friend class Record;
1066
1067 public:
1068 DefInit(const DefInit &Other) = delete;
1069 DefInit &operator=(const DefInit &Other) = delete;
1042 public:
1043 DefInit(const DefInit &) = delete;
1044 DefInit &operator=(const DefInit &) = delete;
10701045
10711046 static bool classof(const Init *I) {
10721047 return I->getKind() == IK_DefInit;
11001075 };
11011076
11021077 /// X.Y - Represent a reference to a subfield of a variable
1103 ///
11041078 class FieldInit : public TypedInit {
11051079 Init *Rec; // Record we are referring to
11061080 StringInit *FieldName; // Field we are accessing
11111085 }
11121086
11131087 public:
1114 FieldInit(const FieldInit &Other) = delete;
1115 FieldInit &operator=(const FieldInit &Other) = delete;
1088 FieldInit(const FieldInit &) = delete;
1089 FieldInit &operator=(const FieldInit &) = delete;
11161090
11171091 static bool classof(const Init *I) {
11181092 return I->getKind() == IK_FieldInit;
11351109 /// (v a, b) - Represent a DAG tree value. DAG inits are required
11361110 /// to have at least one value then a (possibly empty) list of arguments. Each
11371111 /// argument can have a name associated with it.
1138 ///
11391112 class DagInit final : public TypedInit, public FoldingSetNode,
11401113 public TrailingObjects {
1114 friend TrailingObjects;
1115
11411116 Init *Val;
11421117 StringInit *ValName;
11431118 unsigned NumArgs;
11471122 : TypedInit(IK_DagInit, DagRecTy::get()), Val(V), ValName(VN),
11481123 NumArgs(NumArgs), NumArgNames(NumArgNames) {}
11491124
1150 friend TrailingObjects;
11511125 size_t numTrailingObjects(OverloadToken) const { return NumArgs; }
11521126
11531127 public:
1154 DagInit(const DagInit &Other) = delete;
1155 DagInit &operator=(const DagInit &Other) = delete;
1128 DagInit(const DagInit &) = delete;
1129 DagInit &operator=(const DagInit &) = delete;
11561130
11571131 static bool classof(const Init *I) {
11581132 return I->getKind() == IK_DagInit;
11701144 Init *getOperator() const { return Val; }
11711145
11721146 StringInit *getName() const { return ValName; }
1147
11731148 StringRef getNameStr() const {
11741149 return ValName ? ValName->getValue() : StringRef();
11751150 }
11761151
11771152 unsigned getNumArgs() const { return NumArgs; }
1153
11781154 Init *getArg(unsigned Num) const {
11791155 assert(Num < NumArgs && "Arg number out of range!");
11801156 return getTrailingObjects()[Num];
11811157 }
1158
11821159 StringInit *getArgName(unsigned Num) const {
11831160 assert(Num < NumArgNames && "Arg number out of range!");
11841161 return getTrailingObjects()[Num];
11851162 }
1163
11861164 StringRef getArgNameStr(unsigned Num) const {
11871165 StringInit *Init = getArgName(Num);
11881166 return Init ? Init->getValue() : StringRef();
11911169 ArrayRef getArgs() const {
11921170 return makeArrayRef(getTrailingObjects(), NumArgs);
11931171 }
1172
11941173 ArrayRef getArgNames() const {
11951174 return makeArrayRef(getTrailingObjects(), NumArgNames);
11961175 }
11991178
12001179 std::string getAsString() const override;
12011180
1202 typedef SmallVectorImpl::const_iterator const_arg_iterator;
1203 typedef SmallVectorImpl::const_iterator const_name_iterator;
1181 using const_arg_iterator = SmallVectorImpl::const_iterator;
1182 using const_name_iterator = SmallVectorImpl::const_iterator;
12041183
12051184 inline const_arg_iterator arg_begin() const { return getArgs().begin(); }
12061185 inline const_arg_iterator arg_end () const { return getArgs().end(); }
12301209
12311210 class RecordVal {
12321211 friend class Record;
1212
12331213 Init *Name;
12341214 PointerIntPair TyAndPrefix;
12351215 Init *Value;
12971277 // definitions that use them (e.g. Def). However, inside a multiclass they
12981278 // can't be immediately resolved so we mark them ResolveFirst to fully
12991279 // resolve them later as soon as the multiclass is instantiated.
1300 bool ResolveFirst;
1280 bool ResolveFirst = false;
13011281
13021282 void init();
13031283 void checkName();
13071287 explicit Record(Init *N, ArrayRef locs, RecordKeeper &records,
13081288 bool Anonymous = false) :
13091289 Name(N), Locs(locs.begin(), locs.end()), TrackedRecords(records),
1310 ID(LastID++), IsAnonymous(Anonymous), ResolveFirst(false) {
1290 ID(LastID++), IsAnonymous(Anonymous) {
13111291 init();
13121292 }
13131293
13291309 unsigned getID() const { return ID; }
13301310
13311311 StringRef getName() const;
1312
13321313 Init *getNameInit() const {
13331314 return Name;
13341315 }
14341415
14351416 /// If there are any field references that refer to fields
14361417 /// that have been filled in, we can propagate the values now.
1437 ///
14381418 void resolveReferences() { resolveReferencesTo(nullptr); }
14391419
14401420 /// If anything in this record refers to RV, replace the
14671447
14681448 /// Return the initializer for a value with the specified name,
14691449 /// or throw an exception if the field does not exist.
1470 ///
14711450 Init *getValueInit(StringRef FieldName) const;
14721451
14731452 /// Return true if the named field is unset.
14781457 /// This method looks up the specified field and returns
14791458 /// its value as a string, throwing an exception if the field does not exist
14801459 /// or if the value is not a string.
1481 ///
14821460 StringRef getValueAsString(StringRef FieldName) const;
14831461
14841462 /// This method looks up the specified field and returns
14851463 /// its value as a BitsInit, throwing an exception if the field does not exist
14861464 /// or if the value is not the right type.
1487 ///
14881465 BitsInit *getValueAsBitsInit(StringRef FieldName) const;
14891466
14901467 /// This method looks up the specified field and returns
14911468 /// its value as a ListInit, throwing an exception if the field does not exist
14921469 /// or if the value is not the right type.
1493 ///
14941470 ListInit *getValueAsListInit(StringRef FieldName) const;
14951471
14961472 /// This method looks up the specified field and
14971473 /// returns its value as a vector of records, throwing an exception if the
14981474 /// field does not exist or if the value is not the right type.
1499 ///
15001475 std::vector getValueAsListOfDefs(StringRef FieldName) const;
15011476
15021477 /// This method looks up the specified field and
15031478 /// returns its value as a vector of integers, throwing an exception if the
15041479 /// field does not exist or if the value is not the right type.
1505 ///
15061480 std::vector getValueAsListOfInts(StringRef FieldName) const;
15071481
15081482 /// This method looks up the specified field and
15091483 /// returns its value as a vector of strings, throwing an exception if the
15101484 /// field does not exist or if the value is not the right type.
1511 ///
15121485 std::vector getValueAsListOfStrings(StringRef FieldName) const;
15131486
15141487 /// This method looks up the specified field and returns its
15151488 /// value as a Record, throwing an exception if the field does not exist or if
15161489 /// the value is not the right type.
1517 ///
15181490 Record *getValueAsDef(StringRef FieldName) const;
15191491
15201492 /// This method looks up the specified field and returns its
15211493 /// value as a bit, throwing an exception if the field does not exist or if
15221494 /// the value is not the right type.
1523 ///
15241495 bool getValueAsBit(StringRef FieldName) const;
15251496
15261497 /// This method looks up the specified field and
15271498 /// returns its value as a bit. If the field is unset, sets Unset to true and
15281499 /// returns false.
1529 ///
15301500 bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const;
15311501
15321502 /// This method looks up the specified field and returns its
15331503 /// value as an int64_t, throwing an exception if the field does not exist or
15341504 /// if the value is not the right type.
1535 ///
15361505 int64_t getValueAsInt(StringRef FieldName) const;
15371506
15381507 /// This method looks up the specified field and returns its
15391508 /// value as an Dag, throwing an exception if the field does not exist or if
15401509 /// the value is not the right type.
1541 ///
15421510 DagInit *getValueAsDag(StringRef FieldName) const;
15431511 };
15441512
15461514
15471515 struct MultiClass {
15481516 Record Rec; // Placeholder for template args and Name.
1549 typedef std::vector> RecordVector;
1517 using RecordVector = std::vector>;
15501518 RecordVector DefPrototypes;
15511519
15521520 void dump() const;
15561524 };
15571525
15581526 class RecordKeeper {
1559 typedef std::map> RecordMap;
1527 using RecordMap = std::map>;
15601528 RecordMap Classes, Defs;
15611529
15621530 public:
15991567 };
16001568
16011569 /// Sorting predicate to sort record pointers by name.
1602 ///
16031570 struct LessRecord {
16041571 bool operator()(const Record *Rec1, const Record *Rec2) const {
16051572 return StringRef(Rec1->getName()).compare_numeric(Rec2->getName()) < 0;
16181585
16191586 /// Sorting predicate to sort record pointers by their
16201587 /// name field.
1621 ///
16221588 struct LessRecordFieldName {
16231589 bool operator()(const Record *Rec1, const Record *Rec2) const {
16241590 return Rec1->getValueAsString("Name") < Rec2->getValueAsString("Name");
6363
6464 class SetTheory {
6565 public:
66 typedef std::vector RecVec;
67 typedef SmallSetVector RecSet;
66 using RecVec = std::vector;
67 using RecSet = SmallSetVector;
6868
6969 /// Operator - A callback representing a DAG operator.
7070 class Operator {
9494 private:
9595 // Map set defs to their fully expanded contents. This serves as a memoization
9696 // cache and it makes it possible to return const references on queries.
97 typedef std::map ExpandMap;
97 using ExpandMap = std::map;
9898 ExpandMap Expansions;
9999
100100 // Known DAG operators by name.
1919 #include
2020
2121 namespace llvm {
22 class raw_ostream;
22
23 class raw_ostream;
2324
2425 /// StringMatcher - Given a list of strings and code to execute when they match,
2526 /// output a simple switch tree to classify the input string.
2930 ///
3031 class StringMatcher {
3132 public:
32 typedef std::pair StringPair;
33 using StringPair = std::pair;
3334
3435 private:
3536 StringRef StrVariableName;
4849 unsigned CharNo, unsigned IndentCount) const;
4950 };
5051
51 } // end llvm namespace.
52 } // end namespace llvm
5253
53 #endif
54 #endif // LLVM_TABLEGEN_STRINGMATCHER_H
None //===--- Arg.cpp - Argument Implementations -------------------------------===//
0 //===- Arg.cpp - Argument Implementations ---------------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/ADT/SmallString.h"
910 #include "llvm/Option/Arg.h"
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/ADT/Twine.h"
1211 #include "llvm/Option/ArgList.h"
1312 #include "llvm/Option/Option.h"
13 #include "llvm/Support/Compiler.h"
1414 #include "llvm/Support/Debug.h"
1515 #include "llvm/Support/raw_ostream.h"
1616
6666
6767 std::string Arg::getAsString(const ArgList &Args) const {
6868 SmallString<256> Res;
69 llvm::raw_svector_ostream OS(Res);
69 raw_svector_ostream OS(Res);
7070
7171 ArgStringList ASL;
7272 render(Args, ASL);
9797
9898 case Option::RenderCommaJoinedStyle: {
9999 SmallString<256> Res;
100 llvm::raw_svector_ostream OS(Res);
100 raw_svector_ostream OS(Res);
101101 OS << getSpelling();
102102 for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
103103 if (i) OS << ',';
None //===--- ArgList.cpp - Argument List Management ---------------------------===//
0 //===- ArgList.cpp - Argument List Management -----------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/Option/ArgList.h"
9 #include "llvm/ADT/ArrayRef.h"
10 #include "llvm/ADT/None.h"
11 #include "llvm/ADT/SmallVector.h"
1012 #include "llvm/ADT/STLExtras.h"
11 #include "llvm/ADT/SmallString.h"
13 #include "llvm/ADT/StringRef.h"
1214 #include "llvm/ADT/Twine.h"
1315 #include "llvm/Option/Arg.h"
16 #include "llvm/Option/ArgList.h"
1417 #include "llvm/Option/Option.h"
18 #include "llvm/Option/OptSpecifier.h"
19 #include "llvm/Support/Compiler.h"
1520 #include "llvm/Support/Debug.h"
1621 #include "llvm/Support/raw_ostream.h"
22 #include
23 #include
24 #include
25 #include
26 #include
27 #include
1728
1829 using namespace llvm;
1930 using namespace llvm::opt;
196207 LLVM_DUMP_METHOD void ArgList::dump() const { print(dbgs()); }
197208 #endif
198209
199 //
200
201210 void InputArgList::releaseMemory() {
202211 // An InputArgList always owns its arguments.
203212 for (Arg *A : *this)
233242 return getArgString(MakeIndex(Str));
234243 }
235244
236 //
237
238245 DerivedArgList::DerivedArgList(const InputArgList &BaseArgs)
239246 : BaseArgs(BaseArgs) {}
240247
None //===--- OptTable.cpp - Option Table Implementation -----------------------===//
0 //===- OptTable.cpp - Option Table Implementation -------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/Option/OptTable.h"
109 #include "llvm/ADT/STLExtras.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/ADT/StringSet.h"
1112 #include "llvm/Option/Arg.h"
1213 #include "llvm/Option/ArgList.h"
1314 #include "llvm/Option/Option.h"
15 #include "llvm/Option/OptSpecifier.h"
16 #include "llvm/Option/OptTable.h"
17 #include "llvm/Support/Compiler.h"
1418 #include "llvm/Support/ErrorHandling.h"
1519 #include "llvm/Support/raw_ostream.h"
1620 #include
21 #include
1722 #include
23 #include
1824 #include
25 #include
26 #include
27 #include
1928
2029 using namespace llvm;
2130 using namespace llvm::opt;
7988 static inline bool operator<(const OptTable::Info &I, const char *Name) {
8089 return StrCmpOptionNameIgnoreCase(I.Name, Name) < 0;
8190 }
82 }
83 }
91
92 } // end namespace opt
93 } // end namespace llvm
8494
8595 OptSpecifier::OptSpecifier(const Option *Opt) : ID(Opt->getID()) {}
8696
8797 OptTable::OptTable(ArrayRef OptionInfos, bool IgnoreCase)
88 : OptionInfos(OptionInfos), IgnoreCase(IgnoreCase), TheInputOptionID(0),
89 TheUnknownOptionID(0), FirstSearchableIndex(0) {
98 : OptionInfos(OptionInfos), IgnoreCase(IgnoreCase) {
9099 // Explicitly zero initialize the error to work around a bug in array
91100 // value-initialization on MinGW with gcc 4.3.5.
92101
137146 }
138147
139148 // Build prefix chars.
140 for (llvm::StringSet<>::const_iterator I = PrefixesUnion.begin(),
141 E = PrefixesUnion.end(); I != E; ++I) {
149 for (StringSet<>::const_iterator I = PrefixesUnion.begin(),
150 E = PrefixesUnion.end(); I != E; ++I) {
142151 StringRef Prefix = I->getKey();
143152 for (StringRef::const_iterator C = Prefix.begin(), CE = Prefix.end();
144153 C != CE; ++C)
147156 }
148157 }
149158
150 OptTable::~OptTable() {
151 }
159 OptTable::~OptTable() = default;
152160
153161 const Option OptTable::getOption(OptSpecifier Opt) const {
154162 unsigned id = Opt.getID();
158166 return Option(&getInfo(id), this);
159167 }
160168
161 static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg) {
169 static bool isInput(const StringSet<> &Prefixes, StringRef Arg) {
162170 if (Arg == "-")
163171 return true;
164 for (llvm::StringSet<>::const_iterator I = Prefixes.begin(),
165 E = Prefixes.end(); I != E; ++I)
172 for (StringSet<>::const_iterator I = Prefixes.begin(),
173 E = Prefixes.end(); I != E; ++I)
166174 if (Arg.startswith(I->getKey()))
167175 return false;
168176 return true;
345353
346354 static void PrintHelpOptionList(raw_ostream &OS, StringRef Title,
347355 std::vector
348 const char*> > &OptionHelp) {
356 const char*>> &OptionHelp) {
349357 OS << Title << ":\n";
350358
351359 // Find the maximum option length.
411419
412420 // Render help text into a map of group-name to a list of (option, help)
413421 // pairs.
414 typedef std::map
415 std::vector > > helpmap_ty;
422 using helpmap_ty =
423 std::map>>;
416424 helpmap_ty GroupedOptionHelp;
417425
418426 for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
None //===--- Option.cpp - Abstract Driver Options -----------------------------===//
0 //===- Option.cpp - Abstract Driver Options -------------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/Option/Option.h"
9 #include "llvm/ADT/StringRef.h"
1010 #include "llvm/ADT/Twine.h"
1111 #include "llvm/Option/Arg.h"
1212 #include "llvm/Option/ArgList.h"
13 #include "llvm/Option/Option.h"
14 #include "llvm/Option/OptTable.h"
15 #include "llvm/Support/Compiler.h"
1316 #include "llvm/Support/Debug.h"
1417 #include "llvm/Support/ErrorHandling.h"
1518 #include "llvm/Support/raw_ostream.h"
16 #include
1719 #include
20 #include
1821
1922 using namespace llvm;
2023 using namespace llvm::opt;
2124
2225 Option::Option(const OptTable::Info *info, const OptTable *owner)
2326 : Info(info), Owner(owner) {
24
2527 // Multi-level aliases are not supported. This just simplifies option
2628 // tracking, it is not an inherent limitation.
2729 assert((!Info || !getAlias().isValid() || !getAlias().getAlias().isValid()) &&
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/TableGen/Record.h"
13 #include "llvm/ADT/ArrayRef.h"
1414 #include "llvm/ADT/DenseMap.h"
1515 #include "llvm/ADT/FoldingSet.h"
16 #include "llvm/ADT/Hashing.h"
1716 #include "llvm/ADT/SmallString.h"
1817 #include "llvm/ADT/SmallVector.h"
1918 #include "llvm/ADT/StringExtras.h"
2019 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/Allocator.h"
22 #include "llvm/Support/Casting.h"
2123 #include "llvm/Support/Compiler.h"
2224 #include "llvm/Support/ErrorHandling.h"
25 #include "llvm/Support/SMLoc.h"
26 #include "llvm/Support/raw_ostream.h"
2327 #include "llvm/TableGen/Error.h"
28 #include "llvm/TableGen/Record.h"
2429 #include
2530 #include
26 #include <new>
31 #include <memory>
32 #include
33 #include
34 #include
2735
2836 using namespace llvm;
2937
161169 // Initializer implementations
162170 //===----------------------------------------------------------------------===//
163171
164 void Init::anchor() { }
172 void Init::anchor() {}
173
165174 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
166175 LLVM_DUMP_METHOD void Init::dump() const { return print(errs()); }
167176 #endif
300309
301310 // resolveReferences - If there are any field references that refer to fields
302311 // that have been filled in, we can propagate the values now.
303 //
304312 Init *BitsInit::resolveReferences(Record &R, const RecordVal *RV) const {
305313 bool Changed = false;
306314 SmallVector NewBits(getNumBits());
614622
615623 Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
616624 switch (getOpcode()) {
617 case CAST: {
625 case CAST:
618626 if (isa(getType())) {
619627 if (StringInit *LHSs = dyn_cast(LHS))
620628 return LHSs;
679687 }
680688 }
681689 break;
682 }
683 case HEAD: {
690
691 case HEAD:
684692 if (ListInit *LHSl = dyn_cast(LHS)) {
685693 assert(!LHSl->empty() && "Empty list in head");
686694 return LHSl->getElement(0);
687695 }
688696 break;
689 }
690 case TAIL: {
697
698 case TAIL:
691699 if (ListInit *LHSl = dyn_cast(LHS)) {
692700 assert(!LHSl->empty() && "Empty list in tail");
693701 // Note the +1. We can't just pass the result of getValues()
695703 return ListInit::get(LHSl->getValues().slice(1), LHSl->getType());
696704 }
697705 break;
698 }
699 case EMPTY: {
706
707 case EMPTY:
700708 if (ListInit *LHSl = dyn_cast(LHS))
701709 return IntInit::get(LHSl->empty());
702710 if (StringInit *LHSs = dyn_cast(LHS))
703711 return IntInit::get(LHSs->getValue().empty());
704
705712 break;
706 }
707713 }
708714 return const_cast(this);
709715 }
947953
948954 static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
949955 Record *CurRec, MultiClass *CurMultiClass) {
950
951956 OpInit *RHSo = dyn_cast(RHS);
952957
953958 if (!RHSo)
12441249 }
12451250
12461251 VarInit *VarInit::get(Init *VN, RecTy *T) {
1247 typedef std::pair Key;
1252 using Key = std::pair;
12481253 static DenseMap ThePool;
12491254
12501255 Key TheKey(std::make_pair(T, VN));
13191324 }
13201325
13211326 VarBitInit *VarBitInit::get(TypedInit *T, unsigned B) {
1322 typedef std::pair Key;
1327 using Key = std::pair;
13231328 static DenseMap ThePool;
13241329
13251330 Key TheKey(std::make_pair(T, B));
13511356
13521357 VarListElementInit *VarListElementInit::get(TypedInit *T,
13531358 unsigned E) {
1354 typedef std::pair Key;
1359 using Key = std::pair;
13551360 static DenseMap ThePool;
13561361
13571362 Key TheKey(std::make_pair(T, E));
14211426 }
14221427
14231428 FieldInit *FieldInit::get(Init *R, StringInit *FN) {
1424 typedef std::pair Key;
1429 using Key = std::pair;
14251430 static DenseMap ThePool;
14261431
14271432 Key TheKey(std::make_pair(R, FN));
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #include "llvm/TableGen/SetTheory.h"
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Support/Casting.h"
1519 #include "llvm/Support/Format.h"
20 #include "llvm/Support/SMLoc.h"
21 #include "llvm/Support/raw_ostream.h"
1622 #include "llvm/TableGen/Error.h"
1723 #include "llvm/TableGen/Record.h"
24 #include "llvm/TableGen/SetTheory.h"
25 #include
26 #include
27 #include
28 #include
1829
1930 using namespace llvm;
2031
2132 // Define the standard operators.
2233 namespace {
2334
24 typedef SetTheory::RecSet RecSet;
25 typedef SetTheory::RecVec RecVec;
35 using RecSet = SetTheory::RecSet;
36 using RecVec = SetTheory::RecVec;
2637
2738 // (add a, b, ...) Evaluate and union all arguments.
2839 struct AddOp : public SetTheory::Operator {
236247 ST.evaluate(Def->getValueInit(FieldName), Elts, Def->getLoc());
237248 }
238249 };
250
239251 } // end anonymous namespace
240252
241253 // Pin the vtables to this file.
242254 void SetTheory::Operator::anchor() {}
243255 void SetTheory::Expander::anchor() {}
244
245256
246257 SetTheory::SetTheory() {
247258 addOperator("add", llvm::make_unique());
320331 // Set is not expandable.
321332 return nullptr;
322333 }
323