#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
+#include "llvm/MDNode.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DwarfWriter.h"
const PPCSubtarget &Subtarget;
public:
explicit PPCAsmPrinter(raw_ostream &O, TargetMachine &TM,
- const TargetAsmInfo *T, unsigned OL, bool V)
+ const TargetAsmInfo *T, CodeGenOpt::Level OL,
+ bool V)
: AsmPrinter(O, TM, T, OL, V),
Subtarget(TM.getSubtarget<PPCSubtarget>()) {}
std::string Name = Mang->getValueName(GV);
FnStubs.insert(Name);
printSuffixedName(Name, "$stub");
- if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(GV);
return;
}
}
/// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
class VISIBILITY_HIDDEN PPCLinuxAsmPrinter : public PPCAsmPrinter {
- DwarfWriter *DW;
- MachineModuleInfo *MMI;
public:
explicit PPCLinuxAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
- const TargetAsmInfo *T, unsigned OL, bool V)
- : PPCAsmPrinter(O, TM, T, OL, V), DW(0), MMI(0) {}
+ const TargetAsmInfo *T, CodeGenOpt::Level OL,
+ bool V)
+ : PPCAsmPrinter(O, TM, T, OL, V){}
virtual const char *getPassName() const {
return "Linux PPC Assembly Printer";
}
bool runOnMachineFunction(MachineFunction &F);
- bool doInitialization(Module &M);
bool doFinalization(Module &M);
void getAnalysisUsage(AnalysisUsage &AU) const {
/// PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac
/// OS X
class VISIBILITY_HIDDEN PPCDarwinAsmPrinter : public PPCAsmPrinter {
- DwarfWriter *DW;
- MachineModuleInfo *MMI;
raw_ostream &OS;
public:
explicit PPCDarwinAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
- const TargetAsmInfo *T, unsigned OL, bool V)
- : PPCAsmPrinter(O, TM, T, OL, V), DW(0), MMI(0), OS(O) {}
+ const TargetAsmInfo *T, CodeGenOpt::Level OL,
+ bool V)
+ : PPCAsmPrinter(O, TM, T, OL, V), OS(O) {}
virtual const char *getPassName() const {
return "Darwin PPC Assembly Printer";
GVStubs.insert(Name);
printSuffixedName(Name, "$non_lazy_ptr");
}
- if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(GV);
return;
}
}
O << Name;
printOffset(MO.getOffset());
-
- if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(GV);
return;
}
return false;
}
-bool PPCLinuxAsmPrinter::doInitialization(Module &M) {
- bool Result = AsmPrinter::doInitialization(M);
-
- // Emit initial debug information.
- MMI = getAnalysisIfAvailable<MachineModuleInfo>();
- assert(MMI);
- DW = getAnalysisIfAvailable<DwarfWriter>();
- assert(DW && "DwarfWriter is not available");
- DW->BeginModule(&M, MMI, O, this, TAI);
-
- // GNU as handles section names wrapped in quotes
- Mang->setUseQuotes(true);
-
- SwitchToSection(TAI->getTextSection());
-
- return Result;
-}
-
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
printVisibility(name, GVar->getVisibility());
Constant *C = GVar->getInitializer();
+ if (isa<MDNode>(C) || isa<MDString>(C))
+ return;
const Type *Type = C->getType();
- unsigned Size = TD->getTypePaddedSize(Type);
+ unsigned Size = TD->getTypeAllocSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
SwitchToSection(TAI->SectionForGlobal(GVar));
}
O << '\n';
- // If the initializer is a extern weak symbol, remember to emit the weak
- // reference!
- if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
- if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(GV);
-
EmitGlobalConstant(C);
O << '\n';
}
I != E; ++I)
printModuleLevelGV(I);
- // TODO
-
- // Emit initial debug information.
- DW->EndModule();
-
return AsmPrinter::doFinalization(M);
}
O << "\t.machine " << CPUDirectives[Directive] << '\n';
bool Result = AsmPrinter::doInitialization(M);
-
- // Emit initial debug information.
- // We need this for Personality functions.
- // AsmPrinter::doInitialization should have done this analysis.
- MMI = getAnalysisIfAvailable<MachineModuleInfo>();
assert(MMI);
- DW = getAnalysisIfAvailable<DwarfWriter>();
- assert(DW && "DwarfWriter is not available");
- DW->BeginModule(&M, MMI, O, this, TAI);
-
- // Darwin wants symbols to be quoted if they have complex names.
- Mang->setUseQuotes(true);
// Prime text sections so they are adjacent. This reduces the likelihood a
// large data or debug section causes a branch to exceed 16M limit.
Constant *C = GVar->getInitializer();
const Type *Type = C->getType();
- unsigned Size = TD->getTypePaddedSize(Type);
+ unsigned Size = TD->getTypeAllocSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
SwitchToSection(TAI->SectionForGlobal(GVar));
}
O << '\n';
- // If the initializer is a extern weak symbol, remember to emit the weak
- // reference!
- if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
- if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(GV);
-
EmitGlobalConstant(C);
O << '\n';
}
if (TAI->doesSupportExceptionHandling() && MMI) {
// Add the (possibly multiple) personalities to the set of global values.
// Only referenced functions get into the Personalities list.
- const std::vector<Function *>& Personalities = MMI->getPersonalities();
-
+ const std::vector<Function *> &Personalities = MMI->getPersonalities();
for (std::vector<Function *>::const_iterator I = Personalities.begin(),
E = Personalities.end(); I != E; ++I)
if (*I) GVStubs.insert("_" + (*I)->getName());
}
}
-
- // Emit initial debug information.
- DW->EndModule();
-
// Funny Darwin hack: This flag tells the linker that no global symbols
// contain code that falls through to other global symbols (e.g. the obvious
// implementation of multiple entry points). If this doesn't occur, the
///
FunctionPass *llvm::createPPCAsmPrinterPass(raw_ostream &o,
PPCTargetMachine &tm,
- unsigned OptLevel, bool verbose) {
+ CodeGenOpt::Level OptLevel,
+ bool verbose) {
const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
if (Subtarget->isDarwin()) {
extern "C" int PowerPCAsmPrinterForceLink;
int PowerPCAsmPrinterForceLink = 0;
+
+// Force static initialization.
+extern "C" void LLVMInitializePowerPCAsmPrinter() { }