1//===- AlignFragment.h ----------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_LD_ALIGNFRAGMENT_H 10#define MCLD_LD_ALIGNFRAGMENT_H 11#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14 15#include <mcld/Fragment/Fragment.h> 16 17namespace mcld { 18 19class SectionData; 20 21class AlignFragment : public Fragment 22{ 23public: 24 AlignFragment(unsigned int pAlignment, int64_t pValue, unsigned int pValueSize, 25 unsigned int pMaxBytesToEmit, SectionData *pSD = NULL); 26 27 unsigned int getAlignment() const { return m_Alignment; } 28 29 int64_t getValue() const { return m_Value; } 30 31 unsigned int getValueSize() const { return m_ValueSize; } 32 33 unsigned int getMaxBytesToEmit() const { return m_MaxBytesToEmit; } 34 35 bool hasEmitNops() const { return m_bEmitNops; } 36 37 void setEmitNops(bool pValue) { m_bEmitNops = pValue; } 38 39 static bool classof(const Fragment *F) 40 { return F->getKind() == Fragment::Alignment; } 41 static bool classof(const AlignFragment *) { return true; } 42 43 size_t size() const; 44 45private: 46 /// Alignment - The alignment to ensure, in bytes. 47 unsigned int m_Alignment; 48 49 /// Value - Value to use for filling padding bytes. 50 int64_t m_Value; 51 52 /// ValueSize - The size of the integer (in bytes) of \arg Value. 53 unsigned int m_ValueSize; 54 55 /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment 56 /// cannot be satisfied in this width then this fragment is ignored. 57 unsigned int m_MaxBytesToEmit; 58 59 /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead 60 /// of using the provided value. The exact interpretation of this flag is 61 /// target dependent. 62 bool m_bEmitNops : 1; 63 64}; 65 66} // namespace of mcld 67 68#endif 69 70