Adding support for placing global objects in shared data memory.
[oota-llvm.git] / lib / Target / PIC16 / PIC16MemSelOpt.cpp
index c9ebb5756cda4f395573613df7885fb75bdef93c..93ccdd249181051d38a52c9ad7a494530f0adc7c 100644 (file)
@@ -21,6 +21,7 @@
 
 #define DEBUG_TYPE "pic16-codegen"
 #include "PIC16.h"
+#include "PIC16ABINames.h"
 #include "PIC16InstrInfo.h"
 #include "PIC16MCAsmInfo.h"
 #include "PIC16TargetMachine.h"
@@ -143,7 +144,7 @@ bool MemSelOpt::processInstruction(MachineInstr *MI) {
   }
 
   // Get the section name(NewBank) for MemOp.
-  // This assumes that the section names for globals are laready set by
+  // This assumes that the section names for globals are already set by
   // AsmPrinter->doInitialization.
   std::string NewBank = CurBank;
   if (Op.getType() ==  MachineOperand::MO_GlobalAddress &&
@@ -155,7 +156,11 @@ bool MemSelOpt::processInstruction(MachineInstr *MI) {
     std::string Sym = Op.getSymbolName();
     NewBank = PAN::getSectionNameForSym(Sym);
   }
+
+  // If the section is shared section, do not emit banksel.
+  if (NewBank == PAN::getSharedUDataSectionName())
+    return Changed;
+
   // If the previous and new section names are same, we don't need to
   // emit banksel. 
   if (NewBank.compare(CurBank) != 0 ) {