[llvm-commits] [llvm] r74172 - in /llvm/trunk: include/llvm/CodeGen/MachineInstrBuilder.h lib/Target/PIC16/PIC16MemSelOpt.cpp

Sanjiv Gupta sanjiv.gupta at microchip.com
Thu Jun 25 04:03:26 PDT 2009


Author: sgupta
Date: Thu Jun 25 06:03:14 2009
New Revision: 74172

URL: http://llvm.org/viewvc/llvm-project?rev=74172&view=rev
Log:
Identify unconditional gotos and generate a page sel instructions before them.

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h
    llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp

Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h?rev=74172&r1=74171&r2=74172&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h Thu Jun 25 06:03:14 2009
@@ -133,6 +133,8 @@
     if (MO.isGlobal())
       return addGlobalAddress(MO.getGlobal(), MO.getOffset(),
                               MO.getTargetFlags());
+    if (MO.isMBB())
+      return addMBB(MO.getMBB());
     if (MO.isCPI())
       return addConstantPoolIndex(MO.getIndex(), MO.getOffset(),
                                   MO.getTargetFlags());

Modified: llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp?rev=74172&r1=74171&r2=74172&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp Thu Jun 25 06:03:14 2009
@@ -109,7 +109,7 @@
 
   // If this insn is not going to access any memory, return.
   const TargetInstrDesc &TID = TII->get(MI->getOpcode());
-  if (! (TID.isCall() || TID.mayLoad() || TID.mayStore()))
+  if (!(TID.isBranch() || TID.isCall() || TID.mayLoad() || TID.mayStore()))
     return false;
 
   // Scan for the memory address operand.
@@ -119,8 +119,9 @@
   for (unsigned i = 0; i < NumOperands; i++) {
     MachineOperand Op = MI->getOperand(i);
     if (Op.getType() ==  MachineOperand::MO_GlobalAddress ||
-        Op.getType() ==  MachineOperand::MO_ExternalSymbol) {
-      // We found one mem operand. Next one should be BS.
+        Op.getType() ==  MachineOperand::MO_ExternalSymbol || 
+        Op.getType() ==  MachineOperand::MO_MachineBasicBlock) {
+      // We found one mem operand. Next one may be BS.
       MemOpPos = i;
       break;
     }
@@ -133,7 +134,8 @@
   MachineOperand &Op = MI->getOperand(MemOpPos);
 
   // If this is a pagesel material, handle it first.
-  if (MI->getOpcode() == PIC16::CALL) {
+  if (MI->getOpcode() == PIC16::CALL ||
+      MI->getOpcode() == PIC16::br_uncond) {
     DebugLoc dl = MI->getDebugLoc();
     BuildMI(*MBB, MI, dl, TII->get(PIC16::pagesel)).
       addOperand(Op);





More information about the llvm-commits mailing list