GlobalISel: rename legalizer components to match others.

The previous names were both misleading (the MachineLegalizer actually
contained the info tables) and inconsistent with the selector & translator (in
having a "Machine") prefix. This should make everything sensible again.

The only functional change is the name of a couple of command-line options.

llvm-svn: 284287
diff --git a/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt b/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
index 87b4708..fe44b34 100644
--- a/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
+++ b/llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
@@ -5,9 +5,9 @@
       InstructionSelect.cpp
       InstructionSelector.cpp
       MachineIRBuilder.cpp
-      MachineLegalizeHelper.cpp
-      MachineLegalizePass.cpp
-      MachineLegalizer.cpp
+      LegalizerHelper.cpp
+      Legalizer.cpp
+      LegalizerInfo.cpp
       RegBankSelect.cpp
       RegisterBank.cpp
       RegisterBankInfo.cpp
diff --git a/llvm/lib/CodeGen/GlobalISel/GlobalISel.cpp b/llvm/lib/CodeGen/GlobalISel/GlobalISel.cpp
index aac29f5..fcd2722 100644
--- a/llvm/lib/CodeGen/GlobalISel/GlobalISel.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/GlobalISel.cpp
@@ -25,7 +25,7 @@
 
 void llvm::initializeGlobalISel(PassRegistry &Registry) {
   initializeIRTranslatorPass(Registry);
-  initializeMachineLegalizePassPass(Registry);
+  initializeLegalizerPass(Registry);
   initializeRegBankSelectPass(Registry);
   initializeInstructionSelectPass(Registry);
 }
diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
index 70d4dd7..be20355 100644
--- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -14,7 +14,7 @@
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
-#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
+#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
 #include "llvm/IR/Function.h"
@@ -71,12 +71,12 @@
   // Check that our input is fully legal: we require the function to have the
   // Legalized property, so it should be.
   // FIXME: This should be in the MachineVerifier, but it can't use the
-  // MachineLegalizer as it's currently in the separate GlobalISel library.
+  // LegalizerInfo as it's currently in the separate GlobalISel library.
   // The RegBankSelected property is already checked in the verifier. Note
   // that it has the same layering problem, but we only use inline methods so
   // end up not needing to link against the GlobalISel library.
   const MachineRegisterInfo &MRI = MF.getRegInfo();
-  if (const MachineLegalizer *MLI = MF.getSubtarget().getMachineLegalizer())
+  if (const LegalizerInfo *MLI = MF.getSubtarget().getLegalizerInfo())
     for (const MachineBasicBlock &MBB : MF)
       for (const MachineInstr &MI : MBB)
         if (isPreISelGenericOpcode(MI.getOpcode()) && !MLI->isLegal(MI, MRI))
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineLegalizePass.cpp b/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp
similarity index 78%
rename from llvm/lib/CodeGen/GlobalISel/MachineLegalizePass.cpp
rename to llvm/lib/CodeGen/GlobalISel/Legalizer.cpp
index b52cb10..e863568 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineLegalizePass.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp
@@ -1,4 +1,4 @@
-//===-- llvm/CodeGen/GlobalISel/MachineLegalizePass.cpp -------------------===//
+//===-- llvm/CodeGen/GlobalISel/Legalizer.cpp -----------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,49 +7,48 @@
 //
 //===----------------------------------------------------------------------===//
 //
-/// \file This file implements the LegalizeHelper class to legalize individual
-/// instructions and the MachineLegalizePass wrapper pass for the primary
+/// \file This file implements the LegalizerHelper class to legalize individual
+/// instructions and the LegalizePass wrapper pass for the primary
 /// legalization.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/CodeGen/GlobalISel/MachineLegalizePass.h"
-#include "llvm/CodeGen/GlobalISel/MachineLegalizeHelper.h"
-#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
+#include "llvm/CodeGen/GlobalISel/Legalizer.h"
+#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
+#include "llvm/CodeGen/GlobalISel/Legalizer.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetSubtargetInfo.h"
 
-#define DEBUG_TYPE "legalize-mir"
+#define DEBUG_TYPE "legalizer"
 
 using namespace llvm;
 
