[llvm-commits] [llvm] r76666 - /llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp

Richard Osborne richard at xmos.com
Wed Jul 22 03:43:09 PDT 2009


Chris Lattner wrote:
> Author: lattner
> Date: Tue Jul 21 17:39:28 2009
> New Revision: 76666
>
> URL: http://llvm.org/viewvc/llvm-project?rev=76666&view=rev
> Log:
> don't mask out the small flag and then reapply it later.
>
> Modified:
>     llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp?rev=76666&r1=76665&r2=76666&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp Tue Jul 21 17:39:28 2009
> @@ -71,31 +71,17 @@
>  unsigned XCoreTargetAsmInfo::
>  SectionFlagsForGlobal(const GlobalValue *GV, const char* Name) const {
>    unsigned Flags = ELFTargetAsmInfo::SectionFlagsForGlobal(GV, Name);
> -  // Mask out unsupported flags
> -  Flags &= ~SectionFlags::Small;
>  
>    // Set CP / DP relative flags
>    if (GV) {
>      SectionKind::Kind Kind = SectionKindForGlobal(GV);
>      switch (Kind) {
> -    case SectionKind::ThreadData:
> -    case SectionKind::ThreadBSS:
> -    case SectionKind::Data:
> -    case SectionKind::BSS:
> -    case SectionKind::SmallData:
> -    case SectionKind::SmallBSS:
> -      Flags |= SectionFlags::Small;
> -      break;
>      case SectionKind::ROData:
>      case SectionKind::RODataMergeStr:
>      case SectionKind::SmallROData:
> -      if (Subtarget->isXS1A()) {
> +      if (Subtarget->isXS1A())
>          Flags |= SectionFlags::Writeable;
> -      }
> -      Flags |=SectionFlags::Small;
>        break;
> -    case SectionKind::RODataMergeConst:
> -      Flags |=SectionFlags::Small;
>      default:
>        break;
>      }
>   
On the XCore the small section flag "s" is not supported but there are 
two other non standard section flags which must be emitted by the 
backend. Data is normally accessed relative to either the cp or dp 
registers. All sections with the "c" flag are grouped together by the 
linker to form the constant pool and the cp register is set to the start 
of the constant pool by the boot code. Similarly all sections with the 
"d" flag are grouped together to form the data region and the dp 
register is set to the start of the region. The code generated to access 
the global is different depending whether the global is placed in the cp 
or dp. If the there is a mismatch between the code to access the global 
and the section flags for the global the linker will error when it tries 
to apply relocations.

The SectionFlags::Small was being used (misused?) to represent these 
flags. Whether the frontend set SectionFlags::Small was being ignored 
and instead SectionFlags::Writable and SectionFlags::Small were being 
used represent the "d" flag and SectionFlags::Small on its own was used 
to represent the "c" flag.

It would be nice if there was a mechanism to specify target specific 
sections flags for a section, but I don't think this exists at the 
moment. As things stand these changes will break things on the XCore 
since the "c" and "d" flags will no longer be emitted.



More information about the llvm-commits mailing list