Call the InsertAtEndOfBasicBlock hook if the usesCustomDAGSchedInserter
authorChris Lattner <sabre@nondot.org>
Fri, 26 Aug 2005 20:54:47 +0000 (20:54 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 26 Aug 2005 20:54:47 +0000 (20:54 +0000)
flag is set on an instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23098 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 33c9167f69ba950ddffba861a1458eebd9ce16be..dc3996bbfe156773a1d405adbece5bd26d61ab7f 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/CodeGen/SSARegMap.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Target/TargetLowering.h"
 #include "llvm/Support/CommandLine.h"
 using namespace llvm;
 
@@ -166,7 +167,13 @@ unsigned SimpleSched::Emit(SDOperand Op) {
     }
 
     // Now that we have emitted all operands, emit this instruction itself.
-    BB->insert(BB->end(), MI);
+    if ((II.Flags & M_USES_CUSTOM_DAG_SCHED_INSERTION) == 0) {
+      BB->insert(BB->end(), MI);
+    } else {
+      // Insert this instruction into the end of the basic block, potentially
+      // taking some custom action.
+      BB = DAG.getTargetLoweringInfo().InsertAtEndOfBasicBlock(MI, BB);
+    }
   } else {
     switch (Op.getOpcode()) {
     default:
index 227d34e1c47dab1d394ddb02f8b35758ec775fec..7b8d7c549c966191def8d4007ee7fddb8eb7c255 100644 (file)
@@ -855,6 +855,20 @@ void SelectionDAGLowering::visitFree(FreeInst &I) {
   DAG.setRoot(Result.second);
 }
 
+// InsertAtEndOfBasicBlock - This method should be implemented by targets that
+// mark instructions with the 'usesCustomDAGSchedInserter' flag.  These
+// instructions are special in various ways, which require special support to
+// insert.  The specified MachineInstr is created but not inserted into any
+// basic blocks, and the scheduler passes ownership of it to this method.
+MachineBasicBlock *TargetLowering::InsertAtEndOfBasicBlock(MachineInstr *MI,
+                                                       MachineBasicBlock *MBB) {
+  std::cerr << "If a target marks an instruction with "
+               "'usesCustomDAGSchedInserter', it must implement "
+               "TargetLowering::InsertAtEndOfBasicBlock!\n";
+  abort();
+  return 0;  
+}
+
 SDOperand TargetLowering::LowerVAStart(SDOperand Chain,
                                        SDOperand VAListP, Value *VAListV,
                                        SelectionDAG &DAG) {