mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-16 08:08:01 +00:00
make AsmPrinter::doFinalization iterate over the global variables
and call PrintGlobalVariable, allowing elimination and simplification of various targets. llvm-svn: 76604
This commit is contained in:
parent
979d7aa03a
commit
3d4ab7a231
@ -211,6 +211,11 @@ namespace llvm {
|
||||
unsigned AsmVariant,
|
||||
const char *ExtraCode);
|
||||
|
||||
|
||||
/// PrintGlobalVariable - Emit the specified global variable and its
|
||||
/// initializer to the output stream.
|
||||
virtual void PrintGlobalVariable(const GlobalVariable *GV) = 0;
|
||||
|
||||
/// SetupMachineFunction - This should be called when a new MachineFunction
|
||||
/// is being processed from runOnMachineFunction.
|
||||
void SetupMachineFunction(MachineFunction &MF);
|
||||
|
@ -196,6 +196,11 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||
}
|
||||
|
||||
bool AsmPrinter::doFinalization(Module &M) {
|
||||
// Emit global variables.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
PrintGlobalVariable(I);
|
||||
|
||||
// Emit final debug information.
|
||||
if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling())
|
||||
DW->EndModule();
|
||||
|
@ -166,7 +166,7 @@ namespace {
|
||||
unsigned AsmVariant,
|
||||
const char *ExtraCode);
|
||||
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable* GVar);
|
||||
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
||||
void printMachineInstruction(const MachineInstr *MI);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
@ -1066,7 +1066,7 @@ static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS)
|
||||
OS << *Name;
|
||||
}
|
||||
|
||||
void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer()) // External global require no code
|
||||
@ -1207,10 +1207,6 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
|
||||
|
||||
bool ARMAsmPrinter::doFinalization(Module &M) {
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
if (Subtarget->isTargetDarwin()) {
|
||||
SwitchToDataSection("");
|
||||
|
||||
|
@ -49,11 +49,10 @@ namespace {
|
||||
bool printInstruction(const MachineInstr *MI);
|
||||
void printOp(const MachineOperand &MO, bool IsCallOp = false);
|
||||
void printOperand(const MachineInstr *MI, int opNum);
|
||||
void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true);
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void printBaseOffsetPair(const MachineInstr *MI, int i, bool brackets=true);
|
||||
void PrintGlobalVariable(const GlobalVariable *GVar);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doInitialization(Module &M);
|
||||
bool doFinalization(Module &M);
|
||||
|
||||
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
unsigned AsmVariant, const char *ExtraCode);
|
||||
@ -209,7 +208,7 @@ bool AlphaAsmPrinter::doInitialization(Module &M)
|
||||
return AsmPrinter::doInitialization(M);
|
||||
}
|
||||
|
||||
void AlphaAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void AlphaAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer()) return; // External global require no code
|
||||
@ -266,14 +265,6 @@ void AlphaAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
bool AlphaAsmPrinter::doFinalization(Module &M) {
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
||||
/// PrintAsmOperand - Print out an operand for an inline asm expression.
|
||||
///
|
||||
bool AlphaAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
|
@ -282,8 +282,6 @@ namespace {
|
||||
}
|
||||
|
||||
virtual bool runOnMachineFunction(MachineFunction &F) = 0;
|
||||
//! Assembly printer cleanup after function has been emitted
|
||||
virtual bool doFinalization(Module &M) = 0;
|
||||
};
|
||||
|
||||
/// LinuxAsmPrinter - SPU assembly printer, customized for Linux
|
||||
@ -300,8 +298,6 @@ namespace {
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doInitialization(Module &M);
|
||||
//! Dump globals, perform cleanup after function emission
|
||||
bool doFinalization(Module &M);
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.setPreservesAll();
|
||||
@ -311,7 +307,7 @@ namespace {
|
||||
}
|
||||
|
||||
//! Emit a global variable according to its section and type
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable* GVar);
|
||||
};
|
||||
} // end of anonymous namespace
|
||||
|
||||
@ -507,7 +503,7 @@ static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS)
|
||||
\note This code was shamelessly copied from the PowerPC's assembly printer,
|
||||
which sort of screams for some kind of refactorization of common code.
|
||||
*/
|
||||
void LinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer())
|
||||
@ -588,15 +584,6 @@ void LinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
bool LinuxAsmPrinter::doFinalization(Module &M) {
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
||||
/// createSPUCodePrinterPass - Returns a pass that prints the Cell SPU
|
||||
/// assembly code for a MachineFunction to the given output stream, in a format
|
||||
/// that the Linux SPU assembler can deal with.
|
||||
|
@ -111,7 +111,7 @@ namespace {
|
||||
|
||||
void printMachineInstruction(const MachineInstr *MI);
|
||||
void printOp(const MachineOperand &MO, bool isBRCALLinsn= false);
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable *GVar);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doInitialization(Module &M);
|
||||
bool doFinalization(Module &M);
|
||||
@ -258,7 +258,7 @@ bool IA64AsmPrinter::doInitialization(Module &M) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void IA64AsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer())
|
||||
@ -342,11 +342,6 @@ void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
|
||||
|
||||
bool IA64AsmPrinter::doFinalization(Module &M) {
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
// we print out ".global X \n .type X, @function" for each external function
|
||||
O << "\n\n// br.call targets referenced (and not defined) above: \n";
|
||||
for (std::set<std::string>::iterator i = ExternalFunctionNames.begin(),
|
||||
|
@ -59,6 +59,10 @@ namespace {
|
||||
void emitFunctionHeader(const MachineFunction &MF);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
|
||||
virtual void PrintGlobalVariable(const GlobalVariable *GV) {
|
||||
// FIXME: No support for global variables?
|
||||
}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AsmPrinter::getAnalysisUsage(AU);
|
||||
AU.setPreservesAll();
|
||||
|
@ -70,7 +70,7 @@ namespace {
|
||||
const char *Modifier = 0);
|
||||
void printFCCOperand(const MachineInstr *MI, int opNum,
|
||||
const char *Modifier = 0);
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable *GVar);
|
||||
void printSavedRegsBitmask(MachineFunction &MF);
|
||||
void printHex32(unsigned int Value);
|
||||
|
||||
@ -82,7 +82,6 @@ namespace {
|
||||
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doInitialization(Module &M);
|
||||
bool doFinalization(Module &M);
|
||||
};
|
||||
} // end of anonymous namespace
|
||||
|
||||
@ -462,8 +461,7 @@ bool MipsAsmPrinter::doInitialization(Module &M) {
|
||||
return AsmPrinter::doInitialization(M);
|
||||
}
|
||||
|
||||
void MipsAsmPrinter::
|
||||
printModuleLevelGV(const GlobalVariable *GVar) {
|
||||
void MipsAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer())
|
||||
@ -559,18 +557,6 @@ printModuleLevelGV(const GlobalVariable *GVar) {
|
||||
EmitGlobalConstant(C);
|
||||
}
|
||||
|
||||
bool MipsAsmPrinter::
|
||||
doFinalization(Module &M)
|
||||
{
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(),
|
||||
E = M.global_end(); I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
O << '\n';
|
||||
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
||||
// Force static initialization.
|
||||
extern "C" void LLVMInitializeMipsAsmPrinter() {
|
||||
|
@ -291,8 +291,7 @@ bool PIC16AsmPrinter::doFinalization(Module &M) {
|
||||
EmitRemainingAutos();
|
||||
DbgInfo.EndModule(M);
|
||||
O << "\n\t" << "END\n";
|
||||
bool Result = AsmPrinter::doFinalization(M);
|
||||
return Result;
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
||||
void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- PIC16AsmPrinter.h - PIC16 LLVM assembly writer ------------------===//
|
||||
//===-- PIC16AsmPrinter.h - PIC16 LLVM assembly writer ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -35,7 +35,7 @@ namespace llvm {
|
||||
PTLI = static_cast<const PIC16TargetLowering *> (TM.getTargetLowering());
|
||||
PTAI = static_cast<const PIC16TargetAsmInfo *> (T);
|
||||
}
|
||||
private :
|
||||
private:
|
||||
virtual const char *getPassName() const {
|
||||
return "PIC16 Assembly Printer";
|
||||
}
|
||||
@ -55,11 +55,17 @@ namespace llvm {
|
||||
void EmitRomData (Module &M);
|
||||
void EmitFunctionFrame(MachineFunction &MF);
|
||||
void printLibcallDecls(void);
|
||||
protected:
|
||||
protected:
|
||||
bool doInitialization(Module &M);
|
||||
bool doFinalization(Module &M);
|
||||
|
||||
private:
|
||||
/// PrintGlobalVariable - Emit the specified global variable and its
|
||||
/// initializer to the output stream.
|
||||
virtual void PrintGlobalVariable(const GlobalVariable *GV) {
|
||||
// PIC16 doesn't use normal hooks for this.
|
||||
}
|
||||
|
||||
private:
|
||||
PIC16TargetLowering *PTLI;
|
||||
PIC16DbgInfo DbgInfo;
|
||||
const PIC16TargetAsmInfo *PTAI;
|
||||
|
@ -313,7 +313,6 @@ namespace {
|
||||
const char *Modifier);
|
||||
|
||||
virtual bool runOnMachineFunction(MachineFunction &F) = 0;
|
||||
virtual bool doFinalization(Module &M) = 0;
|
||||
|
||||
virtual void EmitExternalGlobal(const GlobalVariable *GV);
|
||||
};
|
||||
@ -330,7 +329,6 @@ namespace {
|
||||
}
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doFinalization(Module &M);
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.setPreservesAll();
|
||||
@ -339,7 +337,7 @@ namespace {
|
||||
PPCAsmPrinter::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable *GVar);
|
||||
};
|
||||
|
||||
/// PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac
|
||||
@ -366,7 +364,7 @@ namespace {
|
||||
PPCAsmPrinter::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable *GVar);
|
||||
};
|
||||
} // end of anonymous namespace
|
||||
|
||||
@ -661,7 +659,7 @@ static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS)
|
||||
OS << *Name;
|
||||
}
|
||||
|
||||
void PPCLinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer())
|
||||
@ -748,14 +746,6 @@ void PPCLinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||
/// method to print assembly for each instruction.
|
||||
@ -875,7 +865,7 @@ bool PPCDarwinAsmPrinter::doInitialization(Module &M) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
void PPCDarwinAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer())
|
||||
@ -982,11 +972,6 @@ void PPCDarwinAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
bool isPPC64 = TD->getPointerSizeInBits() == 64;
|
||||
|
||||
// Output stubs for dynamically-linked functions
|
||||
@ -1093,11 +1078,9 @@ FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o,
|
||||
bool verbose) {
|
||||
const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
|
||||
|
||||
if (Subtarget->isDarwin()) {
|
||||
if (Subtarget->isDarwin())
|
||||
return new PPCDarwinAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
|
||||
} else {
|
||||
return new PPCLinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
|
||||
}
|
||||
return new PPCLinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
|
||||
}
|
||||
|
||||
// Force static initialization.
|
||||
|
@ -59,7 +59,7 @@ namespace {
|
||||
return "Sparc Assembly Printer";
|
||||
}
|
||||
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable *GVar);
|
||||
void printOperand(const MachineInstr *MI, int opNum);
|
||||
void printMemOperand(const MachineInstr *MI, int opNum,
|
||||
const char *Modifier = 0);
|
||||
@ -67,7 +67,6 @@ namespace {
|
||||
|
||||
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doFinalization(Module &M);
|
||||
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
unsigned AsmVariant, const char *ExtraCode);
|
||||
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
@ -221,18 +220,7 @@ void SparcAsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) {
|
||||
O << SPARCCondCodeToString((SPCC::CondCodes)CC);
|
||||
}
|
||||
|
||||
bool SparcAsmPrinter::doFinalization(Module &M) {
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
O << '\n';
|
||||
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
||||
void SparcAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer())
|
||||
|
@ -67,8 +67,7 @@ namespace {
|
||||
|
||||
void emitFunctionHeader(const MachineFunction &MF);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doFinalization(Module &M);
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable* GVar);
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AsmPrinter::getAnalysisUsage(AU);
|
||||
@ -90,15 +89,6 @@ FunctionPass *llvm::createSystemZCodePrinterPass(formatted_raw_ostream &o,
|
||||
return new SystemZAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
|
||||
}
|
||||
|
||||
bool SystemZAsmPrinter::doFinalization(Module &M) {
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I)
|
||||
printModuleLevelGV(I);
|
||||
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
||||
void SystemZAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
|
||||
unsigned FnAlign = MF.getAlignment();
|
||||
const Function *F = MF.getFunction();
|
||||
@ -331,7 +321,7 @@ static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS)
|
||||
OS << *Name;
|
||||
}
|
||||
|
||||
void SystemZAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer())
|
||||
|
@ -763,7 +763,7 @@ bool X86ATTAsmPrinter::doInitialization(Module &M) {
|
||||
return AsmPrinter::doInitialization(M);
|
||||
}
|
||||
|
||||
void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
if (!GVar->hasInitializer())
|
||||
@ -902,8 +902,6 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I) {
|
||||
printModuleLevelGV(I);
|
||||
|
||||
if (I->hasDLLExportLinkage())
|
||||
DLLExportedGVs.insert(Mang->getMangledName(I));
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {
|
||||
unsigned uid) const;
|
||||
|
||||
void printPICLabel(const MachineInstr *MI, unsigned Op);
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
void PrintGlobalVariable(const GlobalVariable* GVar);
|
||||
|
||||
void PrintPICBaseSymbol() const;
|
||||
|
||||
|
@ -474,71 +474,68 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool X86IntelAsmPrinter::doFinalization(Module &M) {
|
||||
void X86IntelAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
|
||||
// Check to see if this is a special global used by LLVM, if so, emit it.
|
||||
if (GV->isDeclaration() ||
|
||||
EmitSpecialLLVMGlobal(GV))
|
||||
return;
|
||||
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
// Print out module-level global variables here.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I) {
|
||||
if (I->isDeclaration()) continue; // External global require no code
|
||||
|
||||
// Check to see if this is a special global used by LLVM, if so, emit it.
|
||||
if (EmitSpecialLLVMGlobal(I))
|
||||
continue;
|
||||
|
||||
std::string name = Mang->getMangledName(I);
|
||||
Constant *C = I->getInitializer();
|
||||
unsigned Align = TD->getPreferredAlignmentLog(I);
|
||||
bool bCustomSegment = false;
|
||||
|
||||
switch (I->getLinkage()) {
|
||||
case GlobalValue::CommonLinkage:
|
||||
case GlobalValue::LinkOnceAnyLinkage:
|
||||
case GlobalValue::LinkOnceODRLinkage:
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
SwitchToDataSection("");
|
||||
O << name << "?\tSEGEMNT PARA common 'COMMON'\n";
|
||||
bCustomSegment = true;
|
||||
// FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256
|
||||
// are also available.
|
||||
break;
|
||||
case GlobalValue::AppendingLinkage:
|
||||
SwitchToDataSection("");
|
||||
O << name << "?\tSEGMENT PARA public 'DATA'\n";
|
||||
bCustomSegment = true;
|
||||
// FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256
|
||||
// are also available.
|
||||
break;
|
||||
case GlobalValue::DLLExportLinkage:
|
||||
DLLExportedGVs.insert(name);
|
||||
// FALL THROUGH
|
||||
case GlobalValue::ExternalLinkage:
|
||||
O << "\tpublic " << name << "\n";
|
||||
// FALL THROUGH
|
||||
case GlobalValue::InternalLinkage:
|
||||
SwitchToSection(TAI->getDataSection());
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unknown linkage type!");
|
||||
}
|
||||
|
||||
if (!bCustomSegment)
|
||||
EmitAlignment(Align, I);
|
||||
|
||||
O << name << ":";
|
||||
if (VerboseAsm)
|
||||
O << "\t\t\t\t" << TAI->getCommentString()
|
||||
<< " " << I->getName();
|
||||
O << '\n';
|
||||
|
||||
EmitGlobalConstant(C);
|
||||
|
||||
if (bCustomSegment)
|
||||
O << name << "?\tends\n";
|
||||
std::string name = Mang->getMangledName(GV);
|
||||
Constant *C = GV->getInitializer();
|
||||
unsigned Align = TD->getPreferredAlignmentLog(GV);
|
||||
bool bCustomSegment = false;
|
||||
|
||||
switch (GV->getLinkage()) {
|
||||
case GlobalValue::CommonLinkage:
|
||||
case GlobalValue::LinkOnceAnyLinkage:
|
||||
case GlobalValue::LinkOnceODRLinkage:
|
||||
case GlobalValue::WeakAnyLinkage:
|
||||
case GlobalValue::WeakODRLinkage:
|
||||
SwitchToDataSection("");
|
||||
O << name << "?\tSEGEMNT PARA common 'COMMON'\n";
|
||||
bCustomSegment = true;
|
||||
// FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256
|
||||
// are also available.
|
||||
break;
|
||||
case GlobalValue::AppendingLinkage:
|
||||
SwitchToDataSection("");
|
||||
O << name << "?\tSEGMENT PARA public 'DATA'\n";
|
||||
bCustomSegment = true;
|
||||
// FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256
|
||||
// are also available.
|
||||
break;
|
||||
case GlobalValue::DLLExportLinkage:
|
||||
DLLExportedGVs.insert(name);
|
||||
// FALL THROUGH
|
||||
case GlobalValue::ExternalLinkage:
|
||||
O << "\tpublic " << name << "\n";
|
||||
// FALL THROUGH
|
||||
case GlobalValue::InternalLinkage:
|
||||
SwitchToSection(TAI->getDataSection());
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unknown linkage type!");
|
||||
}
|
||||
|
||||
if (!bCustomSegment)
|
||||
EmitAlignment(Align, GV);
|
||||
|
||||
O << name << ":";
|
||||
if (VerboseAsm)
|
||||
O << "\t\t\t\t" << TAI->getCommentString()
|
||||
<< " " << GV->getName();
|
||||
O << '\n';
|
||||
|
||||
EmitGlobalConstant(C);
|
||||
|
||||
if (bCustomSegment)
|
||||
O << name << "?\tends\n";
|
||||
}
|
||||
|
||||
// Output linker support code for dllexported globals
|
||||
bool X86IntelAsmPrinter::doFinalization(Module &M) {
|
||||
// Output linker support code for dllexported globals
|
||||
if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) {
|
||||
SwitchToDataSection("");
|
||||
O << "; WARNING: The following code is valid only with MASM v8.x"
|
||||
|
@ -135,6 +135,8 @@ struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter {
|
||||
bool doInitialization(Module &M);
|
||||
bool doFinalization(Module &M);
|
||||
|
||||
void PrintGlobalVariable(const GlobalVariable *GV);
|
||||
|
||||
// We have to propagate some information about MachineFunction to
|
||||
// AsmPrinter. It's ok, when we're printing the function, since we have
|
||||
// access to MachineFunction and can get the appropriate MachineFunctionInfo.
|
||||
|
@ -70,7 +70,7 @@ namespace {
|
||||
void emitExternDirective(const std::string &name);
|
||||
|
||||
void emitArrayBound(const std::string &name, const GlobalVariable *GV);
|
||||
void emitGlobal(const GlobalVariable *GV);
|
||||
virtual void PrintGlobalVariable(const GlobalVariable *GV);
|
||||
|
||||
void emitFunctionStart(MachineFunction &MF);
|
||||
void emitFunctionEnd(MachineFunction &MF);
|
||||
@ -79,7 +79,6 @@ namespace {
|
||||
void printMachineInstruction(const MachineInstr *MI);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doInitialization(Module &M);
|
||||
bool doFinalization(Module &M);
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AsmPrinter::getAnalysisUsage(AU);
|
||||
@ -136,7 +135,7 @@ emitArrayBound(const std::string &name, const GlobalVariable *GV)
|
||||
}
|
||||
}
|
||||
|
||||
void XCoreAsmPrinter::emitGlobal(const GlobalVariable *GV) {
|
||||
void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
|
||||
// Check to see if this is a special global used by LLVM, if so, emit it.
|
||||
if (!GV->hasInitializer() ||
|
||||
EmitSpecialLLVMGlobal(GV))
|
||||
@ -387,13 +386,4 @@ bool XCoreAsmPrinter::doInitialization(Module &M) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool XCoreAsmPrinter::doFinalization(Module &M) {
|
||||
|
||||
// Print out module-level global variables.
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||
I != E; ++I) {
|
||||
emitGlobal(I);
|
||||
}
|
||||
|
||||
return AsmPrinter::doFinalization(M);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user