Skip to content

Commit 3107db6

Browse files
jiegecRot127
andcommitted
Drop MatchByTypeName check in opIsPartOfiPTRPattern
Matching by type name can make incorrect assumption of memory operands, when the destnation register and base register share the same type of GPR. Drop this logic for now. This commit fixes the destination register info of load instructions of LoongArch ISA. Fixes capstone-engine/capstone#2700. Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
1 parent 095dff8 commit 3107db6

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

llvm/utils/TableGen/PrinterCapstone.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,16 +3029,13 @@ bool compareTypeSuperClasses(ArrayRef<std::pair<Record *, SMRange>> OpTypeSC,
30293029
/// @param PatternDag The pattern DAG to search in.
30303030
/// @param PartOfPTRPattern True, if the given pattern is of type iPTR. False
30313031
/// otherwise.
3032-
/// @param MatchByTypeName If true, the same type names are treated as a valid
3033-
/// match.
30343032
/// @param MatchByTypeSuperClasses If true, a valid match is also if any type
30353033
/// super classes are the same.
30363034
/// @return True, if the pattern contains a node with the same name (and
30373035
/// optionally the same type name or same super class type) as the given
30383036
/// operand. False otherwise.
30393037
bool opIsPartOfiPTRPattern(Record const *OpRec, StringRef const &OpName,
30403038
DagInit *PatternDag, bool PartOfPTRPattern,
3041-
bool MatchByTypeName = false,
30423039
bool MatchByTypeSuperClasses = false) {
30433040
for (unsigned I = 0; I < PatternDag->getNumArgs(); ++I) {
30443041
DagInit *DagArg = dyn_cast<DagInit>(PatternDag->getArg(I));
@@ -3054,7 +3051,7 @@ bool opIsPartOfiPTRPattern(Record const *OpRec, StringRef const &OpName,
30543051
MVT::SimpleValueType::iPTR)
30553052
PartOfPTRPattern = true;
30563053
if (opIsPartOfiPTRPattern(OpRec, OpName, DagArg, PartOfPTRPattern,
3057-
MatchByTypeName, MatchByTypeSuperClasses))
3054+
MatchByTypeSuperClasses))
30583055
return true;
30593056
continue;
30603057
}
@@ -3065,11 +3062,6 @@ bool opIsPartOfiPTRPattern(Record const *OpRec, StringRef const &OpName,
30653062
bool Matches;
30663063
StringRef const &PatOpName = PatternDag->getArgNameStr(I);
30673064
Matches = OpName.equals(PatOpName);
3068-
if (MatchByTypeName) {
3069-
std::string OpInitType = OpRec->getNameInitAsString();
3070-
std::string PatOpType = PatternDag->getArg(I)->getAsString();
3071-
Matches |= OpInitType == PatOpType;
3072-
}
30733065
if (MatchByTypeSuperClasses) {
30743066
std::string OpInitType = OpRec->getNameInitAsString();
30753067
std::string PatOpType = PatternDag->getArg(I)->getAsString();
@@ -3137,8 +3129,7 @@ std::string getCSOperandType(
31373129
bool OpTypeIsPartOfAnyPattern =
31383130
any_of(InsnPatternMap.at(CGIName), [&](Record *PatternDag) {
31393131
return opIsPartOfiPTRPattern(
3140-
OpRec, OpName, PatternDag->getValueAsDag("PatternToMatch"), false,
3141-
true);
3132+
OpRec, OpName, PatternDag->getValueAsDag("PatternToMatch"), false);
31423133
});
31433134
if (OpTypeIsPartOfAnyPattern)
31443135
OperandType += " | CS_OP_MEM";

0 commit comments

Comments
 (0)