Add a quick and dirty "loop aligner pass". x86 uses it to align its loops to 16-byte boundaries.

llvm-svn: 47703
This commit is contained in:
Evan Cheng 2008-02-28 00:43:03 +00:00
parent 93e8b679a3
commit c799065cc3
25 changed files with 173 additions and 50 deletions

View File

@ -78,6 +78,10 @@ namespace llvm {
/// CurrentSection - The current section we are emitting to. This is
/// controlled and used by the SwitchSection method.
std::string CurrentSection;
/// IsInTextSection - True if the current section we are emitting to is a
/// text section.
bool IsInTextSection;
protected:
AsmPrinter(std::ostream &o, TargetMachine &TM, const TargetAsmInfo *T);
@ -269,9 +273,7 @@ namespace llvm {
/// an explicit alignment requested, it will unconditionally override the
/// alignment request. However, if ForcedAlignBits is specified, this value
/// has final say: the ultimate alignment will be the max of ForcedAlignBits
/// and the alignment computed with NumBits and the global. If UseFillExpr
/// is true, it also emits an optional second value FillValue which the
/// assembler uses to fill gaps to match alignment.
/// and the alignment computed with NumBits and the global
///
/// The algorithm is:
/// Align = NumBits;
@ -279,8 +281,7 @@ namespace llvm {
/// Align = std::max(Align, ForcedAlignBits);
///
void EmitAlignment(unsigned NumBits, const GlobalValue *GV = 0,
unsigned ForcedAlignBits = 0, bool UseFillExpr = false,
unsigned FillValue = 0) const;
unsigned ForcedAlignBits = 0) const;
/// printLabel - This method prints a local label used by debug and
/// exception handling tables.
@ -317,6 +318,7 @@ namespace llvm {
/// printBasicBlockLabel - This method prints the label for the specified
/// MachineBasicBlock
virtual void printBasicBlockLabel(const MachineBasicBlock *MBB,
bool printAlign = false,
bool printColon = false,
bool printComment = true) const;

View File

@ -75,6 +75,10 @@ class MachineBasicBlock {
/// LiveIns - Keep track of the physical registers that are livein of
/// the basicblock.
std::vector<unsigned> LiveIns;
/// Alignment - Alignment of the basic block. Zero if the basic block does
/// not need to be aligned.
unsigned Alignment;
/// IsLandingPad - Indicate that this basic block is entered via an
/// exception handler.
@ -82,7 +86,8 @@ class MachineBasicBlock {
public:
explicit MachineBasicBlock(const BasicBlock *bb = 0)
: Prev(0), Next(0), BB(bb), Number(-1), xParent(0), IsLandingPad(false) {
: Prev(0), Next(0), BB(bb), Number(-1), xParent(0),
Alignment(0), IsLandingPad(false) {
Insts.parent = this;
}
@ -181,6 +186,14 @@ public:
const_livein_iterator livein_end() const { return LiveIns.end(); }
bool livein_empty() const { return LiveIns.empty(); }
/// getAlignment - Return alignment of the basic block.
///
unsigned getAlignment() const { return Alignment; }
/// setAlignment - Set alignment of the basic block.
///
void setAlignment(unsigned Align) { Alignment = Align; }
/// isLandingPad - Returns true if the block is a landing pad. That is
/// this basic block is entered via an exception handler.
bool isLandingPad() const { return IsLandingPad; }

View File

@ -204,7 +204,7 @@ public:
}
/// getObjectAlignment - Return the alignment of the specified stack object...
int getObjectAlignment(int ObjectIdx) const {
unsigned getObjectAlignment(int ObjectIdx) const {
assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
"Invalid Object Idx!");
return Objects[ObjectIdx+NumFixedObjects].Alignment;

View File

@ -129,6 +129,10 @@ namespace llvm {
/// IfConverter Pass - This pass performs machine code if conversion.
FunctionPass *createIfConverterPass();
/// LoopAligner Pass - This pass aligns loop headers to target specific
/// alignment boundary.
FunctionPass *createLoopAlignerPass();
/// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This
/// allows a debug emitter to determine if the range of two labels is empty,
/// by seeing if the labels map to the same reduced label.

View File

@ -164,6 +164,10 @@ namespace llvm {
/// boundary.
bool AlignmentIsInBytes; // Defaults to true
/// TextAlignFillValue - If non-zero, this is used to fill the executable
/// space created as the result of a alignment directive.
unsigned TextAlignFillValue;
//===--- Section Switching Directives ---------------------------------===//
/// SwitchToSectionDirective - This is the directive used when we want to
@ -503,6 +507,9 @@ namespace llvm {
bool getAlignmentIsInBytes() const {
return AlignmentIsInBytes;
}
unsigned getTextAlignFillValue() const {
return TextAlignFillValue;
}
const char *getSwitchToSectionDirective() const {
return SwitchToSectionDirective;
}

View File

@ -548,17 +548,23 @@ public:
/// getIfCvtBlockLimit - returns the target specific if-conversion block size
/// limit. Any block whose size is greater should not be predicated.
virtual unsigned getIfCvtBlockSizeLimit() const {
unsigned getIfCvtBlockSizeLimit() const {
return IfCvtBlockSizeLimit;
}
/// getIfCvtDupBlockLimit - returns the target specific size limit for a
/// block to be considered for duplication. Any block whose size is greater
/// should not be duplicated to facilitate its predication.
virtual unsigned getIfCvtDupBlockSizeLimit() const {
unsigned getIfCvtDupBlockSizeLimit() const {
return IfCvtDupBlockSizeLimit;
}
/// getPrefLoopAlignment - return the preferred loop alignment.
///
unsigned getPrefLoopAlignment() const {
return PrefLoopAlignment;
}
/// getPreIndexedAddressParts - returns true by value, base pointer and
/// offset pointer and addressing mode by reference if the node's address
/// can be legally represented as pre-indexed load / store address.
@ -583,7 +589,7 @@ public:
/// jumptable.
virtual SDOperand getPICJumpTableRelocBase(SDOperand Table,
SelectionDAG &DAG) const;
//===--------------------------------------------------------------------===//
// TargetLowering Optimization Methods
//
@ -890,6 +896,12 @@ protected:
void setIfCvtDupBlockSizeLimit(unsigned Limit) {
IfCvtDupBlockSizeLimit = Limit;
}
/// setPrefLoopAlignment - Set the target's preferred loop alignment. Default
/// alignment is zero, it means the target does not care about loop alignment.
void setPrefLoopAlignment(unsigned Align) {
PrefLoopAlignment = Align;
}
public:
@ -1276,6 +1288,10 @@ private:
/// duplicated during if-conversion.
unsigned IfCvtDupBlockSizeLimit;
/// PrefLoopAlignment - The perferred loop alignment.
///
unsigned PrefLoopAlignment;
/// StackPointerRegisterToSaveRestore - If set to a physical register, this
/// specifies the register that llvm.savestack/llvm.restorestack should save
/// and restore.

View File

@ -39,7 +39,8 @@ AsmVerbose("asm-verbose", cl::Hidden, cl::desc("Add comments to directives."));
char AsmPrinter::ID = 0;
AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
const TargetAsmInfo *T)
: MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o), TM(tm), TAI(T)
: MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o), TM(tm), TAI(T),
IsInTextSection(false)
{}
std::string AsmPrinter::getSectionForFunction(const Function &F) const {
@ -69,6 +70,8 @@ void AsmPrinter::SwitchToTextSection(const char *NewSection,
if (!CurrentSection.empty())
O << CurrentSection << TAI->getTextSectionStartSuffix() << '\n';
IsInTextSection = true;
}
/// SwitchToDataSection - Switch to the specified data section of the executable
@ -93,6 +96,8 @@ void AsmPrinter::SwitchToDataSection(const char *NewSection,
if (!CurrentSection.empty())
O << CurrentSection << TAI->getDataSectionStartSuffix() << '\n';
IsInTextSection = false;
}
@ -344,7 +349,7 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< '_' << uid << "_set_" << MBB->getNumber();
} else {
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
// If the arch uses custom Jump Table directives, don't calc relative to
// JT
if (!HadJTEntryDirective)
@ -352,7 +357,7 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
<< getFunctionNumber() << '_' << uid;
}
} else {
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
}
}
@ -679,8 +684,7 @@ void AsmPrinter::EmitFile(unsigned Number, const std::string &Name) const {
// Align = std::max(Align, ForcedAlignBits);
//
void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV,
unsigned ForcedAlignBits, bool UseFillExpr,
unsigned FillValue) const {
unsigned ForcedAlignBits) const {
if (GV && GV->getAlignment())
NumBits = Log2_32(GV->getAlignment());
NumBits = std::max(NumBits, ForcedAlignBits);
@ -688,6 +692,9 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV,
if (NumBits == 0) return; // No need to emit alignment.
if (TAI->getAlignmentIsInBytes()) NumBits = 1 << NumBits;
O << TAI->getAlignDirective() << NumBits;
unsigned FillValue = TAI->getTextAlignFillValue();
bool UseFillExpr = IsInTextSection && FillValue;
if (UseFillExpr) O << ",0x" << std::hex << FillValue << std::dec;
O << "\n";
}
@ -1252,7 +1259,7 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
if (Modifier[0]=='l') // labels are target independent
printBasicBlockLabel(MI->getOperand(OpNo).getMBB(),
false, false);
false, false, false);
else {
AsmPrinter *AP = const_cast<AsmPrinter*>(this);
if ((OpFlags & 7) == 4 /*ADDR MODE*/) {
@ -1318,8 +1325,15 @@ bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
/// printBasicBlockLabel - This method prints the label for the specified
/// MachineBasicBlock
void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
bool printAlign,
bool printColon,
bool printComment) const {
if (printAlign) {
unsigned Align = MBB->getAlignment();
if (Align)
EmitAlignment(Log2_32(Align));
}
O << TAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << "_"
<< MBB->getNumber();
if (printColon)
@ -1338,7 +1352,7 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << uid << '\n';
}
@ -1351,7 +1365,7 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid, unsigned uid2,
O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << uid << '_' << uid2
<< "_set_" << MBB->getNumber() << ',';
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << uid << '_' << uid2 << '\n';
}

View File

@ -44,7 +44,7 @@ namespace {
cl::desc("Max number of predecessors to consider tail merging"),
cl::init(100), cl::Hidden);
struct BranchFolder : public MachineFunctionPass {
struct VISIBILITY_HIDDEN BranchFolder : public MachineFunctionPass {
static char ID;
explicit BranchFolder(bool defaultEnableTailMerge) :
MachineFunctionPass((intptr_t)&ID) {

View File

@ -56,7 +56,7 @@ STATISTIC(NumIfConvBBs, "Number of if-converted blocks");
STATISTIC(NumDupBBs, "Number of duplicated blocks");
namespace {
class IfConverter : public MachineFunctionPass {
class VISIBILITY_HIDDEN IfConverter : public MachineFunctionPass {
enum IfcvtKind {
ICNotClassfied, // BB data valid, but not classified.
ICSimpleFalse, // Same as ICSimple, but on the false path.

View File

@ -0,0 +1,65 @@
//===-- LoopAligner.cpp - Loop aligner pass. ------------------------------===//
//
// 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 pass that align loop headers to target specific
// alignment boundary.
//
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "loopalign"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
using namespace llvm;
namespace {
class LoopAligner : public MachineFunctionPass {
const TargetLowering *TLI;
public:
static char ID;
LoopAligner() : MachineFunctionPass((intptr_t)&ID) {}
virtual bool runOnMachineFunction(MachineFunction &MF);
virtual const char *getPassName() const { return "Loop aligner"; }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<MachineLoopInfo>();
AU.addPreserved<MachineLoopInfo>();
MachineFunctionPass::getAnalysisUsage(AU);
}
};
char LoopAligner::ID = 0;
} // end anonymous namespace
FunctionPass *llvm::createLoopAlignerPass() { return new LoopAligner(); }
bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
const MachineLoopInfo *MLI = &getAnalysis<MachineLoopInfo>();
if (MLI->begin() == MLI->end())
return false; // No loops.
unsigned Align = MF.getTarget().getTargetLowering()->getPrefLoopAlignment();
if (!Align)
return false; // Don't care about loop alignment.
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
MachineBasicBlock *MBB = I;
if (MLI->isLoopHeader(MBB))
MBB->setAlignment(Align);
}
return true;
}

View File

@ -166,6 +166,7 @@ void MachineBasicBlock::print(std::ostream &OS) const {
if (LBB) OS << LBB->getName() << ": ";
OS << (const void*)this
<< ", LLVM BB @" << (const void*) LBB << ", ID#" << getNumber();
if (Alignment) OS << ", Alignment " << Alignment;
if (isLandingPad()) OS << ", EH LANDING PAD";
OS << ":\n";

View File

@ -206,6 +206,8 @@ TargetLowering::TargetLowering(TargetMachine &tm)
JumpBufSize = 0;
JumpBufAlignment = 0;
IfCvtBlockSizeLimit = 2;
IfCvtDupBlockSizeLimit = 0;
PrefLoopAlignment = 0;
InitLibcallNames(LibcallRoutineNames);
InitCmpLibcallCCs(CmpLibcallCCs);

View File

@ -248,7 +248,7 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
I != E; ++I) {
// Print a label for the basic block.
if (I != MF.begin()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
@ -710,13 +710,13 @@ void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNo) {
<< '_' << JTI << '_' << MO2.getImm()
<< "_set_" << MBB->getNumber();
else if (TM.getRelocationModel() == Reloc::PIC_) {
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
// If the arch uses custom Jump Table directives, don't calc relative to JT
if (!TAI->getJumpTableDirective())
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
<< getFunctionNumber() << '_' << JTI << '_' << MO2.getImm();
} else
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
if (i != e-1)
O << '\n';
}

View File

@ -171,7 +171,7 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
if (I != MF.begin()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();

View File

@ -460,7 +460,7 @@ LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF)
I != E; ++I) {
// Print a label for the basic block.
if (I != MF.begin()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();

View File

@ -149,7 +149,7 @@ bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
I != E; ++I) {
// Print a label for the basic block if there are any predecessors.
if (!I->pred_empty()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();

View File

@ -297,7 +297,7 @@ runOnMachineFunction(MachineFunction &MF)
// Print a label for the basic block.
if (I != MF.begin()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}

View File

@ -604,7 +604,7 @@ bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
I != E; ++I) {
// Print a label for the basic block.
if (I != MF.begin()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
@ -838,7 +838,7 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
I != E; ++I) {
// Print a label for the basic block.
if (I != MF.begin()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();

View File

@ -116,7 +116,7 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
I != E; ++I) {
// Print a label for the basic block.
if (I != MF.begin()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();

View File

@ -101,36 +101,25 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
if (Subtarget->isTargetDarwin())
// FIXME: This should be parameterized somewhere.
EmitAlignment(4, F, 0, true, 0x90);
else
EmitAlignment(4, F);
EmitAlignment(4, F);
break;
case Function::DLLExportLinkage:
DLLExportedFns.insert(Mang->makeNameProper(F->getName(), ""));
//FALLS THROUGH
case Function::ExternalLinkage:
if (Subtarget->isTargetDarwin())
// FIXME: This should be parameterized somewhere.
EmitAlignment(4, F, 0, true, 0x90);
else
EmitAlignment(4, F);
EmitAlignment(4, F);
O << "\t.globl\t" << CurrentFnName << "\n";
break;
case Function::LinkOnceLinkage:
case Function::WeakLinkage:
EmitAlignment(4, F);
if (Subtarget->isTargetDarwin()) {
// FIXME: This should be parameterized somewhere.
EmitAlignment(4, F, 0, true, 0x90);
O << "\t.globl\t" << CurrentFnName << "\n";
O << TAI->getWeakDefDirective() << CurrentFnName << "\n";
} else if (Subtarget->isTargetCygMing()) {
EmitAlignment(4, F);
O << "\t.globl\t" << CurrentFnName << "\n";
O << "\t.linkonce discard\n";
} else {
EmitAlignment(4, F);
O << "\t.weak\t" << CurrentFnName << "\n";
}
break;
@ -180,7 +169,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
I != E; ++I) {
// Print a label for the basic block.
if (!I->pred_empty()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
@ -515,7 +504,7 @@ void X86ATTAsmPrinter::printPICJumpTableSetLabel(unsigned uid,
O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
if (Subtarget->isPICStyleRIPRel())
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << uid << '\n';
@ -543,12 +532,12 @@ void X86ATTAsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< '_' << uid << "_set_" << MBB->getNumber();
} else if (Subtarget->isPICStyleGOT()) {
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
O << "@GOTOFF";
} else
assert(0 && "Don't know how to print MBB label for this PIC mode");
} else
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
}
bool X86ATTAsmPrinter::printAsmMRegister(const MachineOperand &MO,

View File

@ -714,6 +714,7 @@ X86TargetLowering::X86TargetLowering(TargetMachine &TM)
maxStoresPerMemcpy = 16; // For %llvm.memcpy -> sequence of stores
maxStoresPerMemmove = 16; // For %llvm.memmove -> sequence of stores
allowUnalignedMemoryAccesses = true; // x86 supports it!
setPrefLoopAlignment(16);
}
/// getMaxByValAlign - Helper for getByValTypeAlignment to determine

View File

@ -78,7 +78,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
I != E; ++I) {
// Print a label for the basic block if there are any predecessors.
if (!I->pred_empty()) {
printBasicBlockLabel(I, true);
printBasicBlockLabel(I, true, true);
O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
@ -242,7 +242,7 @@ void X86IntelAsmPrinter::printPICJumpTableSetLabel(unsigned uid,
O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
printBasicBlockLabel(MBB, false, false);
printBasicBlockLabel(MBB, false, false, false);
O << '-' << "\"L" << getFunctionNumber() << "$pb\"'\n";
}

View File

@ -47,6 +47,7 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
switch (Subtarget->TargetType) {
case X86Subtarget::isDarwin:
AlignmentIsInBytes = false;
TextAlignFillValue = 0x90;
GlobalPrefix = "_";
if (!Subtarget->is64Bit())
Data64bitsDirective = 0; // we can't emit a 64-bit unit

View File

@ -164,6 +164,13 @@ bool X86TargetMachine::addPostRegAlloc(FunctionPassManager &PM, bool Fast) {
return true; // -print-machineinstr should print after this.
}
bool X86TargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
if (Fast) return false;
PM.add(createLoopAlignerPass());
return true;
}
bool X86TargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
std::ostream &Out) {
PM.add(createX86CodePrinterPass(Out, *this));

View File

@ -63,6 +63,7 @@ public:
// Set up the pass pipeline.
virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
virtual bool addPostRegAlloc(FunctionPassManager &PM, bool Fast);
virtual bool addPreEmitPass(FunctionPassManager &PM, bool Fast);
virtual bool addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
std::ostream &Out);
virtual bool addCodeEmitter(FunctionPassManager &PM, bool Fast,