From 25afb52e8050526b8e35d3a14c5f0a5e087b0883 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Tue, 16 Apr 2019 21:04:34 +0000 Subject: [PATCH] [NVPTXAsmPrinter] clean up dead code. NFC Summary: The printOperand function takes a default parameter, for which there are zero call sites that explicitly pass such a parameter. As such, there is no case to support. This means that the method printVecModifiedImmediate is purly dead code, and can be removed. The eventual goal for some of these AsmPrinter refactoring is to have printOperand be a virtual method; making it easier to print operands from the base class for more generic Asm printing. It will help if all printOperand methods have the same function signature (ie. no Modifier argument when not needed). Reviewers: echristo, tra Reviewed By: echristo Subscribers: jholewinski, hiraditya, llvm-commits, craig.topper, srhines Tags: #llvm Differential Revision: https://reviews.llvm.org/D60727 llvm-svn: 358527 --- lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 46 +++------------------------- lib/Target/NVPTX/NVPTXAsmPrinter.h | 5 +-- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 68ccd581f59..438716df979 100644 --- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -599,36 +599,6 @@ void NVPTXAsmPrinter::emitVirtualRegister(unsigned int vr, O << getVirtualRegisterName(vr); } -void NVPTXAsmPrinter::printVecModifiedImmediate( - const MachineOperand &MO, const char *Modifier, raw_ostream &O) { - static const char vecelem[] = { '0', '1', '2', '3', '0', '1', '2', '3' }; - int Imm = (int) MO.getImm(); - if (0 == strcmp(Modifier, "vecelem")) - O << "_" << vecelem[Imm]; - else if (0 == strcmp(Modifier, "vecv4comm1")) { - if ((Imm < 0) || (Imm > 3)) - O << "//"; - } else if (0 == strcmp(Modifier, "vecv4comm2")) { - if ((Imm < 4) || (Imm > 7)) - O << "//"; - } else if (0 == strcmp(Modifier, "vecv4pos")) { - if (Imm < 0) - Imm = 0; - O << "_" << vecelem[Imm % 4]; - } else if (0 == strcmp(Modifier, "vecv2comm1")) { - if ((Imm < 0) || (Imm > 1)) - O << "//"; - } else if (0 == strcmp(Modifier, "vecv2comm2")) { - if ((Imm < 2) || (Imm > 3)) - O << "//"; - } else if (0 == strcmp(Modifier, "vecv2pos")) { - if (Imm < 0) - Imm = 0; - O << "_" << vecelem[Imm % 2]; - } else - llvm_unreachable("Unknown Modifier on immediate operand"); -} - void NVPTXAsmPrinter::emitDeclaration(const Function *F, raw_ostream &O) { emitLinkageDirective(F, O); if (isKernelFunction(*F)) @@ -2237,7 +2207,7 @@ bool NVPTXAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, } void NVPTXAsmPrinter::printOperand(const MachineInstr *MI, int opNum, - raw_ostream &O, const char *Modifier) { + raw_ostream &O) { const MachineOperand &MO = MI->getOperand(opNum); switch (MO.getType()) { case MachineOperand::MO_Register: @@ -2249,17 +2219,11 @@ void NVPTXAsmPrinter::printOperand(const MachineInstr *MI, int opNum, } else { emitVirtualRegister(MO.getReg(), O); } - return; + break; case MachineOperand::MO_Immediate: - if (!Modifier) - O << MO.getImm(); - else if (strstr(Modifier, "vec") == Modifier) - printVecModifiedImmediate(MO, Modifier, O); - else - llvm_unreachable( - "Don't know how to handle modifier on immediate operand"); - return; + O << MO.getImm(); + break; case MachineOperand::MO_FPImmediate: printFPConstant(MO.getFPImm(), O); @@ -2271,7 +2235,7 @@ void NVPTXAsmPrinter::printOperand(const MachineInstr *MI, int opNum, case MachineOperand::MO_MachineBasicBlock: MO.getMBB()->getSymbol()->print(O, MAI); - return; + break; default: llvm_unreachable("Operand type not supported."); diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.h b/lib/Target/NVPTX/NVPTXAsmPrinter.h index 8ed9cf7c355..43ae57ac126 100644 --- a/lib/Target/NVPTX/NVPTXAsmPrinter.h +++ b/lib/Target/NVPTX/NVPTXAsmPrinter.h @@ -212,8 +212,6 @@ private: MCOperand GetSymbolRef(const MCSymbol *Symbol); unsigned encodeVirtualRegister(unsigned Reg); - void printVecModifiedImmediate(const MachineOperand &MO, const char *Modifier, - raw_ostream &O); void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O, const char *Modifier = nullptr); void printModuleLevelGV(const GlobalVariable *GVar, raw_ostream &O, @@ -231,8 +229,7 @@ private: void printReturnValStr(const MachineFunction &MF, raw_ostream &O); bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &) override; - void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O, - const char *Modifier = nullptr); + void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O); bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &) override;