-char MachineLegalizePass::ID = 0;
-INITIALIZE_PASS_BEGIN(MachineLegalizePass, DEBUG_TYPE,
+char Legalizer::ID = 0;
+INITIALIZE_PASS_BEGIN(Legalizer, DEBUG_TYPE,
                       "Legalize the Machine IR a function's Machine IR", false,
                       false)
 INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
-INITIALIZE_PASS_END(MachineLegalizePass, DEBUG_TYPE,
+INITIALIZE_PASS_END(Legalizer, DEBUG_TYPE,
                     "Legalize the Machine IR a function's Machine IR", false,
                     false)
 
-MachineLegalizePass::MachineLegalizePass() : MachineFunctionPass(ID) {
-  initializeMachineLegalizePassPass(*PassRegistry::getPassRegistry());
+Legalizer::Legalizer() : MachineFunctionPass(ID) {
+  initializeLegalizerPass(*PassRegistry::getPassRegistry());
 }
 
-void MachineLegalizePass::getAnalysisUsage(AnalysisUsage &AU) const {
+void Legalizer::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addRequired<TargetPassConfig>();
   MachineFunctionPass::getAnalysisUsage(AU);
 }
 
-void MachineLegalizePass::init(MachineFunction &MF) {
+void Legalizer::init(MachineFunction &MF) {
 }
 
-bool MachineLegalizePass::combineExtracts(MachineInstr &MI,
-                                          MachineRegisterInfo &MRI,
-                                          const TargetInstrInfo &TII) {
+bool Legalizer::combineExtracts(MachineInstr &MI, MachineRegisterInfo &MRI,
+                                const TargetInstrInfo &TII) {
   bool Changed = false;
   if (MI.getOpcode() != TargetOpcode::G_EXTRACT)
     return Changed;
@@ -115,7 +114,7 @@
   return Changed;
 }
 
-bool MachineLegalizePass::runOnMachineFunction(MachineFunction &MF) {
+bool Legalizer::runOnMachineFunction(MachineFunction &MF) {
   // If the ISel pipeline failed, do not bother running that pass.
   if (MF.getProperties().hasProperty(
           MachineFunctionProperties::Property::FailedISel))
@@ -123,8 +122,8 @@
   DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n');
   init(MF);
   const TargetPassConfig &TPC = getAnalysis<TargetPassConfig>();
-  const MachineLegalizer &Legalizer = *MF.getSubtarget().getMachineLegalizer();
-  MachineLegalizeHelper Helper(MF);
+  const LegalizerInfo &LegalizerInfo = *MF.getSubtarget().getLegalizerInfo();
+  LegalizerHelper Helper(MF);
 
   // FIXME: an instruction may need more than one pass before it is legal. For
   // example on most architectures <3 x i3> is doubly-illegal. It would
@@ -144,11 +143,11 @@
       if (!isPreISelGenericOpcode(MI->getOpcode()))
         continue;
 
-      auto Res = Helper.legalizeInstr(*MI, Legalizer);
+      auto Res = Helper.legalizeInstr(*MI, LegalizerInfo);
 
       // Error out if we couldn't legalize this instruction. We may want to fall
       // back to DAG ISel instead in the future.
-      if (Res == MachineLegalizeHelper::UnableToLegalize) {
+      if (Res == LegalizerHelper::UnableToLegalize) {
         if (!TPC.isGlobalISelAbortEnabled()) {
           MF.getProperties().set(
               MachineFunctionProperties::Property::FailedISel);
@@ -161,7 +160,7 @@
         report_fatal_error(OS.str());
       }
 
-      Changed |= Res == MachineLegalizeHelper::Legalized;
+      Changed |= Res == LegalizerHelper::Legalized;
     }
 
 
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
similarity index 85%
rename from llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp
rename to llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index d6368b3..ffb22b2 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -1,4 +1,4 @@
-//===-- llvm/CodeGen/GlobalISel/MachineLegalizeHelper.cpp -----------------===//
+//===-- llvm/CodeGen/GlobalISel/LegalizerHelper.cpp -----------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,15 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 //
-/// \file This file implements the MachineLegalizeHelper class to legalize
+/// \file This file implements the LegalizerHelper class to legalize
 /// individual instructions and the LegalizeMachineIR wrapper pass for the
 /// primary legalization.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/CodeGen/GlobalISel/MachineLegalizeHelper.h"
+#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
-#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
+#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -28,36 +28,36 @@
 
 using namespace llvm;
 
-MachineLegalizeHelper::MachineLegalizeHelper(MachineFunction &MF)
+LegalizerHelper::LegalizerHelper(MachineFunction &MF)
   : MRI(MF.getRegInfo()) {
   MIRBuilder.setMF(MF);
 }
 
-MachineLegalizeHelper::LegalizeResult
-MachineLegalizeHelper::legalizeInstrStep(MachineInstr &MI,
-                                         const MachineLegalizer &Legalizer) {
-  auto Action = Legalizer.getAction(MI, MRI);
+LegalizerHelper::LegalizeResult
+LegalizerHelper::legalizeInstrStep(MachineInstr &MI,
+                                   const LegalizerInfo &LegalizerInfo) {
+  auto Action = LegalizerInfo.getAction(MI, MRI);
   switch (std::get<0>(Action)) {
-  case MachineLegalizer::Legal:
+  case LegalizerInfo::Legal:
     return AlreadyLegal;
-  case MachineLegalizer::Libcall:
+  case LegalizerInfo::Libcall:
     return libcall(MI);
-  case MachineLegalizer::NarrowScalar:
+  case LegalizerInfo::NarrowScalar:
     return narrowScalar(MI, std::get<1>(Action), std::get<2>(Action));
-  case MachineLegalizer::WidenScalar:
+  case LegalizerInfo::WidenScalar:
     return widenScalar(MI, std::get<1>(Action), std::get<2>(Action));
-  case MachineLegalizer::Lower:
+  case LegalizerInfo::Lower:
     return lower(MI, std::get<1>(Action), std::get<2>(Action));
-  case MachineLegalizer::FewerElements:
+  case LegalizerInfo::FewerElements:
     return fewerElementsVector(MI, std::get<1>(Action), std::get<2>(Action));
   default:
     return UnableToLegalize;
   }
 }
 
-MachineLegalizeHelper::LegalizeResult
-MachineLegalizeHelper::legalizeInstr(MachineInstr &MI,
-                                     const MachineLegalizer &Legalizer) {
+LegalizerHelper::LegalizeResult
+LegalizerHelper::legalizeInstr(MachineInstr &MI,
+                               const LegalizerInfo &LegalizerInfo) {
   SmallVector<MachineInstr *, 4> WorkList;
   MIRBuilder.recordInsertions(
       [&](MachineInstr *MI) { WorkList.push_back(MI); });
@@ -67,7 +67,7 @@
   LegalizeResult Res;
   unsigned Idx = 0;
   do {
-    Res = legalizeInstrStep(*WorkList[Idx], Legalizer);
+    Res = legalizeInstrStep(*WorkList[Idx], LegalizerInfo);
     if (Res == UnableToLegalize) {
       MIRBuilder.stopRecordingInsertions();
       return UnableToLegalize;
@@ -81,8 +81,8 @@
   return Changed ? Legalized : AlreadyLegal;
 }
 
-void MachineLegalizeHelper::extractParts(unsigned Reg, LLT Ty, int NumParts,
-                                         SmallVectorImpl<unsigned> &VRegs) {
+void LegalizerHelper::extractParts(unsigned Reg, LLT Ty, int NumParts,
+                                   SmallVectorImpl<unsigned> &VRegs) {
   unsigned Size = Ty.getSizeInBits();
   SmallVector<uint64_t, 4> Indexes;
   for (int i = 0; i < NumParts; ++i) {
@@ -92,8 +92,8 @@
   MIRBuilder.buildExtract(VRegs, Indexes, Reg);
 }
 
-MachineLegalizeHelper::LegalizeResult
-MachineLegalizeHelper::libcall(MachineInstr &MI) {
+LegalizerHelper::LegalizeResult
+LegalizerHelper::libcall(MachineInstr &MI) {
   LLT Ty = MRI.getType(MI.getOperand(0).getReg());
   unsigned Size = Ty.getSizeInBits();
   MIRBuilder.setInstr(MI);
@@ -119,9 +119,9 @@
   }
 }
 
-MachineLegalizeHelper::LegalizeResult
-MachineLegalizeHelper::narrowScalar(MachineInstr &MI, unsigned TypeIdx,
-                                    LLT NarrowTy) {
+LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
+                                                              unsigned TypeIdx,
+                                                              LLT NarrowTy) {
   // FIXME: Don't know how to handle secondary types yet.
   if (TypeIdx != 0)
     return UnableToLegalize;
@@ -163,9 +163,8 @@
   }
 }
 
-MachineLegalizeHelper::LegalizeResult
-MachineLegalizeHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx,
-                                   LLT WideTy) {
+LegalizerHelper::LegalizeResult
+LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
   MIRBuilder.setInstr(MI);
 
   switch (MI.getOpcode()) {
@@ -293,8 +292,8 @@
   }
 }
 
-MachineLegalizeHelper::LegalizeResult
-MachineLegalizeHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
+LegalizerHelper::LegalizeResult
+LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
   using namespace TargetOpcode;
   MIRBuilder.setInstr(MI);
 
@@ -319,9 +318,9 @@
   }
 }
 
-MachineLegalizeHelper::LegalizeResult
-MachineLegalizeHelper::fewerElementsVector(MachineInstr &MI, unsigned TypeIdx,
-                                           LLT NarrowTy) {
+LegalizerHelper::LegalizeResult
+LegalizerHelper::fewerElementsVector(MachineInstr &MI, unsigned TypeIdx,
+                                     LLT NarrowTy) {
   // FIXME: Don't know how to handle secondary types yet.
   if (TypeIdx != 0)
     return UnableToLegalize;
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
similarity index 87%
rename from llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp
rename to llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
index 9844dbb..da7428d 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
@@ -1,4 +1,4 @@
-//===---- lib/CodeGen/GlobalISel/MachineLegalizer.cpp - IRTranslator -------==//
+//===---- lib/CodeGen/GlobalISel/LegalizerInfo.cpp - Legalizer -------==//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -17,7 +17,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
+#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
 
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/CodeGen/MachineInstr.h"
@@ -27,7 +27,7 @@
 #include "llvm/Target/TargetOpcodes.h"
 using namespace llvm;
 
-MachineLegalizer::MachineLegalizer() : TablesInitialized(false) {
+LegalizerInfo::LegalizerInfo() : TablesInitialized(false) {
   // FIXME: these two can be legalized to the fundamental load/store Jakob
   // proposed. Once loads & stores are supported.
   DefaultActions[TargetOpcode::G_ANYEXT] = Legal;
@@ -41,7 +41,7 @@
   DefaultActions[TargetOpcode::G_BRCOND] = WidenScalar;
 }
 
-void MachineLegalizer::computeTables() {
+void LegalizerInfo::computeTables() {
   for (unsigned Opcode = 0; Opcode <= LastOp - FirstOp; ++Opcode) {
     for (unsigned Idx = 0; Idx != Actions[Opcode].size(); ++Idx) {
       for (auto &Action : Actions[Opcode][Idx]) {
@@ -63,8 +63,8 @@
 // probably going to need specialized lookup structures for various types before
 // we have any hope of doing well with something like <13 x i3>. Even the common
 // cases should do better than what we have now.
-std::pair<MachineLegalizer::LegalizeAction, LLT>
-MachineLegalizer::getAction(const InstrAspect &Aspect) const {
+std::pair<LegalizerInfo::LegalizeAction, LLT>
+LegalizerInfo::getAction(const InstrAspect &Aspect) const {
   assert(TablesInitialized && "backend forgot to call computeTables");
   // These *have* to be implemented for now, they're the fundamental basis of
   // how everything else is transformed.
@@ -113,9 +113,9 @@
   return findLegalAction(Aspect, FewerElements);
 }
 
-std::tuple<MachineLegalizer::LegalizeAction, unsigned, LLT>
-MachineLegalizer::getAction(const MachineInstr &MI,
-                            const MachineRegisterInfo &MRI) const {
+std::tuple<LegalizerInfo::LegalizeAction, unsigned, LLT>
+LegalizerInfo::getAction(const MachineInstr &MI,
+                         const MachineRegisterInfo &MRI) const {
   SmallBitVector SeenTypes(8);
   const MCOperandInfo *OpInfo = MI.getDesc().OpInfo;
   for (unsigned i = 0; i < MI.getDesc().getNumOperands(); ++i) {
@@ -138,13 +138,13 @@
   return std::make_tuple(Legal, 0, LLT{});
 }
 
-bool MachineLegalizer::isLegal(const MachineInstr &MI,
-                               const MachineRegisterInfo &MRI) const {
+bool LegalizerInfo::isLegal(const MachineInstr &MI,
+                            const MachineRegisterInfo &MRI) const {
   return std::get<0>(getAction(MI, MRI)) == Legal;
 }
 
-LLT MachineLegalizer::findLegalType(const InstrAspect &Aspect,
-                                    LegalizeAction Action) const {
+LLT LegalizerInfo::findLegalType(const InstrAspect &Aspect,
+                                 LegalizeAction Action) const {
   switch(Action) {
   default:
     llvm_unreachable("Cannot find legal type");
diff --git a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
index 5b3b705..2a20e43 100644
--- a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
@@ -12,7 +12,7 @@
 
 #include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
 #include "llvm/ADT/PostOrderIterator.h"
-#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
+#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
 #include "llvm/CodeGen/GlobalISel/RegisterBank.h"
 #include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
 #include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
@@ -571,9 +571,9 @@
   // Check that our input is fully legal: we require the function to have the
   // Legalized property, so it should be.
   // FIXME: This should be in the MachineVerifier, but it can't use the
-  // MachineLegalizer as it's currently in the separate GlobalISel library.
+  // LegalizerInfo as it's currently in the separate GlobalISel library.
   const MachineRegisterInfo &MRI = MF.getRegInfo();
-  if (const MachineLegalizer *MLI = MF.getSubtarget().getMachineLegalizer()) {
+  if (const LegalizerInfo *MLI = MF.getSubtarget().getLegalizerInfo()) {
     for (const MachineBasicBlock &MBB : MF) {
       for (const MachineInstr &MI : MBB) {
         if (isPreISelGenericOpcode(MI.getOpcode()) && !MLI->isLegal(MI, MRI)) {