[llvm-commits] [llvm] r94505 - in /llvm/trunk: include/llvm/CodeGen/MachineJumpTableInfo.h include/llvm/Target/TargetLowering.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/MachineFunction.cpp lib/ExecutionEngine/JIT/JITEmitter.cpp

Chris Lattner sabre at nondot.org
Mon Jan 25 20:05:28 PST 2010


Author: lattner
Date: Mon Jan 25 22:05:28 2010
New Revision: 94505

URL: http://llvm.org/viewvc/llvm-project?rev=94505&view=rev
Log:
Add support for target-specific 32-bit custom-lowered 
jump table entries.

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h
    llvm/trunk/include/llvm/Target/TargetLowering.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/CodeGen/MachineFunction.cpp
    llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp

Modified: llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h?rev=94505&r1=94504&r2=94505&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineJumpTableInfo.h Mon Jan 25 22:05:28 2010
@@ -60,7 +60,11 @@
     /// If the .set directive is supported, this is emitted as:
     ///      .set L4_5_set_123, LBB123 - LJTI1_2
     ///      .word L4_5_set_123
-    EK_LabelDifference32
+    EK_LabelDifference32,
+    
+    /// EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the
+    /// TargetLowering::LowerCustomJumpTableEntry hook.
+    EK_Custom32
   };
 private:
   JTEntryKind EntryKind;

Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=94505&r1=94504&r2=94505&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Mon Jan 25 22:05:28 2010
@@ -46,7 +46,10 @@
   class MachineFunction;
   class MachineFrameInfo;
   class MachineInstr;
+  class MachineJumpTableInfo;
   class MachineModuleInfo;
+  class MCContext;
+  class MCExpr;
   class DwarfWriter;
   class SDNode;
   class SDValue;
@@ -757,10 +760,17 @@
   /// MachineJumpTableInfo::JTEntryKind enum.
   virtual unsigned getJumpTableEncoding() const;
   
+  virtual const MCExpr *
+  LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI,
+                            const MachineBasicBlock *MBB, unsigned uid,
+                            MCContext &Ctx) {
+    assert(0 && "Need to implement this hook if target has custom JTIs");
+  }
+  
   /// getPICJumpTableRelocaBase - Returns relocation base for the given PIC
   /// jumptable.
   virtual SDValue getPICJumpTableRelocBase(SDValue Table,
-                                             SelectionDAG &DAG) const;
+                                           SelectionDAG &DAG) const;
 
   /// isOffsetFoldingLegal - Return true if folding a constant offset
   /// with the given GlobalAddress is legal.  It is frequently not legal in

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=94505&r1=94504&r2=94505&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Jan 25 22:05:28 2010
@@ -479,12 +479,10 @@
   
   // Pick the directive to use to print the jump table entries, and switch to 
   // the appropriate section.
-  TargetLowering *LoweringInfo = TM.getTargetLowering();
-
   const Function *F = MF.getFunction();
   bool JTInDiffSection = false;
   if (F->isWeakForLinker() ||
-      (IsPic && !LoweringInfo->usesGlobalOffsetTable())) {
+      (IsPic && !TM.getTargetLowering()->usesGlobalOffsetTable())) {
     // In PIC mode, we need to emit the jump table to the same section as the
     // function body itself, otherwise the label differences won't make sense.
     // We should also do if the section name is NULL or function is declared in
@@ -546,12 +544,15 @@
                                         unsigned uid) const {
   const MCExpr *Value = 0;
   switch (MJTI->getEntryKind()) {
+  case MachineJumpTableInfo::EK_Custom32:
+    Value = TM.getTargetLowering()->LowerCustomJumpTableEntry(MJTI, MBB, uid,
+                                                              OutContext);
+    break;
   case MachineJumpTableInfo::EK_BlockAddress:
     // EK_BlockAddress - Each entry is a plain address of block, e.g.:
     //     .word LBB123
     Value = MCSymbolRefExpr::Create(GetMBBSymbol(MBB->getNumber()), OutContext);
     break;
-      
   case MachineJumpTableInfo::EK_GPRel32BlockAddress: {
     // EK_GPRel32BlockAddress - Each entry is an address of block, encoded
     // with a relocation as gp-relative, e.g.:
@@ -560,7 +561,7 @@
     OutStreamer.EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext));
     return;
   }
-      
+
   case MachineJumpTableInfo::EK_LabelDifference32: {
     // EK_LabelDifference32 - Each entry is the address of the block minus
     // the address of the jump table.  This is used for PIC jump tables where

Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=94505&r1=94504&r2=94505&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Jan 25 22:05:28 2010
@@ -544,6 +544,7 @@
     return TD.getPointerSize();
   case MachineJumpTableInfo::EK_GPRel32BlockAddress:
   case MachineJumpTableInfo::EK_LabelDifference32:
+  case MachineJumpTableInfo::EK_Custom32:
     return 4;
   }
   assert(0 && "Unknown jump table encoding!");
@@ -560,6 +561,7 @@
     return TD.getPointerABIAlignment();
   case MachineJumpTableInfo::EK_GPRel32BlockAddress:
   case MachineJumpTableInfo::EK_LabelDifference32:
+  case MachineJumpTableInfo::EK_Custom32:
     return TD.getABIIntegerTypeAlignment(32);
   }
   assert(0 && "Unknown jump table encoding!");

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=94505&r1=94504&r2=94505&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Mon Jan 25 22:05:28 2010
@@ -1445,6 +1445,7 @@
     break;
   }
       
+  case MachineJumpTableInfo::EK_Custom32:
   case MachineJumpTableInfo::EK_GPRel32BlockAddress:
   case MachineJumpTableInfo::EK_LabelDifference32: {
     assert(MJTI->getEntrySize(*TheJIT->getTargetData()) == 4&&"Cross JIT'ing?");





More information about the llvm-commits mailing list