blob: 96306578506199555b29d0fbf77a7d687258b968 [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 Lattner1afcace2011-07-09 17:41:24 +000021#include "llvm/ADT/StringMap.h"
Chris Lattner56608462009-12-28 08:20:46 +000022#include "llvm/Support/ValueHandle.h"
Chris Lattnere80250e2009-12-29 21:43:58 +000023#include <map>
Chris Lattnerdf986172009-01-02 07:01:27 +000024
25namespace llvm {
26 class Module;
27 class OpaqueType;
28 class Function;
29 class Value;
30 class BasicBlock;
31 class Instruction;
32 class Constant;
33 class GlobalValue;
Nick Lewycky21cc4462009-04-04 07:22:01 +000034 class MDString;
35 class MDNode;
Chris Lattner1afcace2011-07-09 17:41:24 +000036 class StructType;
Misha Brukman9ea40342009-01-02 22:46:48 +000037
Chris Lattner09d9ef42009-10-28 03:39:23 +000038 /// ValID - Represents a reference of a definition of some sort with no type.
39 /// There are several cases where we have to parse the value but where the
40 /// type can depend on later context. This may either be a numeric reference
41 /// or a symbolic (%var) reference. This is just a discriminated union.
42 struct ValID {
43 enum {
44 t_LocalID, t_GlobalID, // ID in UIntVal.
45 t_LocalName, t_GlobalName, // Name in StrVal.
46 t_APSInt, t_APFloat, // Value in APSIntVal/APFloatVal.
47 t_Null, t_Undef, t_Zero, // No value.
48 t_EmptyArray, // No value: []
49 t_Constant, // Value in ConstantVal.
50 t_InlineAsm, // Value in StrVal/StrVal2/UIntVal.
Chris Lattner287881d2009-12-30 02:11:14 +000051 t_MDNode, // Value in MDNodeVal.
Chris Lattner1afcace2011-07-09 17:41:24 +000052 t_MDString, // Value in MDStringVal.
53 t_ConstantStruct, // Value in ConstantStructElts.
54 t_PackedConstantStruct // Value in ConstantStructElts.
Chris Lattner09d9ef42009-10-28 03:39:23 +000055 } Kind;
56
57 LLLexer::LocTy Loc;
58 unsigned UIntVal;
59 std::string StrVal, StrVal2;
60 APSInt APSIntVal;
61 APFloat APFloatVal;
62 Constant *ConstantVal;
Chris Lattner287881d2009-12-30 02:11:14 +000063 MDNode *MDNodeVal;
64 MDString *MDStringVal;
Chris Lattner1afcace2011-07-09 17:41:24 +000065 Constant **ConstantStructElts;
66
67 ValID() : Kind(t_LocalID), APFloatVal(0.0) {}
68 ~ValID() {
69 if (Kind == t_ConstantStruct || Kind == t_PackedConstantStruct)
70 delete [] ConstantStructElts;
71 }
Chris Lattner09d9ef42009-10-28 03:39:23 +000072
73 bool operator<(const ValID &RHS) const {
74 if (Kind == t_LocalID || Kind == t_GlobalID)
75 return UIntVal < RHS.UIntVal;
Chris Lattner1afcace2011-07-09 17:41:24 +000076 assert((Kind == t_LocalName || Kind == t_GlobalName ||
77 Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) &&
Chris Lattner09d9ef42009-10-28 03:39:23 +000078 "Ordering not defined for this ValID kind yet");
79 return StrVal < RHS.StrVal;
80 }
81 };
82
Chris Lattnerdf986172009-01-02 07:01:27 +000083 class LLParser {
84 public:
85 typedef LLLexer::LocTy LocTy;
86 private:
Chris Lattner4ba9d9b2010-04-07 04:08:57 +000087 LLVMContext &Context;
Chris Lattnerdf986172009-01-02 07:01:27 +000088 LLLexer Lex;
89 Module *M;
Chris Lattner449c3102010-04-01 05:14:45 +000090
91 // Instruction metadata resolution. Each instruction can have a list of
92 // MDRef info associated with them.
Dan Gohman41d6ab42010-08-24 14:31:06 +000093 //
94 // The simpler approach of just creating temporary MDNodes and then calling
95 // RAUW on them when the definition is processed doesn't work because some
96 // instruction metadata kinds, such as dbg, get stored in the IR in an
97 // "optimized" format which doesn't participate in the normal value use
98 // lists. This means that RAUW doesn't work, even on temporary MDNodes
99 // which otherwise support RAUW. Instead, we defer resolving MDNode
100 // references until the definitions have been processed.
Chris Lattner449c3102010-04-01 05:14:45 +0000101 struct MDRef {
102 SMLoc Loc;
103 unsigned MDKind, MDSlot;
104 };
105 DenseMap<Instruction*, std::vector<MDRef> > ForwardRefInstMetadata;
Misha Brukman9ea40342009-01-02 22:46:48 +0000106
Chris Lattner1afcace2011-07-09 17:41:24 +0000107 // Type resolution handling data structures. The location is set when we
108 // have processed a use of the type but not a definition yet.
109 StringMap<std::pair<Type*, LocTy> > NamedTypes;
110 std::vector<std::pair<Type*, LocTy> > NumberedTypes;
111
Chris Lattner0834e6a2009-12-30 04:51:58 +0000112 std::vector<TrackingVH<MDNode> > NumberedMetadata;
Chris Lattnere80250e2009-12-29 21:43:58 +0000113 std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> > ForwardRefMDNodes;
Chris Lattnerdf986172009-01-02 07:01:27 +0000114
115 // Global Value reference information.
116 std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
117 std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
118 std::vector<GlobalValue*> NumberedVals;
Chris Lattner09d9ef42009-10-28 03:39:23 +0000119
120 // References to blockaddress. The key is the function ValID, the value is
121 // a list of references to blocks in that function.
122 std::map<ValID, std::vector<std::pair<ValID, GlobalValue*> > >
123 ForwardRefBlockAddresses;
124
Chris Lattnerdf986172009-01-02 07:01:27 +0000125 public:
Chris Lattnereeb4a842009-07-02 23:08:13 +0000126 LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
Victor Hernandez13ad5aa2009-10-17 00:00:19 +0000127 Context(m->getContext()), Lex(F, SM, Err, m->getContext()),
Chris Lattnerf3a789d2011-06-17 03:16:47 +0000128 M(m) {}
Chris Lattnerad7d1e22009-01-04 20:44:11 +0000129 bool Run();
Misha Brukman9ea40342009-01-02 22:46:48 +0000130
Chris Lattner1afcace2011-07-09 17:41:24 +0000131 LLVMContext &getContext() { return Context; }
Owen Andersonb43eae72009-07-02 17:04:01 +0000132
Chris Lattnerdf986172009-01-02 07:01:27 +0000133 private:
134
Benjamin Kramerd1e17032010-09-27 17:42:11 +0000135 bool Error(LocTy L, const Twine &Msg) const {
Chris Lattnerdf986172009-01-02 07:01:27 +0000136 return Lex.Error(L, Msg);
137 }
Benjamin Kramerd1e17032010-09-27 17:42:11 +0000138 bool TokError(const Twine &Msg) const {
Chris Lattnerdf986172009-01-02 07:01:27 +0000139 return Error(Lex.getLoc(), Msg);
140 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000141
Chris Lattnerdf986172009-01-02 07:01:27 +0000142 /// GetGlobalVal - Get a value with the specified name or ID, creating a
143 /// forward reference record if needed. This can return null if the value
144 /// exists but does not have the right type.
145 GlobalValue *GetGlobalVal(const std::string &N, const Type *Ty, LocTy Loc);
146 GlobalValue *GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000147
Chris Lattnerdf986172009-01-02 07:01:27 +0000148 // Helper Routines.
149 bool ParseToken(lltok::Kind T, const char *ErrMsg);
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000150 bool EatIfPresent(lltok::Kind T) {
151 if (Lex.getKind() != T) return false;
152 Lex.Lex();
153 return true;
154 }
Rafael Espindolad72479c2011-01-13 01:30:30 +0000155 bool ParseOptionalToken(lltok::Kind T, bool &Present, LocTy *Loc = 0) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000156 if (Lex.getKind() != T) {
157 Present = false;
158 } else {
Rafael Espindolad72479c2011-01-13 01:30:30 +0000159 if (Loc)
160 *Loc = Lex.getLoc();
Chris Lattnerdf986172009-01-02 07:01:27 +0000161 Lex.Lex();
162 Present = true;
163 }
164 return false;
165 }
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000166 bool ParseStringConstant(std::string &Result);
167 bool ParseUInt32(unsigned &Val);
168 bool ParseUInt32(unsigned &Val, LocTy &Loc) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000169 Loc = Lex.getLoc();
Chris Lattner3ed88ef2009-01-02 08:05:26 +0000170 return ParseUInt32(Val);
Chris Lattnerdf986172009-01-02 07:01:27 +0000171 }
172 bool ParseOptionalAddrSpace(unsigned &AddrSpace);
173 bool ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind);
174 bool ParseOptionalLinkage(unsigned &Linkage, bool &HasLinkage);
175 bool ParseOptionalLinkage(unsigned &Linkage) {
176 bool HasLinkage; return ParseOptionalLinkage(Linkage, HasLinkage);
177 }
178 bool ParseOptionalVisibility(unsigned &Visibility);
Sandeep Patel65c3c8f2009-09-02 08:44:58 +0000179 bool ParseOptionalCallingConv(CallingConv::ID &CC);
Chris Lattnerdf986172009-01-02 07:01:27 +0000180 bool ParseOptionalAlignment(unsigned &Alignment);
Charles Davis1e063d12010-02-12 00:31:15 +0000181 bool ParseOptionalStackAlignment(unsigned &Alignment);
Chris Lattnerc3a6c5c2009-12-30 05:44:30 +0000182 bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
Chris Lattner628c13a2009-12-30 05:14:00 +0000183 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,bool &AteExtraComma);
184 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
185 bool AteExtraComma;
186 if (ParseIndexList(Indices, AteExtraComma)) return true;
187 if (AteExtraComma)
188 return TokError("expected index");
189 return false;
190 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000191
Chris Lattnerdf986172009-01-02 07:01:27 +0000192 // Top-Level Entities
193 bool ParseTopLevelEntities();
194 bool ValidateEndOfModule();
195 bool ParseTargetDefinition();
196 bool ParseDepLibs();
197 bool ParseModuleAsm();
198 bool ParseUnnamedType();
199 bool ParseNamedType();
200 bool ParseDeclare();
201 bool ParseDefine();
Misha Brukman9ea40342009-01-02 22:46:48 +0000202
Chris Lattnerdf986172009-01-02 07:01:27 +0000203 bool ParseGlobalType(bool &IsConstant);
Dan Gohman3845e502009-08-12 23:32:33 +0000204 bool ParseUnnamedGlobal();
Chris Lattnerdf986172009-01-02 07:01:27 +0000205 bool ParseNamedGlobal();
206 bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
207 bool HasLinkage, unsigned Visibility);
208 bool ParseAlias(const std::string &Name, LocTy Loc, unsigned Visibility);
Devang Patel923078c2009-07-01 19:21:12 +0000209 bool ParseStandaloneMetadata();
Devang Pateleff2ab62009-07-29 00:34:02 +0000210 bool ParseNamedMetadata();
Chris Lattner442ffa12009-12-29 21:53:55 +0000211 bool ParseMDString(MDString *&Result);
Chris Lattner4a72efc2009-12-30 04:15:23 +0000212 bool ParseMDNodeID(MDNode *&Result);
Chris Lattner449c3102010-04-01 05:14:45 +0000213 bool ParseMDNodeID(MDNode *&Result, unsigned &SlotNo);
Misha Brukman9ea40342009-01-02 22:46:48 +0000214
Chris Lattnerdf986172009-01-02 07:01:27 +0000215 // Type Parsing.
Chris Lattner1afcace2011-07-09 17:41:24 +0000216 bool ParseType(Type *&Result, bool AllowVoid = false);
217 bool ParseType(Type *&Result, LocTy &Loc, bool AllowVoid = false) {
Chris Lattnerdf986172009-01-02 07:01:27 +0000218 Loc = Lex.getLoc();
Chris Lattnera9a9e072009-03-09 04:49:14 +0000219 return ParseType(Result, AllowVoid);
Chris Lattnerdf986172009-01-02 07:01:27 +0000220 }
Chris Lattner1afcace2011-07-09 17:41:24 +0000221 bool ParseAnonStructType(Type *&Result, bool Packed);
222 bool ParseStructBody(SmallVectorImpl<Type*> &Body);
223 bool ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
224 std::pair<Type*, LocTy> &Entry,
225 Type *&ResultTy);
226
227 bool ParseArrayVectorType(Type *&Result, bool isVector);
228 bool ParseFunctionType(Type *&Result);
Chris Lattnerdf986172009-01-02 07:01:27 +0000229
Chris Lattnerdf986172009-01-02 07:01:27 +0000230 // Function Semantic Analysis.
231 class PerFunctionState {
232 LLParser &P;
233 Function &F;
234 std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
235 std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
236 std::vector<Value*> NumberedVals;
Chris Lattner09d9ef42009-10-28 03:39:23 +0000237
238 /// FunctionNumber - If this is an unnamed function, this is the slot
239 /// number of it, otherwise it is -1.
240 int FunctionNumber;
Chris Lattnerdf986172009-01-02 07:01:27 +0000241 public:
Chris Lattner09d9ef42009-10-28 03:39:23 +0000242 PerFunctionState(LLParser &p, Function &f, int FunctionNumber);
Chris Lattnerdf986172009-01-02 07:01:27 +0000243 ~PerFunctionState();
Misha Brukman9ea40342009-01-02 22:46:48 +0000244
Chris Lattnerdf986172009-01-02 07:01:27 +0000245 Function &getFunction() const { return F; }
Misha Brukman9ea40342009-01-02 22:46:48 +0000246
Chris Lattner09d9ef42009-10-28 03:39:23 +0000247 bool FinishFunction();
Misha Brukman9ea40342009-01-02 22:46:48 +0000248
Chris Lattnerdf986172009-01-02 07:01:27 +0000249 /// GetVal - Get a value with the specified name or ID, creating a
250 /// forward reference record if needed. This can return null if the value
251 /// exists but does not have the right type.
252 Value *GetVal(const std::string &Name, const Type *Ty, LocTy Loc);
253 Value *GetVal(unsigned ID, const Type *Ty, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000254
Chris Lattnerdf986172009-01-02 07:01:27 +0000255 /// SetInstName - After an instruction is parsed and inserted into its
256 /// basic block, this installs its name.
257 bool SetInstName(int NameID, const std::string &NameStr, LocTy NameLoc,
258 Instruction *Inst);
Misha Brukman9ea40342009-01-02 22:46:48 +0000259
Chris Lattnerdf986172009-01-02 07:01:27 +0000260 /// GetBB - Get a basic block with the specified name or ID, creating a
261 /// forward reference record if needed. This can return null if the value
262 /// is not a BasicBlock.
263 BasicBlock *GetBB(const std::string &Name, LocTy Loc);
264 BasicBlock *GetBB(unsigned ID, LocTy Loc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000265
Chris Lattnerdf986172009-01-02 07:01:27 +0000266 /// DefineBB - Define the specified basic block, which is either named or
267 /// unnamed. If there is an error, this returns null otherwise it returns
268 /// the block being defined.
269 BasicBlock *DefineBB(const std::string &Name, LocTy Loc);
270 };
Misha Brukman9ea40342009-01-02 22:46:48 +0000271
Chris Lattnerdf986172009-01-02 07:01:27 +0000272 bool ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V,
Victor Hernandez92f238d2010-01-11 22:31:58 +0000273 PerFunctionState *PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000274
Chris Lattner1afcace2011-07-09 17:41:24 +0000275 bool ParseValue(const Type *Ty, Value *&V, PerFunctionState *PFS);
276 bool ParseValue(const Type *Ty, Value *&V, PerFunctionState &PFS) {
277 return ParseValue(Ty, V, &PFS);
278 }
Chris Lattnerdf986172009-01-02 07:01:27 +0000279 bool ParseValue(const Type *Ty, Value *&V, LocTy &Loc,
280 PerFunctionState &PFS) {
281 Loc = Lex.getLoc();
Chris Lattner1afcace2011-07-09 17:41:24 +0000282 return ParseValue(Ty, V, &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000283 }
Misha Brukman9ea40342009-01-02 22:46:48 +0000284
Chris Lattner1afcace2011-07-09 17:41:24 +0000285 bool ParseTypeAndValue(Value *&V, PerFunctionState *PFS);
286 bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
287 return ParseTypeAndValue(V, &PFS);
288 }
Chris Lattnerdf986172009-01-02 07:01:27 +0000289 bool ParseTypeAndValue(Value *&V, LocTy &Loc, PerFunctionState &PFS) {
290 Loc = Lex.getLoc();
291 return ParseTypeAndValue(V, PFS);
292 }
Chris Lattnerf9be95f2009-10-27 19:13:16 +0000293 bool ParseTypeAndBasicBlock(BasicBlock *&BB, LocTy &Loc,
294 PerFunctionState &PFS);
295 bool ParseTypeAndBasicBlock(BasicBlock *&BB, PerFunctionState &PFS) {
296 LocTy Loc;
297 return ParseTypeAndBasicBlock(BB, Loc, PFS);
298 }
Victor Hernandez19715562009-12-03 23:40:58 +0000299
Chris Lattnerfdfeb692010-02-12 20:49:41 +0000300
Chris Lattnerdf986172009-01-02 07:01:27 +0000301 struct ParamInfo {
302 LocTy Loc;
303 Value *V;
304 unsigned Attrs;
Misha Brukman9ea40342009-01-02 22:46:48 +0000305 ParamInfo(LocTy loc, Value *v, unsigned attrs)
Chris Lattnerdf986172009-01-02 07:01:27 +0000306 : Loc(loc), V(v), Attrs(attrs) {}
307 };
308 bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
309 PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000310
Victor Hernandezbf170d42010-01-05 22:22:14 +0000311 // Constant Parsing.
312 bool ParseValID(ValID &ID, PerFunctionState *PFS = NULL);
Victor Hernandezbf170d42010-01-05 22:22:14 +0000313 bool ParseGlobalValue(const Type *Ty, Constant *&V);
314 bool ParseGlobalTypeAndValue(Constant *&V);
315 bool ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts);
Dan Gohman309b3af2010-08-24 02:24:03 +0000316 bool ParseMetadataListValue(ValID &ID, PerFunctionState *PFS);
Dan Gohman83448032010-07-14 18:26:50 +0000317 bool ParseMetadataValue(ValID &ID, PerFunctionState *PFS);
Victor Hernandez24e64df2010-01-10 07:14:18 +0000318 bool ParseMDNodeVector(SmallVectorImpl<Value*> &, PerFunctionState *PFS);
Dan Gohman9d072f52010-08-24 02:05:17 +0000319 bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS);
Victor Hernandezbf170d42010-01-05 22:22:14 +0000320
Chris Lattnerdf986172009-01-02 07:01:27 +0000321 // Function Parsing.
322 struct ArgInfo {
323 LocTy Loc;
Chris Lattner1afcace2011-07-09 17:41:24 +0000324 Type *Ty;
Chris Lattnerdf986172009-01-02 07:01:27 +0000325 unsigned Attrs;
326 std::string Name;
Chris Lattner1afcace2011-07-09 17:41:24 +0000327 ArgInfo(LocTy L, Type *ty, unsigned Attr, const std::string &N)
328 : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
Chris Lattnerdf986172009-01-02 07:01:27 +0000329 };
Chris Lattner1afcace2011-07-09 17:41:24 +0000330 bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
Chris Lattnerdf986172009-01-02 07:01:27 +0000331 bool ParseFunctionHeader(Function *&Fn, bool isDefine);
332 bool ParseFunctionBody(Function &Fn);
333 bool ParseBasicBlock(PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000334
Chris Lattnerf1bc7ce2009-12-30 05:23:43 +0000335 // Instruction Parsing. Each instruction parsing routine can return with a
336 // normal result, an error result, or return having eaten an extra comma.
337 enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
338 int ParseInstruction(Instruction *&Inst, BasicBlock *BB,
339 PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000340 bool ParseCmpPredicate(unsigned &Pred, unsigned Opc);
Misha Brukman9ea40342009-01-02 22:46:48 +0000341
Chris Lattner437544f2011-06-17 06:49:41 +0000342 bool ParseRet(Instruction *&Inst, BasicBlock *BB, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000343 bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
344 bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerab21db72009-10-28 00:19:10 +0000345 bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000346 bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
Misha Brukman9ea40342009-01-02 22:46:48 +0000347
Chris Lattnere914b592009-01-05 08:24:46 +0000348 bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
349 unsigned OperandType);
Chris Lattnerdf986172009-01-02 07:01:27 +0000350 bool ParseLogical(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
351 bool ParseCompare(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
352 bool ParseCast(Instruction *&I, PerFunctionState &PFS, unsigned Opc);
353 bool ParseSelect(Instruction *&I, PerFunctionState &PFS);
Chris Lattner0088a5c2009-01-05 08:18:44 +0000354 bool ParseVA_Arg(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000355 bool ParseExtractElement(Instruction *&I, PerFunctionState &PFS);
356 bool ParseInsertElement(Instruction *&I, PerFunctionState &PFS);
357 bool ParseShuffleVector(Instruction *&I, PerFunctionState &PFS);
Chris Lattnera7d7f2c2009-12-30 05:27:33 +0000358 int ParsePHI(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000359 bool ParseCall(Instruction *&I, PerFunctionState &PFS, bool isTail);
Chris Lattnerf3a789d2011-06-17 03:16:47 +0000360 int ParseAlloc(Instruction *&I, PerFunctionState &PFS);
Chris Lattnerc3a6c5c2009-12-30 05:44:30 +0000361 int ParseLoad(Instruction *&I, PerFunctionState &PFS, bool isVolatile);
362 int ParseStore(Instruction *&I, PerFunctionState &PFS, bool isVolatile);
Chris Lattnera7d7f2c2009-12-30 05:27:33 +0000363 int ParseGetElementPtr(Instruction *&I, PerFunctionState &PFS);
364 int ParseExtractValue(Instruction *&I, PerFunctionState &PFS);
365 int ParseInsertValue(Instruction *&I, PerFunctionState &PFS);
Chris Lattner09d9ef42009-10-28 03:39:23 +0000366
367 bool ResolveForwardRefBlockAddresses(Function *TheFn,
368 std::vector<std::pair<ValID, GlobalValue*> > &Refs,
369 PerFunctionState *PFS);
Chris Lattnerdf986172009-01-02 07:01:27 +0000370 };
371} // End llvm namespace
372
373#endif