blob: ad169afb9358417f504e38e3f56265bb3114da10 [file] [log] [blame]
Chris Lattnerac161bf2009-01-02 07:01:27 +00001//===-- LLParser.h - Parser Class -------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattnerac161bf2009-01-02 07:01:27 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the parser class for .ll files.
10//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_ASMPARSER_LLPARSER_H
14#define LLVM_LIB_ASMPARSER_LLPARSER_H
Chris Lattnerac161bf2009-01-02 07:01:27 +000015
16#include "LLLexer.h"
George Burgess IV278199f2016-04-12 01:05:35 +000017#include "llvm/ADT/Optional.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000018#include "llvm/ADT/StringMap.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000019#include "llvm/IR/Attributes.h"
20#include "llvm/IR/Instructions.h"
21#include "llvm/IR/Module.h"
Teresa Johnson63ee0e72018-06-26 13:56:49 +000022#include "llvm/IR/ModuleSummaryIndex.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000023#include "llvm/IR/Operator.h"
24#include "llvm/IR/Type.h"
Chandler Carruth4220e9c2014-03-04 11:17:44 +000025#include "llvm/IR/ValueHandle.h"
Chris Lattner218b22f2009-12-29 21:43:58 +000026#include <map>
Chris Lattnerac161bf2009-01-02 07:01:27 +000027
28namespace 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;
David Majnemerdad0a642014-06-27 18:19:56 +000037 class Comdat;
Nick Lewycky49f89192009-04-04 07:22:01 +000038 class MDString;
39 class MDNode;
Alex Lorenz8955f7d2015-06-23 17:10:10 +000040 struct SlotMapping;
Chris Lattnerb1ed91f2011-07-09 17:41:24 +000041 class StructType;
Misha Brukman1d9a93d2009-01-02 22:46:48 +000042
Chris Lattner3432c622009-10-28 03:39:23 +000043 /// 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.
Benjamin Kramer079b96e2013-09-11 18:05:11 +000047 struct ValID {
Chris Lattner3432c622009-10-28 03:39:23 +000048 enum {
David Majnemerf0f224d2015-11-11 21:57:16 +000049 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.
David Blaikieadbda4b2015-08-03 20:08:41 +000058 } Kind = t_LocalID;
Michael Ilseman26ee2b82012-11-15 22:34:00 +000059
Chris Lattner3432c622009-10-28 03:39:23 +000060 LLLexer::LocTy Loc;
61 unsigned UIntVal;
Karl Schimpf44876c52015-09-03 16:18:32 +000062 FunctionType *FTy = nullptr;
Chris Lattner3432c622009-10-28 03:39:23 +000063 std::string StrVal, StrVal2;
64 APSInt APSIntVal;
David Blaikieadbda4b2015-08-03 20:08:41 +000065 APFloat APFloatVal{0.0};
Chris Lattner3432c622009-10-28 03:39:23 +000066 Constant *ConstantVal;
David Blaikieadbda4b2015-08-03 20:08:41 +000067 std::unique_ptr<Constant *[]> ConstantStructElts;
Michael Ilseman26ee2b82012-11-15 22:34:00 +000068
David Blaikieadbda4b2015-08-03 20:08:41 +000069 ValID() = default;
David Blaikie69374412015-08-03 20:30:53 +000070 ValID(const ValID &RHS)
David Blaikieadbda4b2015-08-03 20:08:41 +000071 : Kind(RHS.Kind), Loc(RHS.Loc), UIntVal(RHS.UIntVal), FTy(RHS.FTy),
David Blaikie69374412015-08-03 20:30:53 +000072 StrVal(RHS.StrVal), StrVal2(RHS.StrVal2), APSIntVal(RHS.APSIntVal),
73 APFloatVal(RHS.APFloatVal), ConstantVal(RHS.ConstantVal) {
74 assert(!RHS.ConstantStructElts);
75 }
Michael Ilseman26ee2b82012-11-15 22:34:00 +000076
Chris Lattner3432c622009-10-28 03:39:23 +000077 bool operator<(const ValID &RHS) const {
78 if (Kind == t_LocalID || Kind == t_GlobalID)
79 return UIntVal < RHS.UIntVal;
Chris Lattnerb1ed91f2011-07-09 17:41:24 +000080 assert((Kind == t_LocalName || Kind == t_GlobalName ||
Michael Ilseman26ee2b82012-11-15 22:34:00 +000081 Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) &&
Chris Lattner3432c622009-10-28 03:39:23 +000082 "Ordering not defined for this ValID kind yet");
83 return StrVal < RHS.StrVal;
84 }
85 };
Michael Ilseman26ee2b82012-11-15 22:34:00 +000086
Benjamin Kramer079b96e2013-09-11 18:05:11 +000087 class LLParser {
Chris Lattnerac161bf2009-01-02 07:01:27 +000088 public:
89 typedef LLLexer::LocTy LocTy;
90 private:
Chris Lattner2e664bd2010-04-07 04:08:57 +000091 LLVMContext &Context;
Chris Lattnerac161bf2009-01-02 07:01:27 +000092 LLLexer Lex;
Teresa Johnson63ee0e72018-06-26 13:56:49 +000093 // Module being parsed, null if we are only parsing summary index.
Chris Lattnerac161bf2009-01-02 07:01:27 +000094 Module *M;
Teresa Johnson63ee0e72018-06-26 13:56:49 +000095 // Summary index being parsed, null if we are only parsing Module.
96 ModuleSummaryIndex *Index;
Alex Lorenz8955f7d2015-06-23 17:10:10 +000097 SlotMapping *Slots;
Michael Ilseman26ee2b82012-11-15 22:34:00 +000098
Chris Lattner8eff0152010-04-01 05:14:45 +000099 // Instruction metadata resolution. Each instruction can have a list of
100 // MDRef info associated with them.
Dan Gohman7c7f13a2010-08-24 14:31:06 +0000101 //
102 // The simpler approach of just creating temporary MDNodes and then calling
103 // RAUW on them when the definition is processed doesn't work because some
104 // instruction metadata kinds, such as dbg, get stored in the IR in an
105 // "optimized" format which doesn't participate in the normal value use
106 // lists. This means that RAUW doesn't work, even on temporary MDNodes
107 // which otherwise support RAUW. Instead, we defer resolving MDNode
108 // references until the definitions have been processed.
Chris Lattner8eff0152010-04-01 05:14:45 +0000109 struct MDRef {
110 SMLoc Loc;
111 unsigned MDKind, MDSlot;
112 };
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000113
Manman Ren209b17c2013-09-28 00:22:27 +0000114 SmallVector<Instruction*, 64> InstsWithTBAATag;
115
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000116 // Type resolution handling data structures. The location is set when we
117 // have processed a use of the type but not a definition yet.
118 StringMap<std::pair<Type*, LocTy> > NamedTypes;
David Majnemer19b51052015-02-11 07:43:56 +0000119 std::map<unsigned, std::pair<Type*, LocTy> > NumberedTypes;
Michael Ilseman26ee2b82012-11-15 22:34:00 +0000120
David Majnemer19b51052015-02-11 07:43:56 +0000121 std::map<unsigned, TrackingMDNodeRef> NumberedMetadata;
Duncan P. N. Exon Smith7d823132015-01-19 21:30:18 +0000122 std::map<unsigned, std::pair<TempMDTuple, LocTy>> ForwardRefMDNodes;
Chris Lattnerac161bf2009-01-02 07:01:27 +0000123
124 // Global Value reference information.
125 std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
126 std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
127 std::vector<GlobalValue*> NumberedVals;
Michael Ilseman26ee2b82012-11-15 22:34:00 +0000128
David Majnemerdad0a642014-06-27 18:19:56 +0000129 // Comdat forward reference information.
130 std::map<std::string, LocTy> ForwardRefComdats;
131
Chris Lattner3432c622009-10-28 03:39:23 +0000132 // References to blockaddress. The key is the function ValID, the value is
133 // a list of references to blocks in that function.
Duncan P. N. Exon Smith17169902014-08-19 00:13:19 +0000134 std::map<ValID, std::map<ValID, GlobalValue *>> ForwardRefBlockAddresses;
135 class PerFunctionState;
136 /// Reference to per-function state to allow basic blocks to be
137 /// forward-referenced by blockaddress instructions within the same
138 /// function.
139 PerFunctionState *BlockAddressPFS;
Michael Ilseman26ee2b82012-11-15 22:34:00 +0000140
Bill Wendling63b88192013-02-06 06:52:58 +0000141 // Attribute builder reference information.
Bill Wendlingb32b0412013-02-08 06:32:06 +0000142 std::map<Value*, std::vector<unsigned> > ForwardRefAttrGroups;
143 std::map<unsigned, AttrBuilder> NumberedAttrBuilders;
Bill Wendling63b88192013-02-06 06:52:58 +0000144
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000145 // Summary global value reference information.
146 std::map<unsigned, std::vector<std::pair<ValueInfo *, LocTy>>>
147 ForwardRefValueInfos;
148 std::map<unsigned, std::vector<std::pair<AliasSummary *, LocTy>>>
149 ForwardRefAliasees;
150 std::vector<ValueInfo> NumberedValueInfos;
151
152 // Summary type id reference information.
153 std::map<unsigned, std::vector<std::pair<GlobalValue::GUID *, LocTy>>>
154 ForwardRefTypeIds;
155
156 // Map of module ID to path.
157 std::map<unsigned, StringRef> ModuleIdMap;
158
Adrian Prantla8b2ddb2017-10-02 18:31:29 +0000159 /// Only the llvm-as tool may set this to false to bypass
160 /// UpgradeDebuginfo so it can generate broken bitcode.
161 bool UpgradeDebugInfo;
162
Yaxun Liuc00d81e2018-01-30 22:32:39 +0000163 /// DataLayout string to override that in LLVM assembly.
164 StringRef DataLayoutStr;
165
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000166 std::string SourceFileName;
167
Chris Lattnerac161bf2009-01-02 07:01:27 +0000168 public:
Alex Lorenz8955f7d2015-06-23 17:10:10 +0000169 LLParser(StringRef F, SourceMgr &SM, SMDiagnostic &Err, Module *M,
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000170 ModuleSummaryIndex *Index, LLVMContext &Context,
Yaxun Liuc00d81e2018-01-30 22:32:39 +0000171 SlotMapping *Slots = nullptr, bool UpgradeDebugInfo = true,
172 StringRef DataLayoutString = "")
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000173 : Context(Context), Lex(F, SM, Err, Context), M(M), Index(Index),
Adrian Prantla8b2ddb2017-10-02 18:31:29 +0000174 Slots(Slots), BlockAddressPFS(nullptr),
Yaxun Liuc00d81e2018-01-30 22:32:39 +0000175 UpgradeDebugInfo(UpgradeDebugInfo), DataLayoutStr(DataLayoutString) {
176 if (!DataLayoutStr.empty())
177 M->setDataLayout(DataLayoutStr);
178 }
Chris Lattnerad6f3352009-01-04 20:44:11 +0000179 bool Run();
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000180
Alex Lorenz1de2acd2015-08-21 21:32:39 +0000181 bool parseStandaloneConstantValue(Constant *&C, const SlotMapping *Slots);
Alex Lorenzd2255952015-07-17 22:07:03 +0000182
Quentin Colombetdafed5d2016-03-08 00:37:07 +0000183 bool parseTypeAtBeginning(Type *&Ty, unsigned &Read,
184 const SlotMapping *Slots);
Quentin Colombet81e72b42016-03-07 22:09:05 +0000185
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000186 LLVMContext &getContext() { return Context; }
Owen Anderson09063ce2009-07-02 17:04:01 +0000187
Chris Lattnerac161bf2009-01-02 07:01:27 +0000188 private:
189
Benjamin Kramerc7583112010-09-27 17:42:11 +0000190 bool Error(LocTy L, const Twine &Msg) const {
Chris Lattnerac161bf2009-01-02 07:01:27 +0000191 return Lex.Error(L, Msg);
192 }
Benjamin Kramerc7583112010-09-27 17:42:11 +0000193 bool TokError(const Twine &Msg) const {
Chris Lattnerac161bf2009-01-02 07:01:27 +0000194 return Error(Lex.getLoc(), Msg);
195 }
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000196
Alex Lorenz1de2acd2015-08-21 21:32:39 +0000197 /// Restore the internal name and slot mappings using the mappings that
198 /// were created at an earlier parsing stage.
199 void restoreParsingState(const SlotMapping *Slots);
200
Chris Lattnerac161bf2009-01-02 07:01:27 +0000201 /// GetGlobalVal - Get a value with the specified name or ID, creating a
202 /// forward reference record if needed. This can return null if the value
203 /// exists but does not have the right type.
Alexander Richardson6bcf2ba2018-08-23 09:25:17 +0000204 GlobalValue *GetGlobalVal(const std::string &N, Type *Ty, LocTy Loc,
205 bool IsCall);
206 GlobalValue *GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc, bool IsCall);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000207
David Majnemerdad0a642014-06-27 18:19:56 +0000208 /// Get a Comdat with the specified name, creating a forward reference
209 /// record if needed.
Fangrui Song28f69c72018-07-12 02:03:53 +0000210 Comdat *getComdat(const std::string &Name, LocTy Loc);
David Majnemerdad0a642014-06-27 18:19:56 +0000211
Chris Lattnerac161bf2009-01-02 07:01:27 +0000212 // Helper Routines.
213 bool ParseToken(lltok::Kind T, const char *ErrMsg);
Chris Lattner3822f632009-01-02 08:05:26 +0000214 bool EatIfPresent(lltok::Kind T) {
215 if (Lex.getKind() != T) return false;
216 Lex.Lex();
217 return true;
218 }
Michael Ilseman92053172012-11-27 00:42:44 +0000219
220 FastMathFlags EatFastMathFlagsIfPresent() {
221 FastMathFlags FMF;
222 while (true)
223 switch (Lex.getKind()) {
Sanjay Patel629c4112017-11-06 16:27:15 +0000224 case lltok::kw_fast: FMF.setFast(); Lex.Lex(); continue;
Michael Ilseman65f14352012-12-09 21:12:04 +0000225 case lltok::kw_nnan: FMF.setNoNaNs(); Lex.Lex(); continue;
226 case lltok::kw_ninf: FMF.setNoInfs(); Lex.Lex(); continue;
227 case lltok::kw_nsz: FMF.setNoSignedZeros(); Lex.Lex(); continue;
228 case lltok::kw_arcp: FMF.setAllowReciprocal(); Lex.Lex(); continue;
Adam Nemetcd847a82017-03-28 20:11:52 +0000229 case lltok::kw_contract:
230 FMF.setAllowContract(true);
231 Lex.Lex();
232 continue;
Sanjay Patel629c4112017-11-06 16:27:15 +0000233 case lltok::kw_reassoc: FMF.setAllowReassoc(); Lex.Lex(); continue;
234 case lltok::kw_afn: FMF.setApproxFunc(); Lex.Lex(); continue;
Michael Ilseman92053172012-11-27 00:42:44 +0000235 default: return FMF;
236 }
237 return FMF;
238 }
239
Craig Topperada08572014-04-16 04:21:27 +0000240 bool ParseOptionalToken(lltok::Kind T, bool &Present,
241 LocTy *Loc = nullptr) {
Chris Lattnerac161bf2009-01-02 07:01:27 +0000242 if (Lex.getKind() != T) {
243 Present = false;
244 } else {
Rafael Espindola026d1522011-01-13 01:30:30 +0000245 if (Loc)
246 *Loc = Lex.getLoc();
Chris Lattnerac161bf2009-01-02 07:01:27 +0000247 Lex.Lex();
248 Present = true;
249 }
250 return false;
251 }
Chris Lattner3822f632009-01-02 08:05:26 +0000252 bool ParseStringConstant(std::string &Result);
253 bool ParseUInt32(unsigned &Val);
254 bool ParseUInt32(unsigned &Val, LocTy &Loc) {
Chris Lattnerac161bf2009-01-02 07:01:27 +0000255 Loc = Lex.getLoc();
Chris Lattner3822f632009-01-02 08:05:26 +0000256 return ParseUInt32(Val);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000257 }
Hal Finkelb0407ba2014-07-18 15:51:28 +0000258 bool ParseUInt64(uint64_t &Val);
259 bool ParseUInt64(uint64_t &Val, LocTy &Loc) {
260 Loc = Lex.getLoc();
261 return ParseUInt64(Val);
262 }
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000263 bool ParseFlag(unsigned &Val);
Hans Wennborgcbe34b42012-06-23 11:37:03 +0000264
Artur Pilipenko17376c42015-08-03 14:31:49 +0000265 bool ParseStringAttribute(AttrBuilder &B);
266
Hans Wennborgcbe34b42012-06-23 11:37:03 +0000267 bool ParseTLSModel(GlobalVariable::ThreadLocalMode &TLM);
268 bool ParseOptionalThreadLocal(GlobalVariable::ThreadLocalMode &TLM);
Peter Collingbourne96efdd62016-06-14 21:01:22 +0000269 bool ParseOptionalUnnamedAddr(GlobalVariable::UnnamedAddr &UnnamedAddr);
Alexander Richardson6bcf2ba2018-08-23 09:25:17 +0000270 bool ParseOptionalAddrSpace(unsigned &AddrSpace, unsigned DefaultAS = 0);
271 bool ParseOptionalProgramAddrSpace(unsigned &AddrSpace) {
272 return ParseOptionalAddrSpace(
273 AddrSpace, M->getDataLayout().getProgramAddressSpace());
274 };
Bill Wendling34c2eb22012-12-04 23:40:58 +0000275 bool ParseOptionalParamAttrs(AttrBuilder &B);
276 bool ParseOptionalReturnAttrs(AttrBuilder &B);
Fangrui Song28f69c72018-07-12 02:03:53 +0000277 bool ParseOptionalLinkage(unsigned &Res, bool &HasLinkage,
Sean Fertilec70d28b2017-10-26 15:00:26 +0000278 unsigned &Visibility, unsigned &DLLStorageClass,
279 bool &DSOLocal);
280 void ParseOptionalDSOLocal(bool &DSOLocal);
Fangrui Song28f69c72018-07-12 02:03:53 +0000281 void ParseOptionalVisibility(unsigned &Res);
282 void ParseOptionalDLLStorageClass(unsigned &Res);
Alexey Samsonov17a9cff2014-09-10 18:00:17 +0000283 bool ParseOptionalCallingConv(unsigned &CC);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000284 bool ParseOptionalAlignment(unsigned &Alignment);
Sanjoy Das31ea6d12015-04-16 20:29:50 +0000285 bool ParseOptionalDerefAttrBytes(lltok::Kind AttrKind, uint64_t &Bytes);
Konstantin Zhuravlyovbb80d3e2017-07-11 22:23:00 +0000286 bool ParseScopeAndOrdering(bool isAtomic, SyncScope::ID &SSID,
Eli Friedmanfee02c62011-07-25 23:16:38 +0000287 AtomicOrdering &Ordering);
Konstantin Zhuravlyovbb80d3e2017-07-11 22:23:00 +0000288 bool ParseScope(SyncScope::ID &SSID);
Tim Northovere94a5182014-03-11 10:48:52 +0000289 bool ParseOrdering(AtomicOrdering &Ordering);
Charles Davisbe5557e2010-02-12 00:31:15 +0000290 bool ParseOptionalStackAlignment(unsigned &Alignment);
Chris Lattnerb2f39502009-12-30 05:44:30 +0000291 bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
Matt Arsenault3c1fc762017-04-10 22:27:50 +0000292 bool ParseOptionalCommaAddrSpace(unsigned &AddrSpace, LocTy &Loc,
293 bool &AteExtraComma);
Reid Kleckner436c42e2014-01-17 23:58:17 +0000294 bool ParseOptionalCommaInAlloca(bool &IsInAlloca);
Fangrui Song28f69c72018-07-12 02:03:53 +0000295 bool parseAllocSizeArguments(unsigned &BaseSizeArg,
George Burgess IV278199f2016-04-12 01:05:35 +0000296 Optional<unsigned> &HowManyArg);
297 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,
298 bool &AteExtraComma);
Chris Lattner28f1eeb2009-12-30 05:14:00 +0000299 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
300 bool AteExtraComma;
301 if (ParseIndexList(Indices, AteExtraComma)) return true;
302 if (AteExtraComma)
303 return TokError("expected index");
304 return false;
305 }
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000306
Chris Lattnerac161bf2009-01-02 07:01:27 +0000307 // Top-Level Entities
308 bool ParseTopLevelEntities();
309 bool ValidateEndOfModule();
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000310 bool ValidateEndOfIndex();
Chris Lattnerac161bf2009-01-02 07:01:27 +0000311 bool ParseTargetDefinition();
Chris Lattnerac161bf2009-01-02 07:01:27 +0000312 bool ParseModuleAsm();
Teresa Johnson83c517c2016-03-30 18:15:08 +0000313 bool ParseSourceFileName();
Bill Wendling706d3d62012-11-28 08:41:48 +0000314 bool ParseDepLibs(); // FIXME: Remove in 4.0.
Chris Lattnerac161bf2009-01-02 07:01:27 +0000315 bool ParseUnnamedType();
316 bool ParseNamedType();
317 bool ParseDeclare();
318 bool ParseDefine();
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000319
Chris Lattnerac161bf2009-01-02 07:01:27 +0000320 bool ParseGlobalType(bool &IsConstant);
Dan Gohman466876b2009-08-12 23:32:33 +0000321 bool ParseUnnamedGlobal();
Chris Lattnerac161bf2009-01-02 07:01:27 +0000322 bool ParseNamedGlobal();
Fangrui Song28f69c72018-07-12 02:03:53 +0000323 bool ParseGlobal(const std::string &Name, LocTy NameLoc, unsigned Linkage,
Nico Rieck7157bb72014-01-14 15:22:47 +0000324 bool HasLinkage, unsigned Visibility,
Sean Fertilec70d28b2017-10-26 15:00:26 +0000325 unsigned DLLStorageClass, bool DSOLocal,
Peter Collingbourne96efdd62016-06-14 21:01:22 +0000326 GlobalVariable::ThreadLocalMode TLM,
327 GlobalVariable::UnnamedAddr UnnamedAddr);
Fangrui Song28f69c72018-07-12 02:03:53 +0000328 bool parseIndirectSymbol(const std::string &Name, LocTy NameLoc,
329 unsigned L, unsigned Visibility,
Sean Fertilec70d28b2017-10-26 15:00:26 +0000330 unsigned DLLStorageClass, bool DSOLocal,
Dmitry Polukhina3d5b0b2016-04-05 08:47:51 +0000331 GlobalVariable::ThreadLocalMode TLM,
Peter Collingbourne96efdd62016-06-14 21:01:22 +0000332 GlobalVariable::UnnamedAddr UnnamedAddr);
David Majnemerdad0a642014-06-27 18:19:56 +0000333 bool parseComdat();
Devang Patel39e64d42009-07-01 19:21:12 +0000334 bool ParseStandaloneMetadata();
Devang Patelbe626972009-07-29 00:34:02 +0000335 bool ParseNamedMetadata();
Chris Lattner1797fc72009-12-29 21:53:55 +0000336 bool ParseMDString(MDString *&Result);
Chris Lattner6dac02a2009-12-30 04:15:23 +0000337 bool ParseMDNodeID(MDNode *&Result);
Bill Wendling63b88192013-02-06 06:52:58 +0000338 bool ParseUnnamedAttrGrp();
Bill Wendlingb32b0412013-02-08 06:32:06 +0000339 bool ParseFnAttributeValuePairs(AttrBuilder &B,
340 std::vector<unsigned> &FwdRefAttrGrps,
Michael Gottesman41748d72013-06-27 00:25:01 +0000341 bool inAttrGrp, LocTy &BuiltinLoc);
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000342
343 // Module Summary Index Parsing.
Teresa Johnson08d5b4e2018-05-26 02:34:13 +0000344 bool SkipModuleSummaryEntry();
345 bool ParseSummaryEntry();
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000346 bool ParseModuleEntry(unsigned ID);
347 bool ParseModuleReference(StringRef &ModulePath);
348 bool ParseGVReference(ValueInfo &VI, unsigned &GVId);
349 bool ParseGVEntry(unsigned ID);
350 bool ParseFunctionSummary(std::string Name, GlobalValue::GUID, unsigned ID);
351 bool ParseVariableSummary(std::string Name, GlobalValue::GUID, unsigned ID);
352 bool ParseAliasSummary(std::string Name, GlobalValue::GUID, unsigned ID);
353 bool ParseGVFlags(GlobalValueSummary::GVFlags &GVFlags);
Eugene Leviant009d8332018-11-23 10:54:51 +0000354 bool ParseGVarFlags(GlobalVarSummary::GVarFlags &GVarFlags);
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000355 bool ParseOptionalFFlags(FunctionSummary::FFlags &FFlags);
356 bool ParseOptionalCalls(std::vector<FunctionSummary::EdgeTy> &Calls);
357 bool ParseHotness(CalleeInfo::HotnessType &Hotness);
358 bool ParseOptionalTypeIdInfo(FunctionSummary::TypeIdInfo &TypeIdInfo);
359 bool ParseTypeTests(std::vector<GlobalValue::GUID> &TypeTests);
360 bool ParseVFuncIdList(lltok::Kind Kind,
361 std::vector<FunctionSummary::VFuncId> &VFuncIdList);
362 bool ParseConstVCallList(
363 lltok::Kind Kind,
364 std::vector<FunctionSummary::ConstVCall> &ConstVCallList);
365 using IdToIndexMapType =
366 std::map<unsigned, std::vector<std::pair<unsigned, LocTy>>>;
367 bool ParseConstVCall(FunctionSummary::ConstVCall &ConstVCall,
368 IdToIndexMapType &IdToIndexMap, unsigned Index);
369 bool ParseVFuncId(FunctionSummary::VFuncId &VFuncId,
370 IdToIndexMapType &IdToIndexMap, unsigned Index);
371 bool ParseOptionalRefs(std::vector<ValueInfo> &Refs);
372 bool ParseTypeIdEntry(unsigned ID);
373 bool ParseTypeIdSummary(TypeIdSummary &TIS);
374 bool ParseTypeTestResolution(TypeTestResolution &TTRes);
375 bool ParseOptionalWpdResolutions(
376 std::map<uint64_t, WholeProgramDevirtResolution> &WPDResMap);
377 bool ParseWpdRes(WholeProgramDevirtResolution &WPDRes);
378 bool ParseOptionalResByArg(
379 std::map<std::vector<uint64_t>, WholeProgramDevirtResolution::ByArg>
380 &ResByArg);
381 bool ParseArgs(std::vector<uint64_t> &Args);
382 void AddGlobalValueToIndex(std::string Name, GlobalValue::GUID,
383 GlobalValue::LinkageTypes Linkage, unsigned ID,
384 std::unique_ptr<GlobalValueSummary> Summary);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000385
Chris Lattnerac161bf2009-01-02 07:01:27 +0000386 // Type Parsing.
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000387 bool ParseType(Type *&Result, const Twine &Msg, bool AllowVoid = false);
388 bool ParseType(Type *&Result, bool AllowVoid = false) {
389 return ParseType(Result, "expected type", AllowVoid);
390 }
391 bool ParseType(Type *&Result, const Twine &Msg, LocTy &Loc,
392 bool AllowVoid = false) {
393 Loc = Lex.getLoc();
394 return ParseType(Result, Msg, AllowVoid);
395 }
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000396 bool ParseType(Type *&Result, LocTy &Loc, bool AllowVoid = false) {
Chris Lattnerac161bf2009-01-02 07:01:27 +0000397 Loc = Lex.getLoc();
Chris Lattnerf880ca22009-03-09 04:49:14 +0000398 return ParseType(Result, AllowVoid);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000399 }
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000400 bool ParseAnonStructType(Type *&Result, bool Packed);
401 bool ParseStructBody(SmallVectorImpl<Type*> &Body);
402 bool ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
403 std::pair<Type*, LocTy> &Entry,
404 Type *&ResultTy);
405
406 bool ParseArrayVectorType(Type *&Result, bool isVector);
407 bool ParseFunctionType(Type *&Result);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000408
Chris Lattnerac161bf2009-01-02 07:01:27 +0000409 // Function Semantic Analysis.
410 class PerFunctionState {
411 LLParser &P;
412 Function &F;
413 std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
414 std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
415 std::vector<Value*> NumberedVals;
Michael Ilseman26ee2b82012-11-15 22:34:00 +0000416
Chris Lattner3432c622009-10-28 03:39:23 +0000417 /// FunctionNumber - If this is an unnamed function, this is the slot
418 /// number of it, otherwise it is -1.
419 int FunctionNumber;
Chris Lattnerac161bf2009-01-02 07:01:27 +0000420 public:
Fangrui Song28f69c72018-07-12 02:03:53 +0000421 PerFunctionState(LLParser &p, Function &f, int functionNumber);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000422 ~PerFunctionState();
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000423
Chris Lattnerac161bf2009-01-02 07:01:27 +0000424 Function &getFunction() const { return F; }
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000425
Chris Lattner3432c622009-10-28 03:39:23 +0000426 bool FinishFunction();
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000427
Chris Lattnerac161bf2009-01-02 07:01:27 +0000428 /// GetVal - Get a value with the specified name or ID, creating a
429 /// forward reference record if needed. This can return null if the value
430 /// exists but does not have the right type.
Alexander Richardsonc11ae182018-02-27 11:15:11 +0000431 Value *GetVal(const std::string &Name, Type *Ty, LocTy Loc, bool IsCall);
432 Value *GetVal(unsigned ID, Type *Ty, LocTy Loc, bool IsCall);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000433
Chris Lattnerac161bf2009-01-02 07:01:27 +0000434 /// SetInstName - After an instruction is parsed and inserted into its
435 /// basic block, this installs its name.
436 bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
437 Instruction *Inst);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000438
Chris Lattnerac161bf2009-01-02 07:01:27 +0000439 /// GetBB - Get a basic block with the specified name or ID, creating a
440 /// forward reference record if needed. This can return null if the value
441 /// is not a BasicBlock.
442 BasicBlock *GetBB(const std::string &Name, LocTy Loc);
443 BasicBlock *GetBB(unsigned ID, LocTy Loc);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000444
Chris Lattnerac161bf2009-01-02 07:01:27 +0000445 /// DefineBB - Define the specified basic block, which is either named or
446 /// unnamed. If there is an error, this returns null otherwise it returns
447 /// the block being defined.
James Y Knightc0e6b8a2019-03-22 18:27:13 +0000448 BasicBlock *DefineBB(const std::string &Name, int NameID, LocTy Loc);
Duncan P. N. Exon Smith17169902014-08-19 00:13:19 +0000449
450 bool resolveForwardRefBlockAddresses();
Chris Lattnerac161bf2009-01-02 07:01:27 +0000451 };
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000452
Chris Lattner229907c2011-07-18 04:54:35 +0000453 bool ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
Alexander Richardsonc11ae182018-02-27 11:15:11 +0000454 PerFunctionState *PFS, bool IsCall);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000455
Alexander Richardson6bcf2ba2018-08-23 09:25:17 +0000456 Value *checkValidVariableType(LocTy Loc, const Twine &Name, Type *Ty,
457 Value *Val, bool IsCall);
458
Alex Lorenzd2255952015-07-17 22:07:03 +0000459 bool parseConstantValue(Type *Ty, Constant *&C);
David Majnemer8a1c45d2015-12-12 05:38:55 +0000460 bool ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS);
461 bool ParseValue(Type *Ty, Value *&V, PerFunctionState &PFS) {
462 return ParseValue(Ty, V, &PFS);
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000463 }
David Majnemer8a1c45d2015-12-12 05:38:55 +0000464
Chris Lattner229907c2011-07-18 04:54:35 +0000465 bool ParseValue(Type *Ty, Value *&V, LocTy &Loc,
Chris Lattnerac161bf2009-01-02 07:01:27 +0000466 PerFunctionState &PFS) {
467 Loc = Lex.getLoc();
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000468 return ParseValue(Ty, V, &PFS);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000469 }
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000470
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000471 bool ParseTypeAndValue(Value *&V, PerFunctionState *PFS);
472 bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
473 return ParseTypeAndValue(V, &PFS);
474 }
Chris Lattnerac161bf2009-01-02 07:01:27 +0000475 bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
476 Loc = Lex.getLoc();
477 return ParseTypeAndValue(V, PFS);
478 }
Chris Lattner3ed871f2009-10-27 19:13:16 +0000479 bool ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
480 PerFunctionState &PFS);
481 bool ParseTypeAndBasicBlock(BasicBlock *&BB, PerFunctionState &PFS) {
482 LocTy Loc;
483 return ParseTypeAndBasicBlock(BB, Loc, PFS);
484 }
Victor Hernandezfa232232009-12-03 23:40:58 +0000485
Chris Lattner392be582010-02-12 20:49:41 +0000486
Chris Lattnerac161bf2009-01-02 07:01:27 +0000487 struct ParamInfo {
488 LocTy Loc;
489 Value *V;
Reid Klecknerc2cb5602017-04-12 00:38:00 +0000490 AttributeSet Attrs;
491 ParamInfo(LocTy loc, Value *v, AttributeSet attrs)
Reid Klecknerb5180542017-03-21 16:57:19 +0000492 : Loc(loc), V(v), Attrs(attrs) {}
Chris Lattnerac161bf2009-01-02 07:01:27 +0000493 };
494 bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
Reid Kleckner83498642014-08-26 00:33:28 +0000495 PerFunctionState &PFS,
496 bool IsMustTailCall = false,
497 bool InVarArgsFunc = false);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000498
Sanjoy Dasb513a9f2015-09-24 23:34:52 +0000499 bool
500 ParseOptionalOperandBundles(SmallVectorImpl<OperandBundleDef> &BundleList,
501 PerFunctionState &PFS);
502
David Majnemer654e1302015-07-31 17:58:14 +0000503 bool ParseExceptionArgs(SmallVectorImpl<Value *> &Args,
504 PerFunctionState &PFS);
505
Victor Hernandezdc6e65a2010-01-05 22:22:14 +0000506 // Constant Parsing.
Craig Topperada08572014-04-16 04:21:27 +0000507 bool ParseValID(ValID &ID, PerFunctionState *PFS = nullptr);
Fangrui Song28f69c72018-07-12 02:03:53 +0000508 bool ParseGlobalValue(Type *Ty, Constant *&C);
Victor Hernandezdc6e65a2010-01-05 22:22:14 +0000509 bool ParseGlobalTypeAndValue(Constant *&V);
Peter Collingbourned93620b2016-11-10 22:34:55 +0000510 bool ParseGlobalValueVector(SmallVectorImpl<Constant *> &Elts,
511 Optional<unsigned> *InRangeOp = nullptr);
Rafael Espindola83a362c2015-01-06 22:55:16 +0000512 bool parseOptionalComdat(StringRef GlobalName, Comdat *&C);
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000513 bool ParseMetadataAsValue(Value *&V, PerFunctionState &PFS);
Duncan P. N. Exon Smith19fc5ed2015-02-13 01:26:47 +0000514 bool ParseValueAsMetadata(Metadata *&MD, const Twine &TypeMsg,
515 PerFunctionState *PFS);
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000516 bool ParseMetadata(Metadata *&MD, PerFunctionState *PFS);
Duncan P. N. Exon Smith58ef9d12015-01-12 21:23:11 +0000517 bool ParseMDTuple(MDNode *&MD, bool IsDistinct = false);
Fangrui Song28f69c72018-07-12 02:03:53 +0000518 bool ParseMDNode(MDNode *&N);
519 bool ParseMDNodeTail(MDNode *&N);
520 bool ParseMDNodeVector(SmallVectorImpl<Metadata *> &Elts);
Duncan P. N. Exon Smith19717ea2015-04-24 21:21:57 +0000521 bool ParseMetadataAttachment(unsigned &Kind, MDNode *&MD);
Duncan P. N. Exon Smith27d702c2015-04-24 21:29:36 +0000522 bool ParseInstructionMetadata(Instruction &Inst);
Peter Collingbournecceae7f2016-05-31 23:01:54 +0000523 bool ParseGlobalObjectMetadataAttachment(GlobalObject &GO);
Duncan P. N. Exon Smith3d4cd752015-04-24 22:04:41 +0000524 bool ParseOptionalFunctionMetadata(Function &F);
Victor Hernandezdc6e65a2010-01-05 22:22:14 +0000525
Duncan P. N. Exon Smith077c0312015-02-04 22:05:21 +0000526 template <class FieldTy>
527 bool ParseMDField(LocTy Loc, StringRef Name, FieldTy &Result);
Duncan P. N. Exon Smitha7477282015-01-20 02:42:29 +0000528 template <class FieldTy> bool ParseMDField(StringRef Name, FieldTy &Result);
Duncan P. N. Exon Smith13890af2015-01-19 23:32:36 +0000529 template <class ParserTy>
Duncan P. N. Exon Smith66ca92e2015-01-19 23:39:32 +0000530 bool ParseMDFieldsImplBody(ParserTy parseField);
531 template <class ParserTy>
Duncan P. N. Exon Smith13890af2015-01-19 23:32:36 +0000532 bool ParseMDFieldsImpl(ParserTy parseField, LocTy &ClosingLoc);
Duncan P. N. Exon Smith6a484832015-01-13 21:10:44 +0000533 bool ParseSpecializedMDNode(MDNode *&N, bool IsDistinct = false);
Duncan P. N. Exon Smithed458fa2015-02-10 01:08:16 +0000534
535#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) \
536 bool Parse##CLASS(MDNode *&Result, bool IsDistinct);
537#include "llvm/IR/Metadata.def"
Duncan P. N. Exon Smith6a484832015-01-13 21:10:44 +0000538
Chris Lattnerac161bf2009-01-02 07:01:27 +0000539 // Function Parsing.
540 struct ArgInfo {
541 LocTy Loc;
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000542 Type *Ty;
Reid Klecknerc2cb5602017-04-12 00:38:00 +0000543 AttributeSet Attrs;
Chris Lattnerac161bf2009-01-02 07:01:27 +0000544 std::string Name;
Reid Klecknerc2cb5602017-04-12 00:38:00 +0000545 ArgInfo(LocTy L, Type *ty, AttributeSet Attr, const std::string &N)
Reid Klecknerb5180542017-03-21 16:57:19 +0000546 : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
Chris Lattnerac161bf2009-01-02 07:01:27 +0000547 };
Chris Lattnerb1ed91f2011-07-09 17:41:24 +0000548 bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000549 bool ParseFunctionHeader(Function *&Fn, bool isDefine);
550 bool ParseFunctionBody(Function &Fn);
551 bool ParseBasicBlock(PerFunctionState &PFS);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000552
Reid Kleckner5772b772014-04-24 20:14:34 +0000553 enum TailCallType { TCT_None, TCT_Tail, TCT_MustTail };
554
Chris Lattner77b89dc2009-12-30 05:23:43 +0000555 // Instruction Parsing. Each instruction parsing routine can return with a
556 // normal result, an error result, or return having eaten an extra comma.
557 enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
558 int ParseInstruction(Instruction *&Inst, BasicBlock *BB,
559 PerFunctionState &PFS);
Fangrui Song28f69c72018-07-12 02:03:53 +0000560 bool ParseCmpPredicate(unsigned &P, unsigned Opc);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000561
Chris Lattner33de4272011-06-17 06:49:41 +0000562 bool ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000563 bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
564 bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerd04cb6d2009-10-28 00:19:10 +0000565 bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000566 bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
Bill Wendlingf891bf82011-07-31 06:30:59 +0000567 bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
David Majnemer654e1302015-07-31 17:58:14 +0000568 bool ParseCleanupRet(Instruction *&Inst, PerFunctionState &PFS);
569 bool ParseCatchRet(Instruction *&Inst, PerFunctionState &PFS);
David Majnemer8a1c45d2015-12-12 05:38:55 +0000570 bool ParseCatchSwitch(Instruction *&Inst, PerFunctionState &PFS);
David Majnemer654e1302015-07-31 17:58:14 +0000571 bool ParseCatchPad(Instruction *&Inst, PerFunctionState &PFS);
David Majnemer654e1302015-07-31 17:58:14 +0000572 bool ParseCleanupPad(Instruction *&Inst, PerFunctionState &PFS);
Craig Topper784929d2019-02-08 20:48:56 +0000573 bool ParseCallBr(Instruction *&Inst, PerFunctionState &PFS);
Misha Brukman1d9a93d2009-01-02 22:46:48 +0000574
Cameron McInallycbde0d92018-11-13 18:15:47 +0000575 bool ParseUnaryOp(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc,
Craig Topper82796952019-05-05 17:19:19 +0000576 bool IsFP);
Fangrui Song28f69c72018-07-12 02:03:53 +0000577 bool ParseArithmetic(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc,
Craig Topper82796952019-05-05 17:19:19 +0000578 bool IsFP);
Fangrui Song28f69c72018-07-12 02:03:53 +0000579 bool ParseLogical(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc);
580 bool ParseCompare(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc);
581 bool ParseCast(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc);
582 bool ParseSelect(Instruction *&Inst, PerFunctionState &PFS);
583 bool ParseVA_Arg(Instruction *&Inst, PerFunctionState &PFS);
584 bool ParseExtractElement(Instruction *&Inst, PerFunctionState &PFS);
585 bool ParseInsertElement(Instruction *&Inst, PerFunctionState &PFS);
586 bool ParseShuffleVector(Instruction *&Inst, PerFunctionState &PFS);
587 int ParsePHI(Instruction *&Inst, PerFunctionState &PFS);
588 bool ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS);
589 bool ParseCall(Instruction *&Inst, PerFunctionState &PFS,
590 CallInst::TailCallKind TCK);
591 int ParseAlloc(Instruction *&Inst, PerFunctionState &PFS);
592 int ParseLoad(Instruction *&Inst, PerFunctionState &PFS);
593 int ParseStore(Instruction *&Inst, PerFunctionState &PFS);
594 int ParseCmpXchg(Instruction *&Inst, PerFunctionState &PFS);
595 int ParseAtomicRMW(Instruction *&Inst, PerFunctionState &PFS);
596 int ParseFence(Instruction *&Inst, PerFunctionState &PFS);
597 int ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS);
598 int ParseExtractValue(Instruction *&Inst, PerFunctionState &PFS);
599 int ParseInsertValue(Instruction *&Inst, PerFunctionState &PFS);
Duncan P. N. Exon Smith0a448fb2014-08-19 21:30:15 +0000600
601 // Use-list order directives.
602 bool ParseUseListOrder(PerFunctionState *PFS = nullptr);
603 bool ParseUseListOrderBB();
604 bool ParseUseListOrderIndexes(SmallVectorImpl<unsigned> &Indexes);
605 bool sortUseListOrder(Value *V, ArrayRef<unsigned> Indexes, SMLoc Loc);
Chris Lattnerac161bf2009-01-02 07:01:27 +0000606 };
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000607} // End llvm namespace
Chris Lattnerac161bf2009-01-02 07:01:27 +0000608
609#endif