summaryrefslogtreecommitdiff
path: root/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp')
-rw-r--r--lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp b/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp
index 035afe88d5..6d969619f7 100644
--- a/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp
+++ b/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp
@@ -13,6 +13,7 @@
#define DEBUG_TYPE "asm-printer"
#include "Hexagon.h"
+#include "HexagonConstExtInfo.h"
#include "HexagonAsmPrinter.h"
#include "HexagonInstPrinter.h"
#include "HexagonMCInst.h"
@@ -107,7 +108,10 @@ void HexagonInstPrinter::printImmOperand(const MCInst *MI, unsigned OpNo,
void HexagonInstPrinter::printExtOperand(const MCInst *MI, unsigned OpNo,
raw_ostream &O) const {
- O << MI->getOperand(OpNo).getImm();
+ if (isConstExtended(MI))
+ O << "#" << MI->getOperand(OpNo).getImm();
+ else
+ O << MI->getOperand(OpNo).getImm();
}
void HexagonInstPrinter::printUnsignedImmOperand(const MCInst *MI,
@@ -117,7 +121,7 @@ void HexagonInstPrinter::printUnsignedImmOperand(const MCInst *MI,
void HexagonInstPrinter::printNegImmOperand(const MCInst *MI, unsigned OpNo,
raw_ostream &O) const {
- O << -MI->getOperand(OpNo).getImm();
+ O << -MI->getOperand(OpNo).getImm();
}
void HexagonInstPrinter::printNOneImmOperand(const MCInst *MI, unsigned OpNo,
@@ -131,7 +135,10 @@ void HexagonInstPrinter::printMEMriOperand(const MCInst *MI, unsigned OpNo,
const MCOperand& MO1 = MI->getOperand(OpNo + 1);
O << getRegisterName(MO0.getReg());
- O << " + #" << MO1.getImm();
+ if (isConstExtended(MI))
+ O << " + ##" << MO1.getImm();
+ else
+ O << " + #" << MO1.getImm();
}
void HexagonInstPrinter::printFrameIndexOperand(const MCInst *MI, unsigned OpNo,
@@ -196,3 +203,17 @@ void HexagonInstPrinter::printSymbol(const MCInst *MI, unsigned OpNo,
}
O << ')';
}
+
+bool HexagonInstPrinter::isConstExtended(const MCInst *MI) const{
+ unsigned short Opcode = MI->getOpcode();
+ short ExtOpNum = HexagonConstExt::getCExtOpNum(Opcode);
+ int MinValue = HexagonConstExt::getMinValue(Opcode);
+ int MaxValue = HexagonConstExt::getMaxValue(Opcode);
+
+ // Instruction has no constant extended operand
+ if (ExtOpNum == -1)
+ return false;
+
+ int ImmValue = MI->getOperand(ExtOpNum).getImm();
+ return (ImmValue < MinValue || ImmValue > MaxValue);
+}