mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 00:11:00 +00:00
split t_Metadata into t_MDNode and t_MDString, eliminating some unsafe casting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92287 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3f5132a024
commit
287881d510
@ -1408,17 +1408,21 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
|
|||||||
if (ParseType(ArgTy, ArgLoc))
|
if (ParseType(ArgTy, ArgLoc))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Parse metadata operands to calls (for intrinsics).
|
||||||
if (Lex.getKind() == lltok::Metadata) {
|
if (Lex.getKind() == lltok::Metadata) {
|
||||||
if (ParseInlineMetadata(V, PFS))
|
if (ParseInlineMetadata(V, PFS))
|
||||||
return true;
|
return true;
|
||||||
} else {
|
ArgList.push_back(ParamInfo(ArgLoc, V, Attribute::None));
|
||||||
if (ParseOptionalAttrs(ArgAttrs1, 0) ||
|
continue;
|
||||||
ParseValue(ArgTy, V, PFS) ||
|
|
||||||
// FIXME: Should not allow attributes after the argument, remove this
|
|
||||||
// in LLVM 3.0.
|
|
||||||
ParseOptionalAttrs(ArgAttrs2, 3))
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise, handle normal operands.
|
||||||
|
if (ParseOptionalAttrs(ArgAttrs1, 0) ||
|
||||||
|
ParseValue(ArgTy, V, PFS) ||
|
||||||
|
// FIXME: Should not allow attributes after the argument, remove this
|
||||||
|
// in LLVM 3.0.
|
||||||
|
ParseOptionalAttrs(ArgAttrs2, 3))
|
||||||
|
return true;
|
||||||
ArgList.push_back(ParamInfo(ArgLoc, V, ArgAttrs1|ArgAttrs2));
|
ArgList.push_back(ParamInfo(ArgLoc, V, ArgAttrs1|ArgAttrs2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1924,7 +1928,6 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||||||
ID.Kind = ValID::t_LocalName;
|
ID.Kind = ValID::t_LocalName;
|
||||||
break;
|
break;
|
||||||
case lltok::Metadata: { // !{...} MDNode, !"foo" MDString
|
case lltok::Metadata: { // !{...} MDNode, !"foo" MDString
|
||||||
ID.Kind = ValID::t_Metadata;
|
|
||||||
Lex.Lex();
|
Lex.Lex();
|
||||||
|
|
||||||
// FIXME: This doesn't belong here.
|
// FIXME: This doesn't belong here.
|
||||||
@ -1934,20 +1937,25 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||||||
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ID.MetadataVal = MDNode::get(Context, Elts.data(), Elts.size());
|
ID.MDNodeVal = MDNode::get(Context, Elts.data(), Elts.size());
|
||||||
|
ID.Kind = ValID::t_MDNode;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Standalone metadata reference
|
// Standalone metadata reference
|
||||||
// !{ ..., !42, ... }
|
// !{ ..., !42, ... }
|
||||||
// FIXME: Split MetadataVal into one for MDNode and one for MDString.
|
// FIXME: Split MetadataVal into one for MDNode and one for MDString.
|
||||||
if (!ParseMDNode((MDNode*&)ID.MetadataVal))
|
if (!ParseMDNode(ID.MDNodeVal)) {
|
||||||
|
ID.Kind = ValID::t_MDNode;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: This can't work.
|
||||||
|
|
||||||
// MDString:
|
// MDString:
|
||||||
// ::= '!' STRINGCONSTANT
|
// ::= '!' STRINGCONSTANT
|
||||||
if (ParseMDString((MDString*&)ID.MetadataVal)) return true;
|
if (ParseMDString(ID.MDStringVal)) return true;
|
||||||
ID.Kind = ValID::t_Metadata;
|
ID.Kind = ValID::t_MDString;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case lltok::APSInt:
|
case lltok::APSInt:
|
||||||
@ -2393,7 +2401,8 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID,
|
|||||||
|
|
||||||
switch (ID.Kind) {
|
switch (ID.Kind) {
|
||||||
default: llvm_unreachable("Unknown ValID!");
|
default: llvm_unreachable("Unknown ValID!");
|
||||||
case ValID::t_Metadata:
|
case ValID::t_MDNode:
|
||||||
|
case ValID::t_MDString:
|
||||||
return Error(ID.Loc, "invalid use of metadata");
|
return Error(ID.Loc, "invalid use of metadata");
|
||||||
case ValID::t_LocalID:
|
case ValID::t_LocalID:
|
||||||
case ValID::t_LocalName:
|
case ValID::t_LocalName:
|
||||||
@ -2499,26 +2508,27 @@ bool LLParser::ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts) {
|
|||||||
|
|
||||||
bool LLParser::ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V,
|
bool LLParser::ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V,
|
||||||
PerFunctionState &PFS) {
|
PerFunctionState &PFS) {
|
||||||
if (ID.Kind == ValID::t_LocalID)
|
switch (ID.Kind) {
|
||||||
V = PFS.GetVal(ID.UIntVal, Ty, ID.Loc);
|
case ValID::t_LocalID: V = PFS.GetVal(ID.UIntVal, Ty, ID.Loc); break;
|
||||||
else if (ID.Kind == ValID::t_LocalName)
|
case ValID::t_LocalName: V = PFS.GetVal(ID.StrVal, Ty, ID.Loc); break;
|
||||||
V = PFS.GetVal(ID.StrVal, Ty, ID.Loc);
|
case ValID::t_MDNode: V = ID.MDNodeVal; break;
|
||||||
else if (ID.Kind == ValID::t_InlineAsm) {
|
case ValID::t_MDString: V = ID.MDStringVal;
|
||||||
|
case ValID::t_InlineAsm: {
|
||||||
const PointerType *PTy = dyn_cast<PointerType>(Ty);
|
const PointerType *PTy = dyn_cast<PointerType>(Ty);
|
||||||
const FunctionType *FTy =
|
const FunctionType *FTy =
|
||||||
PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
|
PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
|
||||||
if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2))
|
if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2))
|
||||||
return Error(ID.Loc, "invalid type for inline asm constraint string");
|
return Error(ID.Loc, "invalid type for inline asm constraint string");
|
||||||
V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1, ID.UIntVal>>1);
|
V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1, ID.UIntVal>>1);
|
||||||
return false;
|
return false;
|
||||||
} else if (ID.Kind == ValID::t_Metadata) {
|
}
|
||||||
V = ID.MetadataVal;
|
default: {
|
||||||
} else {
|
|
||||||
Constant *C;
|
Constant *C;
|
||||||
if (ConvertGlobalValIDToValue(Ty, ID, C)) return true;
|
if (ConvertGlobalValIDToValue(Ty, ID, C)) return true;
|
||||||
V = C;
|
V = C;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return V == 0;
|
return V == 0;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ namespace llvm {
|
|||||||
t_EmptyArray, // No value: []
|
t_EmptyArray, // No value: []
|
||||||
t_Constant, // Value in ConstantVal.
|
t_Constant, // Value in ConstantVal.
|
||||||
t_InlineAsm, // Value in StrVal/StrVal2/UIntVal.
|
t_InlineAsm, // Value in StrVal/StrVal2/UIntVal.
|
||||||
t_Metadata // Value in MetadataVal.
|
t_MDNode, // Value in MDNodeVal.
|
||||||
|
t_MDString // Value in MDStringVal.
|
||||||
} Kind;
|
} Kind;
|
||||||
|
|
||||||
LLLexer::LocTy Loc;
|
LLLexer::LocTy Loc;
|
||||||
@ -55,7 +56,8 @@ namespace llvm {
|
|||||||
APSInt APSIntVal;
|
APSInt APSIntVal;
|
||||||
APFloat APFloatVal;
|
APFloat APFloatVal;
|
||||||
Constant *ConstantVal;
|
Constant *ConstantVal;
|
||||||
MetadataBase *MetadataVal;
|
MDNode *MDNodeVal;
|
||||||
|
MDString *MDStringVal;
|
||||||
ValID() : APFloatVal(0.0) {}
|
ValID() : APFloatVal(0.0) {}
|
||||||
|
|
||||||
bool operator<(const ValID &RHS) const {
|
bool operator<(const ValID &RHS) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user