[llvm-commits] [llvm] r55679 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp lib/Target/X86/X86FastISel.h lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h utils/TableGen/FastISelEmitter.cpp

Evan Cheng evan.cheng at apple.com
Tue Sep 2 17:03:49 PDT 2008


Author: evancheng
Date: Tue Sep  2 19:03:49 2008
New Revision: 55679

URL: http://llvm.org/viewvc/llvm-project?rev=55679&view=rev
Log:
Let tblgen only generate fastisel routines, not the class definition. This makes it easier for targets to define its own fastisel class.

Removed:
    llvm/trunk/lib/Target/X86/X86FastISel.h
Modified:
    llvm/trunk/lib/Target/X86/X86FastISel.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.h
    llvm/trunk/utils/TableGen/FastISelEmitter.cpp

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Sep  2 19:03:49 2008
@@ -16,17 +16,31 @@
 #include "X86.h"
 #include "X86RegisterInfo.h"
 #include "X86ISelLowering.h"
-#include "X86FastISel.h"
 #include "X86TargetMachine.h"
+#include "llvm/CodeGen/FastISel.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "X86GenFastISel.inc"
 
-namespace llvm {
+using namespace llvm;
 
-namespace X86 {
+class X86FastISel : public FastISel {
+  /// Subtarget - Keep a pointer to the X86Subtarget around so that we can
+  /// make the right decision when generating code for different targets.
+  const X86Subtarget *Subtarget;
+    
+ public:
+  explicit X86FastISel(MachineFunction &mf) : FastISel(mf) {}
+
+  virtual bool
+    TargetSelectInstruction(Instruction *I,
+                            DenseMap<const Value *, unsigned> &ValueMap,
+                      DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap,
+                            MachineBasicBlock *MBB);
+
+#include "X86GenFastISel.inc"
+};
 
 bool
-FastISel::TargetSelectInstruction(Instruction *I,
+X86FastISel::TargetSelectInstruction(Instruction *I,
                                   DenseMap<const Value *, unsigned> &ValueMap,
                       DenseMap<const BasicBlock *, MachineBasicBlock *> &MBBMap,
                                   MachineBasicBlock *MBB)  {
@@ -37,6 +51,8 @@
   return false;
 }
 
-}
-
+namespace llvm {
+  llvm::FastISel *X86::createFastISel(MachineFunction &mf) {
+    return new X86FastISel(mf);
+  }
 }

Removed: llvm/trunk/lib/Target/X86/X86FastISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.h?rev=55678&view=auto

==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.h (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.h (removed)
@@ -1,31 +0,0 @@
-//===-- X86FastISel.h - X86 FastISel header -------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the interface to the X86-specific support for the FastISel
-// class.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef X86FASTISEL_H
-#define X86FASTISEL_H
-
-namespace llvm {
-
-class FastISel;
-class MachineFunction;
-
-namespace X86 {
-
-FastISel *createFastISel(MachineFunction &mf);
-
-} // namespace X86
-
-} // namespace llvm
-
-#endif

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Sep  2 19:03:49 2008
@@ -17,7 +17,6 @@
 #include "X86ISelLowering.h"
 #include "X86MachineFunctionInfo.h"
 #include "X86TargetMachine.h"
-#include "X86FastISel.h"
 #include "llvm/CallingConv.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=55679&r1=55678&r2=55679&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Tue Sep  2 19:03:49 2008
@@ -19,6 +19,7 @@
 #include "X86RegisterInfo.h"
 #include "X86MachineFunctionInfo.h"
 #include "llvm/Target/TargetLowering.h"
+#include "llvm/CodeGen/FastIsel.h"
 #include "llvm/CodeGen/SelectionDAG.h"
 #include "llvm/CodeGen/CallingConvLower.h"
 
@@ -595,6 +596,10 @@
                                                           MachineBasicBlock *BB,
                                                           unsigned cmovOpc);
   };
+
+  namespace X86 {
+    FastISel *createFastISel(MachineFunction &mf);
+  }
 }
 
 #endif    // X86ISELLOWERING_H

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

==============================================================================
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Tue Sep  2 19:03:49 2008
@@ -352,89 +352,6 @@
   }
 }
 
