llvm.org GIT mirror llvm / c387f2b
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358527 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Desaulniers 1 year, 7 months ago
2 changed file(s) with 6 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
598598 O << getVirtualRegisterName(vr);
599599 }
600600
601 void NVPTXAsmPrinter::printVecModifiedImmediate(
602 const MachineOperand &MO, const char *Modifier, raw_ostream &O) {
603 static const char vecelem[] = { '0', '1', '2', '3', '0', '1', '2', '3' };
604 int Imm = (int) MO.getImm();
605 if (0 == strcmp(Modifier, "vecelem"))
606 O << "_" << vecelem[Imm];
607 else if (0 == strcmp(Modifier, "vecv4comm1")) {
608 if ((Imm < 0) || (Imm > 3))
609 O << "//";
610 } else if (0 == strcmp(Modifier, "vecv4comm2")) {
611 if ((Imm < 4) || (Imm > 7))
612 O << "//";
613 } else if (0 == strcmp(Modifier, "vecv4pos")) {
614 if (Imm < 0)
615 Imm = 0;
616 O << "_" << vecelem[Imm % 4];
617 } else if (0 == strcmp(Modifier, "vecv2comm1")) {
618 if ((Imm < 0) || (Imm > 1))
619 O << "//";
620 } else if (0 == strcmp(Modifier, "vecv2comm2")) {
621 if ((Imm < 2) || (Imm > 3))
622 O << "//";
623 } else if (0 == strcmp(Modifier, "vecv2pos")) {
624 if (Imm < 0)
625 Imm = 0;
626 O << "_" << vecelem[Imm % 2];
627 } else
628 llvm_unreachable("Unknown Modifier on immediate operand");
629 }
630
631601 void NVPTXAsmPrinter::emitDeclaration(const Function *F, raw_ostream &O) {
632602 emitLinkageDirective(F, O);
633603 if (isKernelFunction(*F))
22362206 }
22372207
22382208 void NVPTXAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
2239 raw_ostream &O, const char *Modifier) {
2209 raw_ostream &O) {
22402210 const MachineOperand &MO = MI->getOperand(opNum);
22412211 switch (MO.getType()) {
22422212 case MachineOperand::MO_Register:
22482218 } else {
22492219 emitVirtualRegister(MO.getReg(), O);
22502220 }
2251 return;
2221 break;
22522222
22532223 case MachineOperand::MO_Immediate:
2254 if (!Modifier)
2255 O << MO.getImm();
2256 else if (strstr(Modifier, "vec") == Modifier)
2257 printVecModifiedImmediate(MO, Modifier, O);
2258 else
2259 llvm_unreachable(
2260 "Don't know how to handle modifier on immediate operand");
2261 return;
2224 O << MO.getImm();
2225 break;
22622226
22632227 case MachineOperand::MO_FPImmediate:
22642228 printFPConstant(MO.getFPImm(), O);
22702234
22712235 case MachineOperand::MO_MachineBasicBlock:
22722236 MO.getMBB()->getSymbol()->print(O, MAI);
2273 return;
2237 break;
22742238
22752239 default:
22762240 llvm_unreachable("Operand type not supported.");
211211 MCOperand GetSymbolRef(const MCSymbol *Symbol);
212212 unsigned encodeVirtualRegister(unsigned Reg);
213213
214 void printVecModifiedImmediate(const MachineOperand &MO, const char *Modifier,
215 raw_ostream &O);
216214 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
217215 const char *Modifier = nullptr);
218216 void printModuleLevelGV(const GlobalVariable *GVar, raw_ostream &O,
230228 void printReturnValStr(const MachineFunction &MF, raw_ostream &O);
231229 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
232230 const char *ExtraCode, raw_ostream &) override;
233 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
234 const char *Modifier = nullptr);
231 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
235232 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
236233 const char *ExtraCode, raw_ostream &) override;
237234