mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 03:29:40 +00:00
factor code even more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92280 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
84d03b11d0
commit
3f5132a024
@ -539,31 +539,23 @@ bool LLParser::ParseStandaloneMetadata() {
|
|||||||
assert(Lex.getKind() == lltok::Metadata);
|
assert(Lex.getKind() == lltok::Metadata);
|
||||||
Lex.Lex();
|
Lex.Lex();
|
||||||
unsigned MetadataID = 0;
|
unsigned MetadataID = 0;
|
||||||
if (ParseUInt32(MetadataID))
|
|
||||||
return true;
|
|
||||||
if (MetadataCache.count(MetadataID))
|
|
||||||
return TokError("Metadata id is already used");
|
|
||||||
if (ParseToken(lltok::equal, "expected '=' here"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
LocTy TyLoc;
|
LocTy TyLoc;
|
||||||
PATypeHolder Ty(Type::getVoidTy(Context));
|
PATypeHolder Ty(Type::getVoidTy(Context));
|
||||||
if (ParseType(Ty, TyLoc))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Lex.getKind() != lltok::Metadata)
|
|
||||||
return TokError("Expected metadata here");
|
|
||||||
|
|
||||||
Lex.Lex();
|
|
||||||
if (Lex.getKind() != lltok::lbrace)
|
|
||||||
return TokError("Expected '{' here");
|
|
||||||
|
|
||||||
// FIXME: This doesn't make sense here.
|
|
||||||
SmallVector<Value *, 16> Elts;
|
SmallVector<Value *, 16> Elts;
|
||||||
if (ParseMDNodeVector(Elts)
|
// FIXME: This doesn't make sense here. Pull braced MD stuff parsing out!
|
||||||
|| ParseToken(lltok::rbrace, "expected end of metadata node"))
|
if (ParseUInt32(MetadataID) ||
|
||||||
|
ParseToken(lltok::equal, "expected '=' here") ||
|
||||||
|
ParseType(Ty, TyLoc) ||
|
||||||
|
ParseToken(lltok::Metadata, "Expected metadata here") ||
|
||||||
|
ParseToken(lltok::lbrace, "Expected '{' here") ||
|
||||||
|
ParseMDNodeVector(Elts) ||
|
||||||
|
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (MetadataCache.count(MetadataID))
|
||||||
|
return TokError("Metadata id is already used");
|
||||||
|
|
||||||
MDNode *Init = MDNode::get(Context, Elts.data(), Elts.size());
|
MDNode *Init = MDNode::get(Context, Elts.data(), Elts.size());
|
||||||
MetadataCache[MetadataID] = Init;
|
MetadataCache[MetadataID] = Init;
|
||||||
std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> >::iterator
|
std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> >::iterator
|
||||||
@ -585,14 +577,12 @@ bool LLParser::ParseInlineMetadata(Value *&V, PerFunctionState &PFS) {
|
|||||||
V = 0;
|
V = 0;
|
||||||
|
|
||||||
Lex.Lex();
|
Lex.Lex();
|
||||||
if (Lex.getKind() == lltok::lbrace) {
|
if (EatIfPresent(lltok::lbrace)) {
|
||||||
Lex.Lex();
|
|
||||||
if (ParseTypeAndValue(V, PFS) ||
|
if (ParseTypeAndValue(V, PFS) ||
|
||||||
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Value *Vals[] = { V };
|
V = MDNode::get(Context, &V, 1);
|
||||||
V = MDNode::get(Context, Vals, 1);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1938,7 +1928,7 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||||||
Lex.Lex();
|
Lex.Lex();
|
||||||
|
|
||||||
// FIXME: This doesn't belong here.
|
// FIXME: This doesn't belong here.
|
||||||
if (Lex.getKind() == lltok::lbrace) {
|
if (EatIfPresent(lltok::lbrace)) {
|
||||||
SmallVector<Value*, 16> Elts;
|
SmallVector<Value*, 16> Elts;
|
||||||
if (ParseMDNodeVector(Elts) ||
|
if (ParseMDNodeVector(Elts) ||
|
||||||
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
||||||
@ -3840,8 +3830,6 @@ bool LLParser::ParseInsertValue(Instruction *&Inst, PerFunctionState &PFS) {
|
|||||||
/// Element
|
/// Element
|
||||||
/// ::= 'null' | TypeAndValue
|
/// ::= 'null' | TypeAndValue
|
||||||
bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts) {
|
bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts) {
|
||||||
assert(Lex.getKind() == lltok::lbrace);
|
|
||||||
Lex.Lex();
|
|
||||||
do {
|
do {
|
||||||
Value *V = 0;
|
Value *V = 0;
|
||||||
// FIXME: REWRITE.
|
// FIXME: REWRITE.
|
||||||
|
Loading…
Reference in New Issue
Block a user