LCOV - code coverage report
Current view: top level - lib/AsmParser - LLParser.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 52 53 98.1 %
Date: 2017-09-14 15:23:50 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- LLParser.h - Parser Class -------------------------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : //  This file defines the parser class for .ll files.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_LIB_ASMPARSER_LLPARSER_H
      15             : #define LLVM_LIB_ASMPARSER_LLPARSER_H
      16             : 
      17             : #include "LLLexer.h"
      18             : #include "llvm/ADT/Optional.h"
      19             : #include "llvm/ADT/StringMap.h"
      20             : #include "llvm/IR/Attributes.h"
      21             : #include "llvm/IR/Instructions.h"
      22             : #include "llvm/IR/Module.h"
      23             : #include "llvm/IR/Operator.h"
      24             : #include "llvm/IR/Type.h"
      25             : #include "llvm/IR/ValueHandle.h"
      26             : #include <map>
      27             : 
      28             : namespace llvm {
      29             :   class Module;
      30             :   class OpaqueType;
      31             :   class Function;
      32             :   class Value;
      33             :   class BasicBlock;
      34             :   class Instruction;
      35             :   class Constant;
      36             :   class GlobalValue;
      37             :   class Comdat;
      38             :   class MDString;
      39             :   class MDNode;
      40             :   struct SlotMapping;
      41             :   class StructType;
      42             : 
      43             :   /// ValID - Represents a reference of a definition of some sort with no type.
      44             :   /// There are several cases where we have to parse the value but where the
      45             :   /// type can depend on later context.  This may either be a numeric reference
      46             :   /// or a symbolic (%var) reference.  This is just a discriminated union.
      47    16955298 :   struct ValID {
      48             :     enum {
      49             :       t_LocalID, t_GlobalID,           // ID in UIntVal.
      50             :       t_LocalName, t_GlobalName,       // Name in StrVal.
      51             :       t_APSInt, t_APFloat,             // Value in APSIntVal/APFloatVal.
      52             :       t_Null, t_Undef, t_Zero, t_None, // No value.
      53             :       t_EmptyArray,                    // No value:  []
      54             :       t_Constant,                      // Value in ConstantVal.
      55             :       t_InlineAsm,                     // Value in FTy/StrVal/StrVal2/UIntVal.
      56             :       t_ConstantStruct,                // Value in ConstantStructElts.
      57             :       t_PackedConstantStruct           // Value in ConstantStructElts.
      58             :     } Kind = t_LocalID;
      59             : 
      60             :     LLLexer::LocTy Loc;
      61             :     unsigned UIntVal;
      62             :     FunctionType *FTy = nullptr;
      63             :     std::string StrVal, StrVal2;
      64             :     APSInt APSIntVal;
      65             :     APFloat APFloatVal{0.0};
      66             :     Constant *ConstantVal;
      67             :     std::unique_ptr<Constant *[]> ConstantStructElts;
      68             : 
      69    16950120 :     ValID() = default;
      70         863 :     ValID(const ValID &RHS)
      71        2589 :         : Kind(RHS.Kind), Loc(RHS.Loc), UIntVal(RHS.UIntVal), FTy(RHS.FTy),
      72             :           StrVal(RHS.StrVal), StrVal2(RHS.StrVal2), APSIntVal(RHS.APSIntVal),
      73        6904 :           APFloatVal(RHS.APFloatVal), ConstantVal(RHS.ConstantVal) {
      74             :       assert(!RHS.ConstantStructElts);
      75         863 :     }
      76             : 
      77             :     bool operator<(const ValID &RHS) const {
      78        1360 :       if (Kind == t_LocalID || Kind == t_GlobalID)
      79          33 :         return UIntVal < RHS.UIntVal;
      80             :       assert((Kind == t_LocalName || Kind == t_GlobalName ||
      81             :               Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) &&
      82             :              "Ordering not defined for this ValID kind yet");
      83        2654 :       return StrVal < RHS.StrVal;
      84             :     }
      85             :   };
      86             : 
      87      342996 :   class LLParser {
      88             :   public:
      89             :     typedef LLLexer::LocTy LocTy;
      90             :   private:
      91             :     LLVMContext &Context;
      92             :     LLLexer Lex;
      93             :     Module *M;
      94             :     SlotMapping *Slots;
      95             : 
      96             :     // Instruction metadata resolution.  Each instruction can have a list of
      97             :     // MDRef info associated with them.
      98             :     //
      99             :     // The simpler approach of just creating temporary MDNodes and then calling
     100             :     // RAUW on them when the definition is processed doesn't work because some
     101             :     // instruction metadata kinds, such as dbg, get stored in the IR in an
     102             :     // "optimized" format which doesn't participate in the normal value use
     103             :     // lists. This means that RAUW doesn't work, even on temporary MDNodes
     104             :     // which otherwise support RAUW. Instead, we defer resolving MDNode
     105             :     // references until the definitions have been processed.
     106             :     struct MDRef {
     107             :       SMLoc Loc;
     108             :       unsigned MDKind, MDSlot;
     109             :     };
     110             : 
     111             :     SmallVector<Instruction*, 64> InstsWithTBAATag;
     112             : 
     113             :     // Type resolution handling data structures.  The location is set when we
     114             :     // have processed a use of the type but not a definition yet.
     115             :     StringMap<std::pair<Type*, LocTy> > NamedTypes;
     116             :     std::map<unsigned, std::pair<Type*, LocTy> > NumberedTypes;
     117             : 
     118             :     std::map<unsigned, TrackingMDNodeRef> NumberedMetadata;
     119             :     std::map<unsigned, std::pair<TempMDTuple, LocTy>> ForwardRefMDNodes;
     120             : 
     121             :     // Global Value reference information.
     122             :     std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
     123             :     std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
     124             :     std::vector<GlobalValue*> NumberedVals;
     125             : 
     126             :     // Comdat forward reference information.
     127             :     std::map<std::string, LocTy> ForwardRefComdats;
     128             : 
     129             :     // References to blockaddress.  The key is the function ValID, the value is
     130             :     // a list of references to blocks in that function.
     131             :     std::map<ValID, std::map<ValID, GlobalValue *>> ForwardRefBlockAddresses;
     132             :     class PerFunctionState;
     133             :     /// Reference to per-function state to allow basic blocks to be
     134             :     /// forward-referenced by blockaddress instructions within the same
     135             :     /// function.
     136             :     PerFunctionState *BlockAddressPFS;
     137             : 
     138             :     // Attribute builder reference information.
     139             :     std::map<Value*, std::vector<unsigned> > ForwardRefAttrGroups;
     140             :     std::map<unsigned, AttrBuilder> NumberedAttrBuilders;
     141             : 
     142             :   public:
     143       28609 :     LLParser(StringRef F, SourceMgr &SM, SMDiagnostic &Err, Module *M,
     144             :              SlotMapping *Slots = nullptr)
     145       28609 :         : Context(M->getContext()), Lex(F, SM, Err, M->getContext()), M(M),
     146      371917 :           Slots(Slots), BlockAddressPFS(nullptr) {}
     147             :     bool Run();
     148             : 
     149             :     bool parseStandaloneConstantValue(Constant *&C, const SlotMapping *Slots);
     150             : 
     151             :     bool parseTypeAtBeginning(Type *&Ty, unsigned &Read,
     152             :                               const SlotMapping *Slots);
     153             : 
     154             :     LLVMContext &getContext() { return Context; }
     155             : 
     156             :   private:
     157             : 
     158             :     bool Error(LocTy L, const Twine &Msg) const {
     159         197 :       return Lex.Error(L, Msg);
     160             :     }
     161             :     bool TokError(const Twine &Msg) const {
     162         141 :       return Error(Lex.getLoc(), Msg);
     163             :     }
     164             : 
     165             :     /// Restore the internal name and slot mappings using the mappings that
     166             :     /// were created at an earlier parsing stage.
     167             :     void restoreParsingState(const SlotMapping *Slots);
     168             : 
     169             :     /// GetGlobalVal - Get a value with the specified name or ID, creating a
     170             :     /// forward reference record if needed.  This can return null if the value
     171             :     /// exists but does not have the right type.
     172             :     GlobalValue *GetGlobalVal(const std::string &N, Type *Ty, LocTy Loc);
     173             :     GlobalValue *GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc);
     174             : 
     175             :     /// Get a Comdat with the specified name, creating a forward reference
     176             :     /// record if needed.
     177             :     Comdat *getComdat(const std::string &N, LocTy Loc);
     178             : 
     179             :     // Helper Routines.
     180             :     bool ParseToken(lltok::Kind T, const char *ErrMsg);
     181             :     bool EatIfPresent(lltok::Kind T) {
     182     6740070 :       if (Lex.getKind() != T) return false;
     183     3479996 :       Lex.Lex();
     184             :       return true;
     185             :     }
     186             : 
     187      146491 :     FastMathFlags EatFastMathFlagsIfPresent() {
     188      146491 :       FastMathFlags FMF;
     189             :       while (true)
     190      154615 :         switch (Lex.getKind()) {
     191       13116 :         case lltok::kw_fast: FMF.setUnsafeAlgebra();   Lex.Lex(); continue;
     192        1896 :         case lltok::kw_nnan: FMF.setNoNaNs();          Lex.Lex(); continue;
     193         272 :         case lltok::kw_ninf: FMF.setNoInfs();          Lex.Lex(); continue;
     194         412 :         case lltok::kw_nsz:  FMF.setNoSignedZeros();   Lex.Lex(); continue;
     195         408 :         case lltok::kw_arcp: FMF.setAllowReciprocal(); Lex.Lex(); continue;
     196          36 :         case lltok::kw_contract:
     197          36 :           FMF.setAllowContract(true);
     198          72 :           Lex.Lex();
     199          36 :           continue;
     200      146491 :         default: return FMF;
     201             :         }
     202             :       return FMF;
     203             :     }
     204             : 
     205             :     bool ParseOptionalToken(lltok::Kind T, bool &Present,
     206             :                             LocTy *Loc = nullptr) {
     207       50123 :       if (Lex.getKind() != T) {
     208             :         Present = false;
     209             :       } else {
     210             :         if (Loc)
     211          54 :           *Loc = Lex.getLoc();
     212       15344 :         Lex.Lex();
     213        7672 :         Present = true;
     214             :       }
     215             :       return false;
     216             :     }
     217             :     bool ParseStringConstant(std::string &Result);
     218             :     bool ParseUInt32(unsigned &Val);
     219             :     bool ParseUInt32(unsigned &Val, LocTy &Loc) {
     220             :       Loc = Lex.getLoc();
     221             :       return ParseUInt32(Val);
     222             :     }
     223             :     bool ParseUInt64(uint64_t &Val);
     224             :     bool ParseUInt64(uint64_t &Val, LocTy &Loc) {
     225             :       Loc = Lex.getLoc();
     226             :       return ParseUInt64(Val);
     227             :     }
     228             : 
     229             :     bool ParseStringAttribute(AttrBuilder &B);
     230             : 
     231             :     bool ParseTLSModel(GlobalVariable::ThreadLocalMode &TLM);
     232             :     bool ParseOptionalThreadLocal(GlobalVariable::ThreadLocalMode &TLM);
     233             :     bool ParseOptionalUnnamedAddr(GlobalVariable::UnnamedAddr &UnnamedAddr);
     234             :     bool ParseOptionalAddrSpace(unsigned &AddrSpace);
     235             :     bool ParseOptionalParamAttrs(AttrBuilder &B);
     236             :     bool ParseOptionalReturnAttrs(AttrBuilder &B);
     237             :     bool ParseOptionalLinkage(unsigned &Linkage, bool &HasLinkage,
     238             :                               unsigned &Visibility, unsigned &DLLStorageClass);
     239             :     void ParseOptionalVisibility(unsigned &Visibility);
     240             :     void ParseOptionalDLLStorageClass(unsigned &DLLStorageClass);
     241             :     bool ParseOptionalCallingConv(unsigned &CC);
     242             :     bool ParseOptionalAlignment(unsigned &Alignment);
     243             :     bool ParseOptionalDerefAttrBytes(lltok::Kind AttrKind, uint64_t &Bytes);
     244             :     bool ParseScopeAndOrdering(bool isAtomic, SyncScope::ID &SSID,
     245             :                                AtomicOrdering &Ordering);
     246             :     bool ParseScope(SyncScope::ID &SSID);
     247             :     bool ParseOrdering(AtomicOrdering &Ordering);
     248             :     bool ParseOptionalStackAlignment(unsigned &Alignment);
     249             :     bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
     250             :     bool ParseOptionalCommaAddrSpace(unsigned &AddrSpace, LocTy &Loc,
     251             :                                      bool &AteExtraComma);
     252             :     bool ParseOptionalCommaInAlloca(bool &IsInAlloca);
     253             :     bool parseAllocSizeArguments(unsigned &ElemSizeArg,
     254             :                                  Optional<unsigned> &HowManyArg);
     255             :     bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,
     256             :                         bool &AteExtraComma);
     257          20 :     bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
     258             :       bool AteExtraComma;
     259          20 :       if (ParseIndexList(Indices, AteExtraComma)) return true;
     260          20 :       if (AteExtraComma)
     261           0 :         return TokError("expected index");
     262             :       return false;
     263             :     }
     264             : 
     265             :     // Top-Level Entities
     266             :     bool ParseTopLevelEntities();
     267             :     bool ValidateEndOfModule();
     268             :     bool ParseTargetDefinition();
     269             :     bool ParseModuleAsm();
     270             :     bool ParseSourceFileName();
     271             :     bool ParseDepLibs();        // FIXME: Remove in 4.0.
     272             :     bool ParseUnnamedType();
     273             :     bool ParseNamedType();
     274             :     bool ParseDeclare();
     275             :     bool ParseDefine();
     276             : 
     277             :     bool ParseGlobalType(bool &IsConstant);
     278             :     bool ParseUnnamedGlobal();
     279             :     bool ParseNamedGlobal();
     280             :     bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
     281             :                      bool HasLinkage, unsigned Visibility,
     282             :                      unsigned DLLStorageClass,
     283             :                      GlobalVariable::ThreadLocalMode TLM,
     284             :                      GlobalVariable::UnnamedAddr UnnamedAddr);
     285             :     bool parseIndirectSymbol(const std::string &Name, LocTy Loc,
     286             :                              unsigned Linkage, unsigned Visibility,
     287             :                              unsigned DLLStorageClass,
     288             :                              GlobalVariable::ThreadLocalMode TLM,
     289             :                              GlobalVariable::UnnamedAddr UnnamedAddr);
     290             :     bool parseComdat();
     291             :     bool ParseStandaloneMetadata();
     292             :     bool ParseNamedMetadata();
     293             :     bool ParseMDString(MDString *&Result);
     294             :     bool ParseMDNodeID(MDNode *&Result);
     295             :     bool ParseUnnamedAttrGrp();
     296             :     bool ParseFnAttributeValuePairs(AttrBuilder &B,
     297             :                                     std::vector<unsigned> &FwdRefAttrGrps,
     298             :                                     bool inAttrGrp, LocTy &BuiltinLoc);
     299             : 
     300             :     // Type Parsing.
     301             :     bool ParseType(Type *&Result, const Twine &Msg, bool AllowVoid = false);
     302      411209 :     bool ParseType(Type *&Result, bool AllowVoid = false) {
     303     9128338 :       return ParseType(Result, "expected type", AllowVoid);
     304             :     }
     305             :     bool ParseType(Type *&Result, const Twine &Msg, LocTy &Loc,
     306             :                    bool AllowVoid = false) {
     307       34048 :       Loc = Lex.getLoc();
     308       17024 :       return ParseType(Result, Msg, AllowVoid);
     309             :     }
     310             :     bool ParseType(Type *&Result, LocTy &Loc, bool AllowVoid = false) {
     311     1282120 :       Loc = Lex.getLoc();
     312     1282120 :       return ParseType(Result, AllowVoid);
     313             :     }
     314             :     bool ParseAnonStructType(Type *&Result, bool Packed);
     315             :     bool ParseStructBody(SmallVectorImpl<Type*> &Body);
     316             :     bool ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
     317             :                                std::pair<Type*, LocTy> &Entry,
     318             :                                Type *&ResultTy);
     319             : 
     320             :     bool ParseArrayVectorType(Type *&Result, bool isVector);
     321             :     bool ParseFunctionType(Type *&Result);
     322             : 
     323             :     // Function Semantic Analysis.
     324             :     class PerFunctionState {
     325             :       LLParser &P;
     326             :       Function &F;
     327             :       std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
     328             :       std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
     329             :       std::vector<Value*> NumberedVals;
     330             : 
     331             :       /// FunctionNumber - If this is an unnamed function, this is the slot
     332             :       /// number of it, otherwise it is -1.
     333             :       int FunctionNumber;
     334             :     public:
     335             :       PerFunctionState(LLParser &p, Function &f, int FunctionNumber);
     336             :       ~PerFunctionState();
     337             : 
     338             :       Function &getFunction() const { return F; }
     339             : 
     340             :       bool FinishFunction();
     341             : 
     342             :       /// GetVal - Get a value with the specified name or ID, creating a
     343             :       /// forward reference record if needed.  This can return null if the value
     344             :       /// exists but does not have the right type.
     345             :       Value *GetVal(const std::string &Name, Type *Ty, LocTy Loc);
     346             :       Value *GetVal(unsigned ID, Type *Ty, LocTy Loc);
     347             : 
     348             :       /// SetInstName - After an instruction is parsed and inserted into its
     349             :       /// basic block, this installs its name.
     350             :       bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
     351             :                        Instruction *Inst);
     352             : 
     353             :       /// GetBB - Get a basic block with the specified name or ID, creating a
     354             :       /// forward reference record if needed.  This can return null if the value
     355             :       /// is not a BasicBlock.
     356             :       BasicBlock *GetBB(const std::string &Name, LocTy Loc);
     357             :       BasicBlock *GetBB(unsigned ID, LocTy Loc);
     358             : 
     359             :       /// DefineBB - Define the specified basic block, which is either named or
     360             :       /// unnamed.  If there is an error, this returns null otherwise it returns
     361             :       /// the block being defined.
     362             :       BasicBlock *DefineBB(const std::string &Name, LocTy Loc);
     363             : 
     364             :       bool resolveForwardRefBlockAddresses();
     365             :     };
     366             : 
     367             :     bool ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
     368             :                              PerFunctionState *PFS);
     369             : 
     370             :     bool parseConstantValue(Type *Ty, Constant *&C);
     371             :     bool ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS);
     372             :     bool ParseValue(Type *Ty, Value *&V, PerFunctionState &PFS) {
     373      602551 :       return ParseValue(Ty, V, &PFS);
     374             :     }
     375             : 
     376             :     bool ParseValue(Type *Ty, Value *&V, LocTy &Loc,
     377             :                     PerFunctionState &PFS) {
     378             :       Loc = Lex.getLoc();
     379             :       return ParseValue(Ty, V, &PFS);
     380             :     }
     381             : 
     382             :     bool ParseTypeAndValue(Value *&V, PerFunctionState *PFS);
     383             :     bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
     384     1228152 :       return ParseTypeAndValue(V, &PFS);
     385             :     }
     386             :     bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
     387     2004790 :       Loc = Lex.getLoc();
     388     1002395 :       return ParseTypeAndValue(V, PFS);
     389             :     }
     390             :     bool ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
     391             :                                 PerFunctionState &PFS);
     392             :     bool ParseTypeAndBasicBlock(BasicBlock *&BB, PerFunctionState &PFS) {
     393       11362 :       LocTy Loc;
     394       11362 :       return ParseTypeAndBasicBlock(BB, Loc, PFS);
     395             :     }
     396             : 
     397             : 
     398             :     struct ParamInfo {
     399             :       LocTy Loc;
     400             :       Value *V;
     401             :       AttributeSet Attrs;
     402             :       ParamInfo(LocTy loc, Value *v, AttributeSet attrs)
     403      208379 :           : Loc(loc), V(v), Attrs(attrs) {}
     404             :     };
     405             :     bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
     406             :                             PerFunctionState &PFS,
     407             :                             bool IsMustTailCall = false,
     408             :                             bool InVarArgsFunc = false);
     409             : 
     410             :     bool
     411             :     ParseOptionalOperandBundles(SmallVectorImpl<OperandBundleDef> &BundleList,
     412             :                                 PerFunctionState &PFS);
     413             : 
     414             :     bool ParseExceptionArgs(SmallVectorImpl<Value *> &Args,
     415             :                             PerFunctionState &PFS);
     416             : 
     417             :     // Constant Parsing.
     418             :     bool ParseValID(ValID &ID, PerFunctionState *PFS = nullptr);
     419             :     bool ParseGlobalValue(Type *Ty, Constant *&V);
     420             :     bool ParseGlobalTypeAndValue(Constant *&V);
     421             :     bool ParseGlobalValueVector(SmallVectorImpl<Constant *> &Elts,
     422             :                                 Optional<unsigned> *InRangeOp = nullptr);
     423             :     bool parseOptionalComdat(StringRef GlobalName, Comdat *&C);
     424             :     bool ParseMetadataAsValue(Value *&V, PerFunctionState &PFS);
     425             :     bool ParseValueAsMetadata(Metadata *&MD, const Twine &TypeMsg,
     426             :                               PerFunctionState *PFS);
     427             :     bool ParseMetadata(Metadata *&MD, PerFunctionState *PFS);
     428             :     bool ParseMDTuple(MDNode *&MD, bool IsDistinct = false);
     429             :     bool ParseMDNode(MDNode *&MD);
     430             :     bool ParseMDNodeTail(MDNode *&MD);
     431             :     bool ParseMDNodeVector(SmallVectorImpl<Metadata *> &MDs);
     432             :     bool ParseMetadataAttachment(unsigned &Kind, MDNode *&MD);
     433             :     bool ParseInstructionMetadata(Instruction &Inst);
     434             :     bool ParseGlobalObjectMetadataAttachment(GlobalObject &GO);
     435             :     bool ParseOptionalFunctionMetadata(Function &F);
     436             : 
     437             :     template <class FieldTy>
     438             :     bool ParseMDField(LocTy Loc, StringRef Name, FieldTy &Result);
     439             :     template <class FieldTy> bool ParseMDField(StringRef Name, FieldTy &Result);
     440             :     template <class ParserTy>
     441             :     bool ParseMDFieldsImplBody(ParserTy parseField);
     442             :     template <class ParserTy>
     443             :     bool ParseMDFieldsImpl(ParserTy parseField, LocTy &ClosingLoc);
     444             :     bool ParseSpecializedMDNode(MDNode *&N, bool IsDistinct = false);
     445             : 
     446             : #define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS)                                  \
     447             :   bool Parse##CLASS(MDNode *&Result, bool IsDistinct);
     448             : #include "llvm/IR/Metadata.def"
     449             : 
     450             :     // Function Parsing.
     451      893742 :     struct ArgInfo {
     452             :       LocTy Loc;
     453             :       Type *Ty;
     454             :       AttributeSet Attrs;
     455             :       std::string Name;
     456             :       ArgInfo(LocTy L, Type *ty, AttributeSet Attr, const std::string &N)
     457      822414 :           : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
     458             :     };
     459             :     bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
     460             :     bool ParseFunctionHeader(Function *&Fn, bool isDefine);
     461             :     bool ParseFunctionBody(Function &Fn);
     462             :     bool ParseBasicBlock(PerFunctionState &PFS);
     463             : 
     464             :     enum TailCallType { TCT_None, TCT_Tail, TCT_MustTail };
     465             : 
     466             :     // Instruction Parsing.  Each instruction parsing routine can return with a
     467             :     // normal result, an error result, or return having eaten an extra comma.
     468             :     enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
     469             :     int ParseInstruction(Instruction *&Inst, BasicBlock *BB,
     470             :                          PerFunctionState &PFS);
     471             :     bool ParseCmpPredicate(unsigned &Pred, unsigned Opc);
     472             : 
     473             :     bool ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
     474             :     bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
     475             :     bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
     476             :     bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
     477             :     bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
     478             :     bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
     479             :     bool ParseCleanupRet(Instruction *&Inst, PerFunctionState &PFS);
     480             :     bool ParseCatchRet(Instruction *&Inst, PerFunctionState &PFS);
     481             :     bool ParseCatchSwitch(Instruction *&Inst, PerFunctionState &PFS);
     482             :     bool ParseCatchPad(Instruction *&Inst, PerFunctionState &PFS);
     483             :     bool ParseCleanupPad(Instruction *&Inst, PerFunctionState &PFS);
     484             : 
     485             :     bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
     486             :                          unsigned OperandType);
     487             :     bool ParseLogical(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
     488             :     bool ParseCompare(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
     489             :     bool ParseCast(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
     490             :     bool ParseSelect(Instruction *&I, PerFunctionState &PFS);
     491             :     bool ParseVA_Arg(Instruction *&I, PerFunctionState &PFS);
     492             :     bool ParseExtractElement(Instruction *&I, PerFunctionState &PFS);
     493             :     bool ParseInsertElement(Instruction *&I, PerFunctionState &PFS);
     494             :     bool ParseShuffleVector(Instruction *&I, PerFunctionState &PFS);
     495             :     int ParsePHI(Instruction *&I, PerFunctionState &PFS);
     496             :     bool ParseLandingPad(Instruction *&I, PerFunctionState &PFS);
     497             :     bool ParseCall(Instruction *&I, PerFunctionState &PFS,
     498             :                    CallInst::TailCallKind IsTail);
     499             :     int ParseAlloc(Instruction *&I, PerFunctionState &PFS);
     500             :     int ParseLoad(Instruction *&I, PerFunctionState &PFS);
     501             :     int ParseStore(Instruction *&I, PerFunctionState &PFS);
     502             :     int ParseCmpXchg(Instruction *&I, PerFunctionState &PFS);
     503             :     int ParseAtomicRMW(Instruction *&I, PerFunctionState &PFS);
     504             :     int ParseFence(Instruction *&I, PerFunctionState &PFS);
     505             :     int ParseGetElementPtr(Instruction *&I, PerFunctionState &PFS);
     506             :     int ParseExtractValue(Instruction *&I, PerFunctionState &PFS);
     507             :     int ParseInsertValue(Instruction *&I, PerFunctionState &PFS);
     508             : 
     509             :     // Use-list order directives.
     510             :     bool ParseUseListOrder(PerFunctionState *PFS = nullptr);
     511             :     bool ParseUseListOrderBB();
     512             :     bool ParseUseListOrderIndexes(SmallVectorImpl<unsigned> &Indexes);
     513             :     bool sortUseListOrder(Value *V, ArrayRef<unsigned> Indexes, SMLoc Loc);
     514             :   };
     515             : } // End llvm namespace
     516             : 
     517             : #endif

Generated by: LCOV version 1.13