mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
AsmParser: Move MDField details to source file, NFC
Move all the types of `MDField` to an anonymous namespace in the source file. This also eliminates the duplication of `ParseMDField()` declarations in the header for each new field type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -2923,6 +2923,44 @@ bool LLParser::ParseMDNodeTail(MDNode *&N) {
|
|||||||
return ParseMDNodeID(N);
|
return ParseMDNodeID(N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
/// 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 = std::move(Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit MDFieldImpl(FieldTy Default)
|
||||||
|
: Val(std::move(Default)), Seen(false) {}
|
||||||
|
};
|
||||||
|
struct MDUnsignedField : public MDFieldImpl<uint64_t> {
|
||||||
|
uint64_t Max;
|
||||||
|
|
||||||
|
MDUnsignedField(uint64_t Default = 0, uint64_t Max = UINT64_MAX)
|
||||||
|
: ImplTy(Default), Max(Max) {}
|
||||||
|
};
|
||||||
|
struct DwarfTagField : public MDUnsignedField {
|
||||||
|
DwarfTagField() : MDUnsignedField(0, ~0u >> 16) {}
|
||||||
|
};
|
||||||
|
struct MDField : public MDFieldImpl<Metadata *> {
|
||||||
|
MDField() : ImplTy(nullptr) {}
|
||||||
|
};
|
||||||
|
struct MDStringField : public MDFieldImpl<std::string> {
|
||||||
|
MDStringField() : ImplTy(std::string()) {}
|
||||||
|
};
|
||||||
|
struct MDFieldList : public MDFieldImpl<SmallVector<Metadata *, 4>> {
|
||||||
|
MDFieldList() : ImplTy(SmallVector<Metadata *, 4>()) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace
|
||||||
|
|
||||||
|
template <>
|
||||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
|
bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
|
||||||
MDUnsignedField &Result) {
|
MDUnsignedField &Result) {
|
||||||
if (Lex.getKind() != lltok::APSInt || Lex.getAPSIntVal().isSigned())
|
if (Lex.getKind() != lltok::APSInt || Lex.getAPSIntVal().isSigned())
|
||||||
@ -2938,6 +2976,7 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
|
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
|
||||||
if (Lex.getKind() == lltok::APSInt)
|
if (Lex.getKind() == lltok::APSInt)
|
||||||
return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
|
return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
|
||||||
@ -2955,6 +2994,7 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDField &Result) {
|
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDField &Result) {
|
||||||
Metadata *MD;
|
Metadata *MD;
|
||||||
if (ParseMetadata(MD, nullptr))
|
if (ParseMetadata(MD, nullptr))
|
||||||
@ -2964,6 +3004,7 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDField &Result) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result) {
|
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result) {
|
||||||
std::string S;
|
std::string S;
|
||||||
if (ParseStringConstant(S))
|
if (ParseStringConstant(S))
|
||||||
@ -2973,6 +3014,7 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDFieldList &Result) {
|
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDFieldList &Result) {
|
||||||
SmallVector<Metadata *, 4> MDs;
|
SmallVector<Metadata *, 4> MDs;
|
||||||
if (ParseMDNodeVector(MDs))
|
if (ParseMDNodeVector(MDs))
|
||||||
|
@ -80,39 +80,6 @@ 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 = std::move(Val);
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit MDFieldImpl(FieldTy Default)
|
|
||||||
: Val(std::move(Default)), Seen(false) {}
|
|
||||||
};
|
|
||||||
struct MDUnsignedField : public MDFieldImpl<uint64_t> {
|
|
||||||
uint64_t Max;
|
|
||||||
|
|
||||||
MDUnsignedField(uint64_t Default = 0, uint64_t Max = UINT64_MAX)
|
|
||||||
: ImplTy(Default), Max(Max) {}
|
|
||||||
};
|
|
||||||
struct DwarfTagField : public MDUnsignedField {
|
|
||||||
DwarfTagField() : MDUnsignedField(0, ~0u >> 16) {}
|
|
||||||
};
|
|
||||||
struct MDField : public MDFieldImpl<Metadata *> {
|
|
||||||
MDField() : ImplTy(nullptr) {}
|
|
||||||
};
|
|
||||||
struct MDStringField : public MDFieldImpl<std::string> {
|
|
||||||
MDStringField() : ImplTy(std::string()) {}
|
|
||||||
};
|
|
||||||
struct MDFieldList : public MDFieldImpl<SmallVector<Metadata *, 4>> {
|
|
||||||
MDFieldList() : ImplTy(SmallVector<Metadata *, 4>()) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class LLParser {
|
class LLParser {
|
||||||
public:
|
public:
|
||||||
typedef LLLexer::LocTy LocTy;
|
typedef LLLexer::LocTy LocTy;
|
||||||
@ -426,11 +393,8 @@ namespace llvm {
|
|||||||
bool ParseMDNodeVector(SmallVectorImpl<Metadata *> &MDs);
|
bool ParseMDNodeVector(SmallVectorImpl<Metadata *> &MDs);
|
||||||
bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS);
|
bool ParseInstructionMetadata(Instruction *Inst, PerFunctionState *PFS);
|
||||||
|
|
||||||
bool ParseMDField(LocTy Loc, StringRef Name, MDUnsignedField &Result);
|
template <class FieldTy>
|
||||||
bool ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result);
|
bool ParseMDField(LocTy Loc, StringRef Name, FieldTy &Result);
|
||||||
bool ParseMDField(LocTy Loc, StringRef Name, MDField &Result);
|
|
||||||
bool ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result);
|
|
||||||
bool ParseMDField(LocTy Loc, StringRef Name, MDFieldList &Result);
|
|
||||||
template <class FieldTy> bool ParseMDField(StringRef Name, FieldTy &Result);
|
template <class FieldTy> bool ParseMDField(StringRef Name, FieldTy &Result);
|
||||||
template <class ParserTy>
|
template <class ParserTy>
|
||||||
bool ParseMDFieldsImplBody(ParserTy parseField);
|
bool ParseMDFieldsImplBody(ParserTy parseField);
|
||||||
|
Reference in New Issue
Block a user