-void FastISelMap::PrintClass(std::ostream &OS) {
-  // Declare the target FastISel class.
-  OS << "class FastISel : public llvm::FastISel {\n";
-  for (OperandsOpcodeTypeRetPredMap::const_iterator OI = SimplePatterns.begin(),
-       OE = SimplePatterns.end(); OI != OE; ++OI) {
-    const OperandsSignature &Operands = OI->first;
-    const OpcodeTypeRetPredMap &OTM = OI->second;
-
-    for (OpcodeTypeRetPredMap::const_iterator I = OTM.begin(), E = OTM.end();
-         I != E; ++I) {
-      const std::string &Opcode = I->first;
-      const TypeRetPredMap &TM = I->second;
-
-      for (TypeRetPredMap::const_iterator TI = TM.begin(), TE = TM.end();
-           TI != TE; ++TI) {
-        MVT::SimpleValueType VT = TI->first;
-        const RetPredMap &RM = TI->second;
-        
-        if (RM.size() != 1)
-          for (RetPredMap::const_iterator RI = RM.begin(), RE = RM.end();
-               RI != RE; ++RI) {
-            MVT::SimpleValueType RetVT = RI->first;
-            OS << "  unsigned FastEmit_" << getLegalCName(Opcode)
-               << "_" << getLegalCName(getName(VT)) << "_"
-               << getLegalCName(getName(RetVT)) << "_";
-            Operands.PrintManglingSuffix(OS);
-            OS << "(";
-            Operands.PrintParameters(OS);
-            OS << ");\n";
-          }
-        
-        OS << "  unsigned FastEmit_" << getLegalCName(Opcode)
-           << "_" << getLegalCName(getName(VT)) << "_";
-        Operands.PrintManglingSuffix(OS);
-        OS << "(MVT::SimpleValueType RetVT";
-        if (!Operands.empty())
-          OS << ", ";
-        Operands.PrintParameters(OS);
-        OS << ");\n";
-      }
-
-      OS << "  unsigned FastEmit_" << getLegalCName(Opcode) << "_";
-      Operands.PrintManglingSuffix(OS);
-      OS << "(MVT::SimpleValueType VT, MVT::SimpleValueType RetVT";
-      if (!Operands.empty())
-        OS << ", ";
-      Operands.PrintParameters(OS);
-      OS << ");\n";
-    }
-
-    OS << "  unsigned FastEmit_";
-    Operands.PrintManglingSuffix(OS);
-    OS << "(MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode";
-    if (!Operands.empty())
-      OS << ", ";
-    Operands.PrintParameters(OS);
-    OS << ");\n";
-  }
-  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";
-  OS << "\n";
-
-  // Declare the constructor.
-  OS << "public:\n";
-  OS << "  explicit FastISel(MachineFunction &mf)\n";
-  OS << "     : llvm::FastISel(mf),\n";
-  OS << "       Subtarget(&TM.getSubtarget<" << InstNS.substr(0, InstNS.size() - 2)
-     << "Subtarget>()) {}\n";
-  OS << "};\n";
-  OS << "\n";
-}
-
 void FastISelMap::PrintFunctionDefinitions(std::ostream &OS) {
   // Now emit code for all the patterns that we collected.
   for (OperandsOpcodeTypeRetPredMap::const_iterator OI = SimplePatterns.begin(),
@@ -462,7 +379,7 @@
             const PredMap &PM = RI->second;
             bool HasPred = false;
 
-            OS << "unsigned FastISel::FastEmit_"
+            OS << "unsigned FastEmit_"
                << getLegalCName(Opcode)
                << "_" << getLegalCName(getName(VT))
                << "_" << getLegalCName(getName(RetVT)) << "_";
@@ -524,7 +441,7 @@
           }
           
           // Emit one function for the type that demultiplexes on return type.
-          OS << "unsigned FastISel::FastEmit_"
+          OS << "unsigned FastEmit_"
              << getLegalCName(Opcode) << "_"
              << getLegalCName(getName(VT)) << "_";
           Operands.PrintManglingSuffix(OS);
@@ -548,7 +465,7 @@
           
         } else {
           // Non-variadic return type.
-          OS << "unsigned FastISel::FastEmit_"
+          OS << "unsigned FastEmit_"
              << getLegalCName(Opcode) << "_"
              << getLegalCName(getName(VT)) << "_";
           Operands.PrintManglingSuffix(OS);
@@ -618,7 +535,7 @@
       }
 
       // Emit one function for the opcode that demultiplexes based on the type.
-      OS << "unsigned FastISel::FastEmit_"
+      OS << "unsigned FastEmit_"
          << getLegalCName(Opcode) << "_";
       Operands.PrintManglingSuffix(OS);
       OS << "(MVT::SimpleValueType VT, MVT::SimpleValueType RetVT";
@@ -651,7 +568,7 @@
 
     // Emit one function for the operand signature that demultiplexes based
     // on opcode and type.
-    OS << "unsigned FastISel::FastEmit_";
+    OS << "unsigned FastEmit_";
     Operands.PrintManglingSuffix(OS);
     OS << "(MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode";
     if (!Operands.empty())
@@ -689,27 +606,9 @@
   EmitSourceFileHeader("\"Fast\" Instruction Selector for the " +
                        Target.getName() + " target", OS);
 
-  OS << "#include \"llvm/CodeGen/FastISel.h\"\n";
-  OS << "\n";
-  OS << "namespace llvm {\n";
-  OS << "\n";
-  OS << "namespace " << InstNS.substr(0, InstNS.size() - 2) << " {\n";
-  OS << "\n";
-  
   FastISelMap F(InstNS);
   F.CollectPatterns(CGP);
-  F.PrintClass(OS);
   F.PrintFunctionDefinitions(OS);
-
-  // Define the target FastISel creation function.
-  OS << "llvm::FastISel *createFastISel(MachineFunction &mf) {\n";
-  OS << "  return new FastISel(mf);\n";
-  OS << "}\n";
-  OS << "\n";
-
-  OS << "} // namespace X86\n";
-  OS << "\n";
-  OS << "} // namespace llvm\n";
 }
 
 FastISelEmitter::FastISelEmitter(RecordKeeper &R)





More information about the llvm-commits mailing list