Skip to content

Commit 566ab9c

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 b020af5 commit 566ab9c

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
@@ -3028,16 +3028,13 @@ bool compareTypeSuperClasses(ArrayRef<std::pair<Record *, SMRange>> OpTypeSC,
30283028
/// @param PatternDag The pattern DAG to search in.
30293029
/// @param PartOfPTRPattern True, if the given pattern is of type iPTR. False
30303030
/// otherwise.
3031-
/// @param MatchByTypeName If true, the same type names are treated as a valid
3032-
/// match.
30333031
/// @param MatchByTypeSuperClasses If true, a valid match is also if any type
30343032
/// super classes are the same.
30353033
/// @return True, if the pattern contains a node with the same name (and
30363034
/// optionally the same type name or same super class type) as the given
30373035
/// operand. False otherwise.
30383036
bool opIsPartOfiPTRPattern(Record const *OpRec, StringRef const &OpName,
30393037
DagInit *PatternDag, bool PartOfPTRPattern,
3040-
bool MatchByTypeName = false,
30413038
bool MatchByTypeSuperClasses = false) {
30423039
for (unsigned I = 0; I < PatternDag->getNumArgs(); ++I) {
30433040
DagInit *DagArg = dyn_cast<DagInit>(PatternDag->getArg(I));
@@ -3053,7 +3050,7 @@ bool opIsPartOfiPTRPattern(Record const *OpRec, StringRef const &OpName,
30533050
MVT::SimpleValueType::iPTR)
30543051
PartOfPTRPattern = true;
30553052
if (opIsPartOfiPTRPattern(OpRec, OpName, DagArg, PartOfPTRPattern,
3056-
MatchByTypeName, MatchByTypeSuperClasses))
3053+
MatchByTypeSuperClasses))
30573054
return true;
30583055
continue;
30593056
}
@@ -3064,11 +3061,6 @@ bool opIsPartOfiPTRPattern(Record const *OpRec, StringRef const &OpName,
30643061
bool Matches;
30653062
StringRef const &PatOpName = PatternDag->getArgNameStr(I);
30663063
Matches = OpName.equals(PatOpName);
3067-
if (MatchByTypeName) {
3068-
std::string OpInitType = OpRec->getNameInitAsString();
3069-
std::string PatOpType = PatternDag->getArg(I)->getAsString();
3070-
Matches |= OpInitType == PatOpType;
3071-
}
30723064
if (MatchByTypeSuperClasses) {
30733065
std::string OpInitType = OpRec->getNameInitAsString();
30743066
std::string PatOpType = PatternDag->getArg(I)->getAsString();
@@ -3136,8 +3128,7 @@ std::string getCSOperandType(
31363128
bool OpTypeIsPartOfAnyPattern =
31373129
any_of(InsnPatternMap.at(CGIName), [&](Record *PatternDag) {
31383130
return opIsPartOfiPTRPattern(
3139-
OpRec, OpName, PatternDag->getValueAsDag("PatternToMatch"), false,
3140-
true);
3131+
OpRec, OpName, PatternDag->getValueAsDag("PatternToMatch"), false);
31413132
});
31423133
if (OpTypeIsPartOfAnyPattern)
31433134
OperandType += " | CS_OP_MEM";

0 commit comments

Comments
 (0)