blob: dda880838117eaa5d0d0f6ba0699ff32aa45379b [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"
Kostya Serebryany164b86b2012-01-20 17:56:17 +000018#include "llvm/Attributes.h"
Eli Friedman47f35132011-07-25 23:16:38 +000019#include "llvm/Instructions.h"
Owen Andersonfba933c2009-07-01 23:57:11 +000020#include "llvm/Module.h"
Chris Lattnerdf986172009-01-02 07:01:27 +000021#include "llvm/Type.h"
Chris Lattnerb45218f2010-04-01 05:20:21 +000022#include "llvm/ADT/DenseMap.h"
Chris Lattner1afcace2011-07-09 17:41:24 +000023#include "llvm/ADT/StringMap.h"
Chris Lattner56608462009-12-28 08:20:46 +000024#include "llvm/Support/ValueHandle.h"
Chris Lattnere80250e2009-12-29 21:43:58 +000025#include <map>
Chris Lattnerdf986172009-01-02 07:01:27 +000026
27namespace llvm {
28 class Module;
29 class OpaqueType;
30 class Function;
31 class Value;
32 class BasicBlock;
33 class Instruction;
34 class Constant;
35 class GlobalValue;
Nick Lewycky21cc4462009-04-04 07:22:01 +000036 class MDString;
37 class MDNode;
Chris Lattner1afcace2011-07-09 17:41:24 +000038 class StructType;
Misha Brukman9ea40342009-01-02 22:46:48 +000039
Chris Lattner09d9ef42009-10-28 03:39:23 +000040 /// ValID - Represents a reference of a definition of some sort with no type.
41 /// There are several cases where we have to parse the value but where the
42 /// type can depend on later context. This may either be a numeric reference
43 /// or a symbolic (%var) reference. This is just a discriminated union.
44 struct ValID {
45 enum {
46 t_LocalID, t_GlobalID, // ID in UIntVal.
47 t_LocalName, t_GlobalName, // Name in StrVal.
48 t_APSInt, t_APFloat, // Value in APSIntVal/APFloatVal.
49 t_Null, t_Undef, t_Zero, // No value.
50 t_EmptyArray, // No value: []
51 t_Constant, // Value in ConstantVal.
52 t_InlineAsm, // Value in StrVal/StrVal2/UIntVal.
Chris Lattner287881d2009-12-30 02:11:14 +000053 t_MDNode, // Value in MDNodeVal.
Chris Lattner1afcace2011-07-09 17:41:24 +000054 t_MDString, // Value in MDStringVal.
55 t_ConstantStruct, // Value in ConstantStructElts.
56 t_PackedConstantStruct // Value in ConstantStructElts.
Chris Lattner09d9ef42009-10-28 03:39:23 +000057 } Kind;
58
59 LLLexer::LocTy Loc;
60 unsigned UIntVal;
61 std::string StrVal, StrVal2;
62 APSInt APSIntVal;
63 APFloat APFloatVal;
64 Constant *ConstantVal;
Chris Lattner287881d2009-12-30 02:11:14 +000065 MDNode *MDNodeVal;
66 MDString *MDStringVal;
Chris Lattner1afcace2011-07-09 17:41:24 +000067 Constant **ConstantStructElts;
68
69 ValID() : Kind(t_LocalID), APFloatVal(0.0) {}
70 ~ValID() {
71 if (Kind == t_ConstantStruct || Kind == t_PackedConstantStruct)
72 delete [] ConstantStructElts;
73 }
Chris Lattner09d9ef42009-10-28 03:39:23 +000074
75 bool operator<(const ValID &RHS) const {
76 if (Kind == t_LocalID || Kind == t_GlobalID)
77 return UIntVal < RHS.UIntVal;
Chris Lattner1afcace2011-07-09 17:41:24 +000078 assert((Kind == t_LocalName || Kind == t_GlobalName ||
79 Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) &&
Chris Lattner09d9ef42009-10-28 03:39:23 +000080 "Ordering not defined for this ValID kind yet");
81 return StrVal < RHS.StrVal;
82 }
83 };
84
Chris Lattnerdf986172009-01-02 07:01:27 +000085 class LLParser {
86 public:
87 typedef LLLexer::LocTy LocTy;
88 private:
Chris Lattner4ba9d9b2010-04-07 04:08:57 +000089 LLVMContext &Context;
Chris Lattnerdf986172009-01-02 07:01:27 +000090 LLLexer Lex;
91 Module *M;
Chris Lattner449c3102010-04-01 05:14:45 +000092
93 // Instruction metadata resolution. Each instruction can have a list of
94 // MDRef info associated with them.
Dan Gohman41d6ab42010-08-24 14:31:06 +000095 //
96 // The simpler approach of just creating temporary MDNodes and then calling
97 // RAUW on them when the definition is processed doesn't work because some
98 // instruction metadata kinds, such as dbg, get stored in the IR in an
99 // "optimized" format which doesn't participate in the normal value use
100 // lists. This means that RAUW doesn't work, even on temporary MDNodes
101 // which otherwise support RAUW. Instead, we defer resolving MDNode
102 // references until the definitions have been processed.
Chris Lattner449c3102010-04-01 05:14:45 +0000103 struct MDRef {
104 SMLoc Loc;
105 unsigned MDKind, MDSlot;
106 };
107 DenseMap<Instruction*, std::vector<MDRef> > ForwardRefInstMetadata;
Misha Brukman9ea40342009-01-02 22:46:48 +0000108
Chris Lattner1afcace2011-07-09 17:41:24 +0000109 // Type resolution handling data structures. The location is set when we
110 // have processed a use of the type but not a definition yet.
111 StringMap<std::pair<Type*, LocTy> > NamedTypes;
112 std::vector<std::pair<Type*, LocTy> > NumberedTypes;
113
Chris Lattner0834e6a2009-12-30 04:51:58 +0000114 std::vector<TrackingVH<MDNode> > NumberedMetadata;
Chris Lattnere80250e2009-12-29 21:43:58 +0000115 std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> > ForwardRefMDNodes;
Chris Lattnerdf986172009-01-02 07:01:27 +0000116
117 // Global Value reference information.
118 std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
119 std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
120 std::vector<GlobalValue*> NumberedVals;
Chris Lattner09d9ef42009-10-28 03:39:23 +0000121
122 // References to blockaddress. The key is the function ValID, the value is
123 // a list of references to blocks in that function.
124 std::map<ValID, std::vector<std::pair<ValID, GlobalValue*> > >
125 ForwardRefBlockAddresses;
126
Chris Lattnerdf986172009-01-02 07:01:27 +0000127 public:
Chris Lattnereeb4a842009-07-02 23:08:13 +0000128 LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
Victor Hernandez13ad5aa2009-10-17 00:00:19 +0000129 Context(m->getContext()), Lex(F, SM, Err, m->getContext()),
Chris Lattnerf3a789d2011-06-17 03:16:47 +0000130 M(m) {}
Chris Lattnerad7d1e22009-01-04 20:44:11 +0000131 bool Run();
Misha Brukman9ea40342009-01-02 22:46:48 +0000132
Chris Lattner1afcace2011-07-09 17:41:24 +0000133 LLVMContext &getContext() { return Context; }
Owen Andersonb43eae72009-07-02 17:04:01 +0000134
Chris Lattnerdf986172009-01-02 07:01:27 +0000135 private:
136
Benjamin Kramerd1e17032010-09-27 17:42:11 +0000137 bool Error(LocTy L, const Twine &Msg) const {
Chris Lattnerdf986172009-01-02 07:01:27 +0000138 return Lex.Error(L, Msg);
139 }
Benjamin Kramerd1e17032010-09-27 17:42:11 +0000140 bool TokError(const Twine &Msg) const {
Chris Lattnerdf986172009-01-02 07:01:27 +0000141 return Error(Lex.getLoc(), Msg);
142 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000143
Chris Lattnerdf986172009-01-02 07:01:27 +0000144 /// GetGlobalVal - Get a value with the specified name or ID, creating a
145 /// forward reference record if needed. This can return null if the value
146 /// exists but does not have the right type.
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000147 GlobalValue *GetGlobalVal(const std::string &N, Type *Ty, LocTy Loc);
148 GlobalValue *GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000149
Chris Lattnerdf986172009-01-02 07:01:27 +0000150 // Helper Routines.
151 bool ParseToken(lltok::Kind T, const char *ErrMsg);
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000152 bool EatIfPresent(lltok::Kind T) {
153 if (Lex.getKind() != T) return false;
154 Lex.Lex();
155 return true;
156 }
Rafael Espindolad72479c2011-01-13 01:30:30 +0000157 bool ParseOptionalToken(lltok::Kind T, bool &Present, LocTy *Loc = 0) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000158 if (Lex.getKind() != T) {
159 Present = false;
160 } else {
Rafael Espindolad72479c2011-01-13 01:30:30 +0000161 if (Loc)
162 *Loc = Lex.getLoc();
Chris Lattnerdf986172009-01-02 07:01:27 +0000163 Lex.Lex();
164 Present = true;
165 }
166 return false;
167 }
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000168 bool ParseStringConstant(std::string &Result);
169 bool ParseUInt32(unsigned &Val);
170 bool ParseUInt32(unsigned &Val, LocTy &Loc) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000171 Loc = Lex.getLoc();
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000172 return ParseUInt32(Val);
Chris Lattnerdf986172009-01-02 07:01:27 +0000173 }
174 bool ParseOptionalAddrSpace(unsigned &AddrSpace);
Kostya Serebryany164b86b2012-01-20 17:56:17 +0000175 bool ParseOptionalAttrs(Attributes &Attrs, unsigned AttrKind);
Chris Lattnerdf986172009-01-02 07:01:27 +0000176 bool ParseOptionalLinkage(unsigned &Linkage, bool &HasLinkage);
177 bool ParseOptionalLinkage(unsigned &Linkage) {
178 bool HasLinkage; return ParseOptionalLinkage(Linkage, HasLinkage);
179 }
180 bool ParseOptionalVisibility(unsigned &Visibility);
Sandeep Patel65c3c8f2009-09-02 08:44:58 +0000181 bool ParseOptionalCallingConv(CallingConv::ID &CC);
Chris Lattnerdf986172009-01-02 07:01:27 +0000182 bool ParseOptionalAlignment(unsigned &Alignment);
Eli Friedman47f35132011-07-25 23:16:38 +0000183 bool ParseScopeAndOrdering(bool isAtomic, SynchronizationScope &Scope,
184 AtomicOrdering &Ordering);
Charles Davis1e063d12010-02-12 00:31:15 +0000185 bool ParseOptionalStackAlignment(unsigned &Alignment);
Chris Lattnerc3a6c5c2009-12-30 05:44:30 +0000186 bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
Chris Lattner628c13a2009-12-30 05:14:00 +0000187 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,bool &AteExtraComma);
188 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
189 bool AteExtraComma;
190 if (ParseIndexList(Indices, AteExtraComma)) return true;
191 if (AteExtraComma)
192 return TokError("expected index");
193 return false;
194 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000195
Chris Lattnerdf986172009-01-02 07:01:27 +0000196 // Top-Level Entities
197 bool ParseTopLevelEntities();
198 bool ValidateEndOfModule();
199 bool ParseTargetDefinition();
200 bool ParseDepLibs();
201 bool ParseModuleAsm();
202 bool ParseUnnamedType();
203 bool ParseNamedType();
204 bool ParseDeclare();
205 bool ParseDefine();
Misha Brukman9ea40342009-01-02 22:46:48 +0000206
Chris Lattnerdf986172009-01-02 07:01:27 +0000207 bool ParseGlobalType(bool &IsConstant);
Dan Gohman3845e502009-08-12 23:32:33 +0000208 bool ParseUnnamedGlobal();
Chris Lattnerdf986172009-01-02 07:01:27 +0000209 bool ParseNamedGlobal();
210 bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
211 bool HasLinkage, unsigned Visibility);
212 bool ParseAlias(const std::string &Name, LocTy Loc, unsigned Visibility);
Devang Patel923078c2009-07-01 19:21:12 +0000213 bool ParseStandaloneMetadata();
Devang Pateleff2ab62009-07-29 00:34:02 +0000214 bool ParseNamedMetadata();
Chris Lattner442ffa12009-12-29 21:53:55 +0000215 bool ParseMDString(MDString *&Result);
Chris Lattner4a72efc2009-12-30 04:15:23 +0000216 bool ParseMDNodeID(MDNode *&Result);
Chris Lattner449c3102010-04-01 05:14:45 +0000217 bool ParseMDNodeID(MDNode *&Result, unsigned &SlotNo);
Misha Brukman9ea40342009-01-02 22:46:48 +0000218
Chris Lattnerdf986172009-01-02 07:01:27 +0000219 // Type Parsing.
Chris Lattner1afcace2011-07-09 17:41:24 +0000220 bool ParseType(Type *&Result, bool AllowVoid = false);
221 bool ParseType(Type *&Result, LocTy &Loc, bool AllowVoid = false) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000222 Loc = Lex.getLoc();
Chris Lattnera9a9e072009-03-09 04:49:14 +0000223 return ParseType(Result, AllowVoid);
Chris Lattnerdf986172009-01-02 07:01:27 +0000224 }
Chris Lattner1afcace2011-07-09 17:41:24 +0000225 bool ParseAnonStructType(Type *&Result, bool Packed);
226 bool ParseStructBody(SmallVectorImpl<Type*> &Body);
227 bool ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
228 std::pair<Type*, LocTy> &Entry,
229 Type *&ResultTy);
230
231 bool ParseArrayVectorType(Type *&Result, bool isVector);
232 bool ParseFunctionType(Type *&Result);
Chris Lattnerdf986172009-01-02 07:01:27 +0000233
Chris Lattnerdf986172009-01-02 07:01:27 +0000234 // Function Semantic Analysis.
235 class PerFunctionState {
236 LLParser &P;
237 Function &F;
238 std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
239 std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
240 std::vector<Value*> NumberedVals;
Chris Lattner09d9ef42009-10-28 03:39:23 +0000241
242 /// FunctionNumber - If this is an unnamed function, this is the slot
243 /// number of it, otherwise it is -1.
244 int FunctionNumber;
Chris Lattnerdf986172009-01-02 07:01:27 +0000245 public:
Chris Lattner09d9ef42009-10-28 03:39:23 +0000246 PerFunctionState(LLParser &p, Function &f, int FunctionNumber);
Chris Lattnerdf986172009-01-02 07:01:27 +0000247 ~PerFunctionState();
Misha Brukman9ea40342009-01-02 22:46:48 +0000248
Chris Lattnerdf986172009-01-02 07:01:27 +0000249 Function &getFunction() const { return F; }
Misha Brukman9ea40342009-01-02 22:46:48 +0000250
Chris Lattner09d9ef42009-10-28 03:39:23 +0000251 bool FinishFunction();
Misha Brukman9ea40342009-01-02 22:46:48 +0000252
Chris Lattnerdf986172009-01-02 07:01:27 +0000253 /// GetVal - Get a value with the specified name or ID, creating a
254 /// forward reference record if needed. This can return null if the value
255 /// exists but does not have the right type.
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000256 Value *GetVal(const std::string &Name, Type *Ty, LocTy Loc);
257 Value *GetVal(unsigned ID, Type *Ty, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000258
Chris Lattnerdf986172009-01-02 07:01:27 +0000259 /// SetInstName - After an instruction is parsed and inserted into its
260 /// basic block, this installs its name.
261 bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
262 Instruction *Inst);
Misha Brukman9ea40342009-01-02 22:46:48 +0000263
Chris Lattnerdf986172009-01-02 07:01:27 +0000264 /// GetBB - Get a basic block with the specified name or ID, creating a
265 /// forward reference record if needed. This can return null if the value
266 /// is not a BasicBlock.
267 BasicBlock *GetBB(const std::string &Name, LocTy Loc);
268 BasicBlock *GetBB(unsigned ID, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000269
Chris Lattnerdf986172009-01-02 07:01:27 +0000270 /// DefineBB - Define the specified basic block, which is either named or
271 /// unnamed. If there is an error, this returns null otherwise it returns
272 /// the block being defined.
273 BasicBlock *DefineBB(const std::string &Name, LocTy Loc);
274 };
Misha Brukman9ea40342009-01-02 22:46:48 +0000275
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000276 bool ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
Victor Hernandez92f238d2010-01-11 22:31:58 +0000277 PerFunctionState *PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000278
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000279 bool ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS);
280 bool ParseValue(Type *Ty, Value *&V, PerFunctionState &PFS) {
Chris Lattner1afcace2011-07-09 17:41:24 +0000281 return ParseValue(Ty, V, &PFS);
282 }
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000283 bool ParseValue(Type *Ty, Value *&V, LocTy &Loc,
Chris Lattnerdf986172009-01-02 07:01:27 +0000284 PerFunctionState &PFS) {
285 Loc = Lex.getLoc();
Chris Lattner1afcace2011-07-09 17:41:24 +0000286 return ParseValue(Ty, V, &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000287 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000288
Chris Lattner1afcace2011-07-09 17:41:24 +0000289 bool ParseTypeAndValue(Value *&V, PerFunctionState *PFS);
290 bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
291 return ParseTypeAndValue(V, &PFS);
292 }
Chris Lattnerdf986172009-01-02 07:01:27 +0000293 bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
294 Loc = Lex.getLoc();
295 return ParseTypeAndValue(V, PFS);
296 }
Chris Lattnerf9be95f2009-10-27 19:13:16 +0000297 bool ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
298 PerFunctionState &PFS);
299 bool ParseTypeAndBasicBlock(BasicBlock *&BB, PerFunctionState &PFS) {
300 LocTy Loc;
301 return ParseTypeAndBasicBlock(BB, Loc, PFS);
302 }
Victor Hernandez19715562009-12-03 23:40:58 +0000303
Chris Lattnerfdfeb692010-02-12 20:49:41 +0000304
Chris Lattnerdf986172009-01-02 07:01:27 +0000305 struct ParamInfo {
306 LocTy Loc;
307 Value *V;
Kostya Serebryany164b86b2012-01-20 17:56:17 +0000308 Attributes Attrs;
309 ParamInfo(LocTy loc, Value *v, Attributes attrs)
Chris Lattnerdf986172009-01-02 07:01:27 +0000310 : Loc(loc), V(v), Attrs(attrs) {}
311 };
312 bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
313 PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000314
Victor Hernandezbf170d42010-01-05 22:22:14 +0000315 // Constant Parsing.
316 bool ParseValID(ValID &ID, PerFunctionState *PFS = NULL);
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000317 bool ParseGlobalValue(Type *Ty, Constant *&V);
Victor Hernandezbf170d42010-01-05 22:22:14 +0000318 bool ParseGlobalTypeAndValue(Constant *&V);
319 bool ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts);
Dan Gohman309b3af2010-08-24 02:24:03 +0000320 bool ParseMetadataListValue(ValID &ID, PerFunctionState *PFS);
Dan Gohman83448032010-07-14 18:26:50 +0000321 bool ParseMetadataValue(ValID &ID, PerFunctionState *PFS);
Victor Hernandez24e64df2010-01-10 07:14:18 +0000322 bool ParseMDNodeVector(SmallVectorImpl<Value*> &, PerFunctionState *PFS);
Dan Gohman9d072f52010-08-24 02:05:17 +0000323 bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS);
Victor Hernandezbf170d42010-01-05 22:22:14 +0000324
Chris Lattnerdf986172009-01-02 07:01:27 +0000325 // Function Parsing.
326 struct ArgInfo {
327 LocTy Loc;
Chris Lattner1afcace2011-07-09 17:41:24 +0000328 Type *Ty;
Kostya Serebryany164b86b2012-01-20 17:56:17 +0000329 Attributes Attrs;
Chris Lattnerdf986172009-01-02 07:01:27 +0000330 std::string Name;
Kostya Serebryany164b86b2012-01-20 17:56:17 +0000331 ArgInfo(LocTy L, Type *ty, Attributes Attr, const std::string &N)
Chris Lattner1afcace2011-07-09 17:41:24 +0000332 : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
Chris Lattnerdf986172009-01-02 07:01:27 +0000333 };
Chris Lattner1afcace2011-07-09 17:41:24 +0000334 bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
Chris Lattnerdf986172009-01-02 07:01:27 +0000335 bool ParseFunctionHeader(Function *&Fn, bool isDefine);
336 bool ParseFunctionBody(Function &Fn);
337 bool ParseBasicBlock(PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000338
Chris Lattnerf1bc7ce2009-12-30 05:23:43 +0000339 // Instruction Parsing. Each instruction parsing routine can return with a
340 // normal result, an error result, or return having eaten an extra comma.
341 enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
342 int ParseInstruction(Instruction *&Inst, BasicBlock *BB,
343 PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000344 bool ParseCmpPredicate(unsigned &Pred, unsigned Opc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000345
Chris Lattner437544f2011-06-17 06:49:41 +0000346 bool ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000347 bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
348 bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerab21db72009-10-28 00:19:10 +0000349 bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000350 bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
Bill Wendlingdccc03b2011-07-31 06:30:59 +0000351 bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000352
Chris Lattnere914b592009-01-05 08:24:46 +0000353 bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
354 unsigned OperandType);
Chris Lattnerdf986172009-01-02 07:01:27 +0000355 bool ParseLogical(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
356 bool ParseCompare(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
357 bool ParseCast(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
358 bool ParseSelect(Instruction *&I, PerFunctionState &PFS);
Chris Lattner0088a5c2009-01-05 08:18:44 +0000359 bool ParseVA_Arg(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000360 bool ParseExtractElement(Instruction *&I, PerFunctionState &PFS);
361 bool ParseInsertElement(Instruction *&I, PerFunctionState &PFS);
362 bool ParseShuffleVector(Instruction *&I, PerFunctionState &PFS);
Chris Lattnera7d7f2c2009-12-30 05:27:33 +0000363 int ParsePHI(Instruction *&I, PerFunctionState &PFS);
Bill Wendlinge6e88262011-08-12 20:24:12 +0000364 bool ParseLandingPad(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000365 bool ParseCall(Instruction *&I, PerFunctionState &PFS, bool isTail);
Chris Lattnerf3a789d2011-06-17 03:16:47 +0000366 int ParseAlloc(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerfbe910e2011-11-27 06:56:53 +0000367 int ParseLoad(Instruction *&I, PerFunctionState &PFS);
368 int ParseStore(Instruction *&I, PerFunctionState &PFS);
Eli Friedmanf03bb262011-08-12 22:50:01 +0000369 int ParseCmpXchg(Instruction *&I, PerFunctionState &PFS);
370 int ParseAtomicRMW(Instruction *&I, PerFunctionState &PFS);
Eli Friedman47f35132011-07-25 23:16:38 +0000371 int ParseFence(Instruction *&I, PerFunctionState &PFS);
Chris Lattnera7d7f2c2009-12-30 05:27:33 +0000372 int ParseGetElementPtr(Instruction *&I, PerFunctionState &PFS);
373 int ParseExtractValue(Instruction *&I, PerFunctionState &PFS);
374 int ParseInsertValue(Instruction *&I, PerFunctionState &PFS);
Chris Lattner09d9ef42009-10-28 03:39:23 +0000375
376 bool ResolveForwardRefBlockAddresses(Function *TheFn,
377 std::vector<std::pair<ValID, GlobalValue*> > &Refs,
378 PerFunctionState *PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000379 };
380} // End llvm namespace
381
382#endif