The code section for an ISR has a specific address.
authorSanjiv Gupta <sanjiv.gupta@microchip.com>
Tue, 16 Feb 2010 03:41:07 +0000 (03:41 +0000)
committerSanjiv Gupta <sanjiv.gupta@microchip.com>
Tue, 16 Feb 2010 03:41:07 +0000 (03:41 +0000)
Currently, whether a function is ISR or not is encoded in the section attribute for that function.

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

lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
lib/Target/PIC16/PIC16ABINames.h
lib/Target/PIC16/PIC16TargetObjectFile.cpp
lib/Target/PIC16/PIC16TargetObjectFile.h

index 72f7c16c6374a6da577a0d7359c0317461468945..b015edd9e1d4db3ef1938fce52772c3f101e5f33 100644 (file)
@@ -106,8 +106,9 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   DbgInfo.BeginFunction(MF);
 
   // Now emit the instructions of function in its code section.
-  const MCSection *fCodeSection 
-    = getObjFileLowering().SectionForCode(CurrentFnSym->getName());
+  const MCSection *fCodeSection = 
+    getObjFileLowering().SectionForCode(CurrentFnSym->getName(), 
+                                        PAN::isISR(F->getSection()));
 
   // Start the Code Section.
   O <<  "\n";
index e18ddf158ec835fb4935205ec03792a91129ac8b..b0b9318d43896811be12a752e3e76d5917a04996 100644 (file)
@@ -325,6 +325,19 @@ namespace llvm {
 
       return o.str();
     } 
+
+    // Return true if the current function is an ISR
+    inline static bool isISR(const std::string SectName) {
+       if (SectName.find("interrupt") != std::string::npos)
+         return true;
+
+       return false;
+    }
+
+    // Return the address for ISR starts in rom.
+    inline static std::string getISRAddr(void) {
+      return "0x4";
+    }
   }; // class PAN.
 } // end namespace llvm;
 
index d7cfe029d359dbf7421a80e2568c93db0d130638..b891c18c4643fae35da950baad65b43d556edce8 100644 (file)
@@ -315,8 +315,12 @@ PIC16TargetObjectFile::allocateSHARED(const GlobalVariable *GV,
 
 // Interface used by AsmPrinter to get a code section for a function.
 const PIC16Section *
-PIC16TargetObjectFile::SectionForCode(const std::string &FnName) const {
+PIC16TargetObjectFile::SectionForCode(const std::string &FnName,
+                                      bool isISR) const {
   const std::string &sec_name = PAN::getCodeSectionName(FnName);
+  // If it is ISR, its code section starts at a specific address.
+  if (isISR)
+    return getPIC16Section(sec_name, CODE, PAN::getISRAddr());
   return getPIC16Section(sec_name, CODE);
 }
 
index 0b0ad43ff946000f998676cc0e1923382a51eec1..cf8bf848e45ec4e0c62d728630565fa89995e839 100644 (file)
@@ -137,7 +137,8 @@ namespace llvm {
 
 
     /// Return a code section for a function.
-    const PIC16Section *SectionForCode (const std::string &FnName) const;
+    const PIC16Section *SectionForCode (const std::string &FnName,
+                                        bool isISR) const;
 
     /// Return a frame section for a function.
     const PIC16Section *SectionForFrame (const std::string &FnName) const;