blob: 93e7f778ebcb75772d3b0952f4fac6bced5b3199 [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"
Owen Andersonfba933c2009-07-01 23:57:11 +000018#include "llvm/Module.h"
Chris Lattnerdf986172009-01-02 07:01:27 +000019#include "llvm/Type.h"
Chris Lattnerb45218f2010-04-01 05:20:21 +000020#include "llvm/ADT/DenseMap.h"
Chris Lattner56608462009-12-28 08:20:46 +000021#include "llvm/Support/ValueHandle.h"
Chris Lattnere80250e2009-12-29 21:43:58 +000022#include <map>
Chris Lattnerdf986172009-01-02 07:01:27 +000023
24namespace llvm {
25 class Module;
26 class OpaqueType;
27 class Function;
28 class Value;
29 class BasicBlock;
30 class Instruction;
31 class Constant;
32 class GlobalValue;
Nick Lewycky21cc4462009-04-04 07:22:01 +000033 class MDString;
34 class MDNode;
Misha Brukman9ea40342009-01-02 22:46:48 +000035
Chris Lattner09d9ef42009-10-28 03:39:23 +000036 /// ValID - Represents a reference of a definition of some sort with no type.
37 /// There are several cases where we have to parse the value but where the
38 /// type can depend on later context. This may either be a numeric reference
39 /// or a symbolic (%var) reference. This is just a discriminated union.
40 struct ValID {
41 enum {
42 t_LocalID, t_GlobalID, // ID in UIntVal.
43 t_LocalName, t_GlobalName, // Name in StrVal.
44 t_APSInt, t_APFloat, // Value in APSIntVal/APFloatVal.
45 t_Null, t_Undef, t_Zero, // No value.
46 t_EmptyArray, // No value: []
47 t_Constant, // Value in ConstantVal.
48 t_InlineAsm, // Value in StrVal/StrVal2/UIntVal.
Chris Lattner287881d2009-12-30 02:11:14 +000049 t_MDNode, // Value in MDNodeVal.
50 t_MDString // Value in MDStringVal.
Chris Lattner09d9ef42009-10-28 03:39:23 +000051 } Kind;
52
53 LLLexer::LocTy Loc;
54 unsigned UIntVal;
55 std::string StrVal, StrVal2;
56 APSInt APSIntVal;
57 APFloat APFloatVal;
58 Constant *ConstantVal;
Chris Lattner287881d2009-12-30 02:11:14 +000059 MDNode *MDNodeVal;
60 MDString *MDStringVal;
Chris Lattner09d9ef42009-10-28 03:39:23 +000061 ValID() : APFloatVal(0.0) {}
62
63 bool operator<(const ValID &RHS) const {
64 if (Kind == t_LocalID || Kind == t_GlobalID)
65 return UIntVal < RHS.UIntVal;
66 assert((Kind == t_LocalName || Kind == t_GlobalName) &&
67 "Ordering not defined for this ValID kind yet");
68 return StrVal < RHS.StrVal;
69 }
70 };
71
Chris Lattnerdf986172009-01-02 07:01:27 +000072 class LLParser {
73 public:
74 typedef LLLexer::LocTy LocTy;
75 private:
Chris Lattner4ba9d9b2010-04-07 04:08:57 +000076 LLVMContext &Context;
Chris Lattnerdf986172009-01-02 07:01:27 +000077 LLLexer Lex;
78 Module *M;
Chris Lattner449c3102010-04-01 05:14:45 +000079
80 // Instruction metadata resolution. Each instruction can have a list of
81 // MDRef info associated with them.
Dan Gohman41d6ab42010-08-24 14:31:06 +000082 //
83 // The simpler approach of just creating temporary MDNodes and then calling
84 // RAUW on them when the definition is processed doesn't work because some
85 // instruction metadata kinds, such as dbg, get stored in the IR in an
86 // "optimized" format which doesn't participate in the normal value use
87 // lists. This means that RAUW doesn't work, even on temporary MDNodes
88 // which otherwise support RAUW. Instead, we defer resolving MDNode
89 // references until the definitions have been processed.
Chris Lattner449c3102010-04-01 05:14:45 +000090 struct MDRef {
91 SMLoc Loc;
92 unsigned MDKind, MDSlot;
93 };
94 DenseMap<Instruction*, std::vector<MDRef> > ForwardRefInstMetadata;
Misha Brukman9ea40342009-01-02 22:46:48 +000095
Chris Lattnerdf986172009-01-02 07:01:27 +000096 // Type resolution handling data structures.
97 std::map<std::string, std::pair<PATypeHolder, LocTy> > ForwardRefTypes;
98 std::map<unsigned, std::pair<PATypeHolder, LocTy> > ForwardRefTypeIDs;
99 std::vector<PATypeHolder> NumberedTypes;
Chris Lattner0834e6a2009-12-30 04:51:58 +0000100 std::vector<TrackingVH<MDNode> > NumberedMetadata;
Chris Lattnere80250e2009-12-29 21:43:58 +0000101 std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> > ForwardRefMDNodes;
Chris Lattnerdf986172009-01-02 07:01:27 +0000102 struct UpRefRecord {
103 /// Loc - This is the location of the upref.
104 LocTy Loc;
Misha Brukman9ea40342009-01-02 22:46:48 +0000105
Chris Lattnerdf986172009-01-02 07:01:27 +0000106 /// NestingLevel - The number of nesting levels that need to be popped
107 /// before this type is resolved.
108 unsigned NestingLevel;
Misha Brukman9ea40342009-01-02 22:46:48 +0000109
Chris Lattnerdf986172009-01-02 07:01:27 +0000110 /// LastContainedTy - This is the type at the current binding level for
111 /// the type. Every time we reduce the nesting level, this gets updated.
112 const Type *LastContainedTy;
Misha Brukman9ea40342009-01-02 22:46:48 +0000113
Chris Lattnerdf986172009-01-02 07:01:27 +0000114 /// UpRefTy - This is the actual opaque type that the upreference is
115 /// represented with.
116 OpaqueType *UpRefTy;
Misha Brukman9ea40342009-01-02 22:46:48 +0000117
Chris Lattnerdf986172009-01-02 07:01:27 +0000118 UpRefRecord(LocTy L, unsigned NL, OpaqueType *URTy)
119 : Loc(L), NestingLevel(NL), LastContainedTy((Type*)URTy),
120 UpRefTy(URTy) {}
121 };
122 std::vector<UpRefRecord> UpRefs;
123
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;
Chris Lattner09d9ef42009-10-28 03:39:23 +0000128
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::vector<std::pair<ValID, GlobalValue*> > >
132 ForwardRefBlockAddresses;
133
134 Function *MallocF;
Chris Lattnerdf986172009-01-02 07:01:27 +0000135 public:
Chris Lattnereeb4a842009-07-02 23:08:13 +0000136 LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
Victor Hernandez13ad5aa2009-10-17 00:00:19 +0000137 Context(m->getContext()), Lex(F, SM, Err, m->getContext()),
138 M(m), MallocF(NULL) {}
Chris Lattnerad7d1e22009-01-04 20:44:11 +0000139 bool Run();
Misha Brukman9ea40342009-01-02 22:46:48 +0000140
Owen Andersonb43eae72009-07-02 17:04:01 +0000141 LLVMContext& getContext() { return Context; }
142
Chris Lattnerdf986172009-01-02 07:01:27 +0000143 private:
144
Benjamin Kramerd1e17032010-09-27 17:42:11 +0000145 bool Error(LocTy L, const Twine &Msg) const {
Chris Lattnerdf986172009-01-02 07:01:27 +0000146 return Lex.Error(L, Msg);
147 }
Benjamin Kramerd1e17032010-09-27 17:42:11 +0000148 bool TokError(const Twine &Msg) const {
Chris Lattnerdf986172009-01-02 07:01:27 +0000149 return Error(Lex.getLoc(), Msg);
150 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000151
Chris Lattnerdf986172009-01-02 07:01:27 +0000152 /// GetGlobalVal - Get a value with the specified name or ID, creating a
153 /// forward reference record if needed. This can return null if the value
154 /// exists but does not have the right type.
155 GlobalValue *GetGlobalVal(const std::string &N, const Type *Ty, LocTy Loc);
156 GlobalValue *GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000157
Chris Lattnerdf986172009-01-02 07:01:27 +0000158 // Helper Routines.
159 bool ParseToken(lltok::Kind T, const char *ErrMsg);
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000160 bool EatIfPresent(lltok::Kind T) {
161 if (Lex.getKind() != T) return false;
162 Lex.Lex();
163 return true;
164 }
Rafael Espindolad72479c2011-01-13 01:30:30 +0000165 bool ParseOptionalToken(lltok::Kind T, bool &Present, LocTy *Loc = 0) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000166 if (Lex.getKind() != T) {
167 Present = false;
168 } else {
Rafael Espindolad72479c2011-01-13 01:30:30 +0000169 if (Loc)
170 *Loc = Lex.getLoc();
Chris Lattnerdf986172009-01-02 07:01:27 +0000171 Lex.Lex();
172 Present = true;
173 }
174 return false;
175 }
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000176 bool ParseStringConstant(std::string &Result);
177 bool ParseUInt32(unsigned &Val);
178 bool ParseUInt32(unsigned &Val, LocTy &Loc) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000179 Loc = Lex.getLoc();
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000180 return ParseUInt32(Val);
Chris Lattnerdf986172009-01-02 07:01:27 +0000181 }
182 bool ParseOptionalAddrSpace(unsigned &AddrSpace);
183 bool ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind);
184 bool ParseOptionalLinkage(unsigned &Linkage, bool &HasLinkage);
185 bool ParseOptionalLinkage(unsigned &Linkage) {
186 bool HasLinkage; return ParseOptionalLinkage(Linkage, HasLinkage);
187 }
188 bool ParseOptionalVisibility(unsigned &Visibility);
Sandeep Patel65c3c8f2009-09-02 08:44:58 +0000189 bool ParseOptionalCallingConv(CallingConv::ID &CC);
Chris Lattnerdf986172009-01-02 07:01:27 +0000190 bool ParseOptionalAlignment(unsigned &Alignment);
Charles Davis1e063d12010-02-12 00:31:15 +0000191 bool ParseOptionalStackAlignment(unsigned &Alignment);
Chris Lattnerc3a6c5c2009-12-30 05:44:30 +0000192 bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
Chris Lattner628c13a2009-12-30 05:14:00 +0000193 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,bool &AteExtraComma);
194 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
195 bool AteExtraComma;
196 if (ParseIndexList(Indices, AteExtraComma)) return true;
197 if (AteExtraComma)
198 return TokError("expected index");
199 return false;
200 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000201
Chris Lattnerdf986172009-01-02 07:01:27 +0000202 // Top-Level Entities
203 bool ParseTopLevelEntities();
204 bool ValidateEndOfModule();
205 bool ParseTargetDefinition();
206 bool ParseDepLibs();
207 bool ParseModuleAsm();
208 bool ParseUnnamedType();
209 bool ParseNamedType();
210 bool ParseDeclare();
211 bool ParseDefine();
Misha Brukman9ea40342009-01-02 22:46:48 +0000212
Chris Lattnerdf986172009-01-02 07:01:27 +0000213 bool ParseGlobalType(bool &IsConstant);
Dan Gohman3845e502009-08-12 23:32:33 +0000214 bool ParseUnnamedGlobal();
Chris Lattnerdf986172009-01-02 07:01:27 +0000215 bool ParseNamedGlobal();
216 bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
217 bool HasLinkage, unsigned Visibility);
218 bool ParseAlias(const std::string &Name, LocTy Loc, unsigned Visibility);
Devang Patel923078c2009-07-01 19:21:12 +0000219 bool ParseStandaloneMetadata();
Devang Pateleff2ab62009-07-29 00:34:02 +0000220 bool ParseNamedMetadata();
Chris Lattner442ffa12009-12-29 21:53:55 +0000221 bool ParseMDString(MDString *&Result);
Chris Lattner4a72efc2009-12-30 04:15:23 +0000222 bool ParseMDNodeID(MDNode *&Result);
Chris Lattner449c3102010-04-01 05:14:45 +0000223 bool ParseMDNodeID(MDNode *&Result, unsigned &SlotNo);
Misha Brukman9ea40342009-01-02 22:46:48 +0000224
Chris Lattnerdf986172009-01-02 07:01:27 +0000225 // Type Parsing.
Chris Lattnera9a9e072009-03-09 04:49:14 +0000226 bool ParseType(PATypeHolder &Result, bool AllowVoid = false);
227 bool ParseType(PATypeHolder &Result, LocTy &Loc, bool AllowVoid = false) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000228 Loc = Lex.getLoc();
Chris Lattnera9a9e072009-03-09 04:49:14 +0000229 return ParseType(Result, AllowVoid);
Chris Lattnerdf986172009-01-02 07:01:27 +0000230 }
231 bool ParseTypeRec(PATypeHolder &H);
232 bool ParseStructType(PATypeHolder &H, bool Packed);
233 bool ParseArrayVectorType(PATypeHolder &H, bool isVector);
234 bool ParseFunctionType(PATypeHolder &Result);
235 PATypeHolder HandleUpRefs(const Type *Ty);
236
Chris Lattnerdf986172009-01-02 07:01:27 +0000237 // Function Semantic Analysis.
238 class PerFunctionState {
239 LLParser &P;
240 Function &F;
241 std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
242 std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
243 std::vector<Value*> NumberedVals;
Chris Lattner09d9ef42009-10-28 03:39:23 +0000244
245 /// FunctionNumber - If this is an unnamed function, this is the slot
246 /// number of it, otherwise it is -1.
247 int FunctionNumber;
Chris Lattnerdf986172009-01-02 07:01:27 +0000248 public:
Chris Lattner09d9ef42009-10-28 03:39:23 +0000249 PerFunctionState(LLParser &p, Function &f, int FunctionNumber);
Chris Lattnerdf986172009-01-02 07:01:27 +0000250 ~PerFunctionState();
Misha Brukman9ea40342009-01-02 22:46:48 +0000251
Chris Lattnerdf986172009-01-02 07:01:27 +0000252 Function &getFunction() const { return F; }
Misha Brukman9ea40342009-01-02 22:46:48 +0000253
Chris Lattner09d9ef42009-10-28 03:39:23 +0000254 bool FinishFunction();
Misha Brukman9ea40342009-01-02 22:46:48 +0000255
Chris Lattnerdf986172009-01-02 07:01:27 +0000256 /// GetVal - Get a value with the specified name or ID, creating a
257 /// forward reference record if needed. This can return null if the value
258 /// exists but does not have the right type.
259 Value *GetVal(const std::string &Name, const Type *Ty, LocTy Loc);
260 Value *GetVal(unsigned ID, const Type *Ty, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000261
Chris Lattnerdf986172009-01-02 07:01:27 +0000262 /// SetInstName - After an instruction is parsed and inserted into its
263 /// basic block, this installs its name.
264 bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
265 Instruction *Inst);
Misha Brukman9ea40342009-01-02 22:46:48 +0000266
Chris Lattnerdf986172009-01-02 07:01:27 +0000267 /// GetBB - Get a basic block with the specified name or ID, creating a
268 /// forward reference record if needed. This can return null if the value
269 /// is not a BasicBlock.
270 BasicBlock *GetBB(const std::string &Name, LocTy Loc);
271 BasicBlock *GetBB(unsigned ID, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000272
Chris Lattnerdf986172009-01-02 07:01:27 +0000273 /// DefineBB - Define the specified basic block, which is either named or
274 /// unnamed. If there is an error, this returns null otherwise it returns
275 /// the block being defined.
276 BasicBlock *DefineBB(const std::string &Name, LocTy Loc);
277 };
Misha Brukman9ea40342009-01-02 22:46:48 +0000278
Chris Lattnerdf986172009-01-02 07:01:27 +0000279 bool ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V,
Victor Hernandez92f238d2010-01-11 22:31:58 +0000280 PerFunctionState *PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000281
Chris Lattnerdf986172009-01-02 07:01:27 +0000282 bool ParseValue(const Type *Ty, Value *&V, PerFunctionState &PFS);
283 bool ParseValue(const Type *Ty, Value *&V, LocTy &Loc,
284 PerFunctionState &PFS) {
285 Loc = Lex.getLoc();
286 return ParseValue(Ty, V, PFS);
287 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000288
Chris Lattnerdf986172009-01-02 07:01:27 +0000289 bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS);
290 bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
291 Loc = Lex.getLoc();
292 return ParseTypeAndValue(V, PFS);
293 }
Chris Lattnerf9be95f2009-10-27 19:13:16 +0000294 bool ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
295 PerFunctionState &PFS);
296 bool ParseTypeAndBasicBlock(BasicBlock *&BB, PerFunctionState &PFS) {
297 LocTy Loc;
298 return ParseTypeAndBasicBlock(BB, Loc, PFS);
299 }
Victor Hernandez19715562009-12-03 23:40:58 +0000300
Chris Lattnerfdfeb692010-02-12 20:49:41 +0000301
Chris Lattnerdf986172009-01-02 07:01:27 +0000302 struct ParamInfo {
303 LocTy Loc;
304 Value *V;
305 unsigned Attrs;
Misha Brukman9ea40342009-01-02 22:46:48 +0000306 ParamInfo(LocTy loc, Value *v, unsigned attrs)
Chris Lattnerdf986172009-01-02 07:01:27 +0000307 : Loc(loc), V(v), Attrs(attrs) {}
308 };
309 bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
310 PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000311
Victor Hernandezbf170d42010-01-05 22:22:14 +0000312 // Constant Parsing.
313 bool ParseValID(ValID &ID, PerFunctionState *PFS = NULL);
Victor Hernandezbf170d42010-01-05 22:22:14 +0000314 bool ParseGlobalValue(const Type *Ty, Constant *&V);
315 bool ParseGlobalTypeAndValue(Constant *&V);
316 bool ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts);
Dan Gohman309b3af2010-08-24 02:24:03 +0000317 bool ParseMetadataListValue(ValID &ID, PerFunctionState *PFS);
Dan Gohman83448032010-07-14 18:26:50 +0000318 bool ParseMetadataValue(ValID &ID, PerFunctionState *PFS);
Victor Hernandez24e64df2010-01-10 07:14:18 +0000319 bool ParseMDNodeVector(SmallVectorImpl<Value*> &, PerFunctionState *PFS);
Dan Gohman9d072f52010-08-24 02:05:17 +0000320 bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS);
Victor Hernandezbf170d42010-01-05 22:22:14 +0000321
Chris Lattnerdf986172009-01-02 07:01:27 +0000322 // Function Parsing.
323 struct ArgInfo {
324 LocTy Loc;
325 PATypeHolder Type;
326 unsigned Attrs;
327 std::string Name;
328 ArgInfo(LocTy L, PATypeHolder Ty, unsigned Attr, const std::string &N)
329 : Loc(L), Type(Ty), Attrs(Attr), Name(N) {}
330 };
331 bool ParseArgumentList(std::vector<ArgInfo> &ArgList,
Chris Lattnerdfd19dd2009-01-05 18:34:07 +0000332 bool &isVarArg, bool inType);
Chris Lattnerdf986172009-01-02 07:01:27 +0000333 bool ParseFunctionHeader(Function *&Fn, bool isDefine);
334 bool ParseFunctionBody(Function &Fn);
335 bool ParseBasicBlock(PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000336
Chris Lattnerf1bc7ce2009-12-30 05:23:43 +0000337 // Instruction Parsing. Each instruction parsing routine can return with a
338 // normal result, an error result, or return having eaten an extra comma.
339 enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
340 int ParseInstruction(Instruction *&Inst, BasicBlock *BB,
341 PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000342 bool ParseCmpPredicate(unsigned &Pred, unsigned Opc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000343
Chris Lattnerf1bc7ce2009-12-30 05:23:43 +0000344 int ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000345 bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
346 bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerab21db72009-10-28 00:19:10 +0000347 bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000348 bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000349
Chris Lattnere914b592009-01-05 08:24:46 +0000350 bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
351 unsigned OperandType);
Chris Lattnerdf986172009-01-02 07:01:27 +0000352 bool ParseLogical(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
353 bool ParseCompare(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
354 bool ParseCast(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
355 bool ParseSelect(Instruction *&I, PerFunctionState &PFS);
Chris Lattner0088a5c2009-01-05 08:18:44 +0000356 bool ParseVA_Arg(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000357 bool ParseExtractElement(Instruction *&I, PerFunctionState &PFS);
358 bool ParseInsertElement(Instruction *&I, PerFunctionState &PFS);
359 bool ParseShuffleVector(Instruction *&I, PerFunctionState &PFS);
Chris Lattnera7d7f2c2009-12-30 05:27:33 +0000360 int ParsePHI(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000361 bool ParseCall(Instruction *&I, PerFunctionState &PFS, bool isTail);
Chris Lattnerc3a6c5c2009-12-30 05:44:30 +0000362 int ParseAlloc(Instruction *&I, PerFunctionState &PFS,
Victor Hernandez13ad5aa2009-10-17 00:00:19 +0000363 BasicBlock *BB = 0, bool isAlloca = true);
Victor Hernandez66284e02009-10-24 04:23:03 +0000364 bool ParseFree(Instruction *&I, PerFunctionState &PFS, BasicBlock *BB);
Chris Lattnerc3a6c5c2009-12-30 05:44:30 +0000365 int ParseLoad(Instruction *&I, PerFunctionState &PFS, bool isVolatile);
366 int ParseStore(Instruction *&I, PerFunctionState &PFS, bool isVolatile);
Chris Lattnerdf986172009-01-02 07:01:27 +0000367 bool ParseGetResult(Instruction *&I, PerFunctionState &PFS);
Chris Lattnera7d7f2c2009-12-30 05:27:33 +0000368 int ParseGetElementPtr(Instruction *&I, PerFunctionState &PFS);
369 int ParseExtractValue(Instruction *&I, PerFunctionState &PFS);
370 int ParseInsertValue(Instruction *&I, PerFunctionState &PFS);
Chris Lattner09d9ef42009-10-28 03:39:23 +0000371
372 bool ResolveForwardRefBlockAddresses(Function *TheFn,
373 std::vector<std::pair<ValID, GlobalValue*> > &Refs,
374 PerFunctionState *PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000375 };
376} // End llvm namespace
377
378#endif