summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PIC16
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-24 17:13:27 +0000
committerChris Lattner <sabre@nondot.org>2009-07-24 17:13:27 +0000
commitb68b506d84be621fd41a1b43c1f8e5bbf6b7cd9b (patch)
treecd17dd3c21daad5f6ff7098a12f1cde2eac55f2c /llvm/lib/Target/PIC16
parent9b6370d230195e4cff3e3fd648eeb8803fa5b311 (diff)
downloadbcm5719-llvm-b68b506d84be621fd41a1b43c1f8e5bbf6b7cd9b.tar.gz
bcm5719-llvm-b68b506d84be621fd41a1b43c1f8e5bbf6b7cd9b.zip
start refactoring pic16 section selection logic.
llvm-svn: 76977
Diffstat (limited to 'llvm/lib/Target/PIC16')
-rw-r--r--llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp25
-rw-r--r--llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h4
2 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
index c7708fa761f..c2b519d893d 100644
--- a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
+++ b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
@@ -249,13 +249,15 @@ const Section*
PIC16TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
// If GV has a sectin name or section address create that section now.
if (GV->hasSection()) {
- std::string SectName = GV->getSection();
- // If address for a variable is specified, get the address and create
- // section.
- std::string AddrStr = "Address=";
- if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) {
- std::string SectAddr = SectName.substr(AddrStr.length());
- return CreateSectionForGlobal(GV, SectAddr);
+ if (const GlobalVariable *GVar = cast<GlobalVariable>(GV)) {
+ std::string SectName = GVar->getSection();
+ // If address for a variable is specified, get the address and create
+ // section.
+ std::string AddrStr = "Address=";
+ if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) {
+ std::string SectAddr = SectName.substr(AddrStr.length());
+ return CreateSectionForGlobal(GVar, SectAddr);
+ }
}
}
@@ -266,13 +268,8 @@ PIC16TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
// Create a new section for global variable. If Addr is given then create
// section at that address else create by name.
const Section *
-PIC16TargetAsmInfo::CreateSectionForGlobal(const GlobalValue *GV1,
- std::string Addr) const {
- const GlobalVariable *GV = dyn_cast<GlobalVariable>(GV1);
-
- if (!GV)
- return TargetAsmInfo::SectionForGlobal(GV1);
-
+PIC16TargetAsmInfo::CreateSectionForGlobal(const GlobalVariable *GV,
+ const std::string &Addr) const {
// See if this is an uninitialized global.
const Constant *C = GV->getInitializer();
if (C->isNullValue())
diff --git a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h
index 8013bba9df9..abbb5042752 100644
--- a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h
+++ b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h
@@ -75,8 +75,8 @@ namespace llvm {
const Section *CreateROSectionForGlobal(const GlobalVariable *GV,
std::string Addr = "") const;
virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
- const Section * CreateSectionForGlobal(const GlobalValue *GV,
- std::string Addr = "") const;
+ const Section *CreateSectionForGlobal(const GlobalVariable *GV,
+ const std::string &Addr = "") const;
public:
void SetSectionForGVs(Module &M);
const std::vector<PIC16Section*> &getBSSSections() const {
OpenPOWER on IntegriCloud