diff options
author | Dmitry Preobrazhensky <dmitry.preobrazhensky@amd.com> | 2017-03-20 14:50:35 +0000 |
---|---|---|
committer | Dmitry Preobrazhensky <dmitry.preobrazhensky@amd.com> | 2017-03-20 14:50:35 +0000 |
commit | 40af9c35d3e6be47b05a87030c8dd9d4fa2a268b (patch) | |
tree | b4abb0267db0b562b52fc1309bc95b876071ed1b /llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp | |
parent | d79253a9f7833c429fbb3920277e8f2a11f8e1a7 (diff) | |
download | bcm5719-llvm-40af9c35d3e6be47b05a87030c8dd9d4fa2a268b.tar.gz bcm5719-llvm-40af9c35d3e6be47b05a87030c8dd9d4fa2a268b.zip |
[AMDGPU][MC] Fix for Bugs 28200, 28202 + LIT tests
Fixed several related issues with VOP3 fp modifiers.
Reviewers: artem.tamazov
Differential Revision: https://reviews.llvm.org/D30821
llvm-svn: 298255
Diffstat (limited to 'llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp b/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp index 202850664db..8d04f834dd9 100644 --- a/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp +++ b/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp @@ -543,13 +543,34 @@ void AMDGPUInstPrinter::printOperandAndFPInputMods(const MCInst *MI, const MCSubtargetInfo &STI, raw_ostream &O) { unsigned InputModifiers = MI->getOperand(OpNo).getImm(); - if (InputModifiers & SISrcMods::NEG) - O << '-'; + + // Use 'neg(...)' instead of '-' to avoid ambiguity. + // This is important for integer literals because + // -1 is not the same value as neg(1). + bool NegMnemo = false; + + if (InputModifiers & SISrcMods::NEG) { + if (OpNo + 1 < MI->getNumOperands() && + (InputModifiers & SISrcMods::ABS) == 0) { + const MCOperand &Op = MI->getOperand(OpNo + 1); + NegMnemo = Op.isImm() || Op.isFPImm(); + } + if (NegMnemo) { + O << "neg("; + } else { + O << '-'; + } + } + if (InputModifiers & SISrcMods::ABS) O << '|'; printOperand(MI, OpNo + 1, STI, O); if (InputModifiers & SISrcMods::ABS) O << '|'; + + if (NegMnemo) { + O << ')'; + } } void AMDGPUInstPrinter::printOperandAndIntInputMods(const MCInst *MI, |