Changeset View
Changeset View
Standalone View
Standalone View
llvm/utils/TableGen/AsmWriterEmitter.cpp
Show First 20 Lines • Show All 935 Lines • ▼ Show 20 Lines | for (auto &Alias : Aliases.second) { | ||||
CGA.TheDef->getValueAsListOfDefs("Predicates"); | CGA.TheDef->getValueAsListOfDefs("Predicates"); | ||||
copy_if(RF, std::back_inserter(ReqFeatures), [](Record *R) { | copy_if(RF, std::back_inserter(ReqFeatures), [](Record *R) { | ||||
return R->getValueAsBit("AssemblerMatcherPredicate"); | return R->getValueAsBit("AssemblerMatcherPredicate"); | ||||
}); | }); | ||||
} | } | ||||
for (auto I = ReqFeatures.cbegin(); I != ReqFeatures.cend(); I++) { | for (auto I = ReqFeatures.cbegin(); I != ReqFeatures.cend(); I++) { | ||||
Record *R = *I; | Record *R = *I; | ||||
StringRef AsmCondString = R->getValueAsString("AssemblerCondString"); | const DagInit *D = R->getValueAsDag("AssemblerCondDag"); | ||||
StringRef CombineType = D->getOperator()->getAsString(); | |||||
if (CombineType != "any_of" && CombineType != "all_of") | |||||
PrintFatalError(R->getLoc(), "Invalid AssemblerCondDag!"); | |||||
if (D->getNumArgs() == 0) | |||||
PrintFatalError(R->getLoc(), "Invalid AssemblerCondDag!"); | |||||
bool IsOr = CombineType == "any_of"; | |||||
for (auto *Arg : D->getArgs()) { | |||||
bool IsNeg = false; | |||||
if (auto *NotArg = dyn_cast<DagInit>(Arg)) { | |||||
if (NotArg->getOperator()->getAsString() != "not" || | |||||
NotArg->getNumArgs() != 1) | |||||
PrintFatalError(R->getLoc(), "Invalid AssemblerCondDag!"); | |||||
Arg = NotArg->getArg(0); | |||||
IsNeg = true; | |||||
} | |||||
if (!isa<DefInit>(Arg) || | |||||
!cast<DefInit>(Arg)->getDef()->isSubClassOf("SubtargetFeature")) | |||||
PrintFatalError(R->getLoc(), "Invalid AssemblerCondDag!"); | |||||
// AsmCondString has syntax [!]F(,[!]F)* | |||||
SmallVector<StringRef, 4> Ops; | |||||
SplitString(AsmCondString, Ops, ","); | |||||
assert(!Ops.empty() && "AssemblerCondString cannot be empty"); | |||||
for (StringRef Op : Ops) { | |||||
assert(!Op.empty() && "Empty operator"); | |||||
bool IsNeg = Op[0] == '!'; | |||||
StringRef Feature = Op.drop_front(IsNeg ? 1 : 0); | |||||
IAP.addCond( | IAP.addCond( | ||||
std::string(formatv("AliasPatternCond::K_{0}Feature, {1}::{2}", | std::string(formatv("AliasPatternCond::K_{0}{1}Feature, {2}::{3}", | ||||
IsNeg ? "Neg" : "", Namespace, Feature))); | IsOr ? "Or" : "", IsNeg ? "Neg" : "", | ||||
} | Namespace, Arg->getAsString()))); | ||||
} | |||||
// If an AssemblerPredicate with ors is used, note end of list should | |||||
// these be combined. | |||||
if (IsOr) | |||||
IAP.addCond("AliasPatternCond::K_EndOrFeatures, 0"); | |||||
} | } | ||||
IAPrinterMap[Aliases.first].push_back(std::move(IAP)); | IAPrinterMap[Aliases.first].push_back(std::move(IAP)); | ||||
} | } | ||||
} | } | ||||
////////////////////////////// | ////////////////////////////// | ||||
// Write out the printAliasInstr function | // Write out the printAliasInstr function | ||||
▲ Show 20 Lines • Show All 268 Lines • Show Last 20 Lines |