[llvm-commits] [llvm] r73201 - in /llvm/trunk: include/llvm/Target/TargetELFWriterInfo.h lib/CodeGen/ELF.h lib/CodeGen/ELFCodeEmitter.cpp lib/CodeGen/ELFWriter.cpp lib/CodeGen/ELFWriter.h lib/Target/X86/X86ELFWriterInfo.cpp lib/Target/X86/X86ELFWriterInfo.h lib/Target/X86/X86TargetMachine.cpp

Bill Wendling isanbard at gmail.com
Thu Jun 11 13:18:15 PDT 2009


On Jun 11, 2009, at 12:16 PM, Bruno Cardoso Lopes wrote:

> Author: bruno
> Date: Thu Jun 11 14:16:03 2009
> New Revision: 73201
>
> URL: http://llvm.org/viewvc/llvm-project?rev=73201&view=rev
> Log:
> Support for ELF Visibility
> Emission for globals, using the correct data sections
> Function alignment can be computed for each target using  
> TargetELFWriterInfo
> Some small fixes
>
>
> Modified:
>    llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h
>    llvm/trunk/lib/CodeGen/ELF.h
>    llvm/trunk/lib/CodeGen/ELFCodeEmitter.cpp
>    llvm/trunk/lib/CodeGen/ELFWriter.cpp
>    llvm/trunk/lib/CodeGen/ELFWriter.h
>    llvm/trunk/lib/Target/X86/X86ELFWriterInfo.cpp
>    llvm/trunk/lib/Target/X86/X86ELFWriterInfo.h
>    llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
>
> Modified: llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h?rev=73201&r1=73200&r2=73201&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetELFWriterInfo.h Thu Jun 11  
> 14:16:03 2009
> @@ -14,6 +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 {
>
>   // 
> = 
> = 
> =-------------------------------------------------------------------- 
> ===//
> @@ -21,9 +25,11 @@
>   // 
> = 
> = 
> =-------------------------------------------------------------------- 
> ===//
>
>   class TargetELFWriterInfo {
> +  protected:
>     // EMachine - This field is the target specific value to emit as  
> the
>     // e_machine member of the ELF header.
>     unsigned short EMachine;
> +    TargetMachine &TM;
>   public:
>
>     // Machine architectures
> @@ -44,10 +50,21 @@
>       EM_X86_64 = 62   // AMD64
>     };
>
> -    explicit TargetELFWriterInfo(MachineType machine) :  
> EMachine(machine) {}
> +    explicit TargetELFWriterInfo(TargetMachine &tm) : TM(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;
> +    }
>   };
>

Instead of pulling all of the headers into this header, why not  
forward declare the classes and then make this method out-of-line?

-bw




More information about the llvm-commits mailing list