References:
MipsModuleDAGToDAGISel
, a pass used to change the subtarget for the Mips Instruction selector.Mips16DAGToDAGISel
, Subclass of MipsDAGToDAGISel
specialized for mips16
.MipsSEDAGToDAGISel
, Subclass of MipsDAGToDAGISel specialized for mips32/64
.The core passes are Mips16DAGToDAGISel
for 16-bit mips and MipsSEDAGToDAGISel
for 32⁄64 bit mips. Both of them finally calls the parent pass entry (SelectionDAGISel::runOnMachineFunction
) in their implementation.
See more impl details on SelectionDAGISel.
Pass registeration:
// llvm/lib/Target/Mips/MipsTargetMachine.cpp
// parent->child: TargetPassConfig -> MipsPassConfig
// Install an instruction selector pass using
// the ISelDag to gen Mips code.
bool MipsPassConfig::addInstSelector() {
addPass(createMipsModuleISelDagPass());
addPass(createMips16ISelDag(getMipsTargetMachine(), getOptLevel()));
addPass(createMipsSEISelDag(getMipsTargetMachine(), getOptLevel()));
return false;
}
// createMipsModuleISelDagPass()
// llvm/lib/Target/Mips/MipsModuleISelDAGToDAG.cpp
llvm::FunctionPass *llvm::createMipsModuleISelDagPass() {
return new MipsModuleDAGToDAGISel();
}
// createMips16ISelDag()
// llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp
FunctionPass *llvm::createMips16ISelDag(MipsTargetMachine &TM,
CodeGenOpt::Level OptLevel) {
return new Mips16DAGToDAGISel(TM, OptLevel);
}
// createMipsSEISelDag()
FunctionPass *llvm::createMipsSEISelDag(MipsTargetMachine &TM,
CodeGenOpt::Level OptLevel) {
return new MipsSEDAGToDAGISel(TM, OptLevel);
}
Inheritance: parent->child
MachineFunctionPass
-> SelectionDAGISel
-> MipsDAGToDAGISel
-> MipsSEDAGToDAGISel
// llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
bool MipsSEDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
Subtarget = &static_cast<const MipsSubtarget &>(MF.getSubtarget());
if (Subtarget->inMips16Mode())
return false;
return MipsDAGToDAGISel::runOnMachineFunction(MF);
}
// MipsDAGToDAGISel::runOnMachineFunction
// llvm/lib/Target/Mips/MipsISelDAGToDAG.cpp
bool MipsDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
Subtarget = &static_cast<const MipsSubtarget &>(MF.getSubtarget());
DebugLL("MipsDAGToDAGISel pass on MF: "<< MF.getName() << "\n")
bool Ret = SelectionDAGISel::runOnMachineFunction(MF);
processFunctionAfterISel(MF);
return Ret;
}
Set the subtarget for MipsTargetMachine
// llvm/lib/Target/Mips/MipsModuleISelDAGToDAG.cpp
bool MipsModuleDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
LLVM_DEBUG(errs() << "In MipsModuleDAGToDAGISel::runMachineFunction\n");
auto &TPC = getAnalysis<TargetPassConfig>();
auto &TM = TPC.getTM<MipsTargetMachine>();
TM.resetSubtarget(&MF);
return false;
}
// MipsTargetMachine::resetSubTarget()
// llvm/lib/Target/Mips/MipsTargetMachine.cpp
void MipsTargetMachine::resetSubtarget(MachineFunction *MF) {
LLVM_DEBUG(dbgs() << "resetSubtarget\n");
Subtarget = &MF->getSubtarget<MipsSubtarget>();
}
Inheritance: parent->child
MachineFunctionPass
-> SelectionDAGISel
-> MipsDAGToDAGISel
-> Mips16DAGToDAGISel
// llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp
bool Mips16DAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
Subtarget = &static_cast<const MipsSubtarget &>(MF.getSubtarget());
DebugLL("Mips16DAGToDAGISel pass on MF: "<< MF.getName() << "\n");
if (!Subtarget->inMips16Mode())
return false;
return MipsDAGToDAGISel::runOnMachineFunction(MF);
}
If you could revise
the fundmental principles of
computer system design
to improve security...
... what would you change?