From c7b8814bb4f2e6052060d6118d3bc3b66f5c5b0b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 19 Jan 2010 22:42:28 +0000 Subject: [PATCH] give MCAsmInfo a 'has little endian' bit. This is unfortunate, but I really want clients of the streamer to be able to say "emit this 64-bit integer" and have it get broken down right by the streamer. I may change this in the future, we'll see how it works out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93934 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 6 +++++- include/llvm/MC/MCAsmInfoCOFF.h | 2 +- include/llvm/MC/MCAsmInfoDarwin.h | 2 +- lib/MC/MCAsmInfo.cpp | 3 ++- lib/MC/MCAsmInfoCOFF.cpp | 2 +- lib/MC/MCAsmInfoDarwin.cpp | 3 ++- lib/Target/ARM/ARMMCAsmInfo.cpp | 4 ++-- lib/Target/Alpha/AlphaMCAsmInfo.cpp | 3 ++- lib/Target/Blackfin/BlackfinMCAsmInfo.cpp | 3 ++- lib/Target/CBackend/CBackend.cpp | 4 ++-- lib/Target/CellSPU/SPUMCAsmInfo.cpp | 3 ++- lib/Target/MSP430/MSP430MCAsmInfo.cpp | 3 ++- lib/Target/Mips/MipsMCAsmInfo.cpp | 3 ++- lib/Target/Mips/MipsMCAsmInfo.h | 18 ++++++++++++++++-- lib/Target/Mips/MipsTargetMachine.cpp | 7 +++---- lib/Target/PIC16/PIC16MCAsmInfo.cpp | 3 ++- lib/Target/PowerPC/PPCMCAsmInfo.cpp | 4 ++-- lib/Target/Sparc/SparcMCAsmInfo.cpp | 3 ++- lib/Target/SystemZ/SystemZMCAsmInfo.cpp | 3 ++- lib/Target/X86/X86MCAsmInfo.cpp | 12 ++++++++---- lib/Target/XCore/XCoreMCAsmInfo.cpp | 3 ++- 21 files changed, 63 insertions(+), 31 deletions(-) diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 0be27530f27..7ca7ecba6ff 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -24,6 +24,7 @@ namespace llvm { namespace ExceptionHandling { enum ExceptionsType { None, Dwarf, SjLj }; } class MCAsmInfo { + bool IsLittleEndian; protected: //===------------------------------------------------------------------===// // Properties to be set by the target writer, used to configure asm printer. @@ -285,9 +286,12 @@ namespace llvm { const char *const *AsmTransCBE; // Defaults to empty public: - explicit MCAsmInfo(); + explicit MCAsmInfo(bool isLittleEndian); virtual ~MCAsmInfo(); + bool isLittleEndian() const { return IsLittleEndian; } + bool isBigEndian() const { return !IsLittleEndian; } + /// getSLEB128Size - Compute the number of bytes required for a signed /// leb128 value. static unsigned getSLEB128Size(int Value); diff --git a/include/llvm/MC/MCAsmInfoCOFF.h b/include/llvm/MC/MCAsmInfoCOFF.h index a3ee1593c3a..97e9aee060a 100644 --- a/include/llvm/MC/MCAsmInfoCOFF.h +++ b/include/llvm/MC/MCAsmInfoCOFF.h @@ -15,7 +15,7 @@ namespace llvm { class MCAsmInfoCOFF : public MCAsmInfo { protected: - explicit MCAsmInfoCOFF(); + explicit MCAsmInfoCOFF(bool isLittleEndian); }; } diff --git a/include/llvm/MC/MCAsmInfoDarwin.h b/include/llvm/MC/MCAsmInfoDarwin.h index c85aa3da957..f5e897d203d 100644 --- a/include/llvm/MC/MCAsmInfoDarwin.h +++ b/include/llvm/MC/MCAsmInfoDarwin.h @@ -24,7 +24,7 @@ namespace llvm { class Mangler; struct MCAsmInfoDarwin : public MCAsmInfo { - explicit MCAsmInfoDarwin(); + explicit MCAsmInfoDarwin(bool isLittleEndian); }; } diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp index cc036141574..c15d61494ca 100644 --- a/lib/MC/MCAsmInfo.cpp +++ b/lib/MC/MCAsmInfo.cpp @@ -18,7 +18,8 @@ #include using namespace llvm; -MCAsmInfo::MCAsmInfo() { +MCAsmInfo::MCAsmInfo(bool isLittleEndian) { + IsLittleEndian = isLittleEndian; HasMachoZeroFillDirective = false; HasStaticCtorDtorReferenceInStaticMode = false; NonexecutableStackDirective = 0; diff --git a/lib/MC/MCAsmInfoCOFF.cpp b/lib/MC/MCAsmInfoCOFF.cpp index 1b27bf026ec..d384c6c0763 100644 --- a/lib/MC/MCAsmInfoCOFF.cpp +++ b/lib/MC/MCAsmInfoCOFF.cpp @@ -16,7 +16,7 @@ #include "llvm/ADT/SmallVector.h" using namespace llvm; -MCAsmInfoCOFF::MCAsmInfoCOFF() { +MCAsmInfoCOFF::MCAsmInfoCOFF(bool isLittleEndian) : MCAsmInfo(isLittleEndian) { GlobalPrefix = "_"; LCOMMDirective = "\t.lcomm\t"; COMMDirectiveTakesAlignment = false; diff --git a/lib/MC/MCAsmInfoDarwin.cpp b/lib/MC/MCAsmInfoDarwin.cpp index 664a55c0888..f024a1668c6 100644 --- a/lib/MC/MCAsmInfoDarwin.cpp +++ b/lib/MC/MCAsmInfoDarwin.cpp @@ -15,7 +15,8 @@ #include "llvm/MC/MCAsmInfoDarwin.h" using namespace llvm; -MCAsmInfoDarwin::MCAsmInfoDarwin() { +MCAsmInfoDarwin::MCAsmInfoDarwin(bool isLittleEndian) + : MCAsmInfo(isLittleEndian) { // Common settings for all Darwin targets. // Syntax: GlobalPrefix = "_"; diff --git a/lib/Target/ARM/ARMMCAsmInfo.cpp b/lib/Target/ARM/ARMMCAsmInfo.cpp index 0ff65d2af88..a3499fa3cbc 100644 --- a/lib/Target/ARM/ARMMCAsmInfo.cpp +++ b/lib/Target/ARM/ARMMCAsmInfo.cpp @@ -40,7 +40,7 @@ static const char *const arm_asm_table[] = { 0,0 }; -ARMMCAsmInfoDarwin::ARMMCAsmInfoDarwin() { +ARMMCAsmInfoDarwin::ARMMCAsmInfoDarwin() : MCAsmInfoDarwin(true) { AsmTransCBE = arm_asm_table; Data64bitsDirective = 0; CommentString = "@"; @@ -52,7 +52,7 @@ ARMMCAsmInfoDarwin::ARMMCAsmInfoDarwin() { AbsoluteEHSectionOffsets = false; } -ARMELFMCAsmInfo::ARMELFMCAsmInfo() { +ARMELFMCAsmInfo::ARMELFMCAsmInfo() : MCAsmInfo(true) { AlignmentIsInBytes = false; Data64bitsDirective = 0; CommentString = "@"; diff --git a/lib/Target/Alpha/AlphaMCAsmInfo.cpp b/lib/Target/Alpha/AlphaMCAsmInfo.cpp index b652a5305a0..25443cc0c69 100644 --- a/lib/Target/Alpha/AlphaMCAsmInfo.cpp +++ b/lib/Target/Alpha/AlphaMCAsmInfo.cpp @@ -14,7 +14,8 @@ #include "AlphaMCAsmInfo.h" using namespace llvm; -AlphaMCAsmInfo::AlphaMCAsmInfo(const Target &T, const StringRef &TT) { +AlphaMCAsmInfo::AlphaMCAsmInfo(const Target &T, const StringRef &TT) + : MCAsmInfo(true) { AlignmentIsInBytes = false; PrivateGlobalPrefix = "$"; PICJumpTableDirective = ".gprel32"; diff --git a/lib/Target/Blackfin/BlackfinMCAsmInfo.cpp b/lib/Target/Blackfin/BlackfinMCAsmInfo.cpp index 6d0f66cd7a5..368cd50ed96 100644 --- a/lib/Target/Blackfin/BlackfinMCAsmInfo.cpp +++ b/lib/Target/Blackfin/BlackfinMCAsmInfo.cpp @@ -15,7 +15,8 @@ using namespace llvm; -BlackfinMCAsmInfo::BlackfinMCAsmInfo(const Target &T, const StringRef &TT) { +BlackfinMCAsmInfo::BlackfinMCAsmInfo(const Target &T, const StringRef &TT) +: MCAsmInfo(true) { GlobalPrefix = "_"; CommentString = "//"; } diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 5015d1bcce8..1feadd2a930 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -60,7 +60,7 @@ extern "C" void LLVMInitializeCBackendTarget() { namespace { class CBEMCAsmInfo : public MCAsmInfo { public: - CBEMCAsmInfo() { + CBEMCAsmInfo(bool isLE) : MCAsmInfo(isLE) { GlobalPrefix = ""; PrivateGlobalPrefix = ""; } @@ -1893,7 +1893,7 @@ bool CWriter::doInitialization(Module &M) { if (const Target *Match = TargetRegistry::lookupTarget(Triple, E)) TAsm = Match->createAsmInfo(Triple); #endif - TAsm = new CBEMCAsmInfo(); + TAsm = new CBEMCAsmInfo(TD->isLittleEndian()); Mang = new Mangler(*TAsm); // Keep track of which functions are static ctors/dtors so they can have diff --git a/lib/Target/CellSPU/SPUMCAsmInfo.cpp b/lib/Target/CellSPU/SPUMCAsmInfo.cpp index 1c921ab87ff..3b43a7e2092 100644 --- a/lib/Target/CellSPU/SPUMCAsmInfo.cpp +++ b/lib/Target/CellSPU/SPUMCAsmInfo.cpp @@ -14,7 +14,8 @@ #include "SPUMCAsmInfo.h" using namespace llvm; -SPULinuxMCAsmInfo::SPULinuxMCAsmInfo(const Target &T, const StringRef &TT) { +SPULinuxMCAsmInfo::SPULinuxMCAsmInfo(const Target &T, const StringRef &TT) + : MCAsmInfo(false) { ZeroDirective = "\t.space\t"; SetDirective = "\t.set"; Data64bitsDirective = "\t.quad\t"; diff --git a/lib/Target/MSP430/MSP430MCAsmInfo.cpp b/lib/Target/MSP430/MSP430MCAsmInfo.cpp index 516eacb5356..92adc381699 100644 --- a/lib/Target/MSP430/MSP430MCAsmInfo.cpp +++ b/lib/Target/MSP430/MSP430MCAsmInfo.cpp @@ -14,7 +14,8 @@ #include "MSP430MCAsmInfo.h" using namespace llvm; -MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) { +MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) : + MCAsmInfo(true) { PrivateGlobalPrefix = ".L"; WeakRefDirective ="\t.weak\t"; SetDirective = "\t.set\t"; diff --git a/lib/Target/Mips/MipsMCAsmInfo.cpp b/lib/Target/Mips/MipsMCAsmInfo.cpp index 60ef1c9e4fe..9a0c0bfdba8 100644 --- a/lib/Target/Mips/MipsMCAsmInfo.cpp +++ b/lib/Target/Mips/MipsMCAsmInfo.cpp @@ -14,7 +14,8 @@ #include "MipsMCAsmInfo.h" using namespace llvm; -MipsMCAsmInfo::MipsMCAsmInfo(const Target &T, const StringRef &TT) { +MipsMCAsmInfo::MipsMCAsmInfo(const Target &T, const StringRef &TT, + bool isLittleEndian) : MCAsmInfo(isLittleEndian) { AlignmentIsInBytes = false; COMMDirectiveTakesAlignment = true; Data16bitsDirective = "\t.half\t"; diff --git a/lib/Target/Mips/MipsMCAsmInfo.h b/lib/Target/Mips/MipsMCAsmInfo.h index 33a4b5edb25..62ef463c0f3 100644 --- a/lib/Target/Mips/MipsMCAsmInfo.h +++ b/lib/Target/Mips/MipsMCAsmInfo.h @@ -22,9 +22,23 @@ namespace llvm { class MipsMCAsmInfo : public MCAsmInfo { public: - explicit MipsMCAsmInfo(const Target &T, const StringRef &TT); + explicit MipsMCAsmInfo(const Target &T, const StringRef &TT, + bool isLittleEndian); + }; + + /// Big Endian MAI. + class MipsBEMCAsmInfo : public MipsMCAsmInfo { + public: + MipsBEMCAsmInfo(const Target &T, const StringRef &TT) + : MipsMCAsmInfo(T, TT, false) {} + }; + + /// Little Endian MAI. + class MipsLEMCAsmInfo : public MipsMCAsmInfo { + public: + MipsLEMCAsmInfo(const Target &T, const StringRef &TT) + : MipsMCAsmInfo(T, TT, true) {} }; - } // namespace llvm #endif diff --git a/lib/Target/Mips/MipsTargetMachine.cpp b/lib/Target/Mips/MipsTargetMachine.cpp index 4724ff7d347..1168fef66e0 100644 --- a/lib/Target/Mips/MipsTargetMachine.cpp +++ b/lib/Target/Mips/MipsTargetMachine.cpp @@ -22,8 +22,8 @@ extern "C" void LLVMInitializeMipsTarget() { // Register the target. RegisterTargetMachine X(TheMipsTarget); RegisterTargetMachine Y(TheMipselTarget); - RegisterAsmInfo A(TheMipsTarget); - RegisterAsmInfo B(TheMipselTarget); + RegisterAsmInfo A(TheMipsTarget); + RegisterAsmInfo B(TheMipselTarget); } // DataLayout --> Big-endian, 32-bit pointer/ABI/alignment @@ -60,8 +60,7 @@ MipselTargetMachine(const Target &T, const std::string &TT, // Install an instruction selector pass using // the ISelDag to gen Mips code. bool MipsTargetMachine:: -addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel) -{ +addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { PM.add(createMipsISelDag(*this)); return false; } diff --git a/lib/Target/PIC16/PIC16MCAsmInfo.cpp b/lib/Target/PIC16/PIC16MCAsmInfo.cpp index 827315e13b7..a6331e64ccc 100644 --- a/lib/Target/PIC16/PIC16MCAsmInfo.cpp +++ b/lib/Target/PIC16/PIC16MCAsmInfo.cpp @@ -20,7 +20,8 @@ #include "PIC16ISelLowering.h" using namespace llvm; -PIC16MCAsmInfo::PIC16MCAsmInfo(const Target &T, const StringRef &TT) { +PIC16MCAsmInfo::PIC16MCAsmInfo(const Target &T, const StringRef &TT) +: MCAsmInfo(true) { CommentString = ";"; GlobalPrefix = PAN::getTagName(PAN::PREFIX_SYMBOL); GlobalDirective = "\tglobal\t"; diff --git a/lib/Target/PowerPC/PPCMCAsmInfo.cpp b/lib/Target/PowerPC/PPCMCAsmInfo.cpp index ee6deb5c509..12de9427f4f 100644 --- a/lib/Target/PowerPC/PPCMCAsmInfo.cpp +++ b/lib/Target/PowerPC/PPCMCAsmInfo.cpp @@ -14,7 +14,7 @@ #include "PPCMCAsmInfo.h" using namespace llvm; -PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) { +PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) : MCAsmInfoDarwin(false) { PCSymbol = "."; CommentString = ";"; ExceptionsType = ExceptionHandling::Dwarf; @@ -25,7 +25,7 @@ PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) { SupportsDebugInformation= true; // Debug information. } -PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) { +PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) : MCAsmInfo(false) { CommentString = "#"; GlobalPrefix = ""; PrivateGlobalPrefix = ".L"; diff --git a/lib/Target/Sparc/SparcMCAsmInfo.cpp b/lib/Target/Sparc/SparcMCAsmInfo.cpp index b67537c1788..cb6da961b83 100644 --- a/lib/Target/Sparc/SparcMCAsmInfo.cpp +++ b/lib/Target/Sparc/SparcMCAsmInfo.cpp @@ -15,7 +15,8 @@ #include "llvm/ADT/SmallVector.h" using namespace llvm; -SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Target &T, const StringRef &TT) { +SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Target &T, const StringRef &TT) + : MCAsmInfo(/*isLittleEndian*/ false) { Data16bitsDirective = "\t.half\t"; Data32bitsDirective = "\t.word\t"; Data64bitsDirective = 0; // .xword is only supported by V9. diff --git a/lib/Target/SystemZ/SystemZMCAsmInfo.cpp b/lib/Target/SystemZ/SystemZMCAsmInfo.cpp index 8ea11c95b27..c17535f4e2b 100644 --- a/lib/Target/SystemZ/SystemZMCAsmInfo.cpp +++ b/lib/Target/SystemZ/SystemZMCAsmInfo.cpp @@ -14,7 +14,8 @@ #include "SystemZMCAsmInfo.h" using namespace llvm; -SystemZMCAsmInfo::SystemZMCAsmInfo(const Target &T, const StringRef &TT) { +SystemZMCAsmInfo::SystemZMCAsmInfo(const Target &T, const StringRef &TT) +: MCAsmInfo(false) { AlignmentIsInBytes = true; PrivateGlobalPrefix = ".L"; diff --git a/lib/Target/X86/X86MCAsmInfo.cpp b/lib/Target/X86/X86MCAsmInfo.cpp index 001ce807286..bba36e86cad 100644 --- a/lib/Target/X86/X86MCAsmInfo.cpp +++ b/lib/Target/X86/X86MCAsmInfo.cpp @@ -43,7 +43,8 @@ static const char *const x86_asm_table[] = { "{cc}", "cc", 0,0}; -X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) { +X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) + : MCAsmInfoDarwin(true /*islittleendian*/) { AsmTransCBE = x86_asm_table; AssemblerDialect = AsmWriterFlavor; @@ -68,7 +69,8 @@ X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) { AbsoluteEHSectionOffsets = false; } -X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple) { +X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple) + : MCAsmInfo(true /*islittleendian*/) { AsmTransCBE = x86_asm_table; AssemblerDialect = AsmWriterFlavor; @@ -93,13 +95,15 @@ X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple) { NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits"; } -X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) { +X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) + : MCAsmInfoCOFF(true /*islittleendian*/) { AsmTransCBE = x86_asm_table; AssemblerDialect = AsmWriterFlavor; } -X86WinMCAsmInfo::X86WinMCAsmInfo(const Triple &Triple) { +X86WinMCAsmInfo::X86WinMCAsmInfo(const Triple &Triple) + : MCAsmInfo(true /*islittleendian*/) { AsmTransCBE = x86_asm_table; AssemblerDialect = AsmWriterFlavor; diff --git a/lib/Target/XCore/XCoreMCAsmInfo.cpp b/lib/Target/XCore/XCoreMCAsmInfo.cpp index dffdda9a1fd..b6c0cfccf90 100644 --- a/lib/Target/XCore/XCoreMCAsmInfo.cpp +++ b/lib/Target/XCore/XCoreMCAsmInfo.cpp @@ -10,7 +10,8 @@ #include "XCoreMCAsmInfo.h" using namespace llvm; -XCoreMCAsmInfo::XCoreMCAsmInfo(const Target &T, const StringRef &TT) { +XCoreMCAsmInfo::XCoreMCAsmInfo(const Target &T, const StringRef &TT) +: MCAsmInfo(true) { SupportsDebugInformation = true; Data16bitsDirective = "\t.short\t"; Data32bitsDirective = "\t.long\t"; -- 2.34.1