[llvm-commits] [llvm] r73209 - in /llvm/trunk: include/llvm/Target/TargetELFWriterInfo.h lib/Target/CMakeLists.txt lib/Target/TargetELFWriterInfo.cpp lib/Target/X86/X86ELFWriterInfo.cpp

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Thu Jun 11 15:13:00 PDT 2009


Author: bruno
Date: Thu Jun 11 17:13:00 2009
New Revision: 73209

URL: http://llvm.org/viewvc/llvm-project?rev=73209&view=rev
Log:
Use forward declarations and move TargetELFWriterInfo impl to a new file.

Added:
    llvm/trunk/lib/Target/TargetELFWriterInfo.cpp
Modified:
    llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h
    llvm/trunk/lib/Target/CMakeLists.txt
    llvm/trunk/lib/Target/X86/X86ELFWriterInfo.cpp

Modified: llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h?rev=73209&r1=73208&r2=73209&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h Thu Jun 11 17:13:00 2009
@@ -14,11 +14,10 @@
 #ifndef LLVM_TARGET_TARGETELFWRITERINFO_H
 #define LLVM_TARGET_TARGETELFWRITERINFO_H
 
-#include "llvm/Target/TargetData.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Function.h"
-
 namespace llvm {
+  class Function;
+  class TargetData;
+  class TargetMachine;
 
   //===--------------------------------------------------------------------===//
   //                          TargetELFWriterInfo
@@ -50,21 +49,14 @@
       EM_X86_64 = 62   // AMD64
     };
 
-    explicit TargetELFWriterInfo(TargetMachine &tm) : TM(tm) {}
-    virtual ~TargetELFWriterInfo() {}
+    explicit TargetELFWriterInfo(TargetMachine &tm);
+    virtual ~TargetELFWriterInfo();
 
     unsigned short getEMachine() const { return EMachine; }
 
     /// getFunctionAlignment - Returns the alignment for function 'F', targets
     /// with different alignment constraints should overload this method
-    virtual unsigned getFunctionAlignment(const Function *F) const {
-      const TargetData *TD = TM.getTargetData();
-      unsigned FnAlign = F->getAlignment();
-      unsigned TDAlign = TD->getPointerABIAlignment();
-      unsigned Align = std::max(FnAlign, TDAlign);
-      assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
-      return Align;
-    }
+    virtual unsigned getFunctionAlignment(const Function *F) const;
   };
 
 } // end llvm namespace

Modified: llvm/trunk/lib/Target/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CMakeLists.txt?rev=73209&r1=73208&r2=73209&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CMakeLists.txt (original)
+++ llvm/trunk/lib/Target/CMakeLists.txt Thu Jun 11 17:13:00 2009
@@ -5,6 +5,7 @@
   Target.cpp
   TargetAsmInfo.cpp
   TargetData.cpp
+  TargetELFWriterInfo.cpp
   TargetFrameInfo.cpp
   TargetInstrInfo.cpp
   TargetMachOWriterInfo.cpp
@@ -14,4 +15,4 @@
   TargetSubtarget.cpp
   )
 
-# TODO: Support other targets besides X86. See Makefile.
\ No newline at end of file
+# TODO: Support other targets besides X86. See Makefile.

Added: llvm/trunk/lib/Target/TargetELFWriterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetELFWriterInfo.cpp?rev=73209&view=auto

==============================================================================
--- llvm/trunk/lib/Target/TargetELFWriterInfo.cpp (added)
+++ llvm/trunk/lib/Target/TargetELFWriterInfo.cpp Thu Jun 11 17:13:00 2009
@@ -0,0 +1,33 @@
+//===-- lib/Target/TargetELFWriterInfo.cpp - ELF Writer Info --0-*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the TargetELFWriterInfo class.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Function.h"
+#include "llvm/Target/TargetELFWriterInfo.h"
+#include "llvm/Target/TargetData.h"
+#include "llvm/Target/TargetMachine.h"
+using namespace llvm;
+
+TargetELFWriterInfo::TargetELFWriterInfo(TargetMachine &tm) : TM(tm) {}
+
+TargetELFWriterInfo::~TargetELFWriterInfo() {}
+
+/// getFunctionAlignment - Returns the alignment for function 'F', targets
+/// with different alignment constraints should overload this method
+unsigned TargetELFWriterInfo::getFunctionAlignment(const Function *F) const {
+  const TargetData *TD = TM.getTargetData();
+  unsigned FnAlign = F->getAlignment();
+  unsigned TDAlign = TD->getPointerABIAlignment();
+  unsigned Align = std::max(FnAlign, TDAlign);
+  assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
+  return Align;
+}

Modified: llvm/trunk/lib/Target/X86/X86ELFWriterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ELFWriterInfo.cpp?rev=73209&r1=73208&r2=73209&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ELFWriterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ELFWriterInfo.cpp Thu Jun 11 17:13:00 2009
@@ -12,8 +12,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "X86ELFWriterInfo.h"
+#include "llvm/Function.h"
+#include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
-#include "llvm/DerivedTypes.h"
 using namespace llvm;
 
 X86ELFWriterInfo::X86ELFWriterInfo(TargetMachine &TM)





More information about the llvm-commits mailing list