14 #ifndef LLVM_ASMPARSER_LLPARSER_H
15 #define LLVM_ASMPARSER_LLPARSER_H
81 "Ordering not defined for this ValID kind yet");
106 unsigned MDKind, MDSlot;
115 std::vector<std::pair<Type*, LocTy> > NumberedTypes;
117 std::vector<TrackingVH<MDNode> > NumberedMetadata;
118 std::map<unsigned, std::pair<TrackingVH<MDNode>,
LocTy> > ForwardRefMDNodes;
121 std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
122 std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
123 std::vector<GlobalValue*> NumberedVals;
127 std::map<ValID, std::vector<std::pair<ValID, GlobalValue*> > >
128 ForwardRefBlockAddresses;
131 std::map<Value*, std::vector<unsigned> > ForwardRefAttrGroups;
132 std::map<unsigned, AttrBuilder> NumberedAttrBuilders;
145 return Lex.
Error(L, Msg);
147 bool TokError(
const Twine &Msg)
const {
148 return Error(Lex.
getLoc(), Msg);
154 GlobalValue *GetGlobalVal(
const std::string &
N,
Type *Ty,
LocTy Loc);
155 GlobalValue *GetGlobalVal(
unsigned ID,
Type *Ty,
LocTy Loc);
160 if (Lex.
getKind() !=
T)
return false;
165 FastMathFlags EatFastMathFlagsIfPresent() {
190 bool ParseStringConstant(std::string &Result);
191 bool ParseUInt32(
unsigned &Val);
192 bool ParseUInt32(
unsigned &Val,
LocTy &Loc) {
194 return ParseUInt32(Val);
199 bool ParseOptionalAddrSpace(
unsigned &AddrSpace);
200 bool ParseOptionalParamAttrs(AttrBuilder &B);
201 bool ParseOptionalReturnAttrs(AttrBuilder &B);
202 bool ParseOptionalLinkage(
unsigned &Linkage,
bool &HasLinkage);
203 bool ParseOptionalLinkage(
unsigned &Linkage) {
204 bool HasLinkage;
return ParseOptionalLinkage(Linkage, HasLinkage);
206 bool ParseOptionalVisibility(
unsigned &Visibility);
208 bool ParseOptionalAlignment(
unsigned &Alignment);
211 bool ParseOptionalStackAlignment(
unsigned &Alignment);
212 bool ParseOptionalCommaAlign(
unsigned &Alignment,
bool &AteExtraComma);
213 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,
bool &AteExtraComma);
214 bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
216 if (ParseIndexList(Indices, AteExtraComma))
return true;
218 return TokError(
"expected index");
223 bool ParseTopLevelEntities();
224 bool ValidateEndOfModule();
225 bool ParseTargetDefinition();
226 bool ParseModuleAsm();
228 bool ParseUnnamedType();
229 bool ParseNamedType();
233 bool ParseGlobalType(
bool &IsConstant);
234 bool ParseUnnamedGlobal();
235 bool ParseNamedGlobal();
236 bool ParseGlobal(
const std::string &
Name,
LocTy Loc,
unsigned Linkage,
237 bool HasLinkage,
unsigned Visibility);
238 bool ParseAlias(
const std::string &
Name,
LocTy Loc,
unsigned Visibility);
239 bool ParseStandaloneMetadata();
240 bool ParseNamedMetadata();
241 bool ParseMDString(MDString *&Result);
242 bool ParseMDNodeID(MDNode *&Result);
243 bool ParseMDNodeID(MDNode *&Result,
unsigned &SlotNo);
244 bool ParseUnnamedAttrGrp();
245 bool ParseFnAttributeValuePairs(AttrBuilder &B,
246 std::vector<unsigned> &FwdRefAttrGrps,
247 bool inAttrGrp,
LocTy &BuiltinLoc);
250 bool ParseType(
Type *&Result,
bool AllowVoid =
false);
251 bool ParseType(
Type *&Result,
LocTy &Loc,
bool AllowVoid =
false) {
253 return ParseType(Result, AllowVoid);
255 bool ParseAnonStructType(
Type *&Result,
bool Packed);
256 bool ParseStructBody(SmallVectorImpl<Type*> &Body);
257 bool ParseStructDefinition(SMLoc TypeLoc, StringRef
Name,
258 std::pair<Type*, LocTy> &Entry,
261 bool ParseArrayVectorType(
Type *&Result,
bool isVector);
262 bool ParseFunctionType(
Type *&Result);
265 class PerFunctionState {
268 std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
269 std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
270 std::vector<Value*> NumberedVals;
279 Function &getFunction()
const {
return F; }
281 bool FinishFunction();
291 bool SetInstName(
int NameID,
const std::string &NameStr,
LocTy NameLoc,
306 bool ConvertValIDToValue(
Type *Ty, ValID &
ID, Value *&V,
307 PerFunctionState *PFS);
309 bool ParseValue(
Type *Ty, Value *&V, PerFunctionState *PFS);
310 bool ParseValue(
Type *Ty, Value *&V, PerFunctionState &PFS) {
311 return ParseValue(Ty, V, &PFS);
313 bool ParseValue(
Type *Ty, Value *&V,
LocTy &Loc,
314 PerFunctionState &PFS) {
316 return ParseValue(Ty, V, &PFS);
319 bool ParseTypeAndValue(Value *&V, PerFunctionState *PFS);
320 bool ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
321 return ParseTypeAndValue(V, &PFS);
323 bool ParseTypeAndValue(Value *&V,
LocTy &Loc, PerFunctionState &PFS) {
325 return ParseTypeAndValue(V, PFS);
328 PerFunctionState &PFS);
329 bool ParseTypeAndBasicBlock(
BasicBlock *&BB, PerFunctionState &PFS) {
331 return ParseTypeAndBasicBlock(BB, Loc, PFS);
339 ParamInfo(
LocTy loc, Value *v, AttributeSet attrs)
340 : Loc(loc), V(v), Attrs(attrs) {}
342 bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
343 PerFunctionState &PFS);
346 bool ParseValID(ValID &
ID, PerFunctionState *PFS = NULL);
348 bool ParseGlobalTypeAndValue(
Constant *&V);
349 bool ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts);
350 bool ParseMetadataListValue(ValID &
ID, PerFunctionState *PFS);
351 bool ParseMetadataValue(ValID &
ID, PerFunctionState *PFS);
352 bool ParseMDNodeVector(SmallVectorImpl<Value*> &, PerFunctionState *PFS);
353 bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS);
361 ArgInfo(
LocTy L,
Type *ty, AttributeSet Attr,
const std::string &
N)
362 : Loc(L), Ty(ty), Attrs(Attr),
Name(N) {}
364 bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
bool &isVarArg);
365 bool ParseFunctionHeader(Function *&Fn,
bool isDefine);
366 bool ParseFunctionBody(Function &Fn);
367 bool ParseBasicBlock(PerFunctionState &PFS);
371 enum InstResult { InstNormal = 0, InstError = 1, InstExtraComma = 2 };
372 int ParseInstruction(Instruction *&Inst,
BasicBlock *BB,
373 PerFunctionState &PFS);
374 bool ParseCmpPredicate(
unsigned &Pred,
unsigned Opc);
376 bool ParseRet(Instruction *&Inst,
BasicBlock *BB, PerFunctionState &PFS);
377 bool ParseBr(Instruction *&Inst, PerFunctionState &PFS);
378 bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
379 bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
380 bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
381 bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
383 bool ParseArithmetic(Instruction *&
I, PerFunctionState &PFS,
unsigned Opc,
385 bool ParseLogical(Instruction *&
I, PerFunctionState &PFS,
unsigned Opc);
386 bool ParseCompare(Instruction *&
I, PerFunctionState &PFS,
unsigned Opc);
387 bool ParseCast(Instruction *&
I, PerFunctionState &PFS,
unsigned Opc);
388 bool ParseSelect(Instruction *&
I, PerFunctionState &PFS);
389 bool ParseVA_Arg(Instruction *&
I, PerFunctionState &PFS);
390 bool ParseExtractElement(Instruction *&
I, PerFunctionState &PFS);
391 bool ParseInsertElement(Instruction *&
I, PerFunctionState &PFS);
392 bool ParseShuffleVector(Instruction *&
I, PerFunctionState &PFS);
393 int ParsePHI(Instruction *&
I, PerFunctionState &PFS);
394 bool ParseLandingPad(Instruction *&
I, PerFunctionState &PFS);
395 bool ParseCall(Instruction *&
I, PerFunctionState &PFS,
bool isTail);
396 int ParseAlloc(Instruction *&
I, PerFunctionState &PFS);
397 int ParseLoad(Instruction *&
I, PerFunctionState &PFS);
398 int ParseStore(Instruction *&
I, PerFunctionState &PFS);
399 int ParseCmpXchg(Instruction *&
I, PerFunctionState &PFS);
400 int ParseAtomicRMW(Instruction *&
I, PerFunctionState &PFS);
401 int ParseFence(Instruction *&
I, PerFunctionState &PFS);
402 int ParseGetElementPtr(Instruction *&
I, PerFunctionState &PFS);
403 int ParseExtractValue(Instruction *&
I, PerFunctionState &PFS);
404 int ParseInsertValue(Instruction *&
I, PerFunctionState &PFS);
406 bool ResolveForwardRefBlockAddresses(Function *TheFn,
407 std::vector<std::pair<ValID, GlobalValue*> > &Refs,
408 PerFunctionState *PFS);
COFF::RelocationTypeX86 Type
The main container class for the LLVM Intermediate Representation.
LLVMContext & getContext()
MDNode - a tuple of other values.
LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m)
bool Run()
Run: module ::= toplevelentity*.
This file contains the simple types necessary to represent the attributes associated with functions a...
ID
LLVM Calling Convention Representation.
bool operator<(const ValID &RHS) const
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
LLVM Constant Representation.
bool Error(LocTy L, const Twine &Msg) const
static bool isAtomic(Instruction *I)
Constant ** ConstantStructElts
enum llvm::ValID::@149 Kind
FunctionNumber(functionNumber)
lltok::Kind getKind() const
Represents a location in source code.