summaryrefslogtreecommitdiff
path: root/lib/Target/PIC16/PIC16TargetObjectFile.cpp
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-08-20 19:28:24 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-08-20 19:28:24 +0000
commiteb01abaad1b0c0987ffcd679824cbeeb2a083199 (patch)
tree00045cdb77c9fb8a7fe4ff5000d2d4eed2df0a38 /lib/Target/PIC16/PIC16TargetObjectFile.cpp
parent72689b4094570666f3aa8e003186998805a06b45 (diff)
downloadllvm-eb01abaad1b0c0987ffcd679824cbeeb2a083199.tar.gz
llvm-eb01abaad1b0c0987ffcd679824cbeeb2a083199.tar.bz2
llvm-eb01abaad1b0c0987ffcd679824cbeeb2a083199.tar.xz
Implement support for ISRs.
Clone functions that are shared between the Main thread and Interrupt thread. CallSites are changed in AsmPrinter currently. A better solution would have been to modify the legalizer (SoftenFloat) to allow targets to change the name of libcalls for float operations. But that currently breaks other targets. Also, cloing of automatic variables is done AsmPrinter, a better approach would be to use the ValueMap in CloneFunction itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79562 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PIC16/PIC16TargetObjectFile.cpp')
-rw-r--r--lib/Target/PIC16/PIC16TargetObjectFile.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/lib/Target/PIC16/PIC16TargetObjectFile.cpp b/lib/Target/PIC16/PIC16TargetObjectFile.cpp
index 07d8381800..3ff27a9ae7 100644
--- a/lib/Target/PIC16/PIC16TargetObjectFile.cpp
+++ b/lib/Target/PIC16/PIC16TargetObjectFile.cpp
@@ -70,8 +70,8 @@ void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){
}
const MCSection *PIC16TargetObjectFile::
-getSectionForFunction(const std::string &FnName) const {
- std::string T = PAN::getCodeSectionName(FnName);
+getSectionForFunction(const std::string &FnName, bool isInterrupt) const {
+ std::string T = PAN::getCodeSectionName(FnName, isInterrupt);
return getPIC16Section(T.c_str(), SectionKind::getText());
}
@@ -196,6 +196,48 @@ PIC16TargetObjectFile::getSectionForAuto(const GlobalVariable *GV) const {
return FoundAutoSec->S_;
}
+void PIC16TargetObjectFile::createClonedSectionForAutos(const std::string &SecName) {
+
+ // If the function is cloned then it will have ".IL" in its name
+ // If this function is not cloned then return;
+ if (SecName.find(".IL") == std::string::npos)
+ return;
+
+ // Come here if the function is cloned.
+ // Get the name of the original section from which it has been cloned.
+ std::string OrigName = SecName;
+ OrigName.replace(SecName.find(".IL"),3,"");
+
+ // Find original section
+ PIC16Section *FoundAutoSec = NULL;
+ for (unsigned i = 0; i < AutosSections.size(); i++) {
+ if (AutosSections[i]->S_->getName() == OrigName) {
+ FoundAutoSec = AutosSections[i];
+ break;
+ }
+ }
+
+ // No auto section exists for the original function.
+ if (!FoundAutoSec)
+ return;
+
+ // Create new section for the cloned function
+ const MCSectionPIC16 *NewSection =
+ getPIC16Section(SecName.c_str(), SectionKind::getMetadata());
+
+ PIC16Section *NewAutoSec = new PIC16Section(NewSection);
+ // Add this newly created autos section to the list of AutosSections.
+ AutosSections.push_back(NewAutoSec);
+
+ // Add the items from the original section to the new section
+ // Donot mangle them here. Because mangling them here will distort
+ // the original names.
+ // These names will be mangled them at the time of printing only
+ const std::vector<const GlobalVariable*> &Items = FoundAutoSec->Items;
+ for (unsigned j = 0; j < Items.size(); j++) {
+ NewAutoSec->Items.push_back(Items[j]);
+ }
+}
// Override default implementation to put the true globals into
// multiple data sections if required.