[llvm-commits] [llvm] r55512 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Target/X86/X86FastISel.cpp utils/TableGen/FastISelEmitter.cpp

Dan Gohman gohman at apple.com
Thu Aug 28 16:21:35 PDT 2008


Author: djg
Date: Thu Aug 28 18:21:34 2008
New Revision: 55512

URL: http://llvm.org/viewvc/llvm-project?rev=55512&view=rev
Log:
Add a target callback for FastISel.

Modified:
    llvm/trunk/include/llvm/CodeGen/FastISel.h
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
    llvm/trunk/lib/Target/X86/X86FastISel.cpp
    llvm/trunk/utils/TableGen/FastISelEmitter.cpp

Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=55512&r1=55511&r2=55512&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/FastISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/FastISel.h Thu Aug 28 18:21:34 2008
@@ -52,10 +52,21 @@
   /// the generated MachineInstrs.
   BasicBlock::iterator
   SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator End,
-                     DenseMap<const Value*, unsigned> &ValueMap,
-                     DenseMap<const BasicBlock*, MachineBasicBlock *> &MBBMap,
+                     DenseMap<const Value *, unsigned> &ValueMap,
+                     DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap,
                      MachineBasicBlock *MBB);
 
+  /// TargetSelectInstruction - This method is called by target-independent
+  /// code when the normal FastISel process fails to select an instruction.
+  /// This gives targets a chance to emit code for anything that doesn't
+  /// fit into FastISel's framework. It returns true if it was successful.
+  ///
+  virtual bool
+  TargetSelectInstruction(Instruction *I,
+                          DenseMap<const Value *, unsigned> &ValueMap,
+                      DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap,
+                          MachineBasicBlock *MBB) = 0;
+
   virtual ~FastISel();
 
 protected:

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=55512&r1=55511&r2=55512&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Aug 28 18:21:34 2008
@@ -5757,10 +5757,15 @@
           Begin = F->SelectInstructions(Begin, End, FuncInfo->ValueMap,
                                         FuncInfo->MBBMap, BB);
 
+          // If the "fast" selector selected the entire block, we're done.
           if (Begin == End)
-            // The "fast" selector selected the entire block, so we're done.
             break;
 
+          // Next, try calling the target to attempt to handle the instruction.
+          if (F->TargetSelectInstruction(Begin, FuncInfo->ValueMap,
+                                         FuncInfo->MBBMap, BB))
+            continue;
+
           // Handle certain instructions as single-LLVM-Instruction blocks.
           if (isa<CallInst>(Begin) || isa<LoadInst>(Begin) ||
               isa<StoreInst>(Begin)) {
@@ -5783,7 +5788,7 @@
             // The "fast" selector couldn't handle something and bailed.
             // For the purpose of debugging, just abort.
 #ifndef NDEBUG
-              Begin->dump();
+            Begin->dump();
 #endif
             assert(0 && "FastISel didn't select the entire block");
           }

Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=55512&r1=55511&r2=55512&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu Aug 28 18:21:34 2008
@@ -19,3 +19,23 @@
 #include "X86FastISel.h"
 #include "X86TargetMachine.h"
 #include "X86GenFastISel.inc"
+
+namespace llvm {
+
+namespace X86 {
+
+bool
+FastISel::TargetSelectInstruction(Instruction *I,
+                                  DenseMap<const Value *, unsigned> &ValueMap,
+                      DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap,
+                                  MachineBasicBlock *MBB)  {
+  switch (I->getOpcode()) {
+  default: break;
+  }
+
+  return false;
+}
+
+}
+
+}

Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=55512&r1=55511&r2=55512&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Thu Aug 28 18:21:34 2008
@@ -351,6 +351,14 @@
   }
   OS << "\n";
 
+  OS << "bool TargetSelectInstruction(Instruction *I,\n";
+  OS << "                             "
+        "DenseMap<const Value *, unsigned> &ValueMap,\n";
+  OS << "                             "
+        "DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap,\n";
+  OS << "                             "
+        "MachineBasicBlock *MBB);\n";
+
   // Declare the Subtarget member, which is used for predicate checks.
   OS << "  const " << InstNS.substr(0, InstNS.size() - 2)
      << "Subtarget *Subtarget;\n";





More information about the llvm-commits mailing list