[llvm] aa82b56 - [CodeGen] MRI call back in TargetMachine
Yashwant Singh via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 3 09:00:04 PDT 2023
Author: Christudasan Devadasan
Date: 2023-07-03T21:29:37+05:30
New Revision: aa82b562b7b4b36f4a3d04e80e5743028bddd577
URL: https://github.com/llvm/llvm-project/commit/aa82b562b7b4b36f4a3d04e80e5743028bddd577
DIFF: https://github.com/llvm/llvm-project/commit/aa82b562b7b4b36f4a3d04e80e5743028bddd577.diff
LOG: [CodeGen] MRI call back in TargetMachine
It is needed for target specific initializatons.
Reviewed By: qcolombet
Differential Revision: https://reviews.llvm.org/D143758
Added:
Modified:
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/CodeGen/MachineModuleInfo.cpp
llvm/lib/CodeGen/ResetMachineFunctionPass.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index 0df1875cc395b9..b6ba36fb09b1bc 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -502,6 +502,9 @@ class LLVMTargetMachine : public TargetMachine {
/// The default variant to use in unqualified `asm` instructions.
/// If this returns 0, `asm "$(foo$|bar$)"` will evaluate to `asm "foo"`.
virtual int unqualifiedInlineAsmVariant() const { return 0; }
+
+ // MachineRegisterInfo callback function
+ virtual void registerMachineRegisterInfoCallback(MachineFunction &MF) const {}
};
/// Helper method for getting the code model, returning Default if
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp
index b9bf0a03dd3369..921feb253d6422 100644
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp
@@ -106,6 +106,10 @@ MachineFunction &MachineModuleInfo::getOrCreateMachineFunction(Function &F) {
const TargetSubtargetInfo &STI = *TM.getSubtargetImpl(F);
MF = new MachineFunction(F, TM, STI, NextFnNum++, *this);
MF->initTargetMachineFunctionInfo(STI);
+
+ // MRI callback for target specific initializations.
+ TM.registerMachineRegisterInfoCallback(*MF);
+
// Update the set entry.
I.first->second.reset(MF);
} else {
diff --git a/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp b/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp
index 0ad6ef84220a36..11bdf3bb2ba8c2 100644
--- a/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp
+++ b/llvm/lib/CodeGen/ResetMachineFunctionPass.cpp
@@ -22,6 +22,7 @@
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Target/TargetMachine.h"
using namespace llvm;
#define DEBUG_TYPE "reset-machine-function"
@@ -68,6 +69,10 @@ namespace {
MF.reset();
MF.initTargetMachineFunctionInfo(MF.getSubtarget());
+ const LLVMTargetMachine &TM = MF.getTarget();
+ // MRI callback for target specific initializations.
+ TM.registerMachineRegisterInfoCallback(MF);
+
if (EmitFallbackDiag) {
const Function &F = MF.getFunction();
DiagnosticInfoISelFallback DiagFallback(F);
More information about the llvm-commits
mailing list