|
15 | 15 |
|
16 | 16 | #include "LLLexer.h"
|
17 | 17 | #include "llvm/ADT/StringMap.h"
|
| 18 | +#include "llvm/AsmParser/NumberedValues.h" |
18 | 19 | #include "llvm/AsmParser/Parser.h"
|
19 | 20 | #include "llvm/IR/Attributes.h"
|
20 | 21 | #include "llvm/IR/FMF.h"
|
@@ -133,7 +134,7 @@ namespace llvm {
|
133 | 134 | // Global Value reference information.
|
134 | 135 | std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
|
135 | 136 | std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
|
136 |
| - std::vector<GlobalValue*> NumberedVals; |
| 137 | + NumberedValues<GlobalValue *> NumberedVals; |
137 | 138 |
|
138 | 139 | // Comdat forward reference information.
|
139 | 140 | std::map<std::string, LocTy> ForwardRefComdats;
|
@@ -346,14 +347,15 @@ namespace llvm {
|
346 | 347 | bool parseGlobalType(bool &IsConstant);
|
347 | 348 | bool parseUnnamedGlobal();
|
348 | 349 | bool parseNamedGlobal();
|
349 |
| - bool parseGlobal(const std::string &Name, LocTy NameLoc, unsigned Linkage, |
350 |
| - bool HasLinkage, unsigned Visibility, |
| 350 | + bool parseGlobal(const std::string &Name, unsigned NameID, LocTy NameLoc, |
| 351 | + unsigned Linkage, bool HasLinkage, unsigned Visibility, |
351 | 352 | unsigned DLLStorageClass, bool DSOLocal,
|
352 | 353 | GlobalVariable::ThreadLocalMode TLM,
|
353 | 354 | GlobalVariable::UnnamedAddr UnnamedAddr);
|
354 |
| - bool parseAliasOrIFunc(const std::string &Name, LocTy NameLoc, unsigned L, |
355 |
| - unsigned Visibility, unsigned DLLStorageClass, |
356 |
| - bool DSOLocal, GlobalVariable::ThreadLocalMode TLM, |
| 355 | + bool parseAliasOrIFunc(const std::string &Name, unsigned NameID, |
| 356 | + LocTy NameLoc, unsigned L, unsigned Visibility, |
| 357 | + unsigned DLLStorageClass, bool DSOLocal, |
| 358 | + GlobalVariable::ThreadLocalMode TLM, |
357 | 359 | GlobalVariable::UnnamedAddr UnnamedAddr);
|
358 | 360 | bool parseComdat();
|
359 | 361 | bool parseStandaloneMetadata();
|
@@ -452,27 +454,13 @@ namespace llvm {
|
452 | 454 | bool parseFunctionType(Type *&Result);
|
453 | 455 | bool parseTargetExtType(Type *&Result);
|
454 | 456 |
|
455 |
| - class NumberedValues { |
456 |
| - DenseMap<unsigned, Value *> Vals; |
457 |
| - unsigned NextUnusedID = 0; |
458 |
| - |
459 |
| - public: |
460 |
| - unsigned getNext() const { return NextUnusedID; } |
461 |
| - Value *get(unsigned ID) const { return Vals.lookup(ID); } |
462 |
| - void add(unsigned ID, Value *V) { |
463 |
| - assert(ID >= NextUnusedID && "Invalid value ID"); |
464 |
| - Vals.insert({ID, V}); |
465 |
| - NextUnusedID = ID + 1; |
466 |
| - } |
467 |
| - }; |
468 |
| - |
469 | 457 | // Function Semantic Analysis.
|
470 | 458 | class PerFunctionState {
|
471 | 459 | LLParser &P;
|
472 | 460 | Function &F;
|
473 | 461 | std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
|
474 | 462 | std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
|
475 |
| - NumberedValues NumberedVals; |
| 463 | + NumberedValues<Value *> NumberedVals; |
476 | 464 |
|
477 | 465 | /// FunctionNumber - If this is an unnamed function, this is the slot
|
478 | 466 | /// number of it, otherwise it is -1.
|
@@ -614,8 +602,10 @@ namespace llvm {
|
614 | 602 | SmallVectorImpl<unsigned> &UnnamedArgNums,
|
615 | 603 | bool &IsVarArg);
|
616 | 604 | bool parseFunctionHeader(Function *&Fn, bool IsDefine,
|
| 605 | + unsigned &FunctionNumber, |
617 | 606 | SmallVectorImpl<unsigned> &UnnamedArgNums);
|
618 |
| - bool parseFunctionBody(Function &Fn, ArrayRef<unsigned> UnnamedArgNums); |
| 607 | + bool parseFunctionBody(Function &Fn, unsigned FunctionNumber, |
| 608 | + ArrayRef<unsigned> UnnamedArgNums); |
619 | 609 | bool parseBasicBlock(PerFunctionState &PFS);
|
620 | 610 |
|
621 | 611 | enum TailCallType { TCT_None, TCT_Tail, TCT_MustTail };
|
|
0 commit comments