mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Eliminate asm parser's dependency on TargetMachine:
- Each target asm parser now creates its own MCSubtatgetInfo (if needed). - Changed AssemblerPredicate to take subtarget features which tablegen uses to generate asm matcher subtarget feature queries. e.g. "ModeThumb,FeatureThumb2" is translated to "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134678 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1817,15 +1817,43 @@ static void EmitComputeAvailableFeatures(AsmMatcherInfo &Info,
|
||||
Info.AsmParser->getValueAsString("AsmParserClassName");
|
||||
|
||||
OS << "unsigned " << Info.Target.getName() << ClassName << "::\n"
|
||||
<< "ComputeAvailableFeatures(const " << Info.Target.getName()
|
||||
<< "Subtarget *Subtarget) const {\n";
|
||||
<< "ComputeAvailableFeatures(uint64_t FB) const {\n";
|
||||
OS << " unsigned Features = 0;\n";
|
||||
for (std::map<Record*, SubtargetFeatureInfo*>::const_iterator
|
||||
it = Info.SubtargetFeatures.begin(),
|
||||
ie = Info.SubtargetFeatures.end(); it != ie; ++it) {
|
||||
SubtargetFeatureInfo &SFI = *it->second;
|
||||
OS << " if (" << SFI.TheDef->getValueAsString("CondString")
|
||||
<< ")\n";
|
||||
|
||||
OS << " if (";
|
||||
StringRef Conds = SFI.TheDef->getValueAsString("AssemblerCondString");
|
||||
std::pair<StringRef,StringRef> Comma = Conds.split(',');
|
||||
bool First = true;
|
||||
do {
|
||||
if (!First)
|
||||
OS << " && ";
|
||||
|
||||
bool Neg = false;
|
||||
StringRef Cond = Comma.first;
|
||||
if (Cond[0] == '!') {
|
||||
Neg = true;
|
||||
Cond = Cond.substr(1);
|
||||
}
|
||||
|
||||
OS << "((FB & " << Info.Target.getName() << "::" << Cond << ")";
|
||||
if (Neg)
|
||||
OS << " == 0";
|
||||
else
|
||||
OS << " != 0";
|
||||
OS << ")";
|
||||
|
||||
if (Comma.second.empty())
|
||||
break;
|
||||
|
||||
First = false;
|
||||
Comma = Comma.second.split(',');
|
||||
} while (true);
|
||||
|
||||
OS << ")\n";
|
||||
OS << " Features |= " << SFI.getEnumName() << ";\n";
|
||||
}
|
||||
OS << " return Features;\n";
|
||||
@@ -2140,8 +2168,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
|
||||
OS << "#undef GET_ASSEMBLER_HEADER\n";
|
||||
OS << " // This should be included into the middle of the declaration of\n";
|
||||
OS << " // your subclasses implementation of TargetAsmParser.\n";
|
||||
OS << " unsigned ComputeAvailableFeatures(const " <<
|
||||
Target.getName() << "Subtarget *Subtarget) const;\n";
|
||||
OS << " unsigned ComputeAvailableFeatures(uint64_t FeatureBits) const;\n";
|
||||
OS << " enum MatchResultTy {\n";
|
||||
OS << " Match_ConversionFail,\n";
|
||||
OS << " Match_InvalidOperand,\n";
|
||||
|
@@ -645,12 +645,18 @@ void SubtargetEmitter::run(raw_ostream &OS) {
|
||||
|
||||
EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS);
|
||||
|
||||
OS << "\n#ifdef GET_SUBTARGETINFO_ENUM\n";
|
||||
OS << "#undef GET_SUBTARGETINFO_ENUM\n";
|
||||
|
||||
OS << "namespace llvm {\n";
|
||||
Enumeration(OS, "SubtargetFeature", true);
|
||||
OS << "} // End llvm namespace \n";
|
||||
OS << "#endif // GET_SUBTARGETINFO_ENUM\n\n";
|
||||
|
||||
OS << "\n#ifdef GET_SUBTARGETINFO_MC_DESC\n";
|
||||
OS << "#undef GET_SUBTARGETINFO_MC_DESC\n";
|
||||
|
||||
OS << "namespace llvm {\n";
|
||||
Enumeration(OS, "SubtargetFeature", true);
|
||||
OS<<"\n";
|
||||
unsigned NumFeatures = FeatureKeyValues(OS);
|
||||
OS<<"\n";
|
||||
unsigned NumProcs = CPUKeyValues(OS);
|
||||
|
Reference in New Issue
Block a user