summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PIC16
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-01-30 04:25:10 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-01-30 04:25:10 +0000
commit964a29f6717b1c29d0f74a56a1e23d77bdc8b1d0 (patch)
tree958b12086832997777dab57f7749c74087d3c1e4 /llvm/lib/Target/PIC16
parent9b3407e5bb5f6fbe5a6fbf4559989426abfd58a8 (diff)
downloadbcm5719-llvm-964a29f6717b1c29d0f74a56a1e23d77bdc8b1d0.tar.gz
bcm5719-llvm-964a29f6717b1c29d0f74a56a1e23d77bdc8b1d0.zip
Enable emitting of constant values in non-default address space as well. The APIs emitting constants now take an additional parameter signifying the address space in which to emit. The APIs like getData8BitsDirective() etc are made virtual enabling targets to be able to define appropirate directivers for various sizes and address spaces.
llvm-svn: 63377
Diffstat (limited to 'llvm/lib/Target/PIC16')
-rw-r--r--llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp41
-rw-r--r--llvm/lib/Target/PIC16/PIC16AsmPrinter.h1
-rw-r--r--llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp32
-rw-r--r--llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h6
4 files changed, 38 insertions, 42 deletions
diff --git a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp
index dc91128d5a3..63ad6e4f448 100644
--- a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp
+++ b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp
@@ -242,48 +242,11 @@ void PIC16AsmPrinter::EmitInitData (Module &M) {
continue;
O << name;
- EmitGlobalConstant(C);
+ EmitGlobalConstant(C, AddrSpace);
}
}
}
-void PIC16AsmPrinter::EmitConstantValueOnly(const Constant* CV) {
- if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
- unsigned BitWidth = CI->getBitWidth();
- int Val = CI->getZExtValue();
- if (BitWidth == 8) {
- // Expecting db directive here. In case of romdata we need to pad the
- // word with zeros.
- if (IsRomData)
- O << 0 <<", ";
- O << Val;
- }
- else if (BitWidth == 16) {
- unsigned Element1, Element2;
- Element1 = 0x00ff & Val;
- Element2 = 0x00ff & (Val >> 8);
- if (IsRomData)
- O << 0 <<", "<<Element1 <<", "<< 0 <<", "<< Element2;
- else
- O << Element1 <<", "<< Element2;
- }
- else if (BitWidth == 32) {
- unsigned Element1, Element2, Element3, Element4;
- Element1 = 0x00ff & Val;
- Element2 = 0x00ff & (Val >> 8);
- Element3 = 0x00ff & (Val >> 16);
- Element4 = 0x00ff & (Val >> 24);
- if (IsRomData)
- O << 0 <<", "<< Element1 <<", "<< 0 <<", "<< Element2 <<", "<< 0
- <<", "<< Element3 <<", "<< 0 <<", "<< Element4;
- else
- O << Element1 <<", "<< Element2 <<", "<< Element3 <<", "<< Element4;
- }
- return;
- }
- AsmPrinter::EmitConstantValueOnly(CV);
-}
-
void PIC16AsmPrinter::EmitRomData (Module &M)
{
SwitchToSection(TAI->getReadOnlySection());
@@ -308,7 +271,7 @@ void PIC16AsmPrinter::EmitRomData (Module &M)
continue;
O << name;
- EmitGlobalConstant(C);
+ EmitGlobalConstant(C, AddrSpace);
O << "\n";
}
}
diff --git a/llvm/lib/Target/PIC16/PIC16AsmPrinter.h b/llvm/lib/Target/PIC16/PIC16AsmPrinter.h
index 876e4be7439..ce79afd6079 100644
--- a/llvm/lib/Target/PIC16/PIC16AsmPrinter.h
+++ b/llvm/lib/Target/PIC16/PIC16AsmPrinter.h
@@ -43,7 +43,6 @@ namespace llvm {
void EmitInitData (Module &M);
void EmitUnInitData (Module &M);
void EmitRomData (Module &M);
- virtual void EmitConstantValueOnly(const Constant *CV);
void emitFunctionData(MachineFunction &MF);
void emitFunctionTempData(MachineFunction &MF, unsigned &FrameSize);
diff --git a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
index 8e2392e6f71..b86576be896 100644
--- a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
+++ b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
@@ -22,8 +22,11 @@ PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
: TargetAsmInfo(TM) {
CommentString = ";";
Data8bitsDirective = " db ";
- Data16bitsDirective = " db ";
- Data32bitsDirective = " db ";
+ Data16bitsDirective = " dw ";
+ Data32bitsDirective = " dl ";
+ RomData8bitsDirective = " dw ";
+ RomData16bitsDirective = " rom_di ";
+ RomData8bitsDirective = " rom_dl ";
ZeroDirective = NULL;
AsciiDirective = " dt ";
AscizDirective = NULL;
@@ -33,3 +36,28 @@ PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
DataSection = getNamedSection("idata.# IDATA", SectionFlags::Writeable);
SwitchToSectionDirective = "";
}
+
+const char *PIC16TargetAsmInfo::getData8bitsDirective(unsigned AddrSpace)
+ const {
+ if (AddrSpace == PIC16ISD::ROM_SPACE)
+ return RomData8bitsDirective;
+ else
+ return Data8bitsDirective;
+ }
+
+const char *PIC16TargetAsmInfo::getData16bitsDirective(unsigned AddrSpace)
+ const {
+ if (AddrSpace == PIC16ISD::ROM_SPACE)
+ return RomData16bitsDirective;
+ else
+ return Data16bitsDirective;
+ }
+
+const char *PIC16TargetAsmInfo::getData32bitsDirective(unsigned AddrSpace)
+ const {
+ if (AddrSpace == PIC16ISD::ROM_SPACE)
+ return RomData32bitsDirective;
+ else
+ return Data32bitsDirective;
+ }
+
diff --git a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h
index 88de79f357e..b75699ba8c4 100644
--- a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h
+++ b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h
@@ -23,7 +23,13 @@ namespace llvm {
struct PIC16TargetAsmInfo : public TargetAsmInfo {
PIC16TargetAsmInfo(const PIC16TargetMachine &TM);
+ const char *RomData8bitsDirective;
+ const char *RomData16bitsDirective;
+ const char *RomData32bitsDirective;
public :
+ virtual const char *getData8bitsDirective(unsigned AddrSpace = 0) const;
+ virtual const char *getData16bitsDirective(unsigned AddrSpace = 0) const;
+ virtual const char *getData32bitsDirective(unsigned AddrSpace = 0) const;
};
} // namespace llvm
OpenPOWER on IntegriCloud