Skip to content

Commit

Permalink
give MCAsmInfo a 'has little endian' bit. This is unfortunate, but
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lattner committed Jan 19, 2010
1 parent 6784753 commit c7b8814
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 31 deletions.
6 changes: 5 additions & 1 deletion include/llvm/MC/MCAsmInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/llvm/MC/MCAsmInfoCOFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace llvm {
class MCAsmInfoCOFF : public MCAsmInfo {
protected:
explicit MCAsmInfoCOFF();
explicit MCAsmInfoCOFF(bool isLittleEndian);

};
}
Expand Down
2 changes: 1 addition & 1 deletion include/llvm/MC/MCAsmInfoDarwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace llvm {
class Mangler;

struct MCAsmInfoDarwin : public MCAsmInfo {
explicit MCAsmInfoDarwin();
explicit MCAsmInfoDarwin(bool isLittleEndian);
};
}

Expand Down
3 changes: 2 additions & 1 deletion lib/MC/MCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include <cstring>
using namespace llvm;

MCAsmInfo::MCAsmInfo() {
MCAsmInfo::MCAsmInfo(bool isLittleEndian) {
IsLittleEndian = isLittleEndian;
HasMachoZeroFillDirective = false;
HasStaticCtorDtorReferenceInStaticMode = false;
NonexecutableStackDirective = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/MC/MCAsmInfoCOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/MC/MCAsmInfoDarwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "_";
Expand Down
4 changes: 2 additions & 2 deletions lib/Target/ARM/ARMMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "@";
Expand All @@ -52,7 +52,7 @@ ARMMCAsmInfoDarwin::ARMMCAsmInfoDarwin() {
AbsoluteEHSectionOffsets = false;
}

ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
ARMELFMCAsmInfo::ARMELFMCAsmInfo() : MCAsmInfo(true) {
AlignmentIsInBytes = false;
Data64bitsDirective = 0;
CommentString = "@";
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/Alpha/AlphaMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/Blackfin/BlackfinMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "//";
}
4 changes: 2 additions & 2 deletions lib/Target/CBackend/CBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern "C" void LLVMInitializeCBackendTarget() {
namespace {
class CBEMCAsmInfo : public MCAsmInfo {
public:
CBEMCAsmInfo() {
CBEMCAsmInfo(bool isLE) : MCAsmInfo(isLE) {
GlobalPrefix = "";
PrivateGlobalPrefix = "";
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/CellSPU/SPUMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/MSP430/MSP430MCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/Mips/MipsMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
18 changes: 16 additions & 2 deletions lib/Target/Mips/MipsMCAsmInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions lib/Target/Mips/MipsTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ extern "C" void LLVMInitializeMipsTarget() {
// Register the target.
RegisterTargetMachine<MipsTargetMachine> X(TheMipsTarget);
RegisterTargetMachine<MipselTargetMachine> Y(TheMipselTarget);
RegisterAsmInfo<MipsMCAsmInfo> A(TheMipsTarget);
RegisterAsmInfo<MipsMCAsmInfo> B(TheMipselTarget);
RegisterAsmInfo<MipsBEMCAsmInfo> A(TheMipsTarget);
RegisterAsmInfo<MipsLEMCAsmInfo> B(TheMipselTarget);
}

// DataLayout --> Big-endian, 32-bit pointer/ABI/alignment
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/PIC16/PIC16MCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions lib/Target/PowerPC/PPCMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/Sparc/SparcMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/SystemZ/SystemZMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
12 changes: 8 additions & 4 deletions lib/Target/X86/X86MCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion lib/Target/XCore/XCoreMCAsmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit c7b8814

Please sign in to comment.