diff options
Diffstat (limited to 'lib/Target/SystemZ/SystemZAsmPrinter.cpp')
| -rw-r--r-- | lib/Target/SystemZ/SystemZAsmPrinter.cpp | 70 |
1 files changed, 52 insertions, 18 deletions
diff --git a/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/lib/Target/SystemZ/SystemZAsmPrinter.cpp index e2de721be568..ef378e4ade7a 100644 --- a/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -1,9 +1,8 @@ //===-- SystemZAsmPrinter.cpp - SystemZ LLVM assembly printer -------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -13,9 +12,10 @@ //===----------------------------------------------------------------------===// #include "SystemZAsmPrinter.h" -#include "InstPrinter/SystemZInstPrinter.h" +#include "MCTargetDesc/SystemZInstPrinter.h" #include "SystemZConstantPoolValue.h" #include "SystemZMCInstLower.h" +#include "TargetInfo/SystemZTargetInfo.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/IR/Mangler.h" @@ -80,6 +80,27 @@ static const MCSymbolRefExpr *getGlobalOffsetTable(MCContext &Context) { Context); } +// MI is an instruction that accepts an optional alignment hint, +// and which was already lowered to LoweredMI. If the alignment +// of the original memory operand is known, update LoweredMI to +// an instruction with the corresponding hint set. +static void lowerAlignmentHint(const MachineInstr *MI, MCInst &LoweredMI, + unsigned Opcode) { + if (!MI->hasOneMemOperand()) + return; + const MachineMemOperand *MMO = *MI->memoperands_begin(); + unsigned AlignmentHint = 0; + if (MMO->getAlignment() >= 16) + AlignmentHint = 4; + else if (MMO->getAlignment() >= 8) + AlignmentHint = 3; + if (AlignmentHint == 0) + return; + + LoweredMI.setOpcode(Opcode); + LoweredMI.addOperand(MCOperand::createImm(AlignmentHint)); +} + // MI loads the high part of a vector from memory. Return an instruction // that uses replicating vector load Opcode to do the same thing. static MCInst lowerSubvectorLoad(const MachineInstr *MI, unsigned Opcode) { @@ -351,6 +372,26 @@ void SystemZAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addReg(SystemZMC::getRegAsVR128(MI->getOperand(1).getReg())); break; + case SystemZ::VL: + Lower.lower(MI, LoweredMI); + lowerAlignmentHint(MI, LoweredMI, SystemZ::VLAlign); + break; + + case SystemZ::VST: + Lower.lower(MI, LoweredMI); + lowerAlignmentHint(MI, LoweredMI, SystemZ::VSTAlign); + break; + + case SystemZ::VLM: + Lower.lower(MI, LoweredMI); + lowerAlignmentHint(MI, LoweredMI, SystemZ::VLMAlign); + break; + + case SystemZ::VSTM: + Lower.lower(MI, LoweredMI); + lowerAlignmentHint(MI, LoweredMI, SystemZ::VSTMAlign); + break; + case SystemZ::VL32: LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPF); break; @@ -618,26 +659,19 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) { OutStreamer->EmitValue(Expr, Size); } -bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI, - unsigned OpNo, - unsigned AsmVariant, +bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) { - if (ExtraCode && *ExtraCode == 'n') { - if (!MI->getOperand(OpNo).isImm()) - return true; - OS << -int64_t(MI->getOperand(OpNo).getImm()); - } else { - SystemZMCInstLower Lower(MF->getContext(), *this); - MCOperand MO(Lower.lowerOperand(MI->getOperand(OpNo))); - SystemZInstPrinter::printOperand(MO, MAI, OS); - } + if (ExtraCode) + return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS); + SystemZMCInstLower Lower(MF->getContext(), *this); + MCOperand MO(Lower.lowerOperand(MI->getOperand(OpNo))); + SystemZInstPrinter::printOperand(MO, MAI, OS); return false; } bool SystemZAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, - unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) { SystemZInstPrinter::printAddress(MI->getOperand(OpNo).getReg(), |
