/// the specified global variable or function definition. This should not
/// be passed external (or available externally) globals.
const Section *SectionForGlobal(const GlobalValue *GV,
+ Mangler *Mang,
const TargetMachine &TM) const;
/// getSpecialCasedSectionGlobals - Allow the target to completely override
/// FIXME: ELIMINATE this by making PIC16 implement ADDRESS with
/// getFlagsForNamedSection.
virtual const Section *
- getSpecialCasedSectionGlobals(const GlobalValue *GV,
+ getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
SectionKind Kind) const {
return 0;
}
}
protected:
- virtual const Section *SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind Kind,
- const TargetMachine &TM) const;
+ virtual const Section *
+ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
+ Mangler *Mang, const TargetMachine &TM) const;
};
void getSectionFlagsAsString(SectionKind Kind,
SmallVectorImpl<char> &Str) const;
- virtual const Section* SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind Kind,
- const TargetMachine &TM) const;
+ virtual const Section *
+ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
+ Mangler *Mang, const TargetMachine &TM) const;
protected:
const Section *DataRelSection;
const Section *DataRelLocalSection;
const Section *SixteenByteConstantSection;
public:
TargetLoweringObjectFileMachO(const TargetMachine &TM);
- virtual const Section *SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind Kind,
- const TargetMachine &TM) const;
+ virtual const Section *
+ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
+ Mangler *Mang, const TargetMachine &TM) const;
virtual const Section *
getSectionForMergeableConstant(SectionKind Kind) const;
virtual const Section *
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
- const TargetMachine &TM) const;
+ Mangler *Mang, const TargetMachine &TM) const;
};
} // end namespace llvm
// the appropriate section.
TargetLowering *LoweringInfo = TM.getTargetLowering();
- const char* JumpTableDataSection = TAI->getJumpTableDataSection();
+ const char *JumpTableDataSection = TAI->getJumpTableDataSection();
const Function *F = MF.getFunction();
- const Section *FuncSection = getObjFileLowering().SectionForGlobal(F, TM);
+ const Section *FuncSection =
+ getObjFileLowering().SectionForGlobal(F, Mang, TM);
bool JTInDiffSection = false;
if ((IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) ||
TM.getTargetLowering()->getObjFileLowering();
// Get the ELF section where this global belongs from TLOF
- const Section *S = TLOF.SectionForGlobal(GV, TM);
+ const Section *S = TLOF.SectionForGlobal(GV, Mang, TM);
unsigned SectionFlags = getElfSectionFlags(S->getKind());
// The symbol align should update the section alignment if needed
if (Subtarget->isTargetELF())
O << "\t.type " << name << ",%object\n";
- const Section *TheSection = getObjFileLowering().SectionForGlobal(GVar, TM);
+ const Section *TheSection =
+ getObjFileLowering().SectionForGlobal(GVar, Mang, TM);
SwitchToSection(TheSection);
// FIXME: get this stuff from section kind flags.
O << TAI->getCOMMDirective() << name << "," << Size
<< ',' << Align;
} else {
- SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, Mang,TM));
O << "\t.globl " << name << '\n'
<< TAI->getWeakDefDirective() << name << '\n';
EmitAlignment(Align, GVar);
// Print out labels for the function.
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
EmitAlignment(MF.getAlignment(), F);
switch (F->getLinkage()) {
unsigned Align = TD->getPreferredAlignmentLog(GVar);
// 0: Switch to section
- SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM));
// 1: Check visibility
printVisibility(name, GVar->getVisibility());
// Print out labels for the function.
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
EmitAlignment(MF.getAlignment(), F);
switch (F->getLinkage()) {
unsigned Size = TD->getTypeAllocSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
- SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM));
if (C->isNullValue() && /* FIXME: Verify correct */
!GVar->hasSection() &&
void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
unsigned FnAlign = MF.getAlignment();
EmitAlignment(FnAlign, F);
//===----------------------------------------------------------------------===//
/// Frame Directive
-void MipsAsmPrinter::
-emitFrameDirective(MachineFunction &MF)
-{
+void MipsAsmPrinter::emitFrameDirective(MachineFunction &MF) {
const TargetRegisterInfo &RI = *TM.getRegisterInfo();
unsigned stackReg = RI.getFrameRegister(MF);
}
/// Emit Set directives.
-const char * MipsAsmPrinter::
-emitCurrentABIString(void)
-{
+const char *MipsAsmPrinter::emitCurrentABIString() {
switch(Subtarget->getTargetABI()) {
case MipsSubtarget::O32: return "abi32";
case MipsSubtarget::O64: return "abiO64";
void MipsAsmPrinter::emitFunctionStart(MachineFunction &MF) {
// Print out the label for the function.
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
// 2 bits aligned
EmitAlignment(MF.getAlignment(), F);
}
/// Emit the directives used by GAS on the end of functions
-void MipsAsmPrinter::
-emitFunctionEnd(MachineFunction &MF)
-{
+void MipsAsmPrinter::emitFunctionEnd(MachineFunction &MF) {
// There are instruction for this macros, but they must
// always be at the function end, and we can't emit and
// break with BB logic.
/// runOnMachineFunction - This uses the printMachineInstruction()
/// method to print assembly for each instruction.
-bool MipsAsmPrinter::
-runOnMachineFunction(MachineFunction &MF)
-{
+bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
this->MF = &MF;
SetupMachineFunction(MF);
}
// Print out an operand for an inline asm expression.
-bool MipsAsmPrinter::
-PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
- unsigned AsmVariant, const char *ExtraCode)
-{
+bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
+ unsigned AsmVariant,const char *ExtraCode){
// Does this asm operand have a single letter operand modifier?
if (ExtraCode && ExtraCode[0])
return true; // Unknown modifier.
return false;
}
-void MipsAsmPrinter::
-printOperand(const MachineInstr *MI, int opNum)
-{
+void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
const MachineOperand &MO = MI->getOperand(opNum);
const TargetRegisterInfo &RI = *TM.getRegisterInfo();
bool closeP = false;
if (closeP) O << ")";
}
-void MipsAsmPrinter::
-printUnsignedImm(const MachineInstr *MI, int opNum) {
+void MipsAsmPrinter::printUnsignedImm(const MachineInstr *MI, int opNum) {
const MachineOperand &MO = MI->getOperand(opNum);
if (MO.getType() == MachineOperand::MO_Immediate)
O << (unsigned short int)MO.getImm();
printVisibility(name, GVar->getVisibility());
- SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM));
if (C->isNullValue() && !GVar->hasSection()) {
if (!GVar->isThreadLocal() &&
// Set the section names for all globals.
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I)
- I->setSection(getObjFileLowering().SectionForGlobal(I, TM)->getName());
+ I->setSection(getObjFileLowering().SectionForGlobal(I, Mang,TM)->getName());
DbgInfo.BeginModule(M);
EmitFunctionDecls(M);
const Section*
PIC16TargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV1,
SectionKind Kind,
+ Mangler *Mang,
const TargetMachine &TM) const {
// We select the section based on the initializer here, so it really
// has to be a GlobalVariable.
const GlobalVariable *GV = dyn_cast<GlobalVariable>(GV1);
if (!GV)
- return TargetLoweringObjectFile::SelectSectionForGlobal(GV1, Kind, TM);
+ return TargetLoweringObjectFile::SelectSectionForGlobal(GV1, Kind, Mang,TM);
// Record External Var Decls.
if (GV->isDeclaration()) {
return getROSectionForGlobal(GV);
// Else let the default implementation take care of it.
- return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, TM);
+ return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, Mang,TM);
}
PIC16TargetObjectFile::~PIC16TargetObjectFile() {
/// section assignment of a global.
const Section *
PIC16TargetObjectFile::getSpecialCasedSectionGlobals(const GlobalValue *GV,
+ Mangler *Mang,
SectionKind Kind) const {
// If GV has a sectin name or section address create that section now.
if (GV->hasSection()) {
std::string AddrStr = "Address=";
if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) {
std::string SectAddr = SectName.substr(AddrStr.length());
- return CreateSectionForGlobal(GVar, SectAddr);
+ return CreateSectionForGlobal(GVar, Mang, SectAddr);
}
// Create the section specified with section attribute.
- return CreateSectionForGlobal(GVar);
+ return CreateSectionForGlobal(GVar, Mang);
}
}
// section at that address else create by name.
const Section *
PIC16TargetObjectFile::CreateSectionForGlobal(const GlobalVariable *GV,
+ Mangler *Mang,
const std::string &Addr) const {
// See if this is an uninitialized global.
const Constant *C = GV->getInitializer();
return CreateROSectionForGlobal(GV, Addr);
// Else let the default implementation take care of it.
- return TargetLoweringObjectFile::SectionForGlobal(GV, TM);
+ return TargetLoweringObjectFile::SectionForGlobal(GV, Mang, TM);
}
// Create uninitialized section for a variable.
/// getSpecialCasedSectionGlobals - Allow the target to completely override
/// section assignment of a global.
virtual const Section *
- getSpecialCasedSectionGlobals(const GlobalValue *GV,
+ getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
SectionKind Kind) const;
virtual const Section *SelectSectionForGlobal(const GlobalValue *GV,
SectionKind Kind,
+ Mangler *Mang,
const TargetMachine&) const;
private:
std::string getSectionNameForSym(const std::string &Sym) const;
const Section *CreateROSectionForGlobal(const GlobalVariable *GV,
std::string Addr = "") const;
const Section *CreateSectionForGlobal(const GlobalVariable *GV,
+ Mangler *Mang,
const std::string &Addr = "") const;
public:
void SetSectionForGVs(Module &M);
// Print out labels for the function.
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!");
// Print out jump tables referenced by the function.
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
// Emit post-function debug information.
DW->EndFunction(&MF);
unsigned Size = TD->getTypeAllocSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
- SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM));
if (C->isNullValue() && /* FIXME: Verify correct */
!GVar->hasSection() &&
// Print out labels for the function.
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!");
unsigned Size = TD->getTypeAllocSize(Type);
unsigned Align = TD->getPreferredAlignmentLog(GVar);
- const Section *TheSection = getObjFileLowering().SectionForGlobal(GVar, TM);
+ const Section *TheSection =
+ getObjFileLowering().SectionForGlobal(GVar, Mang, TM);
SwitchToSection(TheSection);
if (C->isNullValue() && /* FIXME: Verify correct */
// Print out the label for the function.
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
EmitAlignment(MF.getAlignment(), F);
O << "\t.globl\t" << CurrentFnName << '\n';
printVisibility(name, GVar->getVisibility());
- SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM));
if (C->isNullValue() && !GVar->hasSection()) {
if (!GVar->isThreadLocal() &&
unsigned FnAlign = MF.getAlignment();
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
EmitAlignment(FnAlign, F);
O << "\t.type\t" << name << ",@object\n";
- SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM));
if (C->isNullValue() && !GVar->hasSection() &&
!GVar->isThreadLocal() &&
/// the specified global variable or function definition. This should not
/// be passed external (or available externally) globals.
const Section *TargetLoweringObjectFile::
-SectionForGlobal(const GlobalValue *GV, const TargetMachine &TM) const {
+SectionForGlobal(const GlobalValue *GV, Mangler *Mang,
+ const TargetMachine &TM) const {
assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() &&
"Can only be used for global definitions");
if (GV->hasSection()) {
// If the target has special section hacks for specifically named globals,
// return them now.
- if (const Section *TS = getSpecialCasedSectionGlobals(GV, Kind))
+ if (const Section *TS = getSpecialCasedSectionGlobals(GV, Mang, Kind))
return TS;
// If the target has magic semantics for certain section names, make sure to
// Use default section depending on the 'type' of global
- return SelectSectionForGlobal(GV, Kind, TM);
+ return SelectSectionForGlobal(GV, Kind, Mang, TM);
}
// Lame default implementation. Calculate the section name for global.
const Section*
TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
SectionKind Kind,
+ Mangler *Mang,
const TargetMachine &TM) const{
assert(!Kind.isThreadLocal() && "Doesn't support TLS");
const Section *TargetLoweringObjectFileELF::
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
- const TargetMachine &TM) const {
+ Mangler *Mang, const TargetMachine &TM) const {
// If this global is linkonce/weak and the target handles this by emitting it
// into a 'uniqued' section name, create and return the section now.
}
if (Kind.isText()) return TextSection;
+
if (Kind.isMergeableCString()) {
assert(CStringSection_ && "Should have string section prefix");
false, SectionKind::DataRel);
}
-const Section *
-TargetLoweringObjectFileMachO::SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind Kind,
- const TargetMachine &TM) const {
+const Section *TargetLoweringObjectFileMachO::
+SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
+ Mangler *Mang, const TargetMachine &TM) const {
assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS");
if (Kind.isText())
const Section *TargetLoweringObjectFileCOFF::
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
- const TargetMachine &TM) const {
+ Mangler *Mang, const TargetMachine &TM) const {
assert(!Kind.isThreadLocal() && "Doesn't support TLS");
// If this global is linkonce/weak and the target handles this by emitting it
if (Subtarget->isTargetCygMing())
DecorateCygMingName(CurrentFnName, F);
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
if (Subtarget->isTargetELF())
O << "\t.type\t" << name << ",@object\n";
- const Section *TheSection = getObjFileLowering().SectionForGlobal(GVar, TM);
+ const Section *TheSection =
+ getObjFileLowering().SectionForGlobal(GVar, Mang, TM);
SwitchToSection(TheSection);
if (C->isNullValue() && !GVar->hasSection() &&
const TargetData *TD = TM.getTargetData();
- SwitchToSection(getObjFileLowering().SectionForGlobal(GV, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(GV, Mang, TM));
std::string name = Mang->getMangledName(GV);
Constant *C = GV->getInitializer();
// Print out the label for the function.
const Function *F = MF.getFunction();
- SwitchToSection(getObjFileLowering().SectionForGlobal(F, TM));
+ SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
// Mark the start of the function
O << "\t.cc_top " << CurrentFnName << ".function," << CurrentFnName << "\n";