diff options
| author | Brendon Cahoon <bcahoon@codeaurora.org> | 2012-05-11 19:56:59 +0000 |
|---|---|---|
| committer | Brendon Cahoon <bcahoon@codeaurora.org> | 2012-05-11 19:56:59 +0000 |
| commit | 6d532d8860c07a3af3b66339f55ab91b4618ca7d (patch) | |
| tree | 60b50fe7ba7f82abdddb0ac1890cf60ba9319d30 /lib/Target/Hexagon/InstPrinter | |
| parent | e1093e5503060b3031980dc14a141c3236108c50 (diff) | |
| download | external_llvm-6d532d8860c07a3af3b66339f55ab91b4618ca7d.zip external_llvm-6d532d8860c07a3af3b66339f55ab91b4618ca7d.tar.gz external_llvm-6d532d8860c07a3af3b66339f55ab91b4618ca7d.tar.bz2 | |
Hexagon constant extender support.
Patch by Jyotsna Verma.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Hexagon/InstPrinter')
| -rw-r--r-- | lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp b/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp index 035afe8..6d96961 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); +} |
