[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp PPCMachOWriterInfo.h

2007-02-27 Thread Nate Begeman


Changes in directory llvm/lib/Target/PowerPC:

PPCMachOWriterInfo.cpp updated: 1.4 -> 1.5
PPCMachOWriterInfo.h updated: 1.3 -> 1.4
---
Log message:

More Mach-O writer improvements.


---
Diffs of the changes:  (+16 -6)

 PPCMachOWriterInfo.cpp |   20 +++-
 PPCMachOWriterInfo.h   |2 +-
 2 files changed, 16 insertions(+), 6 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.4 
llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.5
--- llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.4  Thu Feb  8 00:05:08 2007
+++ llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp  Wed Feb 28 01:40:50 2007
@@ -35,13 +35,11 @@
  unsigned ToIdx,
  OutputBuffer &RelocOut,
  OutputBuffer &SecOut,
- bool Scattered) const {
+ bool Scattered,
+ bool isExtern) const {
   unsigned NumRelocs = 0;
   uint64_t Addr = 0;
 
-  // Keep track of whether or not this is an externally defined relocation.
-  bool isExtern = false;
-
   // Get the address of whatever it is we're relocating, if possible.
   if (!isExtern)
 Addr = (uintptr_t)MR.getResultPointer() + ToAddr;
@@ -83,12 +81,24 @@
 break;
   case PPC::reloc_pcrel_bx:
 {
+  // FIXME: Presumably someday we will need to branch to other, non-extern
+  // functions too.  Need to figure out some way to distinguish between
+  // target is BB and target is function.
+  if (isExtern) {
+MachORelocation BR24(MR.getMachineCodeOffset(), ToIdx, true, 2, 
+ isExtern, PPC_RELOC_BR24, Scattered, 
+ (intptr_t)MR.getMachineCodeOffset());
+RelocOut.outword(BR24.getAddress());
+RelocOut.outword(BR24.getPackedFields());
+++NumRelocs;
+  }
+
   Addr -= MR.getMachineCodeOffset();
   Addr >>= 2;
   Addr &= 0xFF;
   Addr <<= 2;
   Addr |= (SecOut[MR.getMachineCodeOffset()] << 24);
-
+  Addr |= (SecOut[MR.getMachineCodeOffset()+3] & 0x3);
   SecOut.fixword(Addr, MR.getMachineCodeOffset());
   break;
 }


Index: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.h
diff -u llvm/lib/Target/PowerPC/PPCMachOWriterInfo.h:1.3 
llvm/lib/Target/PowerPC/PPCMachOWriterInfo.h:1.4
--- llvm/lib/Target/PowerPC/PPCMachOWriterInfo.h:1.3Fri Feb  2 20:41:58 2007
+++ llvm/lib/Target/PowerPC/PPCMachOWriterInfo.hWed Feb 28 01:40:50 2007
@@ -34,7 +34,7 @@
  unsigned ToIdx,
  OutputBuffer &RelocOut,
  OutputBuffer &SecOut,
- bool Scattered) const;
+ bool Scattered, bool Extern) const;
 
 // Constants for the relocation r_type field.
 // See 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp

2007-02-07 Thread Bill Wendling


Changes in directory llvm/lib/Target/PowerPC:

PPCMachOWriterInfo.cpp updated: 1.3 -> 1.4
---
Log message:

Fixed comments.


---
Diffs of the changes:  (+2 -3)

 PPCMachOWriterInfo.cpp |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.3 
llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.4
--- llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.3  Wed Feb  7 19:39:44 2007
+++ llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp  Thu Feb  8 00:05:08 2007
@@ -2,9 +2,8 @@
 //
 // The LLVM Compiler Infrastructure
 //
-// This file was developed by Nate Begeman and Bill Wendling and is distributed
-// under the University of Illinois Open Source License. See LICENSE.TXT for
-// details.
+// This file was developed by Bill Wendling and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
 //
 
//===--===//
 //



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp PPCMachOWriterInfo.h

2007-02-02 Thread Bill Wendling


Changes in directory llvm/lib/Target/PowerPC:

PPCMachOWriterInfo.cpp updated: 1.1 -> 1.2
PPCMachOWriterInfo.h updated: 1.2 -> 1.3
---
Log message:

