factorize more darwin TAI stuff. Note that this gives
[oota-llvm.git] / lib / Target / MSP430 / MSP430ISelDAGToDAG.cpp
index b8800f4b42fa36cab56c12ab764df8a5d123fade..6dd3b2a2548550f651b70dfdd469079bd25c4b2c 100644 (file)
@@ -28,8 +28,8 @@
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
-#include <queue>
-#include <set>
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
 /// MSP430DAGToDAGISel - MSP430 specific code to select MSP430 machine
@@ -41,8 +41,8 @@ namespace {
     const MSP430Subtarget &Subtarget;
 
   public:
-    MSP430DAGToDAGISel(MSP430TargetMachine &TM)
-      : SelectionDAGISel(TM),
+    MSP430DAGToDAGISel(MSP430TargetMachine &TM, CodeGenOpt::Level OptLevel)
+      : SelectionDAGISel(TM, OptLevel),
         Lowering(*TM.getTargetLowering()),
         Subtarget(*TM.getSubtargetImpl()) { }
 
@@ -68,8 +68,9 @@ namespace {
 /// createMSP430ISelDag - This pass converts a legalized DAG into a
 /// MSP430-specific DAG, ready for instruction scheduling.
 ///
-FunctionPass *llvm::createMSP430ISelDag(MSP430TargetMachine &TM) {
-  return new MSP430DAGToDAGISel(TM);
+FunctionPass *llvm::createMSP430ISelDag(MSP430TargetMachine &TM,
+                                        CodeGenOpt::Level OptLevel) {
+  return new MSP430DAGToDAGISel(TM, OptLevel);
 }
 
 // FIXME: This is pretty dummy routine and needs to be rewritten in the future.
@@ -107,6 +108,9 @@ bool MSP430DAGToDAGISel::SelectAddr(SDValue Op, SDValue Addr,
                                             MVT::i16, G->getOffset());
       Disp = CurDAG->getTargetConstant(0, MVT::i16);
       return true;
+    } else if (ExternalSymbolSDNode *E = dyn_cast<ExternalSymbolSDNode>(N0)) {
+      Base = CurDAG->getTargetExternalSymbol(E->getSymbol(), MVT::i16);
+      Disp = CurDAG->getTargetConstant(0, MVT::i16);
     }
     break;
   };
@@ -124,8 +128,15 @@ bool MSP430DAGToDAGISel::SelectAddr(SDValue Op, SDValue Addr,
 void MSP430DAGToDAGISel::InstructionSelect() {
   DEBUG(BB->dump());
 
-  // Select target instructions for the DAG.
+  // Codegen the basic block.
+#ifndef NDEBUG
+  DOUT << "===== Instruction selection begins:\n";
+  Indent = 0;
+#endif
   SelectRoot(*CurDAG);
+#ifndef NDEBUG
+  DOUT << "===== Instruction selection ends:\n";
+#endif
 
   CurDAG->RemoveDeadNodes();
 }