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/MachineFunctionPass.h"
14#include "llvm/CodeGen/StackProtector.h"
15#include "llvm/CodeGen/TargetPassConfig.h"
16#include "llvm/Support/Debug.h"
17#include "llvm/Support/raw_ostream.h"
18
19using namespace llvm;
20
21#define DEBUG_TYPE "mips-isel"
22
23namespace {
24 class MipsModuleDAGToDAGISel : public MachineFunctionPass {
25 public:
26 static char ID;
27
28 MipsModuleDAGToDAGISel() : MachineFunctionPass(ID) {}
29
30 // Pass Name
31 StringRef getPassName() const override {
32 return "MIPS DAG->DAG Pattern Instruction Selection";
33 }
34
35 void getAnalysisUsage(AnalysisUsage &AU) const override {
36 AU.addRequired<TargetPassConfig>();
37 AU.addPreserved<StackProtector>();
38 MachineFunctionPass::getAnalysisUsage(AU);
39 }
40
41 bool runOnMachineFunction(MachineFunction &MF) override;
42 };
43
44 char MipsModuleDAGToDAGISel::ID = 0;
45}
46
47bool MipsModuleDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
48 LLVM_DEBUG(errs() << "In MipsModuleDAGToDAGISel::runMachineFunction\n");
49 auto &TPC = getAnalysis<TargetPassConfig>();
50 auto &TM = TPC.getTM<MipsTargetMachine>();
51 TM.resetSubtarget(MF: &MF);
52 return false;
53}
54
55llvm::FunctionPass *llvm::createMipsModuleISelDagPass() {
56 return new MipsModuleDAGToDAGISel();
57}
58