diff options
-rw-r--r-- | include/llvm/Target/TargetAsmInfo.h | 26 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16TargetAsmInfo.cpp | 41 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16TargetAsmInfo.h | 7 |
3 files changed, 40 insertions, 34 deletions
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h index 1cd55d0fcd..0e44666e5c 100644 --- a/include/llvm/Target/TargetAsmInfo.h +++ b/include/llvm/Target/TargetAsmInfo.h @@ -298,6 +298,15 @@ namespace llvm { const char *Data32bitsDirective; // Defaults to "\t.long\t" const char *Data64bitsDirective; // Defaults to "\t.quad\t" + /// getASDirective - Targets can override it to provide different data + /// directives for various sizes and non-default address spaces. + virtual const char *getASDirective(unsigned size, + unsigned AS) const { + assert (AS > 0 + && "Dont know the directives for default addr space"); + return NULL; + } + //===--- Alignment Information ----------------------------------------===// /// AlignDirective - The directive used to emit round up to an alignment @@ -600,19 +609,20 @@ namespace llvm { // Data directive accessors // - virtual const char *getData8bitsDirective(unsigned AddrSpace = 0) const { - return Data8bitsDirective; + const char *getData8bitsDirective(unsigned AS = 0) const { + return AS == 0 ? Data8bitsDirective : getASDirective(8, AS); } - virtual const char *getData16bitsDirective(unsigned AddrSpace = 0) const { - return Data16bitsDirective; + const char *getData16bitsDirective(unsigned AS = 0) const { + return AS == 0 ? Data16bitsDirective : getASDirective(16, AS); } - virtual const char *getData32bitsDirective(unsigned AddrSpace = 0) const { - return Data32bitsDirective; + const char *getData32bitsDirective(unsigned AS = 0) const { + return AS == 0 ? Data32bitsDirective : getASDirective(32, AS); } - virtual const char *getData64bitsDirective(unsigned AddrSpace = 0) const { - return Data64bitsDirective; + const char *getData64bitsDirective(unsigned AS = 0) const { + return AS == 0 ? Data64bitsDirective : getASDirective(64, AS); } + // Accessors. // const Section *getTextSection() const { diff --git a/lib/Target/PIC16/PIC16TargetAsmInfo.cpp b/lib/Target/PIC16/PIC16TargetAsmInfo.cpp index b86576be89..d40f2065b8 100644 --- a/lib/Target/PIC16/PIC16TargetAsmInfo.cpp +++ b/lib/Target/PIC16/PIC16TargetAsmInfo.cpp @@ -26,7 +26,7 @@ PIC16TargetAsmInfo(const PIC16TargetMachine &TM) Data32bitsDirective = " dl "; RomData8bitsDirective = " dw "; RomData16bitsDirective = " rom_di "; - RomData8bitsDirective = " rom_dl "; + RomData32bitsDirective = " rom_dl "; ZeroDirective = NULL; AsciiDirective = " dt "; AscizDirective = NULL; @@ -37,27 +37,24 @@ PIC16TargetAsmInfo(const PIC16TargetMachine &TM) SwitchToSectionDirective = ""; } -const char *PIC16TargetAsmInfo::getData8bitsDirective(unsigned AddrSpace) - const { - if (AddrSpace == PIC16ISD::ROM_SPACE) - return RomData8bitsDirective; - else - return Data8bitsDirective; - } +const char *PIC16TargetAsmInfo::getRomDirective(unsigned size) const +{ + if (size == 8) + return RomData8bitsDirective; + else if (size == 16) + return RomData16bitsDirective; + else if (size == 32) + return RomData32bitsDirective; + else + return NULL; +} -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; - } +const char *PIC16TargetAsmInfo::getASDirective(unsigned size, + unsigned AS) const { + if (AS == PIC16ISD::ROM_SPACE) + return getRomDirective(size); + else + return NULL; +} diff --git a/lib/Target/PIC16/PIC16TargetAsmInfo.h b/lib/Target/PIC16/PIC16TargetAsmInfo.h index b75699ba8c..305e74d5a3 100644 --- a/lib/Target/PIC16/PIC16TargetAsmInfo.h +++ b/lib/Target/PIC16/PIC16TargetAsmInfo.h @@ -23,13 +23,12 @@ namespace llvm { struct PIC16TargetAsmInfo : public TargetAsmInfo { PIC16TargetAsmInfo(const PIC16TargetMachine &TM); + private: 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; + const char *getRomDirective(unsigned size) const; + virtual const char *getASDirective(unsigned size, unsigned AS) const; }; } // namespace llvm |