Moved the GetTargetRelocation method from PPCMachOWriter to here. It uses
non-Mach-O-specific information.


---
Diffs of the changes:  (+143 -1)

 PPCMachOWriterInfo.cpp |  119 +
 PPCMachOWriterInfo.h   |   25 +-
 2 files changed, 143 insertions(+), 1 deletion(-)


Index: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.1 
llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.2
--- llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.1  Tue Jan 23 21:36:05 2007
+++ llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp  Fri Feb  2 20:41:58 2007
@@ -12,7 +12,10 @@
 
//===--===//
 
 #include "PPCMachOWriterInfo.h"
+#include "PPCRelocations.h"
 #include "PPCTargetMachine.h"
+#include "llvm/CodeGen/MachORelocation.h"
+#include "llvm/Support/OutputBuffer.h"
 using namespace llvm;
 
 PPCMachOWriterInfo::PPCMachOWriterInfo(const PPCTargetMachine &TM)
@@ -20,3 +23,119 @@
   HDR_CPU_TYPE_POWERPC64 :
   HDR_CPU_TYPE_POWERPC,
   HDR_CPU_SUBTYPE_POWERPC_ALL) {}
+PPCMachOWriterInfo::~PPCMachOWriterInfo() {}
+
+
+/// GetTargetRelocation - For the MachineRelocation MR, convert it to one or
+/// more PowerPC MachORelocation(s), add the new relocations to the
+/// MachOSection, and rewrite the instruction at the section offset if required
+/// by that relocation type.
+unsigned PPCMachOWriterInfo::GetTargetRelocation(MachineRelocation &MR,
+ unsigned FromIdx,
+ unsigned ToAddr,
+ unsigned ToIdx,
+ OutputBuffer &RelocOut,
+ OutputBuffer &SecOut,
+ bool Scattered) const {
+  unsigned NumRelocs = 0;
+  uint64_t Addr = 0;
+
+  // Keep track of whether or not this is an externally defined relocation.
+  bool isExtern = false;
+
+  // Get the address of whatever it is we're relocating, if possible.
+  if (!isExtern)
+Addr = (uintptr_t)MR.getResultPointer() + ToAddr;
+
+  switch ((PPC::RelocationType)MR.getRelocationType()) {
+  default: assert(0 && "Unknown PPC relocation type!");
+  case PPC::reloc_absolute_low_ix:
+assert(0 && "Unhandled PPC relocation type!");
+break;
+  case PPC::reloc_vanilla:
+{
+  // FIXME: need to handle 64 bit vanilla relocs
+  MachORelocation VANILLA(MR.getMachineCodeOffset(), ToIdx,
+  false, 2, isExtern,
+  PPC_RELOC_VANILLA,
+  Scattered, (intptr_t)MR.getResultPointer());
+  ++NumRelocs;
+
+  if (Scattered) {
+RelocOut.outword(VANILLA.getPackedFields());
+RelocOut.outword(VANILLA.getAddress());
+  } else {
+RelocOut.outword(VANILLA.getAddress());
+RelocOut.outword(VANILLA.getPackedFields());
+  }
+  
+  intptr_t SymbolOffset;
+
+  if (Scattered)
+SymbolOffset = Addr + MR.getConstantVal();
+  else
+SymbolOffset = Addr;
+
+  printf("vanilla fixup: sec_%x[%x] = %x\n", FromIdx,
+ unsigned(MR.getMachineCodeOffset()),
+ unsigned(SymbolOffset));
+  SecOut.fixword(SymbolOffset, MR.getMachineCodeOffset());
+}
+break;
+  case PPC::reloc_pcrel_bx:
+{
+  Addr -= MR.getMachineCodeOffset();
+  Addr >>= 2;
+  Addr &= 0xFF;
+  Addr <<= 2;
+  Addr |= (SecOut[MR.getMachineCodeOffset()] << 24);
+
+  SecOut.fixword(Addr, MR.getMachineCodeOffset());
+  break;
+}
+  case PPC::reloc_pcrel_bcx:
+{
+  Addr -= MR.getMachineCodeOffset();
+  Addr &= 0xFFFC;
+
+  SecOut.fixhalf(Addr, MR.getMachineCodeOffset() + 2);
+  break;
+}
+  case PPC::reloc_absolute_high:
+{
+  MachORelocation HA16(MR.getMachineCodeOffset(), ToIdx, false, 2,
+   isExtern, PPC_RELOC_HA16);
+  MachORelocation PAIR(Addr & 0x, 0xFF, false, 2, isExtern,
+   PPC_RELOC_PAIR);
+  NumRelocs = 2;
+
+  RelocOut.outword(HA16.getRawAddress());
+  RelocOut.outword(HA16.getPackedFields());
+  RelocOut.outword(PAIR.getRawAddress());
+  RelocOut.outword(PAIR.getPackedFields());
+
+  Addr += 0x8000;
+
+  SecOut.fixhalf(Addr >> 16, MR.getMachineCodeOffset() + 2);
+  break;
+}
+  case PPC::reloc_absolute_low:
+{
+  MachORelocation LO16(MR.getMachineCodeOffset(), ToIdx, false, 2,
+   isExtern, PPC_RELOC_LO16);
+  MachORelocation PAIR(Addr >> 16, 0xFF, false, 2, isExtern,
+   

[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp PPCMachOWriterInfo.h

2007-01-23 Thread Bill Wendling


Changes in directory llvm/lib/Target/PowerPC:

PPCMachOWriterInfo.cpp added (r1.1)
PPCMachOWriterInfo.h added (r1.1)
---
Log message:

New "TargetMachOWriterInfo" class. It holds target-specific information
that the MachOWriter needs in order to do its writing stuff 'n things.


---
Diffs of the changes:  (+57 -0)

 PPCMachOWriterInfo.cpp |   22 ++
 PPCMachOWriterInfo.h   |   35 +++
 2 files changed, 57 insertions(+)


Index: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
diff -c /dev/null llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp:1.1
*** /dev/null   Tue Jan 23 21:36:15 2007
--- llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp  Tue Jan 23 21:36:05 2007
***
*** 0 
--- 1,22 
+ //===-- PPCMachOWriterInfo.cpp - Mach-O Writer Info for the PowerPC 
---===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Bill Wendling and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ 
//===--===//
+ //
+ // This file implements Mach-O writer information for the PowerPC backend.
+ //
+ 
//===--===//
+ 
+ #include "PPCMachOWriterInfo.h"
+ #include "PPCTargetMachine.h"
+ using namespace llvm;
+ 
+ PPCMachOWriterInfo::PPCMachOWriterInfo(const PPCTargetMachine &TM)
+   : TargetMachOWriterInfo(TM.getTargetData()->getPointerSizeInBits() == 64 ?
+   HDR_CPU_TYPE_POWERPC64 :
+   HDR_CPU_TYPE_POWERPC,
+   HDR_CPU_SUBTYPE_POWERPC_ALL) {}


Index: llvm/lib/Target/PowerPC/PPCMachOWriterInfo.h
diff -c /dev/null llvm/lib/Target/PowerPC/PPCMachOWriterInfo.h:1.1
*** /dev/null   Tue Jan 23 21:36:25 2007
--- llvm/lib/Target/PowerPC/PPCMachOWriterInfo.hTue Jan 23 21:36:05 2007
***
*** 0 
--- 1,35 
+ //===-- PPCMachOWriterInfo.h - Mach-O Writer Info for PowerPC ---*- C++ 
-*-===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Bill Wendling and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ 
//===--===//
+ //
+ // This file implements Mach-O writer information for the PowerPC backend.
+ //
+ 
//===--===//
+ 
+ #ifndef PPC_MACHO_WRITER_INFO_H
+ #define PPC_MACHO_WRITER_INFO_H
+ 
+ #include "llvm/Target/TargetMachOWriterInfo.h"
+ 
+ namespace llvm {
+ 
+   // Forward declarations
+   class PPCTargetMachine;
+ 
+   struct PPCMachOWriterInfo : public TargetMachOWriterInfo {
+ PPCMachOWriterInfo(const PPCTargetMachine &TM);
+ virtual ~PPCMachOWriterInfo() {}
+ 
+ virtual const char *getPassName() const {
+   return "PowerPC Mach-O Writer";
+ }
+   };
+ 
+ } // end llvm namespace
+ 
+ #endif // PPC_MACHO_WRITER_INFO_H



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits