mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
AsmParser: Simplify MDUnsignedField
We only need `uint64_t` for storage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228205 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ab47b42e26
commit
321b43e7cc
@ -2924,23 +2924,23 @@ bool LLParser::ParseMDNodeTail(MDNode *&N) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
|
bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
|
||||||
MDUnsignedField<uint32_t> &Result) {
|
MDUnsignedField &Result) {
|
||||||
if (Lex.getKind() != lltok::APSInt || Lex.getAPSIntVal().isSigned())
|
if (Lex.getKind() != lltok::APSInt || Lex.getAPSIntVal().isSigned())
|
||||||
return TokError("expected unsigned integer");
|
return TokError("expected unsigned integer");
|
||||||
uint64_t Val64 = Lex.getAPSIntVal().getLimitedValue(Result.Max + 1ull);
|
|
||||||
|
|
||||||
if (Val64 > Result.Max)
|
auto &U = Lex.getAPSIntVal();
|
||||||
|
if (U.ugt(Result.Max))
|
||||||
return TokError("value for '" + Name + "' too large, limit is " +
|
return TokError("value for '" + Name + "' too large, limit is " +
|
||||||
Twine(Result.Max));
|
Twine(Result.Max));
|
||||||
Result.assign(Val64);
|
Result.assign(U.getZExtValue());
|
||||||
|
assert(Result.Val <= Result.Max && "Expected value in range");
|
||||||
Lex.Lex();
|
Lex.Lex();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
|
||||||
static_cast<MDUnsignedField<uint32_t> &>(Result));
|
|
||||||
|
|
||||||
if (Result.Seen)
|
if (Result.Seen)
|
||||||
return Error(Loc,
|
return Error(Loc,
|
||||||
@ -3063,8 +3063,8 @@ bool LLParser::ParseSpecializedMDNode(MDNode *&N, bool IsDistinct) {
|
|||||||
/// ::= !MDLocation(line: 43, column: 8, scope: !5, inlinedAt: !6)
|
/// ::= !MDLocation(line: 43, column: 8, scope: !5, inlinedAt: !6)
|
||||||
bool LLParser::ParseMDLocation(MDNode *&Result, bool IsDistinct) {
|
bool LLParser::ParseMDLocation(MDNode *&Result, bool IsDistinct) {
|
||||||
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
|
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
|
||||||
OPTIONAL(line, MDUnsignedField<uint32_t>, (0, ~0u >> 8)); \
|
OPTIONAL(line, MDUnsignedField, (0, ~0u >> 8)); \
|
||||||
OPTIONAL(column, MDUnsignedField<uint32_t>, (0, ~0u >> 16)); \
|
OPTIONAL(column, MDUnsignedField, (0, ~0u >> 16)); \
|
||||||
REQUIRED(scope, MDField, ); \
|
REQUIRED(scope, MDField, ); \
|
||||||
OPTIONAL(inlinedAt, MDField, );
|
OPTIONAL(inlinedAt, MDField, );
|
||||||
PARSE_MD_FIELDS();
|
PARSE_MD_FIELDS();
|
||||||
|
@ -94,16 +94,14 @@ namespace llvm {
|
|||||||
explicit MDFieldImpl(FieldTy Default)
|
explicit MDFieldImpl(FieldTy Default)
|
||||||
: Val(std::move(Default)), Seen(false) {}
|
: Val(std::move(Default)), Seen(false) {}
|
||||||
};
|
};
|
||||||
template <class NumTy> struct MDUnsignedField : public MDFieldImpl<NumTy> {
|
struct MDUnsignedField : public MDFieldImpl<uint64_t> {
|
||||||
typedef typename MDUnsignedField::ImplTy ImplTy;
|
uint64_t Max;
|
||||||
NumTy Max;
|
|
||||||
|
|
||||||
MDUnsignedField(NumTy Default = 0,
|
MDUnsignedField(uint64_t Default = 0, uint64_t Max = UINT64_MAX)
|
||||||
NumTy Max = std::numeric_limits<NumTy>::max())
|
|
||||||
: ImplTy(Default), Max(Max) {}
|
: ImplTy(Default), Max(Max) {}
|
||||||
};
|
};
|
||||||
struct DwarfTagField : public MDUnsignedField<uint32_t> {
|
struct DwarfTagField : public MDUnsignedField {
|
||||||
DwarfTagField() : MDUnsignedField<uint32_t>(0, ~0u >> 16) {}
|
DwarfTagField() : MDUnsignedField(0, ~0u >> 16) {}
|
||||||
};
|
};
|
||||||
struct MDField : public MDFieldImpl<Metadata *> {
|
struct MDField : public MDFieldImpl<Metadata *> {
|
||||||
MDField() : ImplTy(nullptr) {}
|
MDField() : ImplTy(nullptr) {}
|
||||||
@ -428,8 +426,7 @@ 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,
|
bool ParseMDField(LocTy Loc, StringRef Name, MDUnsignedField &Result);
|
||||||
MDUnsignedField<uint32_t> &Result);
|
|
||||||
bool ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result);
|
bool ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result);
|
||||||
bool ParseMDField(LocTy Loc, StringRef Name, MDField &Result);
|
bool ParseMDField(LocTy Loc, StringRef Name, MDField &Result);
|
||||||
bool ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result);
|
bool ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user