forked from OSchip/llvm-project
switch asmprinter to emit alignments through OutStreamer.
llvm-svn: 79406
This commit is contained in:
parent
4b7dadb76e
commit
37b7234a75
|
@ -753,15 +753,12 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV,
|
||||||
NumBits = std::max(NumBits, ForcedAlignBits);
|
NumBits = std::max(NumBits, ForcedAlignBits);
|
||||||
|
|
||||||
if (NumBits == 0) return; // No need to emit alignment.
|
if (NumBits == 0) return; // No need to emit alignment.
|
||||||
if (TAI->getAlignmentIsInBytes()) NumBits = 1 << NumBits;
|
|
||||||
O << TAI->getAlignDirective() << NumBits;
|
unsigned FillValue = 0;
|
||||||
|
|
||||||
if (getCurrentSection()->getKind().isText())
|
if (getCurrentSection()->getKind().isText())
|
||||||
if (unsigned FillValue = TAI->getTextAlignFillValue()) {
|
FillValue = TAI->getTextAlignFillValue();
|
||||||
O << ',';
|
|
||||||
PrintHex(FillValue);
|
OutStreamer.EmitValueToAlignment(1 << NumBits, FillValue, 1, 0);
|
||||||
}
|
|
||||||
O << '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitZeros - Emit a block of zeros.
|
/// EmitZeros - Emit a block of zeros.
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/MC/MCValue.h"
|
#include "llvm/MC/MCValue.h"
|
||||||
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
@ -224,24 +226,37 @@ void MCAsmStreamer::EmitValue(const MCValue &Value, unsigned Size) {
|
||||||
void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
|
void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
|
||||||
unsigned ValueSize,
|
unsigned ValueSize,
|
||||||
unsigned MaxBytesToEmit) {
|
unsigned MaxBytesToEmit) {
|
||||||
// Some assemblers don't support .balign, so we always emit as .p2align if
|
// Some assemblers don't support non-power of two alignments, so we always
|
||||||
// this is a power of two. Otherwise we assume the client knows the target
|
// emit alignments as a power of two if possible.
|
||||||
// supports .balign and use that.
|
if (isPowerOf2_32(ByteAlignment)) {
|
||||||
unsigned Pow2 = Log2_32(ByteAlignment);
|
OS << TAI.getAlignDirective();
|
||||||
bool IsPow2 = (1U << Pow2) == ByteAlignment;
|
|
||||||
|
if (TAI.getAlignmentIsInBytes())
|
||||||
|
OS << ByteAlignment;
|
||||||
|
else
|
||||||
|
OS << Log2_32(ByteAlignment);
|
||||||
|
|
||||||
|
if (Value || MaxBytesToEmit) {
|
||||||
|
OS << ", " << truncateToSize(Value, ValueSize);
|
||||||
|
|
||||||
|
if (MaxBytesToEmit)
|
||||||
|
OS << ", " << MaxBytesToEmit;
|
||||||
|
}
|
||||||
|
OS << '\n';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Non-power of two alignment. This is not widely supported by assemblers.
|
||||||
|
// FIXME: Parameterize this based on TAI.
|
||||||
switch (ValueSize) {
|
switch (ValueSize) {
|
||||||
default:
|
default: llvm_unreachable("Invalid size for machine code value!");
|
||||||
llvm_unreachable("Invalid size for machine code value!");
|
case 1: OS << ".balign"; break;
|
||||||
case 8:
|
case 2: OS << ".balignw"; break;
|
||||||
llvm_unreachable("Unsupported alignment size!");
|
case 4: OS << ".balignl"; break;
|
||||||
case 1: OS << (IsPow2 ? ".p2align" : ".balign"); break;
|
case 8: llvm_unreachable("Unsupported alignment size!");
|
||||||
case 2: OS << (IsPow2 ? ".p2alignw" : ".balignw"); break;
|
|
||||||
case 4: OS << (IsPow2 ? ".p2alignl" : ".balignl"); break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OS << ' ' << (IsPow2 ? Pow2 : ByteAlignment);
|
OS << ' ' << ByteAlignment;
|
||||||
|
|
||||||
OS << ", " << truncateToSize(Value, ValueSize);
|
OS << ", " << truncateToSize(Value, ValueSize);
|
||||||
if (MaxBytesToEmit)
|
if (MaxBytesToEmit)
|
||||||
OS << ", " << MaxBytesToEmit;
|
OS << ", " << MaxBytesToEmit;
|
||||||
|
|
Loading…
Reference in New Issue