Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ static Expected<ResultOperand> matchSimpleOperand(const Init *Arg,
const StringInit *ArgName,
const Record *Op,
const CodeGenTarget &T) {
if (Op->isSubClassOf("RegisterClass") ||
Op->isSubClassOf("RegisterOperand")) {
const Record *OpRC =
Op->isSubClassOf("RegisterClass") ? Op : Op->getValueAsDef("RegClass");

if (const Record *OpRC = T.getAsRegClassLike(Op)) {
if (const auto *ArgDef = dyn_cast<DefInit>(Arg)) {
const Record *ArgRec = ArgDef->getDef();

Expand Down Expand Up @@ -111,11 +107,9 @@ static Expected<ResultOperand> matchSimpleOperand(const Init *Arg,
return ResultOperand::createRecord(ArgName->getAsUnquotedString(),
ArgDef->getDef());
}

return createStringError("argument must be a subclass of Operand");
}

llvm_unreachable("Unknown operand kind");
return createStringError("argument must be a subclass of 'Operand' but got " +
Op->getName() + " instead");
}

static Expected<ResultOperand> matchComplexOperand(const Init *Arg,
Expand Down
10 changes: 6 additions & 4 deletions llvm/utils/TableGen/Common/CodeGenTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,14 @@ const Record *CodeGenTarget::getInitValueAsRegClassLike(const Init *V) const {
const DefInit *VDefInit = dyn_cast<DefInit>(V);
if (!VDefInit)
return nullptr;
return getAsRegClassLike(VDefInit->getDef());
}

const Record *RegClass = VDefInit->getDef();
if (RegClass->isSubClassOf("RegisterOperand"))
return RegClass->getValueAsDef("RegClass");
const Record *CodeGenTarget::getAsRegClassLike(const Record *Rec) const {
if (Rec->isSubClassOf("RegisterOperand"))
return Rec->getValueAsDef("RegClass");

return RegClass->isSubClassOf("RegisterClassLike") ? RegClass : nullptr;
return Rec->isSubClassOf("RegisterClassLike") ? Rec : nullptr;
}

CodeGenSchedModels &CodeGenTarget::getSchedModels() const {
Expand Down
1 change: 1 addition & 0 deletions llvm/utils/TableGen/Common/CodeGenTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class CodeGenTarget {
/// return the Record. This is used as a convenience function to handle direct
/// RegisterClass references, or those wrapped in a RegisterOperand.
const Record *getInitValueAsRegClassLike(const Init *V) const;
const Record *getAsRegClassLike(const Record *V) const;

CodeGenSchedModels &getSchedModels() const;

Expand Down
Loading