2013-04-10 03:46:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Instruction Selector Subtarget Control
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// This file defines a pass used to change the subtarget for the
|
|
|
|
// Mips Instruction selector.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-03-14 17:20:52 +08:00
|
|
|
#include "Mips.h"
|
2015-03-09 23:50:58 +08:00
|
|
|
#include "MipsTargetMachine.h"
|
2017-05-19 01:21:13 +08:00
|
|
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
2013-04-10 03:46:01 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
2015-03-24 02:07:13 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2015-03-14 17:20:52 +08:00
|
|
|
|
2015-03-09 23:50:58 +08:00
|
|
|
using namespace llvm;
|
2013-04-10 03:46:01 +08:00
|
|
|
|
2014-04-22 06:55:11 +08:00
|
|
|
#define DEBUG_TYPE "mips-isel"
|
|
|
|
|
2015-03-09 23:50:58 +08:00
|
|
|
namespace {
|
2015-03-14 17:20:52 +08:00
|
|
|
class MipsModuleDAGToDAGISel : public MachineFunctionPass {
|
|
|
|
public:
|
|
|
|
static char ID;
|
2015-03-09 23:50:58 +08:00
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
MipsModuleDAGToDAGISel() : MachineFunctionPass(ID) {}
|
2015-03-09 23:50:58 +08:00
|
|
|
|
2015-03-14 17:20:52 +08:00
|
|
|
// Pass Name
|
2016-10-01 10:56:57 +08:00
|
|
|
StringRef getPassName() const override {
|
2015-03-14 17:20:52 +08:00
|
|
|
return "MIPS DAG->DAG Pattern Instruction Selection";
|
|
|
|
}
|
2015-03-09 23:50:58 +08:00
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
|
|
AU.addRequired<TargetPassConfig>();
|
|
|
|
MachineFunctionPass::getAnalysisUsage(AU);
|
|
|
|
}
|
2015-03-09 23:50:58 +08:00
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
2015-03-14 17:20:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
char MipsModuleDAGToDAGISel::ID = 0;
|
2015-06-23 17:49:53 +08:00
|
|
|
}
|
2013-04-10 03:46:01 +08:00
|
|
|
|
|
|
|
bool MipsModuleDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
|
|
|
|
DEBUG(errs() << "In MipsModuleDAGToDAGISel::runMachineFunction\n");
|
2017-05-19 01:21:13 +08:00
|
|
|
auto &TPC = getAnalysis<TargetPassConfig>();
|
|
|
|
auto &TM = TPC.getTM<MipsTargetMachine>();
|
2014-07-19 07:41:32 +08:00
|
|
|
TM.resetSubtarget(&MF);
|
2013-04-10 03:46:01 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
llvm::FunctionPass *llvm::createMipsModuleISelDagPass() {
|
|
|
|
return new MipsModuleDAGToDAGISel();
|
2013-04-10 03:46:01 +08:00
|
|
|
}
|