forked from OSchip/llvm-project
[NVPTX] Delete dead code from the AsmPrinter.
llvm-svn: 333924
This commit is contained in:
parent
f921d85422
commit
f663eba561
|
@ -84,7 +84,6 @@
|
|||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
@ -1960,65 +1959,6 @@ void NVPTXAsmPrinter::bufferAggregateConstant(const Constant *CPV,
|
|||
llvm_unreachable("unsupported constant type in printAggregateConstant()");
|
||||
}
|
||||
|
||||
// buildTypeNameMap - Run through symbol table looking for type names.
|
||||
//
|
||||
|
||||
bool NVPTXAsmPrinter::ignoreLoc(const MachineInstr &MI) {
|
||||
switch (MI.getOpcode()) {
|
||||
default:
|
||||
return false;
|
||||
case NVPTX::CallArgBeginInst:
|
||||
case NVPTX::CallArgEndInst0:
|
||||
case NVPTX::CallArgEndInst1:
|
||||
case NVPTX::CallArgF32:
|
||||
case NVPTX::CallArgF64:
|
||||
case NVPTX::CallArgI16:
|
||||
case NVPTX::CallArgI32:
|
||||
case NVPTX::CallArgI32imm:
|
||||
case NVPTX::CallArgI64:
|
||||
case NVPTX::CallArgParam:
|
||||
case NVPTX::CallVoidInst:
|
||||
case NVPTX::CallVoidInstReg:
|
||||
case NVPTX::Callseq_End:
|
||||
case NVPTX::CallVoidInstReg64:
|
||||
case NVPTX::DeclareParamInst:
|
||||
case NVPTX::DeclareRetMemInst:
|
||||
case NVPTX::DeclareRetRegInst:
|
||||
case NVPTX::DeclareRetScalarInst:
|
||||
case NVPTX::DeclareScalarParamInst:
|
||||
case NVPTX::DeclareScalarRegInst:
|
||||
case NVPTX::StoreParamF32:
|
||||
case NVPTX::StoreParamF64:
|
||||
case NVPTX::StoreParamI16:
|
||||
case NVPTX::StoreParamI32:
|
||||
case NVPTX::StoreParamI64:
|
||||
case NVPTX::StoreParamI8:
|
||||
case NVPTX::StoreRetvalF32:
|
||||
case NVPTX::StoreRetvalF64:
|
||||
case NVPTX::StoreRetvalI16:
|
||||
case NVPTX::StoreRetvalI32:
|
||||
case NVPTX::StoreRetvalI64:
|
||||
case NVPTX::StoreRetvalI8:
|
||||
case NVPTX::LastCallArgF32:
|
||||
case NVPTX::LastCallArgF64:
|
||||
case NVPTX::LastCallArgI16:
|
||||
case NVPTX::LastCallArgI32:
|
||||
case NVPTX::LastCallArgI32imm:
|
||||
case NVPTX::LastCallArgI64:
|
||||
case NVPTX::LastCallArgParam:
|
||||
case NVPTX::LoadParamMemF32:
|
||||
case NVPTX::LoadParamMemF64:
|
||||
case NVPTX::LoadParamMemI16:
|
||||
case NVPTX::LoadParamMemI32:
|
||||
case NVPTX::LoadParamMemI64:
|
||||
case NVPTX::LoadParamMemI8:
|
||||
case NVPTX::PrototypeInst:
|
||||
case NVPTX::DBG_VALUE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// lowerConstantForGV - Return an MCExpr for the given Constant. This is mostly
|
||||
/// a copy from AsmPrinter::lowerConstant, except customized to only handle
|
||||
/// expressions that are representable in PTX and create
|
||||
|
@ -2319,44 +2259,6 @@ void NVPTXAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum,
|
|||
}
|
||||
}
|
||||
|
||||
void NVPTXAsmPrinter::emitSrcInText(StringRef filename, unsigned line) {
|
||||
std::stringstream temp;
|
||||
LineReader *reader = this->getReader(filename);
|
||||
temp << "\n//";
|
||||
temp << filename.str();
|
||||
temp << ":";
|
||||
temp << line;
|
||||
temp << " ";
|
||||
temp << reader->readLine(line);
|
||||
temp << "\n";
|
||||
this->OutStreamer->EmitRawText(temp.str());
|
||||
}
|
||||
|
||||
LineReader *NVPTXAsmPrinter::getReader(const std::string &filename) {
|
||||
if (!reader) {
|
||||
reader = new LineReader(filename);
|
||||
}
|
||||
|
||||
if (reader->fileName() != filename) {
|
||||
delete reader;
|
||||
reader = new LineReader(filename);
|
||||
}
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
||||
std::string LineReader::readLine(unsigned lineNum) {
|
||||
if (lineNum < theCurLine) {
|
||||
theCurLine = 0;
|
||||
fstr.seekg(0, std::ios::beg);
|
||||
}
|
||||
while (theCurLine < lineNum) {
|
||||
fstr.getline(buff, 500);
|
||||
theCurLine++;
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
|
||||
// Force static initialization.
|
||||
extern "C" void LLVMInitializeNVPTXAsmPrinter() {
|
||||
RegisterAsmPrinter<NVPTXAsmPrinter> X(getTheNVPTXTarget32());
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "llvm/Target/TargetMachine.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -60,27 +59,6 @@ namespace llvm {
|
|||
|
||||
class MCOperand;
|
||||
|
||||
class LineReader {
|
||||
private:
|
||||
unsigned theCurLine;
|
||||
std::ifstream fstr;
|
||||
char buff[512];
|
||||
std::string theFileName;
|
||||
SmallVector<unsigned, 32> lineOffset;
|
||||
|
||||
public:
|
||||
LineReader(std::string filename) {
|
||||
theCurLine = 0;
|
||||
fstr.open(filename.c_str());
|
||||
theFileName = filename;
|
||||
}
|
||||
|
||||
~LineReader() { fstr.close(); }
|
||||
|
||||
std::string fileName() { return theFileName; }
|
||||
std::string readLine(unsigned line);
|
||||
};
|
||||
|
||||
class LLVM_LIBRARY_VISIBILITY NVPTXAsmPrinter : public AsmPrinter {
|
||||
|
||||
class AggBuffer {
|
||||
|
@ -217,8 +195,6 @@ class LLVM_LIBRARY_VISIBILITY NVPTXAsmPrinter : public AsmPrinter {
|
|||
|
||||
friend class AggBuffer;
|
||||
|
||||
void emitSrcInText(StringRef filename, unsigned line);
|
||||
|
||||
private:
|
||||
StringRef getPassName() const override { return "NVPTX Assembly Printer"; }
|
||||
|
||||
|
@ -271,8 +247,6 @@ protected:
|
|||
bool doFinalization(Module &M) override;
|
||||
|
||||
private:
|
||||
std::string CurrentBankselLabelInBasicBlock;
|
||||
|
||||
bool GlobalsEmitted;
|
||||
|
||||
// This is specific per MachineFunction.
|
||||
|
@ -287,17 +261,9 @@ private:
|
|||
// Cache the subtarget here.
|
||||
const NVPTXSubtarget *nvptxSubtarget;
|
||||
|
||||
// Build the map between type name and ID based on module's type
|
||||
// symbol table.
|
||||
std::map<Type *, std::string> TypeNameMap;
|
||||
|
||||
// List of variables demoted to a function scope.
|
||||
std::map<const Function *, std::vector<const GlobalVariable *>> localDecls;
|
||||
|
||||
// To record filename to ID mapping
|
||||
std::map<std::string, unsigned> filenameMap;
|
||||
void recordAndEmitFilenames(Module &);
|
||||
|
||||
void emitPTXGlobalVariable(const GlobalVariable *GVar, raw_ostream &O);
|
||||
void emitPTXAddressSpace(unsigned int AddressSpace, raw_ostream &O) const;
|
||||
std::string getPTXFundamentalTypeStr(Type *Ty, bool = true) const;
|
||||
|
@ -317,10 +283,6 @@ private:
|
|||
|
||||
bool isLoopHeaderOfNoUnroll(const MachineBasicBlock &MBB) const;
|
||||
|
||||
LineReader *reader = nullptr;
|
||||
|
||||
LineReader *getReader(const std::string &);
|
||||
|
||||
// Used to control the need to emit .generic() in the initializer of
|
||||
// module scope variables.
|
||||
// Although ptx supports the hybrid mode like the following,
|
||||
|
@ -340,10 +302,6 @@ public:
|
|||
EmitGeneric(static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() ==
|
||||
NVPTX::CUDA) {}
|
||||
|
||||
~NVPTXAsmPrinter() override {
|
||||
delete reader;
|
||||
}
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &F) override;
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
|
@ -351,8 +309,6 @@ public:
|
|||
AsmPrinter::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
bool ignoreLoc(const MachineInstr &);
|
||||
|
||||
std::string getVirtualRegisterName(unsigned) const;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue