1 //===----------------------------------------------------------------------===// 2 // Instruction Selector Subtarget Control 3 //===----------------------------------------------------------------------===// 4 5 //===----------------------------------------------------------------------===// 6 // This file defines a pass used to change the subtarget for the 7 // Mips Instruction selector. 8 // 9 //===----------------------------------------------------------------------===// 10 11 #include "Mips.h" 12 #include "MipsTargetMachine.h" 13 #include "llvm/CodeGen/TargetPassConfig.h" 14 #include "llvm/Support/Debug.h" 15 #include "llvm/Support/raw_ostream.h" 16 17 using namespace llvm; 18 19 #define DEBUG_TYPE "mips-isel" 20 21 namespace { 22 class MipsModuleDAGToDAGISel : public MachineFunctionPass { 23 public: 24 static char ID; 25 26 MipsModuleDAGToDAGISel() : MachineFunctionPass(ID) {} 27 28 // Pass Name 29 StringRef getPassName() const override { 30 return "MIPS DAG->DAG Pattern Instruction Selection"; 31 } 32 33 void getAnalysisUsage(AnalysisUsage &AU) const override { 34 AU.addRequired<TargetPassConfig>(); 35 MachineFunctionPass::getAnalysisUsage(AU); 36 } 37 38 bool runOnMachineFunction(MachineFunction &MF) override; 39 }; 40 41 char MipsModuleDAGToDAGISel::ID = 0; 42 } 43 44 bool MipsModuleDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) { 45 DEBUG(errs() << "In MipsModuleDAGToDAGISel::runMachineFunction\n"); 46 auto &TPC = getAnalysis<TargetPassConfig>(); 47 auto &TM = TPC.getTM<MipsTargetMachine>(); 48 TM.resetSubtarget(&MF); 49 return false; 50 } 51 52 llvm::FunctionPass *llvm::createMipsModuleISelDagPass() { 53 return new MipsModuleDAGToDAGISel(); 54 } 55