blob: c2537d7bda744ead22f36276c0c4db6b5b845ab2 [file] [log] [blame]
Chris Lattnerdf986172009-01-02 07:01:27 +00001//===-- 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_ASMPARSER_LLPARSER_H
15#define LLVM_ASMPARSER_LLPARSER_H
16
17#include "LLLexer.h"
Eli Friedman47f35132011-07-25 23:16:38 +000018#include "llvm/Instructions.h"
Owen Andersonfba933c2009-07-01 23:57:11 +000019#include "llvm/Module.h"
Chris Lattnerdf986172009-01-02 07:01:27 +000020#include "llvm/Type.h"
Chris Lattnerb45218f2010-04-01 05:20:21 +000021#include "llvm/ADT/DenseMap.h"
Chris Lattner1afcace2011-07-09 17:41:24 +000022#include "llvm/ADT/StringMap.h"
Chris Lattner56608462009-12-28 08:20:46 +000023#include "llvm/Support/ValueHandle.h"
Chris Lattnere80250e2009-12-29 21:43:58 +000024#include <map>
Chris Lattnerdf986172009-01-02 07:01:27 +000025
26namespace llvm {
27 class Module;
28 class OpaqueType;
29 class Function;
30 class Value;
31 class BasicBlock;
32 class Instruction;
33 class Constant;
34 class GlobalValue;
Nick Lewycky21cc4462009-04-04 07:22:01 +000035 class MDString;
36 class MDNode;
Chris Lattner1afcace2011-07-09 17:41:24 +000037 class StructType;
Misha Brukman9ea40342009-01-02 22:46:48 +000038
Chris Lattner09d9ef42009-10-28 03:39:23 +000039 /// ValID - Represents a reference of a definition of some sort with no type.
40 /// There are several cases where we have to parse the value but where the
41 /// type can depend on later context. This may either be a numeric reference
42 /// or a symbolic (%var) reference. This is just a discriminated union.
43 struct ValID {
44 enum {
45 t_LocalID, t_GlobalID, // ID in UIntVal.
46 t_LocalName, t_GlobalName, // Name in StrVal.
47 t_APSInt, t_APFloat, // Value in APSIntVal/APFloatVal.
48 t_Null, t_Undef, t_Zero, // No value.
49 t_EmptyArray, // No value: []
50 t_Constant, // Value in ConstantVal.
51 t_InlineAsm, // Value in StrVal/StrVal2/UIntVal.
Chris Lattner287881d2009-12-30 02:11:14 +000052 t_MDNode, // Value in MDNodeVal.
Chris Lattner1afcace2011-07-09 17:41:24 +000053 t_MDString, // Value in MDStringVal.
54 t_ConstantStruct, // Value in ConstantStructElts.
55 t_PackedConstantStruct // Value in ConstantStructElts.
Chris Lattner09d9ef42009-10-28 03:39:23 +000056 } Kind;
57
58 LLLexer::LocTy Loc;
59 unsigned UIntVal;
60 std::string StrVal, StrVal2;
61 APSInt APSIntVal;
62 APFloat APFloatVal;
63 Constant *ConstantVal;
Chris Lattner287881d2009-12-30 02:11:14 +000064 MDNode *MDNodeVal;
65 MDString *MDStringVal;
Chris Lattner1afcace2011-07-09 17:41:24 +000066 Constant **ConstantStructElts;
67
68 ValID() : Kind(t_LocalID), APFloatVal(0.0) {}
69 ~ValID() {
70 if (Kind == t_ConstantStruct || Kind == t_PackedConstantStruct)
71 delete [] ConstantStructElts;
72 }
Chris Lattner09d9ef42009-10-28 03:39:23 +000073
74 bool operator<(const ValID &RHS) const {
75 if (Kind == t_LocalID || Kind == t_GlobalID)
76 return UIntVal < RHS.UIntVal;
Chris Lattner1afcace2011-07-09 17:41:24 +000077 assert((Kind == t_LocalName || Kind == t_GlobalName ||
78 Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) &&
Chris Lattner09d9ef42009-10-28 03:39:23 +000079 "Ordering not defined for this ValID kind yet");
80 return StrVal < RHS.StrVal;
81 }
82 };
83
Chris Lattnerdf986172009-01-02 07:01:27 +000084 class LLParser {
85 public:
86 typedef LLLexer::LocTy LocTy;
87 private:
Chris Lattner4ba9d9b2010-04-07 04:08:57 +000088 LLVMContext &Context;
Chris Lattnerdf986172009-01-02 07:01:27 +000089 LLLexer Lex;
90 Module *M;
Chris Lattner449c3102010-04-01 05:14:45 +000091
92 // Instruction metadata resolution. Each instruction can have a list of
93 // MDRef info associated with them.
Dan Gohman41d6ab42010-08-24 14:31:06 +000094 //
95 // The simpler approach of just creating temporary MDNodes and then calling
96 // RAUW on them when the definition is processed doesn't work because some
97 // instruction metadata kinds, such as dbg, get stored in the IR in an
98 // "optimized" format which doesn't participate in the normal value use
99 // lists. This means that RAUW doesn't work, even on temporary MDNodes
100 // which otherwise support RAUW. Instead, we defer resolving MDNode
101 // references until the definitions have been processed.
Chris Lattner449c3102010-04-01 05:14:45 +0000102 struct MDRef {
103 SMLoc Loc;
104 unsigned MDKind, MDSlot;
105 };
106 DenseMap<Instruction*, std::vector<MDRef> > ForwardRefInstMetadata;
Misha Brukman9ea40342009-01-02 22:46:48 +0000107
Chris Lattner1afcace2011-07-09 17:41:24 +0000108 // Type resolution handling data structures. The location is set when we
109 // have processed a use of the type but not a definition yet.
110 StringMap<std::pair<Type*, LocTy> > NamedTypes;
111 std::vector<std::pair<Type*, LocTy> > NumberedTypes;
112
Chris Lattner0834e6a2009-12-30 04:51:58 +0000113 std::vector<TrackingVH<MDNode> > NumberedMetadata;
Chris Lattnere80250e2009-12-29 21:43:58 +0000114 std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> > ForwardRefMDNodes;
Chris Lattnerdf986172009-01-02 07:01:27 +0000115
116 // Global Value reference information.
117 std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
118 std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
119 std::vector<GlobalValue*> NumberedVals;
Chris Lattner09d9ef42009-10-28 03:39:23 +0000120
121 // References to blockaddress. The key is the function ValID, the value is
122 // a list of references to blocks in that function.
123 std::map<ValID, std::vector<std::pair<ValID, GlobalValue*> > >
124 ForwardRefBlockAddresses;
125
Chris Lattnerdf986172009-01-02 07:01:27 +0000126 public:
Chris Lattnereeb4a842009-07-02 23:08:13 +0000127 LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
Victor Hernandez13ad5aa2009-10-17 00:00:19 +0000128 Context(m->getContext()), Lex(F, SM, Err, m->getContext()),
Chris Lattnerf3a789d2011-06-17 03:16:47 +0000129 M(m) {}
Chris Lattnerad7d1e22009-01-04 20:44:11 +0000130 bool Run();
Misha Brukman9ea40342009-01-02 22:46:48 +0000131
Chris Lattner1afcace2011-07-09 17:41:24 +0000132 LLVMContext &getContext() { return Context; }
Owen Andersonb43eae72009-07-02 17:04:01 +0000133
Chris Lattnerdf986172009-01-02 07:01:27 +0000134 private:
135
Benjamin Kramerd1e17032010-09-27 17:42:11 +0000136 bool Error(LocTy L, const Twine &Msg) const {
Chris Lattnerdf986172009-01-02 07:01:27 +0000137 return Lex.Error(L, Msg);
138 }
Benjamin Kramerd1e17032010-09-27 17:42:11 +0000139 bool TokError(const Twine &Msg) const {
Chris Lattnerdf986172009-01-02 07:01:27 +0000140 return Error(Lex.getLoc(), Msg);
141 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000142
Chris Lattnerdf986172009-01-02 07:01:27 +0000143 /// GetGlobalVal - Get a value with the specified name or ID, creating a
144 /// forward reference record if needed. This can return null if the value
145 /// exists but does not have the right type.
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000146 GlobalValue *GetGlobalVal(const std::string &N, Type *Ty, LocTy Loc);
147 GlobalValue *GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000148
Chris Lattnerdf986172009-01-02 07:01:27 +0000149 // Helper Routines.
150 bool ParseToken(lltok::Kind T, const char *ErrMsg);
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000151 bool EatIfPresent(lltok::Kind T) {
152 if (Lex.getKind() != T) return false;
153 Lex.Lex();
154 return true;
155 }
Rafael Espindolad72479c2011-01-13 01:30:30 +0000156 bool ParseOptionalToken(lltok::Kind T, bool &Present, LocTy *Loc = 0) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000157 if (Lex.getKind() != T) {
158 Present = false;
159 } else {
Rafael Espindolad72479c2011-01-13 01:30:30 +0000160 if (Loc)
161 *Loc = Lex.getLoc();
Chris Lattnerdf986172009-01-02 07:01:27 +0000162 Lex.Lex();
163 Present = true;
164 }
165 return false;
166 }
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000167 bool ParseStringConstant(std::string &Result);
168 bool ParseUInt32(unsigned &Val);
169 bool ParseUInt32(unsigned &Val, LocTy &Loc) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000170 Loc = Lex.getLoc();
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000171 return ParseUInt32(Val);
Chris Lattnerdf986172009-01-02 07:01:27 +0000172 }
173 bool ParseOptionalAddrSpace(unsigned &AddrSpace);
174 bool ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind);
175 bool ParseOptionalLinkage(unsigned &Linkage, bool &HasLinkage);
176 bool ParseOptionalLinkage(unsigned &Linkage) {
177 bool HasLinkage; return ParseOptionalLinkage(Linkage, HasLinkage);
178 }
179 bool ParseOptionalVisibility(unsigned &Visibility);
Sandeep Patel65c3c8f2009-09-02 08:44:58 +0000180 bool ParseOptionalCallingConv(CallingConv::ID &CC);
Chris Lattnerdf986172009-01-02 07:01:27 +0000181 bool ParseOptionalAlignment(unsigned &Alignment);
Eli Friedman47f35132011-07-25 23:16:38 +0000182 bool ParseScopeAndOrdering(bool isAtomic, SynchronizationScope &Scope,
183 AtomicOrdering &Ordering);
Charles Davis1e063d12010-02-12 00:31:15 +0000184 bool ParseOptionalStackAlignment(unsigned &Alignment);
Chris Lattnerc3a6c5c2009-12-30 05:44:30 +0000185 bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
Chris Lattner628c13a2009-12-30 05:14:00 +0000186 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,bool &AteExtraComma);
187 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
188 bool AteExtraComma;
189 if (ParseIndexList(Indices, AteExtraComma)) return true;
190 if (AteExtraComma)
191 return TokError("expected index");
192 return false;
193 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000194
Chris Lattnerdf986172009-01-02 07:01:27 +0000195 // Top-Level Entities
196 bool ParseTopLevelEntities();
197 bool ValidateEndOfModule();
198 bool ParseTargetDefinition();
199 bool ParseDepLibs();
200 bool ParseModuleAsm();
201 bool ParseUnnamedType();
202 bool ParseNamedType();
203 bool ParseDeclare();
204 bool ParseDefine();
Misha Brukman9ea40342009-01-02 22:46:48 +0000205
Chris Lattnerdf986172009-01-02 07:01:27 +0000206 bool ParseGlobalType(bool &IsConstant);
Dan Gohman3845e502009-08-12 23:32:33 +0000207 bool ParseUnnamedGlobal();
Chris Lattnerdf986172009-01-02 07:01:27 +0000208 bool ParseNamedGlobal();
209 bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
210 bool HasLinkage, unsigned Visibility);
211 bool ParseAlias(const std::string &Name, LocTy Loc, unsigned Visibility);
Devang Patel923078c2009-07-01 19:21:12 +0000212 bool ParseStandaloneMetadata();
Devang Pateleff2ab62009-07-29 00:34:02 +0000213 bool ParseNamedMetadata();
Chris Lattner442ffa12009-12-29 21:53:55 +0000214 bool ParseMDString(MDString *&Result);
Chris Lattner4a72efc2009-12-30 04:15:23 +0000215 bool ParseMDNodeID(MDNode *&Result);
Chris Lattner449c3102010-04-01 05:14:45 +0000216 bool ParseMDNodeID(MDNode *&Result, unsigned &SlotNo);
Misha Brukman9ea40342009-01-02 22:46:48 +0000217
Chris Lattnerdf986172009-01-02 07:01:27 +0000218 // Type Parsing.
Chris Lattner1afcace2011-07-09 17:41:24 +0000219 bool ParseType(Type *&Result, bool AllowVoid = false);
220 bool ParseType(Type *&Result, LocTy &Loc, bool AllowVoid = false) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000221 Loc = Lex.getLoc();
Chris Lattnera9a9e072009-03-09 04:49:14 +0000222 return ParseType(Result, AllowVoid);
Chris Lattnerdf986172009-01-02 07:01:27 +0000223 }
Chris Lattner1afcace2011-07-09 17:41:24 +0000224 bool ParseAnonStructType(Type *&Result, bool Packed);
225 bool ParseStructBody(SmallVectorImpl<Type*> &Body);
226 bool ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
227 std::pair<Type*, LocTy> &Entry,
228 Type *&ResultTy);
229
230 bool ParseArrayVectorType(Type *&Result, bool isVector);
231 bool ParseFunctionType(Type *&Result);
Chris Lattnerdf986172009-01-02 07:01:27 +0000232
Chris Lattnerdf986172009-01-02 07:01:27 +0000233 // Function Semantic Analysis.
234 class PerFunctionState {
235 LLParser &P;
236 Function &F;
237 std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
238 std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
239 std::vector<Value*> NumberedVals;
Chris Lattner09d9ef42009-10-28 03:39:23 +0000240
241 /// FunctionNumber - If this is an unnamed function, this is the slot
242 /// number of it, otherwise it is -1.
243 int FunctionNumber;
Chris Lattnerdf986172009-01-02 07:01:27 +0000244 public:
Chris Lattner09d9ef42009-10-28 03:39:23 +0000245 PerFunctionState(LLParser &p, Function &f, int FunctionNumber);
Chris Lattnerdf986172009-01-02 07:01:27 +0000246 ~PerFunctionState();
Misha Brukman9ea40342009-01-02 22:46:48 +0000247
Chris Lattnerdf986172009-01-02 07:01:27 +0000248 Function &getFunction() const { return F; }
Misha Brukman9ea40342009-01-02 22:46:48 +0000249
Chris Lattner09d9ef42009-10-28 03:39:23 +0000250 bool FinishFunction();
Misha Brukman9ea40342009-01-02 22:46:48 +0000251
Chris Lattnerdf986172009-01-02 07:01:27 +0000252 /// GetVal - Get a value with the specified name or ID, creating a
253 /// forward reference record if needed. This can return null if the value
254 /// exists but does not have the right type.
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000255 Value *GetVal(const std::string &Name, Type *Ty, LocTy Loc);
256 Value *GetVal(unsigned ID, Type *Ty, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000257
Chris Lattnerdf986172009-01-02 07:01:27 +0000258 /// SetInstName - After an instruction is parsed and inserted into its
259 /// basic block, this installs its name.
260 bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
261 Instruction *Inst);
Misha Brukman9ea40342009-01-02 22:46:48 +0000262
Chris Lattnerdf986172009-01-02 07:01:27 +0000263 /// GetBB - Get a basic block with the specified name or ID, creating a
264 /// forward reference record if needed. This can return null if the value
265 /// is not a BasicBlock.
266 BasicBlock *GetBB(const std::string &Name, LocTy Loc);
267 BasicBlock *GetBB(unsigned ID, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000268
Chris Lattnerdf986172009-01-02 07:01:27 +0000269 /// DefineBB - Define the specified basic block, which is either named or
270 /// unnamed. If there is an error, this returns null otherwise it returns
271 /// the block being defined.
272 BasicBlock *DefineBB(const std::string &Name, LocTy Loc);
273 };
Misha Brukman9ea40342009-01-02 22:46:48 +0000274
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000275 bool ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
Victor Hernandez92f238d2010-01-11 22:31:58 +0000276 PerFunctionState *PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000277
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000278 bool ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS);
279 bool ParseValue(Type *Ty, Value *&V, PerFunctionState &PFS) {
Chris Lattner1afcace2011-07-09 17:41:24 +0000280 return ParseValue(Ty, V, &PFS);
281 }
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000282 bool ParseValue(Type *Ty, Value *&V, LocTy &Loc,
Chris Lattnerdf986172009-01-02 07:01:27 +0000283 PerFunctionState &PFS) {
284 Loc = Lex.getLoc();
Chris Lattner1afcace2011-07-09 17:41:24 +0000285 return ParseValue(Ty, V, &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000286 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000287
Chris Lattner1afcace2011-07-09 17:41:24 +0000288 bool ParseTypeAndValue(Value *&V, PerFunctionState *PFS);
289 bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
290 return ParseTypeAndValue(V, &PFS);
291 }
Chris Lattnerdf986172009-01-02 07:01:27 +0000292 bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
293 Loc = Lex.getLoc();
294 return ParseTypeAndValue(V, PFS);
295 }
Chris Lattnerf9be95f2009-10-27 19:13:16 +0000296 bool ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
297 PerFunctionState &PFS);
298 bool ParseTypeAndBasicBlock(BasicBlock *&BB, PerFunctionState &PFS) {
299 LocTy Loc;
300 return ParseTypeAndBasicBlock(BB, Loc, PFS);
301 }
Victor Hernandez19715562009-12-03 23:40:58 +0000302
Chris Lattnerfdfeb692010-02-12 20:49:41 +0000303
Chris Lattnerdf986172009-01-02 07:01:27 +0000304 struct ParamInfo {
305 LocTy Loc;
306 Value *V;
307 unsigned Attrs;
Misha Brukman9ea40342009-01-02 22:46:48 +0000308 ParamInfo(LocTy loc, Value *v, unsigned attrs)
Chris Lattnerdf986172009-01-02 07:01:27 +0000309 : Loc(loc), V(v), Attrs(attrs) {}
310 };
311 bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
312 PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000313
Victor Hernandezbf170d42010-01-05 22:22:14 +0000314 // Constant Parsing.
315 bool ParseValID(ValID &ID, PerFunctionState *PFS = NULL);
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000316 bool ParseGlobalValue(Type *Ty, Constant *&V);
Victor Hernandezbf170d42010-01-05 22:22:14 +0000317 bool ParseGlobalTypeAndValue(Constant *&V);
318 bool ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts);
Dan Gohman309b3af2010-08-24 02:24:03 +0000319 bool ParseMetadataListValue(ValID &ID, PerFunctionState *PFS);
Dan Gohman83448032010-07-14 18:26:50 +0000320 bool ParseMetadataValue(ValID &ID, PerFunctionState *PFS);
Victor Hernandez24e64df2010-01-10 07:14:18 +0000321 bool ParseMDNodeVector(SmallVectorImpl<Value*> &, PerFunctionState *PFS);
Dan Gohman9d072f52010-08-24 02:05:17 +0000322 bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS);
Victor Hernandezbf170d42010-01-05 22:22:14 +0000323
Chris Lattnerdf986172009-01-02 07:01:27 +0000324 // Function Parsing.
325 struct ArgInfo {
326 LocTy Loc;
Chris Lattner1afcace2011-07-09 17:41:24 +0000327 Type *Ty;
Chris Lattnerdf986172009-01-02 07:01:27 +0000328 unsigned Attrs;
329 std::string Name;
Chris Lattner1afcace2011-07-09 17:41:24 +0000330 ArgInfo(LocTy L, Type *ty, unsigned Attr, const std::string &N)
331 : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
Chris Lattnerdf986172009-01-02 07:01:27 +0000332 };
Chris Lattner1afcace2011-07-09 17:41:24 +0000333 bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
Chris Lattnerdf986172009-01-02 07:01:27 +0000334 bool ParseFunctionHeader(Function *&Fn, bool isDefine);
335 bool ParseFunctionBody(Function &Fn);
336 bool ParseBasicBlock(PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000337
Chris Lattnerf1bc7ce2009-12-30 05:23:43 +0000338 // Instruction Parsing. Each instruction parsing routine can return with a
339 // normal result, an error result, or return having eaten an extra comma.
340 enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
341 int ParseInstruction(Instruction *&Inst, BasicBlock *BB,
342 PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000343 bool ParseCmpPredicate(unsigned &Pred, unsigned Opc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000344
Chris Lattner437544f2011-06-17 06:49:41 +0000345 bool ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000346 bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
347 bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerab21db72009-10-28 00:19:10 +0000348 bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000349 bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
Bill Wendlingdccc03b2011-07-31 06:30:59 +0000350 bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000351
Chris Lattnere914b592009-01-05 08:24:46 +0000352 bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
353 unsigned OperandType);
Chris Lattnerdf986172009-01-02 07:01:27 +0000354 bool ParseLogical(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
355 bool ParseCompare(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
356 bool ParseCast(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
357 bool ParseSelect(Instruction *&I, PerFunctionState &PFS);
Chris Lattner0088a5c2009-01-05 08:18:44 +0000358 bool ParseVA_Arg(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000359 bool ParseExtractElement(Instruction *&I, PerFunctionState &PFS);
360 bool ParseInsertElement(Instruction *&I, PerFunctionState &PFS);
361 bool ParseShuffleVector(Instruction *&I, PerFunctionState &PFS);
Chris Lattnera7d7f2c2009-12-30 05:27:33 +0000362 int ParsePHI(Instruction *&I, PerFunctionState &PFS);
Bill Wendlinge6e88262011-08-12 20:24:12 +0000363 bool ParseLandingPad(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000364 bool ParseCall(Instruction *&I, PerFunctionState &PFS, bool isTail);
Chris Lattnerf3a789d2011-06-17 03:16:47 +0000365 int ParseAlloc(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerfbe910e2011-11-27 06:56:53 +0000366 int ParseLoad(Instruction *&I, PerFunctionState &PFS);
367 int ParseStore(Instruction *&I, PerFunctionState &PFS);
Eli Friedmanf03bb262011-08-12 22:50:01 +0000368 int ParseCmpXchg(Instruction *&I, PerFunctionState &PFS);
369 int ParseAtomicRMW(Instruction *&I, PerFunctionState &PFS);
Eli Friedman47f35132011-07-25 23:16:38 +0000370 int ParseFence(Instruction *&I, PerFunctionState &PFS);
Chris Lattnera7d7f2c2009-12-30 05:27:33 +0000371 int ParseGetElementPtr(Instruction *&I, PerFunctionState &PFS);
372 int ParseExtractValue(Instruction *&I, PerFunctionState &PFS);
373 int ParseInsertValue(Instruction *&I, PerFunctionState &PFS);
Chris Lattner09d9ef42009-10-28 03:39:23 +0000374
375 bool ResolveForwardRefBlockAddresses(Function *TheFn,
376 std::vector<std::pair<ValID, GlobalValue*> > &Refs,
377 PerFunctionState *PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000378 };
379} // End llvm namespace
380
381#endif