Fix printer functions which get Address as argument
Some checks failed
LLVM-Tblgen-Build / build-and-test-llvm-tblgen (push) Has been cancelled

This commit is contained in:
Rot127 2024-11-01 09:55:01 -05:00 committed by Rot127
parent 290cd0784e
commit 92c98d24a3

View File

@ -793,6 +793,19 @@ static void patchTemplateArgs(const std::string &TargetName,
}
}
static void patchPrintOperandAddr(std::string &Decoder) {
bool ContainsAddress = Decoder.find("Address") != std::string::npos;
bool PrintOperand = Decoder.find("printOperand(") != std::string::npos;
bool PrintAdrLabelOperand = Decoder.find("printAdrLabelOperand") != std::string::npos;
if (ContainsAddress) {
if (PrintOperand) {
Decoder = Regex("printOperand\\(").sub("printOperandAddr(", Decoder);
} else if (PrintAdrLabelOperand) {
Decoder = Regex("printAdrLabelOperand").sub("printAdrLabelOperandAddr", Decoder);
}
}
}
std::string PrinterCapstone::translateToC(std::string const &TargetName,
std::string const &Code) {
std::string PatchedCode(Code);
@ -800,6 +813,9 @@ std::string PrinterCapstone::translateToC(std::string const &TargetName,
patchNullptr(PatchedCode);
patchIsGetImmReg(PatchedCode);
patchTemplateArgs(TargetName, PatchedCode);
if (TargetName == "ARM") {
patchPrintOperandAddr(PatchedCode);
}
return PatchedCode;
}