mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-07 16:54:48 +00:00
Use raw_ostream throughout the AsmPrinter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55092 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f4a97da407
commit
cb37188323
@ -34,6 +34,7 @@ namespace llvm {
|
|||||||
class Mangler;
|
class Mangler;
|
||||||
class TargetAsmInfo;
|
class TargetAsmInfo;
|
||||||
class Type;
|
class Type;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
/// AsmPrinter - This class is intended to be used as a driving class for all
|
/// AsmPrinter - This class is intended to be used as a driving class for all
|
||||||
/// asm writers.
|
/// asm writers.
|
||||||
@ -64,7 +65,7 @@ namespace llvm {
|
|||||||
public:
|
public:
|
||||||
/// Output stream on which we're printing assembly code.
|
/// Output stream on which we're printing assembly code.
|
||||||
///
|
///
|
||||||
std::ostream &O;
|
raw_ostream &O;
|
||||||
|
|
||||||
/// Target machine description.
|
/// Target machine description.
|
||||||
///
|
///
|
||||||
@ -96,7 +97,7 @@ namespace llvm {
|
|||||||
bool IsInTextSection;
|
bool IsInTextSection;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AsmPrinter(std::ostream &o, TargetMachine &TM, const TargetAsmInfo *T);
|
AsmPrinter(raw_ostream &o, TargetMachine &TM, const TargetAsmInfo *T);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~AsmPrinter();
|
virtual ~AsmPrinter();
|
||||||
|
@ -31,6 +31,7 @@ class MachineModuleInfo;
|
|||||||
class MachineFunction;
|
class MachineFunction;
|
||||||
class Module;
|
class Module;
|
||||||
class TargetAsmInfo;
|
class TargetAsmInfo;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// DwarfWriter - Emits Dwarf debug and exception handling directives.
|
// DwarfWriter - Emits Dwarf debug and exception handling directives.
|
||||||
@ -48,7 +49,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DwarfWriter(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T);
|
DwarfWriter(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T);
|
||||||
virtual ~DwarfWriter();
|
virtual ~DwarfWriter();
|
||||||
|
|
||||||
/// SetModuleInfo - Set machine module info when it's known that pass manager
|
/// SetModuleInfo - Set machine module info when it's known that pass manager
|
||||||
|
@ -21,10 +21,11 @@ namespace llvm {
|
|||||||
class PassManagerBase;
|
class PassManagerBase;
|
||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
MachineCodeEmitter *AddELFWriter(PassManagerBase &FPM, std::ostream &O,
|
MachineCodeEmitter *AddELFWriter(PassManagerBase &FPM, raw_ostream &O,
|
||||||
TargetMachine &TM);
|
TargetMachine &TM);
|
||||||
MachineCodeEmitter *AddMachOWriter(PassManagerBase &FPM, std::ostream &O,
|
MachineCodeEmitter *AddMachOWriter(PassManagerBase &FPM, raw_ostream &O,
|
||||||
TargetMachine &TM);
|
TargetMachine &TM);
|
||||||
|
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class GCMetadataPrinter;
|
class GCMetadataPrinter;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
/// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
|
/// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
|
||||||
/// defaults from Registry.
|
/// defaults from Registry.
|
||||||
@ -63,10 +64,10 @@ namespace llvm {
|
|||||||
iterator end() { return S->end(); }
|
iterator end() { return S->end(); }
|
||||||
|
|
||||||
/// beginAssembly/finishAssembly - Emit module metadata as assembly code.
|
/// beginAssembly/finishAssembly - Emit module metadata as assembly code.
|
||||||
virtual void beginAssembly(std::ostream &OS, AsmPrinter &AP,
|
virtual void beginAssembly(raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI);
|
const TargetAsmInfo &TAI);
|
||||||
|
|
||||||
virtual void finishAssembly(std::ostream &OS, AsmPrinter &AP,
|
virtual void finishAssembly(raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI);
|
const TargetAsmInfo &TAI);
|
||||||
|
|
||||||
virtual ~GCMetadataPrinter();
|
virtual ~GCMetadataPrinter();
|
||||||
|
@ -258,6 +258,11 @@ public:
|
|||||||
}
|
}
|
||||||
void print(std::ostream &OS, const TargetMachine *TM = 0) const;
|
void print(std::ostream &OS, const TargetMachine *TM = 0) const;
|
||||||
void print(std::ostream *OS) const { if (OS) print(*OS); }
|
void print(std::ostream *OS) const { if (OS) print(*OS); }
|
||||||
|
void print(raw_ostream *OS, const TargetMachine *TM) const {
|
||||||
|
if (OS) print(*OS, TM);
|
||||||
|
}
|
||||||
|
void print(raw_ostream &OS, const TargetMachine *TM = 0) const;
|
||||||
|
void print(raw_ostream *OS) const { if (OS) print(*OS); }
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
@ -316,6 +321,11 @@ inline std::ostream& operator<<(std::ostream &OS, const MachineInstr &MI) {
|
|||||||
return OS;
|
return OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline raw_ostream& operator<<(raw_ostream &OS, const MachineInstr &MI) {
|
||||||
|
MI.print(OS);
|
||||||
|
return OS;
|
||||||
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,6 +26,7 @@ class GlobalValue;
|
|||||||
class MachineInstr;
|
class MachineInstr;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class MachineRegisterInfo;
|
class MachineRegisterInfo;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
/// MachineOperand class - Representation of each machine instruction operand.
|
/// MachineOperand class - Representation of each machine instruction operand.
|
||||||
///
|
///
|
||||||
@ -117,6 +118,7 @@ public:
|
|||||||
const MachineInstr *getParent() const { return ParentMI; }
|
const MachineInstr *getParent() const { return ParentMI; }
|
||||||
|
|
||||||
void print(std::ostream &os, const TargetMachine *TM = 0) const;
|
void print(std::ostream &os, const TargetMachine *TM = 0) const;
|
||||||
|
void print(raw_ostream &os, const TargetMachine *TM = 0) const;
|
||||||
|
|
||||||
/// Accessors that tell you what kind of MachineOperand you're looking at.
|
/// Accessors that tell you what kind of MachineOperand you're looking at.
|
||||||
///
|
///
|
||||||
@ -425,6 +427,11 @@ inline std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO) {
|
|||||||
return OS;
|
return OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline raw_ostream &operator<<(raw_ostream &OS, const MachineOperand& MO) {
|
||||||
|
MO.print(OS, 0);
|
||||||
|
return OS;
|
||||||
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef LLVM_SUPPORT_RAW_OSTREAM_H
|
#ifndef LLVM_SUPPORT_RAW_OSTREAM_H
|
||||||
#define LLVM_SUPPORT_RAW_OSTREAM_H
|
#define LLVM_SUPPORT_RAW_OSTREAM_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -72,7 +73,11 @@ public:
|
|||||||
return write(Str, strlen(Str));
|
return write(Str, strlen(Str));
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_ostream &operator<<(unsigned N) {
|
raw_ostream &operator<<(const std::string& Str) {
|
||||||
|
return write(Str.data(), Str.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_ostream &operator<<(uint64_t N) {
|
||||||
// Zero is a special case.
|
// Zero is a special case.
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
return *this << '0';
|
return *this << '0';
|
||||||
@ -88,6 +93,34 @@ public:
|
|||||||
return write(CurPtr, EndPtr-CurPtr);
|
return write(CurPtr, EndPtr-CurPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raw_ostream &operator<<(int64_t N) {
|
||||||
|
if (N < 0) {
|
||||||
|
if (OutBufCur >= OutBufEnd)
|
||||||
|
flush_impl();
|
||||||
|
*OutBufCur++ = '-';
|
||||||
|
|
||||||
|
N = -N;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->operator<<(static_cast<uint64_t>(N));
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_ostream &operator<<(uint32_t N) {
|
||||||
|
return this->operator<<(static_cast<uint64_t>(N));
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_ostream &operator<<(int32_t N) {
|
||||||
|
return this->operator<<(static_cast<int64_t>(N));
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_ostream &operator<<(size_t N) {
|
||||||
|
return this->operator<<(static_cast<uint64_t>(N));
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_ostream &operator<<(double N) {
|
||||||
|
return this->operator<<(ftostr(N));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
raw_ostream &write(const char *Ptr, unsigned Size) {
|
raw_ostream &write(const char *Ptr, unsigned Size) {
|
||||||
if (OutBufCur+Size > OutBufEnd)
|
if (OutBufCur+Size > OutBufEnd)
|
||||||
|
@ -35,6 +35,7 @@ class PassManager;
|
|||||||
class Pass;
|
class Pass;
|
||||||
class TargetMachOWriterInfo;
|
class TargetMachOWriterInfo;
|
||||||
class TargetELFWriterInfo;
|
class TargetELFWriterInfo;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
// Relocation model types.
|
// Relocation model types.
|
||||||
namespace Reloc {
|
namespace Reloc {
|
||||||
@ -196,7 +197,7 @@ public:
|
|||||||
/// is not supported.
|
/// is not supported.
|
||||||
///
|
///
|
||||||
virtual FileModel::Model addPassesToEmitFile(PassManagerBase &,
|
virtual FileModel::Model addPassesToEmitFile(PassManagerBase &,
|
||||||
std::ostream &,
|
raw_ostream &,
|
||||||
CodeGenFileType,
|
CodeGenFileType,
|
||||||
bool /*Fast*/) {
|
bool /*Fast*/) {
|
||||||
return FileModel::None;
|
return FileModel::None;
|
||||||
@ -227,7 +228,7 @@ public:
|
|||||||
/// require having the entire module at once. This is not recommended, do not
|
/// require having the entire module at once. This is not recommended, do not
|
||||||
/// use this.
|
/// use this.
|
||||||
virtual bool WantsWholeFile() const { return false; }
|
virtual bool WantsWholeFile() const { return false; }
|
||||||
virtual bool addPassesToEmitWholeFile(PassManager &, std::ostream &,
|
virtual bool addPassesToEmitWholeFile(PassManager &, raw_ostream &,
|
||||||
CodeGenFileType, bool /*Fast*/) {
|
CodeGenFileType, bool /*Fast*/) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -253,7 +254,7 @@ public:
|
|||||||
/// target-specific passes in standard locations.
|
/// target-specific passes in standard locations.
|
||||||
///
|
///
|
||||||
virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM,
|
virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM,
|
||||||
std::ostream &Out,
|
raw_ostream &Out,
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
bool Fast);
|
bool Fast);
|
||||||
|
|
||||||
@ -309,7 +310,7 @@ public:
|
|||||||
/// the asmprinter, if asm emission is supported. If this is not supported,
|
/// the asmprinter, if asm emission is supported. If this is not supported,
|
||||||
/// 'true' should be returned.
|
/// 'true' should be returned.
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &, bool /*Fast*/,
|
virtual bool addAssemblyEmitter(PassManagerBase &, bool /*Fast*/,
|
||||||
std::ostream &) {
|
raw_ostream &) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
@ -31,11 +31,12 @@
|
|||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
char AsmPrinter::ID = 0;
|
char AsmPrinter::ID = 0;
|
||||||
AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
|
AsmPrinter::AsmPrinter(raw_ostream &o, TargetMachine &tm,
|
||||||
const TargetAsmInfo *T)
|
const TargetAsmInfo *T)
|
||||||
: MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o),
|
: MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o),
|
||||||
TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
|
TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
|
||||||
@ -268,8 +269,9 @@ void AsmPrinter::EmitConstantPool(unsigned Alignment, const char *Section,
|
|||||||
EmitAlignment(Alignment);
|
EmitAlignment(Alignment);
|
||||||
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
||||||
O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
|
O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
|
||||||
<< CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << ' ';
|
<< CP[i].second << ":\t\t\t\t\t";
|
||||||
WriteTypeSymbolic(O, CP[i].first.getType(), 0);
|
// O << TAI->getCommentString() << ' ' <<
|
||||||
|
// WriteTypeSymbolic(O, CP[i].first.getType(), 0);
|
||||||
O << '\n';
|
O << '\n';
|
||||||
if (CP[i].first.isMachineConstantPoolEntry())
|
if (CP[i].first.isMachineConstantPoolEntry())
|
||||||
EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
|
EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
|
||||||
@ -495,7 +497,7 @@ void AsmPrinter::PrintULEB128(unsigned Value) const {
|
|||||||
unsigned Byte = Value & 0x7f;
|
unsigned Byte = Value & 0x7f;
|
||||||
Value >>= 7;
|
Value >>= 7;
|
||||||
if (Value) Byte |= 0x80;
|
if (Value) Byte |= 0x80;
|
||||||
O << "0x" << std::hex << Byte << std::dec;
|
O << "0x" << utohexstr(Byte);
|
||||||
if (Value) O << ", ";
|
if (Value) O << ", ";
|
||||||
} while (Value);
|
} while (Value);
|
||||||
}
|
}
|
||||||
@ -511,7 +513,7 @@ void AsmPrinter::PrintSLEB128(int Value) const {
|
|||||||
Value >>= 7;
|
Value >>= 7;
|
||||||
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
|
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
|
||||||
if (IsMore) Byte |= 0x80;
|
if (IsMore) Byte |= 0x80;
|
||||||
O << "0x" << std::hex << Byte << std::dec;
|
O << "0x" << utohexstr(Byte);
|
||||||
if (IsMore) O << ", ";
|
if (IsMore) O << ", ";
|
||||||
} while (IsMore);
|
} while (IsMore);
|
||||||
}
|
}
|
||||||
@ -523,7 +525,7 @@ void AsmPrinter::PrintSLEB128(int Value) const {
|
|||||||
/// PrintHex - Print a value as a hexidecimal value.
|
/// PrintHex - Print a value as a hexidecimal value.
|
||||||
///
|
///
|
||||||
void AsmPrinter::PrintHex(int Value) const {
|
void AsmPrinter::PrintHex(int Value) const {
|
||||||
O << "0x" << std::hex << Value << std::dec;
|
O << "0x" << utohexstr(static_cast<unsigned>(Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EOL - Print a newline character to asm stream. If a comment is present
|
/// EOL - Print a newline character to asm stream. If a comment is present
|
||||||
@ -622,7 +624,7 @@ static inline char toOctal(int X) {
|
|||||||
|
|
||||||
/// printStringChar - Print a char, escaped if necessary.
|
/// printStringChar - Print a char, escaped if necessary.
|
||||||
///
|
///
|
||||||
static void printStringChar(std::ostream &O, unsigned char C) {
|
static void printStringChar(raw_ostream &O, char C) {
|
||||||
if (C == '"') {
|
if (C == '"') {
|
||||||
O << "\\\"";
|
O << "\\\"";
|
||||||
} else if (C == '\\') {
|
} else if (C == '\\') {
|
||||||
@ -706,7 +708,7 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV,
|
|||||||
|
|
||||||
unsigned FillValue = TAI->getTextAlignFillValue();
|
unsigned FillValue = TAI->getTextAlignFillValue();
|
||||||
UseFillExpr &= IsInTextSection && FillValue;
|
UseFillExpr &= IsInTextSection && FillValue;
|
||||||
if (UseFillExpr) O << ",0x" << std::hex << FillValue << std::dec;
|
if (UseFillExpr) O << ",0x" << utohexstr(FillValue);
|
||||||
O << '\n';
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -855,7 +857,7 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
|
|||||||
/// printAsCString - Print the specified array as a C compatible string, only if
|
/// printAsCString - Print the specified array as a C compatible string, only if
|
||||||
/// the predicate isString is true.
|
/// the predicate isString is true.
|
||||||
///
|
///
|
||||||
static void printAsCString(std::ostream &O, const ConstantArray *CVA,
|
static void printAsCString(raw_ostream &O, const ConstantArray *CVA,
|
||||||
unsigned LastElt) {
|
unsigned LastElt) {
|
||||||
assert(CVA->isString() && "Array is not string compatible!");
|
assert(CVA->isString() && "Array is not string compatible!");
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/System/Path.h"
|
#include "llvm/System/Path.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
@ -820,7 +821,7 @@ protected:
|
|||||||
//
|
//
|
||||||
/// O - Stream to .s file.
|
/// O - Stream to .s file.
|
||||||
///
|
///
|
||||||
std::ostream &O;
|
raw_ostream &O;
|
||||||
|
|
||||||
/// Asm - Target of Dwarf emission.
|
/// Asm - Target of Dwarf emission.
|
||||||
///
|
///
|
||||||
@ -856,7 +857,7 @@ protected:
|
|||||||
const char * const Flavor;
|
const char * const Flavor;
|
||||||
|
|
||||||
unsigned SetCounter;
|
unsigned SetCounter;
|
||||||
Dwarf(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T,
|
Dwarf(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T,
|
||||||
const char *flavor)
|
const char *flavor)
|
||||||
: O(OS)
|
: O(OS)
|
||||||
, Asm(A)
|
, Asm(A)
|
||||||
@ -2673,7 +2674,7 @@ public:
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Main entry points.
|
// Main entry points.
|
||||||
//
|
//
|
||||||
DwarfDebug(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
|
DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
|
||||||
: Dwarf(OS, A, T, "dbg")
|
: Dwarf(OS, A, T, "dbg")
|
||||||
, CompileUnits()
|
, CompileUnits()
|
||||||
, AbbreviationsSet(InitAbbreviationsSetSize)
|
, AbbreviationsSet(InitAbbreviationsSetSize)
|
||||||
@ -3479,7 +3480,7 @@ public:
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Main entry points.
|
// Main entry points.
|
||||||
//
|
//
|
||||||
DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
|
DwarfException(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
|
||||||
: Dwarf(OS, A, T, "eh")
|
: Dwarf(OS, A, T, "eh")
|
||||||
, shouldEmitTable(false)
|
, shouldEmitTable(false)
|
||||||
, shouldEmitMoves(false)
|
, shouldEmitMoves(false)
|
||||||
@ -3879,7 +3880,7 @@ void DIE::dump() {
|
|||||||
/// DwarfWriter Implementation
|
/// DwarfWriter Implementation
|
||||||
///
|
///
|
||||||
|
|
||||||
DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A,
|
DwarfWriter::DwarfWriter(raw_ostream &OS, AsmPrinter *A,
|
||||||
const TargetAsmInfo *T) {
|
const TargetAsmInfo *T) {
|
||||||
DE = new DwarfException(OS, A, T);
|
DE = new DwarfException(OS, A, T);
|
||||||
DD = new DwarfDebug(OS, A, T);
|
DD = new DwarfDebug(OS, A, T);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/CodeGen/GCMetadataPrinter.h"
|
#include "llvm/CodeGen/GCMetadataPrinter.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
@ -25,10 +26,10 @@ namespace {
|
|||||||
|
|
||||||
class VISIBILITY_HIDDEN OcamlGCMetadataPrinter : public GCMetadataPrinter {
|
class VISIBILITY_HIDDEN OcamlGCMetadataPrinter : public GCMetadataPrinter {
|
||||||
public:
|
public:
|
||||||
void beginAssembly(std::ostream &OS, AsmPrinter &AP,
|
void beginAssembly(raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI);
|
const TargetAsmInfo &TAI);
|
||||||
|
|
||||||
void finishAssembly(std::ostream &OS, AsmPrinter &AP,
|
void finishAssembly(raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI);
|
const TargetAsmInfo &TAI);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ Y("ocaml", "ocaml 3.10-compatible collector");
|
|||||||
|
|
||||||
void llvm::linkOcamlGCPrinter() { }
|
void llvm::linkOcamlGCPrinter() { }
|
||||||
|
|
||||||
static void EmitCamlGlobal(const Module &M, std::ostream &OS, AsmPrinter &AP,
|
static void EmitCamlGlobal(const Module &M, raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI, const char *Id) {
|
const TargetAsmInfo &TAI, const char *Id) {
|
||||||
const std::string &MId = M.getModuleIdentifier();
|
const std::string &MId = M.getModuleIdentifier();
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ static void EmitCamlGlobal(const Module &M, std::ostream &OS, AsmPrinter &AP,
|
|||||||
OS << Mangled << ":\n";
|
OS << Mangled << ":\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void OcamlGCMetadataPrinter::beginAssembly(std::ostream &OS, AsmPrinter &AP,
|
void OcamlGCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI) {
|
const TargetAsmInfo &TAI) {
|
||||||
AP.SwitchToTextSection(TAI.getTextSection());
|
AP.SwitchToTextSection(TAI.getTextSection());
|
||||||
EmitCamlGlobal(getModule(), OS, AP, TAI, "code_begin");
|
EmitCamlGlobal(getModule(), OS, AP, TAI, "code_begin");
|
||||||
@ -84,7 +85,7 @@ void OcamlGCMetadataPrinter::beginAssembly(std::ostream &OS, AsmPrinter &AP,
|
|||||||
/// (FrameSize and LiveOffsets would overflow). FrameTablePrinter will abort if
|
/// (FrameSize and LiveOffsets would overflow). FrameTablePrinter will abort if
|
||||||
/// either condition is detected in a function which uses the GC.
|
/// either condition is detected in a function which uses the GC.
|
||||||
///
|
///
|
||||||
void OcamlGCMetadataPrinter::finishAssembly(std::ostream &OS, AsmPrinter &AP,
|
void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI) {
|
const TargetAsmInfo &TAI) {
|
||||||
const char *AddressDirective;
|
const char *AddressDirective;
|
||||||
int AddressAlignLog;
|
int AddressAlignLog;
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
#include "llvm/Support/OutputBuffer.h"
|
#include "llvm/Support/OutputBuffer.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ char ELFWriter::ID = 0;
|
|||||||
/// AddELFWriter - Concrete function to add the ELF writer to the function pass
|
/// AddELFWriter - Concrete function to add the ELF writer to the function pass
|
||||||
/// manager.
|
/// manager.
|
||||||
MachineCodeEmitter *llvm::AddELFWriter(PassManagerBase &PM,
|
MachineCodeEmitter *llvm::AddELFWriter(PassManagerBase &PM,
|
||||||
std::ostream &O,
|
raw_ostream &O,
|
||||||
TargetMachine &TM) {
|
TargetMachine &TM) {
|
||||||
ELFWriter *EW = new ELFWriter(O, TM);
|
ELFWriter *EW = new ELFWriter(O, TM);
|
||||||
PM.add(EW);
|
PM.add(EW);
|
||||||
@ -193,7 +194,7 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &F) {
|
|||||||
// ELFWriter Implementation
|
// ELFWriter Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
ELFWriter::ELFWriter(std::ostream &o, TargetMachine &tm)
|
ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm)
|
||||||
: MachineFunctionPass((intptr_t)&ID), O(o), TM(tm) {
|
: MachineFunctionPass((intptr_t)&ID), O(o), TM(tm) {
|
||||||
e_flags = 0; // e_flags defaults to 0, no flags.
|
e_flags = 0; // e_flags defaults to 0, no flags.
|
||||||
|
|
||||||
@ -536,7 +537,7 @@ void ELFWriter::OutputSectionsAndSectionTable() {
|
|||||||
if (S.Align)
|
if (S.Align)
|
||||||
for (size_t NewFileOff = (FileOff+S.Align-1) & ~(S.Align-1);
|
for (size_t NewFileOff = (FileOff+S.Align-1) & ~(S.Align-1);
|
||||||
FileOff != NewFileOff; ++FileOff)
|
FileOff != NewFileOff; ++FileOff)
|
||||||
O.put((char)0xAB);
|
O << (char)0xAB;
|
||||||
O.write((char*)&S.SectionData[0], S.SectionData.size());
|
O.write((char*)&S.SectionData[0], S.SectionData.size());
|
||||||
FileOff += S.SectionData.size();
|
FileOff += S.SectionData.size();
|
||||||
|
|
||||||
@ -557,7 +558,7 @@ void ELFWriter::OutputSectionsAndSectionTable() {
|
|||||||
// Align output for the section table.
|
// Align output for the section table.
|
||||||
for (size_t NewFileOff = (FileOff+TableAlign-1) & ~(TableAlign-1);
|
for (size_t NewFileOff = (FileOff+TableAlign-1) & ~(TableAlign-1);
|
||||||
FileOff != NewFileOff; ++FileOff)
|
FileOff != NewFileOff; ++FileOff)
|
||||||
O.put((char)0xAB);
|
O << (char)0xAB;
|
||||||
|
|
||||||
// Emit the section table itself.
|
// Emit the section table itself.
|
||||||
O.write((char*)&Table[0], Table.size());
|
O.write((char*)&Table[0], Table.size());
|
||||||
|
@ -23,6 +23,7 @@ namespace llvm {
|
|||||||
class Mangler;
|
class Mangler;
|
||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
class ELFCodeEmitter;
|
class ELFCodeEmitter;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
/// ELFWriter - This class implements the common target-independent code for
|
/// ELFWriter - This class implements the common target-independent code for
|
||||||
/// writing ELF files. Targets should derive a class from this to
|
/// writing ELF files. Targets should derive a class from this to
|
||||||
@ -37,7 +38,7 @@ namespace llvm {
|
|||||||
return *(MachineCodeEmitter*)MCE;
|
return *(MachineCodeEmitter*)MCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ELFWriter(std::ostream &O, TargetMachine &TM);
|
ELFWriter(raw_ostream &O, TargetMachine &TM);
|
||||||
~ELFWriter();
|
~ELFWriter();
|
||||||
|
|
||||||
typedef std::vector<unsigned char> DataBuffer;
|
typedef std::vector<unsigned char> DataBuffer;
|
||||||
@ -45,7 +46,7 @@ namespace llvm {
|
|||||||
protected:
|
protected:
|
||||||
/// Output stream to send the resultant object file to.
|
/// Output stream to send the resultant object file to.
|
||||||
///
|
///
|
||||||
std::ostream &O;
|
raw_ostream &O;
|
||||||
|
|
||||||
/// Target machine description.
|
/// Target machine description.
|
||||||
///
|
///
|
||||||
|
@ -19,12 +19,12 @@ GCMetadataPrinter::GCMetadataPrinter() { }
|
|||||||
|
|
||||||
GCMetadataPrinter::~GCMetadataPrinter() { }
|
GCMetadataPrinter::~GCMetadataPrinter() { }
|
||||||
|
|
||||||
void GCMetadataPrinter::beginAssembly(std::ostream &OS, AsmPrinter &AP,
|
void GCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI) {
|
const TargetAsmInfo &TAI) {
|
||||||
// Default is no action.
|
// Default is no action.
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCMetadataPrinter::finishAssembly(std::ostream &OS, AsmPrinter &AP,
|
void GCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
|
||||||
const TargetAsmInfo &TAI) {
|
const TargetAsmInfo &TAI) {
|
||||||
// Default is no action.
|
// Default is no action.
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden,
|
static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden,
|
||||||
@ -50,7 +51,7 @@ DisablePostRAScheduler("disable-post-RA-scheduler",
|
|||||||
|
|
||||||
FileModel::Model
|
FileModel::Model
|
||||||
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
||||||
std::ostream &Out,
|
raw_ostream &Out,
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
bool Fast) {
|
bool Fast) {
|
||||||
// Standard LLVM-Level Passes.
|
// Standard LLVM-Level Passes.
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/OutputBuffer.h"
|
#include "llvm/Support/OutputBuffer.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -44,7 +45,7 @@ using namespace llvm;
|
|||||||
/// AddMachOWriter - Concrete function to add the Mach-O writer to the function
|
/// AddMachOWriter - Concrete function to add the Mach-O writer to the function
|
||||||
/// pass manager.
|
/// pass manager.
|
||||||
MachineCodeEmitter *llvm::AddMachOWriter(PassManagerBase &PM,
|
MachineCodeEmitter *llvm::AddMachOWriter(PassManagerBase &PM,
|
||||||
std::ostream &O,
|
raw_ostream &O,
|
||||||
TargetMachine &TM) {
|
TargetMachine &TM) {
|
||||||
MachOWriter *MOW = new MachOWriter(O, TM);
|
MachOWriter *MOW = new MachOWriter(O, TM);
|
||||||
PM.add(MOW);
|
PM.add(MOW);
|
||||||
@ -334,7 +335,7 @@ void MachOCodeEmitter::emitJumpTables(MachineJumpTableInfo *MJTI) {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
char MachOWriter::ID = 0;
|
char MachOWriter::ID = 0;
|
||||||
MachOWriter::MachOWriter(std::ostream &o, TargetMachine &tm)
|
MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm)
|
||||||
: MachineFunctionPass((intptr_t)&ID), O(o), TM(tm) {
|
: MachineFunctionPass((intptr_t)&ID), O(o), TM(tm) {
|
||||||
is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
|
is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
|
||||||
isLittleEndian = TM.getTargetData()->isLittleEndian();
|
isLittleEndian = TM.getTargetData()->isLittleEndian();
|
||||||
|
@ -29,6 +29,7 @@ namespace llvm {
|
|||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
class MachOCodeEmitter;
|
class MachOCodeEmitter;
|
||||||
class OutputBuffer;
|
class OutputBuffer;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
/// MachOSym - This struct contains information about each symbol that is
|
/// MachOSym - This struct contains information about each symbol that is
|
||||||
/// added to logical symbol table for the module. This is eventually
|
/// added to logical symbol table for the module. This is eventually
|
||||||
@ -90,7 +91,7 @@ namespace llvm {
|
|||||||
return *(MachineCodeEmitter*)MCE;
|
return *(MachineCodeEmitter*)MCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MachOWriter(std::ostream &O, TargetMachine &TM);
|
MachOWriter(raw_ostream &O, TargetMachine &TM);
|
||||||
virtual ~MachOWriter();
|
virtual ~MachOWriter();
|
||||||
|
|
||||||
virtual const char *getPassName() const {
|
virtual const char *getPassName() const {
|
||||||
@ -101,7 +102,7 @@ namespace llvm {
|
|||||||
protected:
|
protected:
|
||||||
/// Output stream to send the resultant object file to.
|
/// Output stream to send the resultant object file to.
|
||||||
///
|
///
|
||||||
std::ostream &O;
|
raw_ostream &O;
|
||||||
|
|
||||||
/// Target machine description.
|
/// Target machine description.
|
||||||
///
|
///
|
||||||
|
@ -19,15 +19,15 @@ using namespace llvm;
|
|||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#ifndef STDIN_FILENO
|
#ifndef STDIN_FILENO
|
||||||
# define STDIN_FILENO 0
|
# define STDIN_FILENO 0
|
||||||
#endif
|
#endif
|
||||||
#ifndef STDOUT_FILENO
|
#ifndef STDOUT_FILENO
|
||||||
# define STDOUT_FILENO 1
|
# define STDOUT_FILENO 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef STDERR_FILENO
|
#ifndef STDERR_FILENO
|
||||||
# define STDERR_FILENO 2
|
# define STDERR_FILENO 2
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// An out of line virtual method to provide a home for the class vtable.
|
// An out of line virtual method to provide a home for the class vtable.
|
||||||
@ -82,14 +82,14 @@ void raw_stderr_ostream::handle() {}
|
|||||||
|
|
||||||
/// outs() - This returns a reference to a raw_ostream for standard output.
|
/// outs() - This returns a reference to a raw_ostream for standard output.
|
||||||
/// Use it like: outs() << "foo" << "bar";
|
/// Use it like: outs() << "foo" << "bar";
|
||||||
raw_ostream &outs() {
|
raw_ostream &llvm::outs() {
|
||||||
static raw_stdout_ostream S;
|
static raw_stdout_ostream S;
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// errs() - This returns a reference to a raw_ostream for standard error.
|
/// errs() - This returns a reference to a raw_ostream for standard error.
|
||||||
/// Use it like: errs() << "foo" << "bar";
|
/// Use it like: errs() << "foo" << "bar";
|
||||||
raw_ostream &errs() {
|
raw_ostream &llvm::errs() {
|
||||||
static raw_stderr_ostream S;
|
static raw_stderr_ostream S;
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ namespace llvm {
|
|||||||
class ARMTargetMachine;
|
class ARMTargetMachine;
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
// Enums corresponding to ARM condition codes
|
// Enums corresponding to ARM condition codes
|
||||||
namespace ARMCC {
|
namespace ARMCC {
|
||||||
@ -87,7 +88,7 @@ inline static const char *ARMCondCodeToString(ARMCC::CondCodes CC) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *createARMISelDag(ARMTargetMachine &TM);
|
FunctionPass *createARMISelDag(ARMTargetMachine &TM);
|
||||||
FunctionPass *createARMCodePrinterPass(std::ostream &O, ARMTargetMachine &TM);
|
FunctionPass *createARMCodePrinterPass(raw_ostream &O, ARMTargetMachine &TM);
|
||||||
FunctionPass *createARMCodeEmitterPass(ARMTargetMachine &TM,
|
FunctionPass *createARMCodeEmitterPass(ARMTargetMachine &TM,
|
||||||
MachineCodeEmitter &MCE);
|
MachineCodeEmitter &MCE);
|
||||||
FunctionPass *createARMLoadStoreOptimizationPass();
|
FunctionPass *createARMLoadStoreOptimizationPass();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetMachineRegistry.h"
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -143,7 +144,7 @@ bool ARMTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ARMTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
bool ARMTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out) {
|
raw_ostream &Out) {
|
||||||
// Output assembly language.
|
// Output assembly language.
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
@ -163,7 +164,7 @@ bool ARMTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
|
|||||||
if (DumpAsm) {
|
if (DumpAsm) {
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
PM.add(AsmPrinterCtor(*cerr.stream(), *this));
|
PM.add(AsmPrinterCtor(errs(), *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -176,7 +177,7 @@ bool ARMTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
|||||||
if (DumpAsm) {
|
if (DumpAsm) {
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
PM.add(AsmPrinterCtor(*cerr.stream(), *this));
|
PM.add(AsmPrinterCtor(errs(), *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,7 +38,7 @@ class ARMTargetMachine : public LLVMTargetMachine {
|
|||||||
protected:
|
protected:
|
||||||
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
|
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
|
||||||
// set this functions to ctor pointer at startup time if they are linked in.
|
// set this functions to ctor pointer at startup time if they are linked in.
|
||||||
typedef FunctionPass *(*AsmPrinterCtorFn)(std::ostream &o,
|
typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
|
||||||
ARMTargetMachine &tm);
|
ARMTargetMachine &tm);
|
||||||
static AsmPrinterCtorFn AsmPrinterCtor;
|
static AsmPrinterCtorFn AsmPrinterCtor;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||||
bool DumpAsm, MachineCodeEmitter &MCE);
|
bool DumpAsm, MachineCodeEmitter &MCE);
|
||||||
virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter {
|
struct VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter {
|
||||||
ARMAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
ARMAsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||||
: AsmPrinter(O, TM, T), DW(O, this, T), MMI(NULL), AFI(NULL),
|
: AsmPrinter(O, TM, T), DW(O, this, T), MMI(NULL), AFI(NULL),
|
||||||
InCPMode(false) {
|
InCPMode(false) {
|
||||||
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
||||||
@ -342,7 +343,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printSOImm(std::ostream &O, int64_t V, const TargetAsmInfo *TAI) {
|
static void printSOImm(raw_ostream &O, int64_t V, const TargetAsmInfo *TAI) {
|
||||||
assert(V < (1 << 12) && "Not a valid so_imm value!");
|
assert(V < (1 << 12) && "Not a valid so_imm value!");
|
||||||
unsigned Imm = ARM_AM::getSOImmValImm(V);
|
unsigned Imm = ARM_AM::getSOImmValImm(V);
|
||||||
unsigned Rot = ARM_AM::getSOImmValRot(V);
|
unsigned Rot = ARM_AM::getSOImmValRot(V);
|
||||||
@ -824,7 +825,7 @@ bool ARMAsmPrinter::doInitialization(Module &M) {
|
|||||||
|
|
||||||
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
|
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
|
||||||
/// Don't print things like \n or \0.
|
/// Don't print things like \n or \0.
|
||||||
static void PrintUnmangledNameSafely(const Value *V, std::ostream &OS) {
|
static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
|
||||||
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
|
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
|
||||||
Name != E; ++Name)
|
Name != E; ++Name)
|
||||||
if (isprint(*Name))
|
if (isprint(*Name))
|
||||||
@ -1030,7 +1031,7 @@ bool ARMAsmPrinter::doFinalization(Module &M) {
|
|||||||
/// using the given target machine description. This should work
|
/// using the given target machine description. This should work
|
||||||
/// regardless of whether the function is in SSA form.
|
/// regardless of whether the function is in SSA form.
|
||||||
///
|
///
|
||||||
FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o,
|
FunctionPass *llvm::createARMCodePrinterPass(raw_ostream &o,
|
||||||
ARMTargetMachine &tm) {
|
ARMTargetMachine &tm) {
|
||||||
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,10 @@ namespace llvm {
|
|||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM);
|
FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM);
|
||||||
FunctionPass *createAlphaCodePrinterPass(std::ostream &OS,
|
FunctionPass *createAlphaCodePrinterPass(raw_ostream &OS,
|
||||||
TargetMachine &TM);
|
TargetMachine &TM);
|
||||||
FunctionPass *createAlphaPatternInstructionSelector(TargetMachine &TM);
|
FunctionPass *createAlphaPatternInstructionSelector(TargetMachine &TM);
|
||||||
FunctionPass *createAlphaCodeEmitterPass(AlphaTargetMachine &TM,
|
FunctionPass *createAlphaCodeEmitterPass(AlphaTargetMachine &TM,
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ namespace {
|
|||||||
/// Unique incrementer for label values for referencing Global values.
|
/// Unique incrementer for label values for referencing Global values.
|
||||||
///
|
///
|
||||||
|
|
||||||
AlphaAsmPrinter(std::ostream &o, TargetMachine &tm, const TargetAsmInfo *T)
|
AlphaAsmPrinter(raw_ostream &o, TargetMachine &tm, const TargetAsmInfo *T)
|
||||||
: AsmPrinter(o, tm, T) {
|
: AsmPrinter(o, tm, T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ namespace {
|
|||||||
/// using the given target machine description. This should work
|
/// using the given target machine description. This should work
|
||||||
/// regardless of whether the function is in SSA form.
|
/// regardless of whether the function is in SSA form.
|
||||||
///
|
///
|
||||||
FunctionPass *llvm::createAlphaCodePrinterPass(std::ostream &o,
|
FunctionPass *llvm::createAlphaCodePrinterPass(raw_ostream &o,
|
||||||
TargetMachine &tm) {
|
TargetMachine &tm) {
|
||||||
return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Target/TargetMachineRegistry.h"
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ bool AlphaTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool AlphaTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
bool AlphaTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out) {
|
raw_ostream &Out) {
|
||||||
PM.add(createAlphaLLRPPass(*this));
|
PM.add(createAlphaLLRPPass(*this));
|
||||||
PM.add(createAlphaCodePrinterPass(Out, *this));
|
PM.add(createAlphaCodePrinterPass(Out, *this));
|
||||||
return false;
|
return false;
|
||||||
@ -87,7 +88,7 @@ bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
|
|||||||
bool DumpAsm, MachineCodeEmitter &MCE) {
|
bool DumpAsm, MachineCodeEmitter &MCE) {
|
||||||
PM.add(createAlphaCodeEmitterPass(*this, MCE));
|
PM.add(createAlphaCodeEmitterPass(*this, MCE));
|
||||||
if (DumpAsm)
|
if (DumpAsm)
|
||||||
PM.add(createAlphaCodePrinterPass(*cerr.stream(), *this));
|
PM.add(createAlphaCodePrinterPass(errs(), *this));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
|
bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||||
bool DumpAsm, MachineCodeEmitter &MCE);
|
bool DumpAsm, MachineCodeEmitter &MCE);
|
||||||
virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "llvm/Support/InstVisitor.h"
|
#include "llvm/Support/InstVisitor.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
@ -76,7 +77,7 @@ namespace {
|
|||||||
/// CWriter - This class is the main chunk of code that converts an LLVM
|
/// CWriter - This class is the main chunk of code that converts an LLVM
|
||||||
/// module to a C translation unit.
|
/// module to a C translation unit.
|
||||||
class CWriter : public FunctionPass, public InstVisitor<CWriter> {
|
class CWriter : public FunctionPass, public InstVisitor<CWriter> {
|
||||||
std::ostream &Out;
|
raw_ostream &Out;
|
||||||
IntrinsicLowering *IL;
|
IntrinsicLowering *IL;
|
||||||
Mangler *Mang;
|
Mangler *Mang;
|
||||||
LoopInfo *LI;
|
LoopInfo *LI;
|
||||||
@ -90,7 +91,7 @@ namespace {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
explicit CWriter(std::ostream &o)
|
explicit CWriter(raw_ostream &o)
|
||||||
: FunctionPass((intptr_t)&ID), Out(o), IL(0), Mang(0), LI(0),
|
: FunctionPass((intptr_t)&ID), Out(o), IL(0), Mang(0), LI(0),
|
||||||
TheModule(0), TAsm(0), TD(0) {}
|
TheModule(0), TAsm(0), TD(0) {}
|
||||||
|
|
||||||
@ -126,16 +127,24 @@ namespace {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &printType(std::ostream &Out, const Type *Ty,
|
raw_ostream &printType(raw_ostream &Out, const Type *Ty,
|
||||||
bool isSigned = false,
|
bool isSigned = false,
|
||||||
const std::string &VariableName = "",
|
const std::string &VariableName = "",
|
||||||
bool IgnoreName = false,
|
bool IgnoreName = false,
|
||||||
const PAListPtr &PAL = PAListPtr());
|
const PAListPtr &PAL = PAListPtr());
|
||||||
std::ostream &printSimpleType(std::ostream &Out, const Type *Ty,
|
std::ostream &printType(std::ostream &Out, const Type *Ty,
|
||||||
|
bool isSigned = false,
|
||||||
|
const std::string &VariableName = "",
|
||||||
|
bool IgnoreName = false,
|
||||||
|
const PAListPtr &PAL = PAListPtr());
|
||||||
|
raw_ostream &printSimpleType(raw_ostream &Out, const Type *Ty,
|
||||||
bool isSigned,
|
bool isSigned,
|
||||||
const std::string &NameSoFar = "");
|
const std::string &NameSoFar = "");
|
||||||
|
std::ostream &printSimpleType(std::ostream &Out, const Type *Ty,
|
||||||
|
bool isSigned,
|
||||||
|
const std::string &NameSoFar = "");
|
||||||
|
|
||||||
void printStructReturnPointerFunctionType(std::ostream &Out,
|
void printStructReturnPointerFunctionType(raw_ostream &Out,
|
||||||
const PAListPtr &PAL,
|
const PAListPtr &PAL,
|
||||||
const PointerType *Ty);
|
const PointerType *Ty);
|
||||||
|
|
||||||
@ -398,7 +407,7 @@ bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) {
|
|||||||
/// printStructReturnPointerFunctionType - This is like printType for a struct
|
/// printStructReturnPointerFunctionType - This is like printType for a struct
|
||||||
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
|
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
|
||||||
/// print it as "Struct (*)(...)", for struct return functions.
|
/// print it as "Struct (*)(...)", for struct return functions.
|
||||||
void CWriter::printStructReturnPointerFunctionType(std::ostream &Out,
|
void CWriter::printStructReturnPointerFunctionType(raw_ostream &Out,
|
||||||
const PAListPtr &PAL,
|
const PAListPtr &PAL,
|
||||||
const PointerType *TheTy) {
|
const PointerType *TheTy) {
|
||||||
const FunctionType *FTy = cast<FunctionType>(TheTy->getElementType());
|
const FunctionType *FTy = cast<FunctionType>(TheTy->getElementType());
|
||||||
@ -433,6 +442,51 @@ void CWriter::printStructReturnPointerFunctionType(std::ostream &Out,
|
|||||||
/*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
|
/*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raw_ostream &
|
||||||
|
CWriter::printSimpleType(raw_ostream &Out, const Type *Ty, bool isSigned,
|
||||||
|
const std::string &NameSoFar) {
|
||||||
|
assert((Ty->isPrimitiveType() || Ty->isInteger() || isa<VectorType>(Ty)) &&
|
||||||
|
"Invalid type for printSimpleType");
|
||||||
|
switch (Ty->getTypeID()) {
|
||||||
|
case Type::VoidTyID: return Out << "void " << NameSoFar;
|
||||||
|
case Type::IntegerTyID: {
|
||||||
|
unsigned NumBits = cast<IntegerType>(Ty)->getBitWidth();
|
||||||
|
if (NumBits == 1)
|
||||||
|
return Out << "bool " << NameSoFar;
|
||||||
|
else if (NumBits <= 8)
|
||||||
|
return Out << (isSigned?"signed":"unsigned") << " char " << NameSoFar;
|
||||||
|
else if (NumBits <= 16)
|
||||||
|
return Out << (isSigned?"signed":"unsigned") << " short " << NameSoFar;
|
||||||
|
else if (NumBits <= 32)
|
||||||
|
return Out << (isSigned?"signed":"unsigned") << " int " << NameSoFar;
|
||||||
|
else if (NumBits <= 64)
|
||||||
|
return Out << (isSigned?"signed":"unsigned") << " long long "<< NameSoFar;
|
||||||
|
else {
|
||||||
|
assert(NumBits <= 128 && "Bit widths > 128 not implemented yet");
|
||||||
|
return Out << (isSigned?"llvmInt128":"llvmUInt128") << " " << NameSoFar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case Type::FloatTyID: return Out << "float " << NameSoFar;
|
||||||
|
case Type::DoubleTyID: return Out << "double " << NameSoFar;
|
||||||
|
// Lacking emulation of FP80 on PPC, etc., we assume whichever of these is
|
||||||
|
// present matches host 'long double'.
|
||||||
|
case Type::X86_FP80TyID:
|
||||||
|
case Type::PPC_FP128TyID:
|
||||||
|
case Type::FP128TyID: return Out << "long double " << NameSoFar;
|
||||||
|
|
||||||
|
case Type::VectorTyID: {
|
||||||
|
const VectorType *VTy = cast<VectorType>(Ty);
|
||||||
|
return printSimpleType(Out, VTy->getElementType(), isSigned,
|
||||||
|
" __attribute__((vector_size(" +
|
||||||
|
utostr(TD->getABITypeSize(VTy)) + " ))) " + NameSoFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
cerr << "Unknown primitive type: " << *Ty << "\n";
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream &
|
std::ostream &
|
||||||
CWriter::printSimpleType(std::ostream &Out, const Type *Ty, bool isSigned,
|
CWriter::printSimpleType(std::ostream &Out, const Type *Ty, bool isSigned,
|
||||||
const std::string &NameSoFar) {
|
const std::string &NameSoFar) {
|
||||||
@ -478,6 +532,111 @@ CWriter::printSimpleType(std::ostream &Out, const Type *Ty, bool isSigned,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pass the Type* and the variable name and this prints out the variable
|
||||||
|
// declaration.
|
||||||
|
//
|
||||||
|
raw_ostream &CWriter::printType(raw_ostream &Out, const Type *Ty,
|
||||||
|
bool isSigned, const std::string &NameSoFar,
|
||||||
|
bool IgnoreName, const PAListPtr &PAL) {
|
||||||
|
if (Ty->isPrimitiveType() || Ty->isInteger() || isa<VectorType>(Ty)) {
|
||||||
|
printSimpleType(Out, Ty, isSigned, NameSoFar);
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check to see if the type is named.
|
||||||
|
if (!IgnoreName || isa<OpaqueType>(Ty)) {
|
||||||
|
std::map<const Type *, std::string>::iterator I = TypeNames.find(Ty);
|
||||||
|
if (I != TypeNames.end()) return Out << I->second << ' ' << NameSoFar;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Ty->getTypeID()) {
|
||||||
|
case Type::FunctionTyID: {
|
||||||
|
const FunctionType *FTy = cast<FunctionType>(Ty);
|
||||||
|
std::stringstream FunctionInnards;
|
||||||
|
FunctionInnards << " (" << NameSoFar << ") (";
|
||||||
|
unsigned Idx = 1;
|
||||||
|
for (FunctionType::param_iterator I = FTy->param_begin(),
|
||||||
|
E = FTy->param_end(); I != E; ++I) {
|
||||||
|
const Type *ArgTy = *I;
|
||||||
|
if (PAL.paramHasAttr(Idx, ParamAttr::ByVal)) {
|
||||||
|
assert(isa<PointerType>(ArgTy));
|
||||||
|
ArgTy = cast<PointerType>(ArgTy)->getElementType();
|
||||||
|
}
|
||||||
|
if (I != FTy->param_begin())
|
||||||
|
FunctionInnards << ", ";
|
||||||
|
printType(FunctionInnards, ArgTy,
|
||||||
|
/*isSigned=*/PAL.paramHasAttr(Idx, ParamAttr::SExt), "");
|
||||||
|
++Idx;
|
||||||
|
}
|
||||||
|
if (FTy->isVarArg()) {
|
||||||
|
if (FTy->getNumParams())
|
||||||
|
FunctionInnards << ", ...";
|
||||||
|
} else if (!FTy->getNumParams()) {
|
||||||
|
FunctionInnards << "void";
|
||||||
|
}
|
||||||
|
FunctionInnards << ')';
|
||||||
|
std::string tstr = FunctionInnards.str();
|
||||||
|
printType(Out, FTy->getReturnType(),
|
||||||
|
/*isSigned=*/PAL.paramHasAttr(0, ParamAttr::SExt), tstr);
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
case Type::StructTyID: {
|
||||||
|
const StructType *STy = cast<StructType>(Ty);
|
||||||
|
Out << NameSoFar + " {\n";
|
||||||
|
unsigned Idx = 0;
|
||||||
|
for (StructType::element_iterator I = STy->element_begin(),
|
||||||
|
E = STy->element_end(); I != E; ++I) {
|
||||||
|
Out << " ";
|
||||||
|
printType(Out, *I, false, "field" + utostr(Idx++));
|
||||||
|
Out << ";\n";
|
||||||
|
}
|
||||||
|
Out << '}';
|
||||||
|
if (STy->isPacked())
|
||||||
|
Out << " __attribute__ ((packed))";
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Type::PointerTyID: {
|
||||||
|
const PointerType *PTy = cast<PointerType>(Ty);
|
||||||
|
std::string ptrName = "*" + NameSoFar;
|
||||||
|
|
||||||
|
if (isa<ArrayType>(PTy->getElementType()) ||
|
||||||
|
isa<VectorType>(PTy->getElementType()))
|
||||||
|
ptrName = "(" + ptrName + ")";
|
||||||
|
|
||||||
|
if (!PAL.isEmpty())
|
||||||
|
// Must be a function ptr cast!
|
||||||
|
return printType(Out, PTy->getElementType(), false, ptrName, true, PAL);
|
||||||
|
return printType(Out, PTy->getElementType(), false, ptrName);
|
||||||
|
}
|
||||||
|
|
||||||
|
case Type::ArrayTyID: {
|
||||||
|
const ArrayType *ATy = cast<ArrayType>(Ty);
|
||||||
|
unsigned NumElements = ATy->getNumElements();
|
||||||
|
if (NumElements == 0) NumElements = 1;
|
||||||
|
// Arrays are wrapped in structs to allow them to have normal
|
||||||
|
// value semantics (avoiding the array "decay").
|
||||||
|
Out << NameSoFar << " { ";
|
||||||
|
printType(Out, ATy->getElementType(), false,
|
||||||
|
"array[" + utostr(NumElements) + "]");
|
||||||
|
return Out << "; }";
|
||||||
|
}
|
||||||
|
|
||||||
|
case Type::OpaqueTyID: {
|
||||||
|
static int Count = 0;
|
||||||
|
std::string TyName = "struct opaque_" + itostr(Count++);
|
||||||
|
assert(TypeNames.find(Ty) == TypeNames.end());
|
||||||
|
TypeNames[Ty] = TyName;
|
||||||
|
return Out << TyName << ' ' << NameSoFar;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
assert(0 && "Unhandled case in getTypeProps!");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
|
||||||
// Pass the Type* and the variable name and this prints out the variable
|
// Pass the Type* and the variable name and this prints out the variable
|
||||||
// declaration.
|
// declaration.
|
||||||
//
|
//
|
||||||
@ -1427,7 +1586,7 @@ void CWriter::writeOperandWithCast(Value* Operand, const ICmpInst &Cmp) {
|
|||||||
// generateCompilerSpecificCode - This is where we add conditional compilation
|
// generateCompilerSpecificCode - This is where we add conditional compilation
|
||||||
// directives to cater to specific compilers as need be.
|
// directives to cater to specific compilers as need be.
|
||||||
//
|
//
|
||||||
static void generateCompilerSpecificCode(std::ostream& Out,
|
static void generateCompilerSpecificCode(raw_ostream& Out,
|
||||||
const TargetData *TD) {
|
const TargetData *TD) {
|
||||||
// Alloca is hard to get, and we don't want to include stdlib.h here.
|
// Alloca is hard to get, and we don't want to include stdlib.h here.
|
||||||
Out << "/* get a declaration for alloca */\n"
|
Out << "/* get a declaration for alloca */\n"
|
||||||
@ -1871,31 +2030,31 @@ void CWriter::printFloatingPointConstants(Function &F) {
|
|||||||
double Val = FPC->getValueAPF().convertToDouble();
|
double Val = FPC->getValueAPF().convertToDouble();
|
||||||
uint64_t i = FPC->getValueAPF().convertToAPInt().getZExtValue();
|
uint64_t i = FPC->getValueAPF().convertToAPInt().getZExtValue();
|
||||||
Out << "static const ConstantDoubleTy FPConstant" << FPCounter++
|
Out << "static const ConstantDoubleTy FPConstant" << FPCounter++
|
||||||
<< " = 0x" << std::hex << i << std::dec
|
<< " = 0x" << utohexstr(i)
|
||||||
<< "ULL; /* " << Val << " */\n";
|
<< "ULL; /* " << Val << " */\n";
|
||||||
} else if (FPC->getType() == Type::FloatTy) {
|
} else if (FPC->getType() == Type::FloatTy) {
|
||||||
float Val = FPC->getValueAPF().convertToFloat();
|
float Val = FPC->getValueAPF().convertToFloat();
|
||||||
uint32_t i = (uint32_t)FPC->getValueAPF().convertToAPInt().
|
uint32_t i = (uint32_t)FPC->getValueAPF().convertToAPInt().
|
||||||
getZExtValue();
|
getZExtValue();
|
||||||
Out << "static const ConstantFloatTy FPConstant" << FPCounter++
|
Out << "static const ConstantFloatTy FPConstant" << FPCounter++
|
||||||
<< " = 0x" << std::hex << i << std::dec
|
<< " = 0x" << utohexstr(i)
|
||||||
<< "U; /* " << Val << " */\n";
|
<< "U; /* " << Val << " */\n";
|
||||||
} else if (FPC->getType() == Type::X86_FP80Ty) {
|
} else if (FPC->getType() == Type::X86_FP80Ty) {
|
||||||
// api needed to prevent premature destruction
|
// api needed to prevent premature destruction
|
||||||
APInt api = FPC->getValueAPF().convertToAPInt();
|
APInt api = FPC->getValueAPF().convertToAPInt();
|
||||||
const uint64_t *p = api.getRawData();
|
const uint64_t *p = api.getRawData();
|
||||||
Out << "static const ConstantFP80Ty FPConstant" << FPCounter++
|
Out << "static const ConstantFP80Ty FPConstant" << FPCounter++
|
||||||
<< " = { 0x" << std::hex
|
<< " = { 0x"
|
||||||
<< ((uint16_t)p[1] | (p[0] & 0xffffffffffffLL)<<16)
|
<< utohexstr((uint16_t)p[1] | (p[0] & 0xffffffffffffLL)<<16)
|
||||||
<< "ULL, 0x" << (uint16_t)(p[0] >> 48) << ",{0,0,0}"
|
<< "ULL, 0x" << utohexstr((uint16_t)(p[0] >> 48)) << ",{0,0,0}"
|
||||||
<< "}; /* Long double constant */\n" << std::dec;
|
<< "}; /* Long double constant */\n";
|
||||||
} else if (FPC->getType() == Type::PPC_FP128Ty) {
|
} else if (FPC->getType() == Type::PPC_FP128Ty) {
|
||||||
APInt api = FPC->getValueAPF().convertToAPInt();
|
APInt api = FPC->getValueAPF().convertToAPInt();
|
||||||
const uint64_t *p = api.getRawData();
|
const uint64_t *p = api.getRawData();
|
||||||
Out << "static const ConstantFP128Ty FPConstant" << FPCounter++
|
Out << "static const ConstantFP128Ty FPConstant" << FPCounter++
|
||||||
<< " = { 0x" << std::hex
|
<< " = { 0x"
|
||||||
<< p[0] << ", 0x" << p[1]
|
<< utohexstr(p[0]) << ", 0x" << utohexstr(p[1])
|
||||||
<< "}; /* Long double constant */\n" << std::dec;
|
<< "}; /* Long double constant */\n";
|
||||||
|
|
||||||
} else
|
} else
|
||||||
assert(0 && "Unknown float type!");
|
assert(0 && "Unknown float type!");
|
||||||
@ -2869,11 +3028,16 @@ bool CWriter::visitBuiltinCall(CallInst &I, Intrinsic::ID ID,
|
|||||||
case Intrinsic::dbg_stoppoint: {
|
case Intrinsic::dbg_stoppoint: {
|
||||||
// If we use writeOperand directly we get a "u" suffix which is rejected
|
// If we use writeOperand directly we get a "u" suffix which is rejected
|
||||||
// by gcc.
|
// by gcc.
|
||||||
|
std::stringstream SPIStr;
|
||||||
DbgStopPointInst &SPI = cast<DbgStopPointInst>(I);
|
DbgStopPointInst &SPI = cast<DbgStopPointInst>(I);
|
||||||
|
SPI.getDirectory()->print(SPIStr);
|
||||||
Out << "\n#line "
|
Out << "\n#line "
|
||||||
<< SPI.getLine()
|
<< SPI.getLine()
|
||||||
<< " \"" << SPI.getDirectory()
|
<< " \"";
|
||||||
<< SPI.getFileName() << "\"\n";
|
Out << SPIStr.str();
|
||||||
|
SPIStr.clear();
|
||||||
|
SPI.getFileName()->print(SPIStr);
|
||||||
|
Out << SPIStr.str() << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case Intrinsic::x86_sse_cmp_ss:
|
case Intrinsic::x86_sse_cmp_ss:
|
||||||
@ -3375,7 +3539,7 @@ void CWriter::visitExtractValueInst(ExtractValueInst &EVI) {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
bool CTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
|
bool CTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
|
||||||
std::ostream &o,
|
raw_ostream &o,
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
bool Fast) {
|
bool Fast) {
|
||||||
if (FileType != TargetMachine::AssemblyFile) return true;
|
if (FileType != TargetMachine::AssemblyFile) return true;
|
||||||
|
@ -26,7 +26,7 @@ struct CTargetMachine : public TargetMachine {
|
|||||||
: DataLayout(&M) {}
|
: DataLayout(&M) {}
|
||||||
|
|
||||||
virtual bool WantsWholeFile() const { return true; }
|
virtual bool WantsWholeFile() const { return true; }
|
||||||
virtual bool addPassesToEmitWholeFile(PassManager &PM, std::ostream &Out,
|
virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
|
||||||
CodeGenFileType FileType, bool Fast);
|
CodeGenFileType FileType, bool Fast);
|
||||||
|
|
||||||
// This class always works, but shouldn't be the default in most cases.
|
// This class always works, but shouldn't be the default in most cases.
|
||||||
|
@ -20,9 +20,10 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
class SPUTargetMachine;
|
class SPUTargetMachine;
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
|
FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
|
||||||
FunctionPass *createSPUAsmPrinterPass(std::ostream &o, SPUTargetMachine &tm);
|
FunctionPass *createSPUAsmPrinterPass(raw_ostream &o, SPUTargetMachine &tm);
|
||||||
|
|
||||||
/*--== Utility functions/predicates/etc used all over the place: --==*/
|
/*--== Utility functions/predicates/etc used all over the place: --==*/
|
||||||
//! Predicate test for a signed 10-bit value
|
//! Predicate test for a signed 10-bit value
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
@ -47,7 +48,7 @@ namespace {
|
|||||||
struct VISIBILITY_HIDDEN SPUAsmPrinter : public AsmPrinter {
|
struct VISIBILITY_HIDDEN SPUAsmPrinter : public AsmPrinter {
|
||||||
std::set<std::string> FnStubs, GVStubs;
|
std::set<std::string> FnStubs, GVStubs;
|
||||||
|
|
||||||
SPUAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T) :
|
SPUAsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T) :
|
||||||
AsmPrinter(O, TM, T)
|
AsmPrinter(O, TM, T)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -275,7 +276,7 @@ namespace {
|
|||||||
DwarfWriter DW;
|
DwarfWriter DW;
|
||||||
MachineModuleInfo *MMI;
|
MachineModuleInfo *MMI;
|
||||||
|
|
||||||
LinuxAsmPrinter(std::ostream &O, SPUTargetMachine &TM,
|
LinuxAsmPrinter(raw_ostream &O, SPUTargetMachine &TM,
|
||||||
const TargetAsmInfo *T) :
|
const TargetAsmInfo *T) :
|
||||||
SPUAsmPrinter(O, TM, T),
|
SPUAsmPrinter(O, TM, T),
|
||||||
DW(O, this, T),
|
DW(O, this, T),
|
||||||
@ -651,7 +652,7 @@ bool LinuxAsmPrinter::doFinalization(Module &M) {
|
|||||||
/// assembly code for a MachineFunction to the given output stream, in a format
|
/// assembly code for a MachineFunction to the given output stream, in a format
|
||||||
/// that the Linux SPU assembler can deal with.
|
/// that the Linux SPU assembler can deal with.
|
||||||
///
|
///
|
||||||
FunctionPass *llvm::createSPUAsmPrinterPass(std::ostream &o,
|
FunctionPass *llvm::createSPUAsmPrinterPass(raw_ostream &o,
|
||||||
SPUTargetMachine &tm) {
|
SPUTargetMachine &tm) {
|
||||||
return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ SPUTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out) {
|
raw_ostream &Out) {
|
||||||
PM.add(createSPUAsmPrinterPass(Out, *this));
|
PM.add(createSPUAsmPrinterPass(Out, *this));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
// Pass Pipeline Configuration
|
// Pass Pipeline Configuration
|
||||||
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -86,7 +87,7 @@ namespace {
|
|||||||
/// module to a C++ translation unit.
|
/// module to a C++ translation unit.
|
||||||
class CppWriter : public ModulePass {
|
class CppWriter : public ModulePass {
|
||||||
const char* progname;
|
const char* progname;
|
||||||
std::ostream &Out;
|
raw_ostream &Out;
|
||||||
const Module *TheModule;
|
const Module *TheModule;
|
||||||
uint64_t uniqueNum;
|
uint64_t uniqueNum;
|
||||||
TypeMap TypeNames;
|
TypeMap TypeNames;
|
||||||
@ -101,7 +102,7 @@ namespace {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
explicit CppWriter(std::ostream &o) :
|
explicit CppWriter(raw_ostream &o) :
|
||||||
ModulePass((intptr_t)&ID), Out(o), uniqueNum(0), is_inline(false) {}
|
ModulePass((intptr_t)&ID), Out(o), uniqueNum(0), is_inline(false) {}
|
||||||
|
|
||||||
virtual const char *getPassName() const { return "C++ backend"; }
|
virtual const char *getPassName() const { return "C++ backend"; }
|
||||||
@ -154,7 +155,7 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static unsigned indent_level = 0;
|
static unsigned indent_level = 0;
|
||||||
inline std::ostream& nl(std::ostream& Out, int delta = 0) {
|
inline raw_ostream& nl(raw_ostream& Out, int delta = 0) {
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
if (delta >= 0 || indent_level >= unsigned(-delta))
|
if (delta >= 0 || indent_level >= unsigned(-delta))
|
||||||
indent_level += delta;
|
indent_level += delta;
|
||||||
@ -252,13 +253,13 @@ namespace {
|
|||||||
else
|
else
|
||||||
Out << StrVal << "f";
|
Out << StrVal << "f";
|
||||||
} else if (CFP->getType() == Type::DoubleTy)
|
} else if (CFP->getType() == Type::DoubleTy)
|
||||||
Out << "BitsToDouble(0x" << std::hex
|
Out << "BitsToDouble(0x"
|
||||||
<< CFP->getValueAPF().convertToAPInt().getZExtValue()
|
<< utohexstr(CFP->getValueAPF().convertToAPInt().getZExtValue())
|
||||||
<< std::dec << "ULL) /* " << StrVal << " */";
|
<< "ULL) /* " << StrVal << " */";
|
||||||
else
|
else
|
||||||
Out << "BitsToFloat(0x" << std::hex
|
Out << "BitsToFloat(0x"
|
||||||
<< (uint32_t)CFP->getValueAPF().convertToAPInt().getZExtValue()
|
<< utohexstr((uint32_t)CFP->getValueAPF().convertToAPInt().getZExtValue())
|
||||||
<< std::dec << "U) /* " << StrVal << " */";
|
<< "U) /* " << StrVal << " */";
|
||||||
Out << ")";
|
Out << ")";
|
||||||
#if HAVE_PRINTF_A
|
#if HAVE_PRINTF_A
|
||||||
}
|
}
|
||||||
@ -1982,7 +1983,7 @@ char CppWriter::ID = 0;
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
bool CPPTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
|
bool CPPTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
|
||||||
std::ostream &o,
|
raw_ostream &o,
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
bool Fast) {
|
bool Fast) {
|
||||||
if (FileType != TargetMachine::AssemblyFile) return true;
|
if (FileType != TargetMachine::AssemblyFile) return true;
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
struct CPPTargetMachine : public TargetMachine {
|
struct CPPTargetMachine : public TargetMachine {
|
||||||
const TargetData DataLayout; // Calculates type size & alignment
|
const TargetData DataLayout; // Calculates type size & alignment
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ struct CPPTargetMachine : public TargetMachine {
|
|||||||
: DataLayout(&M) {}
|
: DataLayout(&M) {}
|
||||||
|
|
||||||
virtual bool WantsWholeFile() const { return true; }
|
virtual bool WantsWholeFile() const { return true; }
|
||||||
virtual bool addPassesToEmitWholeFile(PassManager &PM, std::ostream &Out,
|
virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
|
||||||
CodeGenFileType FileType, bool Fast);
|
CodeGenFileType FileType, bool Fast);
|
||||||
|
|
||||||
// This class always works, but shouldn't be the default in most cases.
|
// This class always works, but shouldn't be the default in most cases.
|
||||||
|
@ -20,6 +20,7 @@ namespace llvm {
|
|||||||
|
|
||||||
class IA64TargetMachine;
|
class IA64TargetMachine;
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
/// createIA64DAGToDAGInstructionSelector - This pass converts an LLVM
|
/// createIA64DAGToDAGInstructionSelector - This pass converts an LLVM
|
||||||
/// function into IA64 machine code in a sane, DAG->DAG transform.
|
/// function into IA64 machine code in a sane, DAG->DAG transform.
|
||||||
@ -36,7 +37,7 @@ FunctionPass *createIA64BundlingPass(IA64TargetMachine &TM);
|
|||||||
/// using the given target machine description. This should work
|
/// using the given target machine description. This should work
|
||||||
/// regardless of whether the function is in SSA form.
|
/// regardless of whether the function is in SSA form.
|
||||||
///
|
///
|
||||||
FunctionPass *createIA64CodePrinterPass(std::ostream &o, IA64TargetMachine &tm);
|
FunctionPass *createIA64CodePrinterPass(raw_ostream &o, IA64TargetMachine &tm);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ namespace {
|
|||||||
struct IA64AsmPrinter : public AsmPrinter {
|
struct IA64AsmPrinter : public AsmPrinter {
|
||||||
std::set<std::string> ExternalFunctionNames, ExternalObjectNames;
|
std::set<std::string> ExternalFunctionNames, ExternalObjectNames;
|
||||||
|
|
||||||
IA64AsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
IA64AsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||||
: AsmPrinter(O, TM, T) {
|
: AsmPrinter(O, TM, T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +337,7 @@ void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
O << "\t.size " << name << ',' << Size << '\n';
|
O << "\t.size " << name << ',' << Size << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
O << name << ":\t\t\t\t// " << *C << '\n';
|
O << name << ":\n";
|
||||||
EmitGlobalConstant(C);
|
EmitGlobalConstant(C);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +371,7 @@ bool IA64AsmPrinter::doFinalization(Module &M) {
|
|||||||
/// assembly code for a MachineFunction to the given output stream, using
|
/// assembly code for a MachineFunction to the given output stream, using
|
||||||
/// the given target machine description.
|
/// the given target machine description.
|
||||||
///
|
///
|
||||||
FunctionPass *llvm::createIA64CodePrinterPass(std::ostream &o,
|
FunctionPass *llvm::createIA64CodePrinterPass(raw_ostream &o,
|
||||||
IA64TargetMachine &tm) {
|
IA64TargetMachine &tm) {
|
||||||
return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo());
|
return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out) {
|
raw_ostream &Out) {
|
||||||
PM.add(createIA64CodePrinterPass(Out, *this));
|
PM.add(createIA64CodePrinterPass(Out, *this));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
};
|
};
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace {
|
|||||||
: DataLayout(&M) {}
|
: DataLayout(&M) {}
|
||||||
|
|
||||||
virtual bool WantsWholeFile() const { return true; }
|
virtual bool WantsWholeFile() const { return true; }
|
||||||
virtual bool addPassesToEmitWholeFile(PassManager &PM, std::ostream &Out,
|
virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
|
||||||
CodeGenFileType FileType, bool Fast);
|
CodeGenFileType FileType, bool Fast);
|
||||||
|
|
||||||
// This class always works, but shouldn't be the default in most cases.
|
// This class always works, but shouldn't be the default in most cases.
|
||||||
@ -1191,7 +1191,7 @@ void MSILWriter::printBasicBlock(const BasicBlock* BB) {
|
|||||||
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
|
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
|
||||||
const Instruction* Inst = I;
|
const Instruction* Inst = I;
|
||||||
// Comment llvm original instruction
|
// Comment llvm original instruction
|
||||||
Out << "\n//" << *Inst << "\n";
|
// Out << "\n//" << *Inst << "\n";
|
||||||
// Do not handle PHI instruction in current block
|
// Do not handle PHI instruction in current block
|
||||||
if (Inst->getOpcode()==Instruction::PHI) continue;
|
if (Inst->getOpcode()==Instruction::PHI) continue;
|
||||||
// Print instruction
|
// Print instruction
|
||||||
@ -1367,8 +1367,8 @@ void MSILWriter::printStaticInitializerList() {
|
|||||||
for (std::vector<StaticInitializer>::const_iterator I = InitList.begin(),
|
for (std::vector<StaticInitializer>::const_iterator I = InitList.begin(),
|
||||||
E = InitList.end(); I!=E; ++I) {
|
E = InitList.end(); I!=E; ++I) {
|
||||||
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(I->constant)) {
|
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(I->constant)) {
|
||||||
Out << "\n// Init " << getValueName(VarI->first) << ", offset " <<
|
// Out << "\n// Init " << getValueName(VarI->first) << ", offset " <<
|
||||||
utostr(I->offset) << ", type "<< *I->constant->getType() << "\n\n";
|
// utostr(I->offset) << ", type "<< *I->constant->getType() << "\n\n";
|
||||||
// Load variable address
|
// Load variable address
|
||||||
printValueLoad(VarI->first);
|
printValueLoad(VarI->first);
|
||||||
// Add offset
|
// Add offset
|
||||||
@ -1648,7 +1648,7 @@ void MSILWriter::printExternals() {
|
|||||||
// External Interface declaration
|
// External Interface declaration
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM, std::ostream &o,
|
bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM, raw_ostream &o,
|
||||||
CodeGenFileType FileType, bool Fast)
|
CodeGenFileType FileType, bool Fast)
|
||||||
{
|
{
|
||||||
if (FileType != TargetMachine::AssemblyFile) return true;
|
if (FileType != TargetMachine::AssemblyFile) return true;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "llvm/Analysis/FindUsedTypes.h"
|
#include "llvm/Analysis/FindUsedTypes.h"
|
||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopInfo.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetMachineRegistry.h"
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
@ -75,7 +76,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::ostream &Out;
|
raw_ostream &Out;
|
||||||
Module* ModulePtr;
|
Module* ModulePtr;
|
||||||
const TargetData* TD;
|
const TargetData* TD;
|
||||||
Mangler* Mang;
|
Mangler* Mang;
|
||||||
@ -85,7 +86,7 @@ namespace {
|
|||||||
StaticInitList;
|
StaticInitList;
|
||||||
const std::set<const Type *>* UsedTypes;
|
const std::set<const Type *>* UsedTypes;
|
||||||
static char ID;
|
static char ID;
|
||||||
MSILWriter(std::ostream &o) : FunctionPass((intptr_t)&ID), Out(o) {
|
MSILWriter(raw_ostream &o) : FunctionPass((intptr_t)&ID), Out(o) {
|
||||||
UniqID = 0;
|
UniqID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,11 @@ namespace llvm {
|
|||||||
class MipsTargetMachine;
|
class MipsTargetMachine;
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
|
FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
|
||||||
FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
|
FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
|
||||||
FunctionPass *createMipsCodePrinterPass(std::ostream &OS,
|
FunctionPass *createMipsCodePrinterPass(raw_ostream &OS,
|
||||||
MipsTargetMachine &TM);
|
MipsTargetMachine &TM);
|
||||||
} // end namespace llvm;
|
} // end namespace llvm;
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -48,7 +49,7 @@ namespace {
|
|||||||
|
|
||||||
const MipsSubtarget *Subtarget;
|
const MipsSubtarget *Subtarget;
|
||||||
|
|
||||||
MipsAsmPrinter(std::ostream &O, MipsTargetMachine &TM,
|
MipsAsmPrinter(raw_ostream &O, MipsTargetMachine &TM,
|
||||||
const TargetAsmInfo *T):
|
const TargetAsmInfo *T):
|
||||||
AsmPrinter(O, TM, T) {
|
AsmPrinter(O, TM, T) {
|
||||||
Subtarget = &TM.getSubtarget<MipsSubtarget>();
|
Subtarget = &TM.getSubtarget<MipsSubtarget>();
|
||||||
@ -89,7 +90,7 @@ namespace {
|
|||||||
/// assembly code for a MachineFunction to the given output stream,
|
/// assembly code for a MachineFunction to the given output stream,
|
||||||
/// using the given target machine description. This should work
|
/// using the given target machine description. This should work
|
||||||
/// regardless of whether the function is in SSA form.
|
/// regardless of whether the function is in SSA form.
|
||||||
FunctionPass *llvm::createMipsCodePrinterPass(std::ostream &o,
|
FunctionPass *llvm::createMipsCodePrinterPass(raw_ostream &o,
|
||||||
MipsTargetMachine &tm)
|
MipsTargetMachine &tm)
|
||||||
{
|
{
|
||||||
return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||||
@ -175,10 +176,9 @@ printSavedRegsBitmask(MachineFunction &MF)
|
|||||||
void MipsAsmPrinter::
|
void MipsAsmPrinter::
|
||||||
printHex32(unsigned int Value)
|
printHex32(unsigned int Value)
|
||||||
{
|
{
|
||||||
O << "0x" << std::hex;
|
O << "0x";
|
||||||
for (int i = 7; i >= 0; i--)
|
for (int i = 7; i >= 0; i--)
|
||||||
O << std::hex << ( (Value & (0xF << (i*4))) >> (i*4) );
|
O << utohexstr( (Value & (0xF << (i*4))) >> (i*4) );
|
||||||
O << std::dec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -117,7 +117,7 @@ addPreEmitPass(PassManagerBase &PM, bool Fast)
|
|||||||
// true if AssemblyEmitter is supported
|
// true if AssemblyEmitter is supported
|
||||||
bool MipsTargetMachine::
|
bool MipsTargetMachine::
|
||||||
addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out)
|
raw_ostream &Out)
|
||||||
{
|
{
|
||||||
// Output assembly language.
|
// Output assembly language.
|
||||||
PM.add(createMipsCodePrinterPass(Out, *this));
|
PM.add(createMipsCodePrinterPass(Out, *this));
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include "llvm/Target/TargetFrameInfo.h"
|
#include "llvm/Target/TargetFrameInfo.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
class MipsTargetMachine : public LLVMTargetMachine {
|
class MipsTargetMachine : public LLVMTargetMachine {
|
||||||
MipsSubtarget Subtarget;
|
MipsSubtarget Subtarget;
|
||||||
const TargetData DataLayout; // Calculates type size & alignment
|
const TargetData DataLayout; // Calculates type size & alignment
|
||||||
@ -58,7 +60,7 @@ namespace llvm {
|
|||||||
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// MipselTargetMachine - Mipsel target machine.
|
/// MipselTargetMachine - Mipsel target machine.
|
||||||
|
@ -22,9 +22,10 @@ namespace llvm {
|
|||||||
class FunctionPassManager;
|
class FunctionPassManager;
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
|
FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
|
||||||
FunctionPass *createPIC16CodePrinterPass(std::ostream &OS,
|
FunctionPass *createPIC16CodePrinterPass(raw_ostream &OS,
|
||||||
PIC16TargetMachine &TM);
|
PIC16TargetMachine &TM);
|
||||||
} // end namespace llvm;
|
} // end namespace llvm;
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
@ -43,7 +44,7 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
|
struct VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
|
||||||
PIC16AsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
PIC16AsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||||
: AsmPrinter(O, TM, T) {
|
: AsmPrinter(O, TM, T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ namespace {
|
|||||||
/// using the given target machine description. This should work
|
/// using the given target machine description. This should work
|
||||||
/// regardless of whether the function is in SSA form.
|
/// regardless of whether the function is in SSA form.
|
||||||
///
|
///
|
||||||
FunctionPass *llvm::createPIC16CodePrinterPass(std::ostream &o,
|
FunctionPass *llvm::createPIC16CodePrinterPass(raw_ostream &o,
|
||||||
PIC16TargetMachine &tm) {
|
PIC16TargetMachine &tm) {
|
||||||
return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo());
|
return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||||
}
|
}
|
||||||
@ -275,7 +276,7 @@ printOperand(const MachineInstr *MI, int opNum, const char *Modifier)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
printSOImm(std::ostream &O, int64_t V, const TargetAsmInfo *TAI)
|
printSOImm(raw_ostream &O, int64_t V, const TargetAsmInfo *TAI)
|
||||||
{
|
{
|
||||||
assert(V < (1 << 12) && "Not a valid so_imm value!");
|
assert(V < (1 << 12) && "Not a valid so_imm value!");
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ bool PIC16TargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PIC16TargetMachine::
|
bool PIC16TargetMachine::
|
||||||
addAssemblyEmitter(PassManagerBase &PM, bool Fast, std::ostream &Out)
|
addAssemblyEmitter(PassManagerBase &PM, bool Fast, raw_ostream &Out)
|
||||||
{
|
{
|
||||||
// Output assembly language.
|
// Output assembly language.
|
||||||
PM.add(createPIC16CodePrinterPass(Out, *this));
|
PM.add(createPIC16CodePrinterPass(Out, *this));
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
virtual bool addPrologEpilogInserter(PassManagerBase &PM, bool Fast);
|
virtual bool addPrologEpilogInserter(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
};
|
};
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
@ -52,7 +53,7 @@ namespace {
|
|||||||
std::set<std::string> FnStubs, GVStubs;
|
std::set<std::string> FnStubs, GVStubs;
|
||||||
const PPCSubtarget &Subtarget;
|
const PPCSubtarget &Subtarget;
|
||||||
|
|
||||||
PPCAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
PPCAsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||||
: AsmPrinter(O, TM, T), Subtarget(TM.getSubtarget<PPCSubtarget>()) {
|
: AsmPrinter(O, TM, T), Subtarget(TM.getSubtarget<PPCSubtarget>()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +296,7 @@ namespace {
|
|||||||
DwarfWriter DW;
|
DwarfWriter DW;
|
||||||
MachineModuleInfo *MMI;
|
MachineModuleInfo *MMI;
|
||||||
|
|
||||||
PPCLinuxAsmPrinter(std::ostream &O, PPCTargetMachine &TM,
|
PPCLinuxAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
|
||||||
const TargetAsmInfo *T)
|
const TargetAsmInfo *T)
|
||||||
: PPCAsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
|
: PPCAsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
|
||||||
}
|
}
|
||||||
@ -327,7 +328,7 @@ namespace {
|
|||||||
DwarfWriter DW;
|
DwarfWriter DW;
|
||||||
MachineModuleInfo *MMI;
|
MachineModuleInfo *MMI;
|
||||||
|
|
||||||
PPCDarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM,
|
PPCDarwinAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
|
||||||
const TargetAsmInfo *T)
|
const TargetAsmInfo *T)
|
||||||
: PPCAsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
|
: PPCAsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
|
||||||
}
|
}
|
||||||
@ -649,7 +650,7 @@ bool PPCLinuxAsmPrinter::doInitialization(Module &M) {
|
|||||||
|
|
||||||
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
|
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
|
||||||
/// Don't print things like \n or \0.
|
/// Don't print things like \n or \0.
|
||||||
static void PrintUnmangledNameSafely(const Value *V, std::ostream &OS) {
|
static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
|
||||||
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
|
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
|
||||||
Name != E; ++Name)
|
Name != E; ++Name)
|
||||||
if (isprint(*Name))
|
if (isprint(*Name))
|
||||||
@ -1107,7 +1108,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
|
|||||||
/// for a MachineFunction to the given output stream, in a format that the
|
/// for a MachineFunction to the given output stream, in a format that the
|
||||||
/// Darwin assembler can deal with.
|
/// Darwin assembler can deal with.
|
||||||
///
|
///
|
||||||
FunctionPass *llvm::createPPCAsmPrinterPass(std::ostream &o,
|
FunctionPass *llvm::createPPCAsmPrinterPass(raw_ostream &o,
|
||||||
PPCTargetMachine &tm) {
|
PPCTargetMachine &tm) {
|
||||||
const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
|
const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
|
||||||
|
|
||||||
|
@ -25,10 +25,11 @@ namespace llvm {
|
|||||||
class PPCTargetMachine;
|
class PPCTargetMachine;
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
FunctionPass *createPPCBranchSelectionPass();
|
FunctionPass *createPPCBranchSelectionPass();
|
||||||
FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
|
FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
|
||||||
FunctionPass *createPPCAsmPrinterPass(std::ostream &OS,
|
FunctionPass *createPPCAsmPrinterPass(raw_ostream &OS,
|
||||||
PPCTargetMachine &TM);
|
PPCTargetMachine &TM);
|
||||||
FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
|
FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
|
||||||
MachineCodeEmitter &MCE);
|
MachineCodeEmitter &MCE);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Target/TargetMachineRegistry.h"
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
// Register the targets
|
// Register the targets
|
||||||
@ -134,7 +135,7 @@ bool PPCTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PPCTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
bool PPCTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out) {
|
raw_ostream &Out) {
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
PM.add(AsmPrinterCtor(Out, *this));
|
PM.add(AsmPrinterCtor(Out, *this));
|
||||||
@ -167,7 +168,7 @@ bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
|
|||||||
if (DumpAsm) {
|
if (DumpAsm) {
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
PM.add(AsmPrinterCtor(*cerr.stream(), *this));
|
PM.add(AsmPrinterCtor(errs(), *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -180,7 +181,7 @@ bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
|||||||
if (DumpAsm) {
|
if (DumpAsm) {
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
PM.add(AsmPrinterCtor(*cerr.stream(), *this));
|
PM.add(AsmPrinterCtor(errs(), *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -44,7 +44,7 @@ protected:
|
|||||||
|
|
||||||
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
|
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
|
||||||
// set this functions to ctor pointer at startup time if they are linked in.
|
// set this functions to ctor pointer at startup time if they are linked in.
|
||||||
typedef FunctionPass *(*AsmPrinterCtorFn)(std::ostream &o,
|
typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
|
||||||
PPCTargetMachine &tm);
|
PPCTargetMachine &tm);
|
||||||
static AsmPrinterCtorFn AsmPrinterCtor;
|
static AsmPrinterCtorFn AsmPrinterCtor;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||||
bool DumpAsm, MachineCodeEmitter &MCE);
|
bool DumpAsm, MachineCodeEmitter &MCE);
|
||||||
virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
FunctionPass *createSparcISelDag(TargetMachine &TM);
|
FunctionPass *createSparcISelDag(TargetMachine &TM);
|
||||||
FunctionPass *createSparcCodePrinterPass(std::ostream &OS, TargetMachine &TM);
|
FunctionPass *createSparcCodePrinterPass(raw_ostream &OS, TargetMachine &TM);
|
||||||
FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM);
|
FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM);
|
||||||
FunctionPass *createSparcFPMoverPass(TargetMachine &TM);
|
FunctionPass *createSparcFPMoverPass(TargetMachine &TM);
|
||||||
} // end namespace llvm;
|
} // end namespace llvm;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
@ -39,7 +40,7 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct VISIBILITY_HIDDEN SparcAsmPrinter : public AsmPrinter {
|
struct VISIBILITY_HIDDEN SparcAsmPrinter : public AsmPrinter {
|
||||||
SparcAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
SparcAsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||||
: AsmPrinter(O, TM, T) {
|
: AsmPrinter(O, TM, T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ namespace {
|
|||||||
/// using the given target machine description. This should work
|
/// using the given target machine description. This should work
|
||||||
/// regardless of whether the function is in SSA form.
|
/// regardless of whether the function is in SSA form.
|
||||||
///
|
///
|
||||||
FunctionPass *llvm::createSparcCodePrinterPass(std::ostream &o,
|
FunctionPass *llvm::createSparcCodePrinterPass(raw_ostream &o,
|
||||||
TargetMachine &tm) {
|
TargetMachine &tm) {
|
||||||
return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out) {
|
raw_ostream &Out) {
|
||||||
// Output assembly language.
|
// Output assembly language.
|
||||||
PM.add(createSparcCodePrinterPass(Out, *this));
|
PM.add(createSparcCodePrinterPass(Out, *this));
|
||||||
return false;
|
return false;
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -84,7 +85,7 @@ static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
|
|||||||
|
|
||||||
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
|
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
|
||||||
/// Don't print things like \n or \0.
|
/// Don't print things like \n or \0.
|
||||||
static void PrintUnmangledNameSafely(const Value *V, std::ostream &OS) {
|
static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
|
||||||
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
|
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
|
||||||
Name != E; ++Name)
|
Name != E; ++Name)
|
||||||
if (isprint(*Name))
|
if (isprint(*Name))
|
||||||
|
@ -34,7 +34,7 @@ struct VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {
|
|||||||
|
|
||||||
const X86Subtarget *Subtarget;
|
const X86Subtarget *Subtarget;
|
||||||
|
|
||||||
X86ATTAsmPrinter(std::ostream &O, X86TargetMachine &TM,
|
X86ATTAsmPrinter(raw_ostream &O, X86TargetMachine &TM,
|
||||||
const TargetAsmInfo *T)
|
const TargetAsmInfo *T)
|
||||||
: AsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
|
: AsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
|
||||||
Subtarget = &TM.getSubtarget<X86Subtarget>();
|
Subtarget = &TM.getSubtarget<X86Subtarget>();
|
||||||
|
@ -23,7 +23,7 @@ using namespace llvm;
|
|||||||
/// for a MachineFunction to the given output stream, using the given target
|
/// for a MachineFunction to the given output stream, using the given target
|
||||||
/// machine description.
|
/// machine description.
|
||||||
///
|
///
|
||||||
FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,
|
FunctionPass *llvm::createX86CodePrinterPass(raw_ostream &o,
|
||||||
X86TargetMachine &tm) {
|
X86TargetMachine &tm) {
|
||||||
const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
|
const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
|
||||||
|
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/ADT/StringSet.h"
|
#include "llvm/ADT/StringSet.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter {
|
struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter {
|
||||||
X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM,
|
X86IntelAsmPrinter(raw_ostream &O, X86TargetMachine &TM,
|
||||||
const TargetAsmInfo *T)
|
const TargetAsmInfo *T)
|
||||||
: AsmPrinter(O, TM, T) {
|
: AsmPrinter(O, TM, T) {
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ namespace llvm {
|
|||||||
class X86TargetMachine;
|
class X86TargetMachine;
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
class MachineCodeEmitter;
|
class MachineCodeEmitter;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
/// createX86ISelDag - This pass converts a legalized DAG into a
|
/// createX86ISelDag - This pass converts a legalized DAG into a
|
||||||
/// X86-specific DAG, ready for instruction scheduling.
|
/// X86-specific DAG, ready for instruction scheduling.
|
||||||
@ -38,7 +39,7 @@ FunctionPass *createX86FloatingPointStackifierPass();
|
|||||||
/// assembly code for a MachineFunction to the given output stream,
|
/// assembly code for a MachineFunction to the given output stream,
|
||||||
/// using the given target machine description.
|
/// using the given target machine description.
|
||||||
///
|
///
|
||||||
FunctionPass *createX86CodePrinterPass(std::ostream &o, X86TargetMachine &tm);
|
FunctionPass *createX86CodePrinterPass(raw_ostream &o, X86TargetMachine &tm);
|
||||||
|
|
||||||
/// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
|
/// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
|
||||||
/// to the specified MCE object.
|
/// to the specified MCE object.
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
#include "llvm/Target/TargetMachineRegistry.h"
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -189,7 +190,7 @@ bool X86TargetMachine::addPostRegAlloc(PassManagerBase &PM, bool Fast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool X86TargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
bool X86TargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out) {
|
raw_ostream &Out) {
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
PM.add(AsmPrinterCtor(Out, *this));
|
PM.add(AsmPrinterCtor(Out, *this));
|
||||||
@ -218,7 +219,7 @@ bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
|
|||||||
if (DumpAsm) {
|
if (DumpAsm) {
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
PM.add(AsmPrinterCtor(*cerr.stream(), *this));
|
PM.add(AsmPrinterCtor(errs(), *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -230,7 +231,7 @@ bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
|||||||
if (DumpAsm) {
|
if (DumpAsm) {
|
||||||
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
||||||
if (AsmPrinterCtor)
|
if (AsmPrinterCtor)
|
||||||
PM.add(AsmPrinterCtor(*cerr.stream(), *this));
|
PM.add(AsmPrinterCtor(errs(), *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "X86ISelLowering.h"
|
#include "X86ISelLowering.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
class X86TargetMachine : public LLVMTargetMachine {
|
class X86TargetMachine : public LLVMTargetMachine {
|
||||||
X86Subtarget Subtarget;
|
X86Subtarget Subtarget;
|
||||||
@ -41,7 +43,7 @@ protected:
|
|||||||
|
|
||||||
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
|
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
|
||||||
// set this functions to ctor pointer at startup time if they are linked in.
|
// set this functions to ctor pointer at startup time if they are linked in.
|
||||||
typedef FunctionPass *(*AsmPrinterCtorFn)(std::ostream &o,
|
typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
|
||||||
X86TargetMachine &tm);
|
X86TargetMachine &tm);
|
||||||
static AsmPrinterCtorFn AsmPrinterCtor;
|
static AsmPrinterCtorFn AsmPrinterCtor;
|
||||||
|
|
||||||
@ -75,7 +77,7 @@ public:
|
|||||||
virtual bool addPreRegAlloc(PassManagerBase &PM, bool Fast);
|
virtual bool addPreRegAlloc(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addPostRegAlloc(PassManagerBase &PM, bool Fast);
|
virtual bool addPostRegAlloc(PassManagerBase &PM, bool Fast);
|
||||||
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
|
||||||
std::ostream &Out);
|
raw_ostream &Out);
|
||||||
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||||
bool DumpAsm, MachineCodeEmitter &MCE);
|
bool DumpAsm, MachineCodeEmitter &MCE);
|
||||||
virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/PluginLoader.h"
|
#include "llvm/Support/PluginLoader.h"
|
||||||
#include "llvm/Support/FileUtilities.h"
|
#include "llvm/Support/FileUtilities.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Analysis/Verifier.h"
|
#include "llvm/Analysis/Verifier.h"
|
||||||
#include "llvm/System/Signals.h"
|
#include "llvm/System/Signals.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
@ -106,10 +107,10 @@ GetFileNameRoot(const std::string &InputFilename) {
|
|||||||
return outputFilename;
|
return outputFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::ostream *GetOutputStream(const char *ProgName) {
|
static raw_ostream *GetOutputStream(const char *ProgName) {
|
||||||
if (OutputFilename != "") {
|
if (OutputFilename != "") {
|
||||||
if (OutputFilename == "-")
|
if (OutputFilename == "-")
|
||||||
return &std::cout;
|
return &outs();
|
||||||
|
|
||||||
// Specified an output filename?
|
// Specified an output filename?
|
||||||
if (!Force && std::ifstream(OutputFilename.c_str())) {
|
if (!Force && std::ifstream(OutputFilename.c_str())) {
|
||||||
@ -123,12 +124,13 @@ static std::ostream *GetOutputStream(const char *ProgName) {
|
|||||||
// SIGINT
|
// SIGINT
|
||||||
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
||||||
|
|
||||||
return new std::ofstream(OutputFilename.c_str());
|
std::string error;
|
||||||
|
return new raw_fd_ostream(OutputFilename.c_str(), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InputFilename == "-") {
|
if (InputFilename == "-") {
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
return &std::cout;
|
return &outs();
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputFilename = GetFileNameRoot(InputFilename);
|
OutputFilename = GetFileNameRoot(InputFilename);
|
||||||
@ -165,9 +167,10 @@ static std::ostream *GetOutputStream(const char *ProgName) {
|
|||||||
// SIGINT
|
// SIGINT
|
||||||
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
||||||
|
|
||||||
std::ostream *Out = new std::ofstream(OutputFilename.c_str());
|
std::string error;
|
||||||
if (!Out->good()) {
|
raw_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(), error);
|
||||||
std::cerr << ProgName << ": error opening " << OutputFilename << "!\n";
|
if (!error.empty()) {
|
||||||
|
std::cerr << error;
|
||||||
delete Out;
|
delete Out;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -229,7 +232,7 @@ int main(int argc, char **argv) {
|
|||||||
TargetMachine &Target = *target.get();
|
TargetMachine &Target = *target.get();
|
||||||
|
|
||||||
// Figure out where we are going to send the output...
|
// Figure out where we are going to send the output...
|
||||||
std::ostream *Out = GetOutputStream(argv[0]);
|
raw_ostream *Out = GetOutputStream(argv[0]);
|
||||||
if (Out == 0) return 1;
|
if (Out == 0) return 1;
|
||||||
|
|
||||||
// If this target requires addPassesToEmitWholeFile, do it now. This is
|
// If this target requires addPassesToEmitWholeFile, do it now. This is
|
||||||
@ -244,7 +247,7 @@ int main(int argc, char **argv) {
|
|||||||
if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, Fast)) {
|
if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, Fast)) {
|
||||||
std::cerr << argv[0] << ": target does not support generation of this"
|
std::cerr << argv[0] << ": target does not support generation of this"
|
||||||
<< " file type!\n";
|
<< " file type!\n";
|
||||||
if (Out != &std::cout) delete Out;
|
if (Out != &outs()) delete Out;
|
||||||
// And the Out file is empty and useless, so remove it now.
|
// And the Out file is empty and useless, so remove it now.
|
||||||
sys::Path(OutputFilename).eraseFromDisk();
|
sys::Path(OutputFilename).eraseFromDisk();
|
||||||
return 1;
|
return 1;
|
||||||
@ -271,7 +274,7 @@ int main(int argc, char **argv) {
|
|||||||
case FileModel::Error:
|
case FileModel::Error:
|
||||||
std::cerr << argv[0] << ": target does not support generation of this"
|
std::cerr << argv[0] << ": target does not support generation of this"
|
||||||
<< " file type!\n";
|
<< " file type!\n";
|
||||||
if (Out != &std::cout) delete Out;
|
if (Out != &outs()) delete Out;
|
||||||
// And the Out file is empty and useless, so remove it now.
|
// And the Out file is empty and useless, so remove it now.
|
||||||
sys::Path(OutputFilename).eraseFromDisk();
|
sys::Path(OutputFilename).eraseFromDisk();
|
||||||
return 1;
|
return 1;
|
||||||
@ -288,7 +291,7 @@ int main(int argc, char **argv) {
|
|||||||
if (Target.addPassesToEmitFileFinish(Passes, MCE, Fast)) {
|
if (Target.addPassesToEmitFileFinish(Passes, MCE, Fast)) {
|
||||||
std::cerr << argv[0] << ": target does not support generation of this"
|
std::cerr << argv[0] << ": target does not support generation of this"
|
||||||
<< " file type!\n";
|
<< " file type!\n";
|
||||||
if (Out != &std::cout) delete Out;
|
if (Out != &outs()) delete Out;
|
||||||
// And the Out file is empty and useless, so remove it now.
|
// And the Out file is empty and useless, so remove it now.
|
||||||
sys::Path(OutputFilename).eraseFromDisk();
|
sys::Path(OutputFilename).eraseFromDisk();
|
||||||
return 1;
|
return 1;
|
||||||
@ -306,7 +309,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete the ostream if it's not a stdout stream
|
// Delete the ostream if it's not a stdout stream
|
||||||
if (Out != &std::cout) delete Out;
|
if (Out != &outs()) delete Out;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "llvm/Support/SystemUtils.h"
|
#include "llvm/Support/SystemUtils.h"
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/System/Signals.h"
|
#include "llvm/System/Signals.h"
|
||||||
#include "llvm/Analysis/Passes.h"
|
#include "llvm/Analysis/Passes.h"
|
||||||
#include "llvm/Analysis/LoopPass.h"
|
#include "llvm/Analysis/LoopPass.h"
|
||||||
@ -162,9 +163,12 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg)
|
|||||||
sys::RemoveFileOnSignal(uniqueAsmPath);
|
sys::RemoveFileOnSignal(uniqueAsmPath);
|
||||||
|
|
||||||
// generate assembly code
|
// generate assembly code
|
||||||
std::ofstream asmFile(uniqueAsmPath.c_str());
|
std::string error;
|
||||||
bool genResult = this->generateAssemblyCode(asmFile, errMsg);
|
bool genResult = false;
|
||||||
asmFile.close();
|
{
|
||||||
|
raw_fd_ostream asmFile(uniqueAsmPath.c_str(), error);
|
||||||
|
genResult = this->generateAssemblyCode(asmFile, errMsg);
|
||||||
|
}
|
||||||
if ( genResult ) {
|
if ( genResult ) {
|
||||||
if ( uniqueAsmPath.exists() )
|
if ( uniqueAsmPath.exists() )
|
||||||
uniqueAsmPath.eraseFromDisk();
|
uniqueAsmPath.eraseFromDisk();
|
||||||
@ -309,7 +313,8 @@ void LTOCodeGenerator::applyScopeRestrictions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Optimize merged modules using various IPO passes
|
/// Optimize merged modules using various IPO passes
|
||||||
bool LTOCodeGenerator::generateAssemblyCode(std::ostream& out, std::string& errMsg)
|
bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
|
||||||
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
if ( this->determineTarget(errMsg) )
|
if ( this->determineTarget(errMsg) )
|
||||||
return true;
|
return true;
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
//
|
//
|
||||||
// C++ class which implements the opaque lto_code_gen_t
|
// C++ class which implements the opaque lto_code_gen_t
|
||||||
//
|
//
|
||||||
|
|
||||||
|
class llvm::raw_ostream;
|
||||||
class LTOCodeGenerator {
|
class LTOCodeGenerator {
|
||||||
public:
|
public:
|
||||||
static const char* getVersionString();
|
static const char* getVersionString();
|
||||||
@ -41,8 +43,8 @@ public:
|
|||||||
const void* compile(size_t* length, std::string& errMsg);
|
const void* compile(size_t* length, std::string& errMsg);
|
||||||
void setCodeGenDebugOptions(const char *opts);
|
void setCodeGenDebugOptions(const char *opts);
|
||||||
private:
|
private:
|
||||||
bool generateAssemblyCode(std::ostream& out,
|
bool generateAssemblyCode(llvm::raw_ostream& out,
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
bool assemble(const std::string& asmPath,
|
bool assemble(const std::string& asmPath,
|
||||||
const std::string& objPath, std::string& errMsg);
|
const std::string& objPath, std::string& errMsg);
|
||||||
void applyScopeRestrictions();
|
void applyScopeRestrictions();
|
||||||
|
Loading…
Reference in New Issue
Block a user