diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-13 21:10:44 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-13 21:10:44 +0000 |
commit | 6a4848324bc8ed9789e3d9d99e8715b1667547d3 (patch) | |
tree | 0d7be7c5469f3d78cc75b980930e1f0c72c2d674 /llvm/lib/AsmParser/LLParser.h | |
parent | a4f2925bd10233f143ef92a4df18a5f2457df0dd (diff) | |
download | bcm5719-llvm-6a4848324bc8ed9789e3d9d99e8715b1667547d3.tar.gz bcm5719-llvm-6a4848324bc8ed9789e3d9d99e8715b1667547d3.zip |
AsmParser/Bitcode: Add support for MDLocation
This adds assembly and bitcode support for `MDLocation`. The assembly
side is rather big, since this is the first `MDNode` subclass (that
isn't `MDTuple`). Part of PR21433.
(If you're wondering where the mountains of testcase updates are, we
don't need them until I update `DILocation` and `DebugLoc` to actually
use this class.)
llvm-svn: 225830
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.h')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/LLParser.h b/llvm/lib/AsmParser/LLParser.h index 8607b70f312..220562d66fc 100644 --- a/llvm/lib/AsmParser/LLParser.h +++ b/llvm/lib/AsmParser/LLParser.h @@ -80,6 +80,31 @@ namespace llvm { } }; + /// Structure to represent an optional metadata field. + template <class FieldTy> struct MDFieldImpl { + typedef MDFieldImpl ImplTy; + FieldTy Val; + bool Seen; + + void assign(FieldTy Val) { + Seen = true; + this->Val = Val; + } + + explicit MDFieldImpl(FieldTy Default) : Val(Default), Seen(false) {} + }; + template <class NumTy> struct MDUnsignedField : public MDFieldImpl<NumTy> { + typedef typename MDUnsignedField::ImplTy ImplTy; + NumTy Max; + + MDUnsignedField(NumTy Default = 0, + NumTy Max = std::numeric_limits<NumTy>::max()) + : ImplTy(Default), Max(Max) {} + }; + struct MDField : public MDFieldImpl<Metadata *> { + MDField() : ImplTy(nullptr) {} + }; + class LLParser { public: typedef LLLexer::LocTy LocTy; @@ -393,6 +418,13 @@ namespace llvm { bool ParseMDNodeVector(SmallVectorImpl<Metadata *> &MDs); bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS); + bool ParseMDField(LocTy Loc, StringRef Name, + MDUnsignedField<uint32_t> &Result); + bool ParseMDField(LocTy Loc, StringRef Name, MDField &Result); + template <class ParserTy> bool ParseMDFieldsImpl(ParserTy parseField); + bool ParseSpecializedMDNode(MDNode *&N, bool IsDistinct = false); + bool ParseMDLocation(MDNode *&Result, bool IsDistinct); + // Function Parsing. struct ArgInfo { LocTy Loc; |