mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-19 10:53:55 +00:00
Refactor various TargetAsmInfo subclasses' TargetMachine members away
adding a TargetMachine member to the base TargetAsmInfo class instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58624 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3a5797d946
commit
8f092252d3
@ -44,8 +44,6 @@ namespace llvm {
|
||||
const Section* MergeableConstSection(const Type *Ty) const;
|
||||
const Section* MergeableStringSection(const GlobalVariable *GV) const;
|
||||
const Section* SelectSectionForMachineConst(const Type *Ty) const;
|
||||
protected:
|
||||
const TargetMachine* DTM;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,6 @@ namespace llvm {
|
||||
const Section* MergeableStringSection(const GlobalVariable *GV) const;
|
||||
virtual const Section*
|
||||
SelectSectionForMachineConst(const Type *Ty) const;
|
||||
protected:
|
||||
const TargetMachine* ETM;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,9 @@ namespace llvm {
|
||||
mutable SectionFlags::FlagsStringsMapType FlagsStrings;
|
||||
void fillDefaultValues();
|
||||
protected:
|
||||
/// TM - The current TargetMachine.
|
||||
const TargetMachine &TM;
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// Properties to be set by the target writer, used to configure asm printer.
|
||||
//
|
||||
@ -510,8 +513,7 @@ namespace llvm {
|
||||
const char *const *AsmTransCBE; // Defaults to empty
|
||||
|
||||
public:
|
||||
TargetAsmInfo();
|
||||
TargetAsmInfo(const TargetMachine &TM);
|
||||
explicit TargetAsmInfo(const TargetMachine &TM);
|
||||
virtual ~TargetAsmInfo();
|
||||
|
||||
const Section* getNamedSection(const char *Name,
|
||||
|
@ -45,7 +45,7 @@ const char *const llvm::arm_asm_table[] = {
|
||||
|
||||
ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
|
||||
ARMTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
|
||||
Subtarget = &DTM->getSubtarget<ARMSubtarget>();
|
||||
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
||||
|
||||
GlobalPrefix = "_";
|
||||
PrivateGlobalPrefix = "L";
|
||||
@ -93,7 +93,7 @@ ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
|
||||
|
||||
ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM):
|
||||
ARMTargetAsmInfo<ELFTargetAsmInfo>(TM) {
|
||||
Subtarget = &ETM->getSubtarget<ARMSubtarget>();
|
||||
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
||||
|
||||
NeedsSet = false;
|
||||
HasLEB128 = true;
|
||||
|
@ -11,11 +11,13 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "AlphaTargetMachine.h"
|
||||
#include "AlphaTargetAsmInfo.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
AlphaTargetAsmInfo::AlphaTargetAsmInfo(const AlphaTargetMachine &TM) {
|
||||
AlphaTargetAsmInfo::AlphaTargetAsmInfo(const AlphaTargetMachine &TM)
|
||||
: TargetAsmInfo(TM) {
|
||||
AlignmentIsInBytes = false;
|
||||
PrivateGlobalPrefix = "$";
|
||||
JumpTableDirective = ".gprel32";
|
||||
|
@ -16,7 +16,8 @@
|
||||
#include "llvm/Function.h"
|
||||
using namespace llvm;
|
||||
|
||||
SPUTargetAsmInfo::SPUTargetAsmInfo(const SPUTargetMachine &TM) {
|
||||
SPUTargetAsmInfo::SPUTargetAsmInfo(const SPUTargetMachine &TM)
|
||||
: TargetAsmInfo(TM) {
|
||||
PCSymbol = ".";
|
||||
CommentString = "#";
|
||||
GlobalPrefix = "";
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) {
|
||||
DTM = &TM;
|
||||
DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
|
||||
: TargetAsmInfo(TM) {
|
||||
|
||||
CStringSection_ = getUnnamedSection("\t.cstring",
|
||||
SectionFlags::Mergeable | SectionFlags::Strings);
|
||||
@ -76,7 +76,7 @@ const Section*
|
||||
DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
||||
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
||||
bool isWeak = GV->mayBeOverridden();
|
||||
bool isNonStatic = (DTM->getRelocationModel() != Reloc::Static);
|
||||
bool isNonStatic = TM.getRelocationModel() != Reloc::Static;
|
||||
|
||||
switch (Kind) {
|
||||
case SectionKind::Text:
|
||||
@ -112,13 +112,12 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
||||
|
||||
const Section*
|
||||
DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
|
||||
const TargetData *TD = DTM->getTargetData();
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
|
||||
const Type *Type = cast<ConstantArray>(C)->getType()->getElementType();
|
||||
|
||||
unsigned Size = TD->getABITypeSize(Type);
|
||||
if (Size) {
|
||||
const TargetData *TD = DTM->getTargetData();
|
||||
unsigned Align = TD->getPreferredAlignment(GV);
|
||||
if (Align <= 32)
|
||||
return getCStringSection_();
|
||||
@ -136,7 +135,7 @@ DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
|
||||
|
||||
inline const Section*
|
||||
DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
|
||||
const TargetData *TD = DTM->getTargetData();
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
unsigned Size = TD->getABITypeSize(Ty);
|
||||
if (Size == 4)
|
||||
@ -155,7 +154,7 @@ DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
|
||||
|
||||
// Handle weird special case, when compiling PIC stuff.
|
||||
if (S == getReadOnlySection() &&
|
||||
DTM->getRelocationModel() != Reloc::Static)
|
||||
TM.getRelocationModel() != Reloc::Static)
|
||||
return ConstDataSection;
|
||||
|
||||
return S;
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) {
|
||||
ETM = &TM;
|
||||
ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
|
||||
: TargetAsmInfo(TM) {
|
||||
|
||||
BSSSection_ = getUnnamedSection("\t.bss",
|
||||
SectionFlags::Writeable | SectionFlags::BSS);
|
||||
@ -102,7 +102,7 @@ ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
|
||||
|
||||
inline const Section*
|
||||
ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
|
||||
const TargetData *TD = ETM->getTargetData();
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
// FIXME: string here is temporary, until stuff will fully land in.
|
||||
// We cannot use {Four,Eight,Sixteen}ByteConstantSection here, since it's
|
||||
@ -121,7 +121,7 @@ ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
|
||||
|
||||
const Section*
|
||||
ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
|
||||
const TargetData *TD = ETM->getTargetData();
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
Constant *C = cast<GlobalVariable>(GV)->getInitializer();
|
||||
const ConstantArray *CVA = cast<ConstantArray>(C);
|
||||
const Type *Ty = CVA->getType()->getElementType();
|
||||
@ -131,7 +131,6 @@ ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
|
||||
assert(getCStringSection() && "Should have string section prefix");
|
||||
|
||||
// We also need alignment here
|
||||
const TargetData *TD = ETM->getTargetData();
|
||||
unsigned Align = TD->getPrefTypeAlignment(Ty);
|
||||
if (Align < Size)
|
||||
Align = Size;
|
||||
|
@ -65,7 +65,7 @@ SectionKindForGlobal(const GlobalValue *GV) const {
|
||||
return K;
|
||||
|
||||
if (isa<GlobalVariable>(GV)) {
|
||||
const TargetData *TD = ETM->getTargetData();
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
unsigned Size = TD->getABITypeSize(GV->getType()->getElementType());
|
||||
unsigned Threshold = Subtarget->getSSectionThreshold();
|
||||
|
||||
|
@ -12,12 +12,13 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "PIC16TargetAsmInfo.h"
|
||||
#include "PIC16TargetMachine.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
PIC16TargetAsmInfo::
|
||||
PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
|
||||
{
|
||||
PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
|
||||
: TargetAsmInfo(TM) {
|
||||
Data16bitsDirective = "\t.half\t";
|
||||
Data32bitsDirective = "\t.word\t";
|
||||
CommentString = ";";
|
||||
|
@ -119,11 +119,8 @@ void TargetAsmInfo::fillDefaultValues() {
|
||||
DataSection = getUnnamedSection("\t.data", SectionFlags::Writeable);
|
||||
}
|
||||
|
||||
TargetAsmInfo::TargetAsmInfo() {
|
||||
fillDefaultValues();
|
||||
}
|
||||
|
||||
TargetAsmInfo::TargetAsmInfo(const TargetMachine &TM) {
|
||||
TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm)
|
||||
: TM(tm) {
|
||||
fillDefaultValues();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ const char *const llvm::x86_asm_table[] = {
|
||||
|
||||
X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
|
||||
X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) {
|
||||
const X86Subtarget* Subtarget = &DTM->getSubtarget<X86Subtarget>();
|
||||
const X86Subtarget* Subtarget = &TM.getSubtarget<X86Subtarget>();
|
||||
bool is64Bit = Subtarget->is64Bit();
|
||||
|
||||
AlignmentIsInBytes = false;
|
||||
@ -52,7 +52,7 @@ X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
|
||||
LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata
|
||||
BSSSection = 0; // no BSS section.
|
||||
ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
|
||||
if (DTM->getRelocationModel() != Reloc::Static)
|
||||
if (TM.getRelocationModel() != Reloc::Static)
|
||||
ConstantPoolSection = "\t.const_data";
|
||||
else
|
||||
ConstantPoolSection = "\t.const\n";
|
||||
@ -171,17 +171,17 @@ X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
|
||||
DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
|
||||
|
||||
// On Linux we must declare when we can use a non-executable stack.
|
||||
if (ETM->getSubtarget<X86Subtarget>().isLinux())
|
||||
if (TM.getSubtarget<X86Subtarget>().isLinux())
|
||||
NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
|
||||
}
|
||||
|
||||
unsigned
|
||||
X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
|
||||
bool Global) const {
|
||||
CodeModel::Model CM = ETM->getCodeModel();
|
||||
bool is64Bit = ETM->getSubtarget<X86Subtarget>().is64Bit();
|
||||
CodeModel::Model CM = TM.getCodeModel();
|
||||
bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
|
||||
|
||||
if (ETM->getRelocationModel() == Reloc::PIC_) {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_) {
|
||||
unsigned Format = 0;
|
||||
|
||||
if (!is64Bit)
|
||||
@ -216,7 +216,6 @@ X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
|
||||
|
||||
X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
|
||||
X86GenericTargetAsmInfo(TM) {
|
||||
X86TM = &TM;
|
||||
|
||||
GlobalPrefix = "_";
|
||||
LCOMMDirective = "\t.lcomm\t";
|
||||
@ -251,10 +250,10 @@ X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
|
||||
unsigned
|
||||
X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
|
||||
bool Global) const {
|
||||
CodeModel::Model CM = X86TM->getCodeModel();
|
||||
bool is64Bit = X86TM->getSubtarget<X86Subtarget>().is64Bit();
|
||||
CodeModel::Model CM = TM.getCodeModel();
|
||||
bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
|
||||
|
||||
if (X86TM->getRelocationModel() == Reloc::PIC_) {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_) {
|
||||
unsigned Format = 0;
|
||||
|
||||
if (!is64Bit)
|
||||
|
@ -63,8 +63,6 @@ namespace llvm {
|
||||
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
|
||||
SectionKind::Kind kind) const;
|
||||
virtual std::string printSectionFlags(unsigned flags) const;
|
||||
protected:
|
||||
const X86TargetMachine *X86TM;
|
||||
};
|
||||
|
||||
struct X86WinTargetAsmInfo : public X86GenericTargetAsmInfo {
|
||||
|
Loading…
x
Reference in New Issue
Block a user