diff options
author | Kevin Enderby <enderby@apple.com> | 2010-02-23 18:26:34 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2010-02-23 18:26:34 +0000 |
commit | 6e72048add2a6464e038121c6c275da37528aa0a (patch) | |
tree | 00c107b21ab078d0f18c75447a14577af7de4cb4 /include | |
parent | 4ee2aa7eb29079eaf4cdefe533151200214a3a2c (diff) | |
download | llvm-6e72048add2a6464e038121c6c275da37528aa0a.tar.gz llvm-6e72048add2a6464e038121c6c275da37528aa0a.tar.bz2 llvm-6e72048add2a6464e038121c6c275da37528aa0a.tar.xz |
This is the first patch to put the needed bits in place to eventually allow code
to be aligned with optimal nops. This patch does not change any functionality
and when the compiler is changed to use EmitCodeAlignment() it should also not
change the resulting output. Once the compiler change is made and everything
looks good the next patch with the table of optimal X86 nops will be added to
WriteNopData() changing the output. There are many FIXMEs in this patch which
will be removed when we have better target hooks (coming soon I hear).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96963 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/MC/MCAssembler.h | 10 | ||||
-rw-r--r-- | include/llvm/MC/MCStreamer.h | 14 |
2 files changed, 22 insertions, 2 deletions
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 4527f3c28d..882929f2ee 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -195,12 +195,16 @@ class MCAlignFragment : public MCFragment { /// cannot be satisfied in this width then this fragment is ignored. unsigned MaxBytesToEmit; + /// EmitNops - true when aligning code and optimal nops to be used for filling + bool EmitNops; + public: MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize, - unsigned _MaxBytesToEmit, MCSectionData *SD = 0) + unsigned _MaxBytesToEmit, bool _EmitNops, + MCSectionData *SD = 0) : MCFragment(FT_Align, SD), Alignment(_Alignment), Value(_Value),ValueSize(_ValueSize), - MaxBytesToEmit(_MaxBytesToEmit) {} + MaxBytesToEmit(_MaxBytesToEmit), EmitNops(_EmitNops) {} /// @name Accessors /// @{ @@ -217,6 +221,8 @@ public: unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; } + unsigned getEmitNops() const { return EmitNops; } + /// @} static bool classof(const MCFragment *F) { diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index b104b9ad57..696d024aa8 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -232,6 +232,20 @@ namespace llvm { unsigned ValueSize = 1, unsigned MaxBytesToEmit = 0) = 0; + /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment + /// is reached. + /// + /// This used to align code where the alignment bytes may be executed. This + /// can emit different bytes for different sizes to optimize execution. + /// + /// @param ByteAlignment - The alignment to reach. This must be a power of + /// two on some targets. + /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If + /// the alignment cannot be reached in this many bytes, no bytes are + /// emitted. + virtual void EmitCodeAlignment(unsigned ByteAlignment, + unsigned MaxBytesToEmit = 0) = 0; + /// EmitValueToOffset - Emit some number of copies of @p Value until the /// byte offset @p Offset is reached. /// |