#include "llvm/Support/raw_ostream.h"
using namespace llvm;
+namespace llvm {
+ bool EnableFastISel;
+}
+
static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden,
cl::desc("Print LLVM IR produced by the loop-reduce pass"));
static cl::opt<bool> PrintISelInput("print-isel-input", cl::Hidden,
cl::desc("Disable scheduling after register allocation"),
cl::init(true));
+// Enable or disable FastISel. Both options are needed, because
+// FastISel is enabled by default with -fast, and we wish to be
+// able to enable or disable fast-isel independently from -fast.
+static cl::opt<bool>
+EnableFastISelOption("fast-isel", cl::Hidden,
+ cl::desc("Enable the experimental \"fast\" instruction selector"));
+static cl::opt<bool>
+DisableFastISelOption("disable-fast-isel", cl::Hidden,
+ cl::desc("Disable the experimental \"fast\" instruction selector"));
+
FileModel::Model
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
raw_ostream &Out,
if (addPreEmitPass(PM, Fast) && PrintMachineCode)
PM.add(createMachineFunctionPrinterPass(cerr));
- if (!Fast && !OptimizeForSize)
+ if (!Fast)
PM.add(createLoopAlignerPass());
switch (FileType) {
// Standard Lower-Level Passes.
+ // Enable FastISel with -fast, but allow that to be overridden.
+ assert((!EnableFastISelOption || !DisableFastISelOption) &&
+ "Both -fast-isel and -disable-fast-isel given!");
+ if (EnableFastISelOption ||
+ (Fast && !DisableFastISelOption))
+ EnableFastISel = true;
+
// Ask the target for an isel.
if (addInstSelector(PM, Fast))
return true;
if (PrintMachineCode)
PM.add(createMachineFunctionPrinterPass(cerr));
+ // If we're using Fast-ISel, clean up the mess.
+ if (EnableFastISel)
+ PM.add(createDeadMachineInstructionElimPass());
+
if (EnableLICM)
PM.add(createMachineLICMPass());