1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02:00

[ORC] Print CPU feature string in JITTargetMachineBuilder debugging output.

This commit is contained in:
Lang Hames 2021-02-19 14:36:15 +11:00
parent f6e848a7ad
commit 04856db5a7
3 changed files with 39 additions and 16 deletions

View File

@ -32,6 +32,9 @@ namespace orc {
/// A utility class for building TargetMachines for JITs.
class JITTargetMachineBuilder {
#ifndef NDEBUG
friend class JITTargetMachineBuilderPrinter;
#endif
public:
/// Create a JITTargetMachineBuilder based on the given triple.
///
@ -139,12 +142,6 @@ public:
/// Access Triple.
const Triple &getTargetTriple() const { return TT; }
#ifndef NDEBUG
/// Debug-dump a JITTargetMachineBuilder.
friend raw_ostream &operator<<(raw_ostream &OS,
const JITTargetMachineBuilder &JTMB);
#endif
private:
Triple TT;
std::string CPU;
@ -155,6 +152,26 @@ private:
CodeGenOpt::Level OptLevel = CodeGenOpt::Default;
};
#ifndef NDEBUG
class JITTargetMachineBuilderPrinter {
public:
JITTargetMachineBuilderPrinter(JITTargetMachineBuilder &JTMB,
StringRef Indent)
: JTMB(JTMB), Indent(Indent) {}
void print(raw_ostream &OS) const;
friend raw_ostream &operator<<(raw_ostream &OS,
const JITTargetMachineBuilderPrinter &JTMBP) {
JTMBP.print(OS);
return OS;
}
private:
JITTargetMachineBuilder &JTMB;
StringRef Indent;
};
#endif // NDEBUG
} // end namespace orc
} // end namespace llvm

View File

@ -65,9 +65,13 @@ JITTargetMachineBuilder &JITTargetMachineBuilder::addFeatures(
}
#ifndef NDEBUG
raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) {
OS << "{ Triple = \"" << JTMB.TT.str() << "\", CPU = \"" << JTMB.CPU
<< "\", Options = <not-printable>, Relocation Model = ";
void JITTargetMachineBuilderPrinter::print(raw_ostream &OS) const {
OS << Indent << "{\n"
<< Indent << " Triple = \"" << JTMB.TT.str() << "\"\n"
<< Indent << " CPU = \"" << JTMB.CPU << "\"\n"
<< Indent << " Features = \"" << JTMB.Features.getString() << "\"\n"
<< Indent << " Options = <not-printable>\n"
<< Indent << " Relocation Model = ";
if (JTMB.RM) {
switch (*JTMB.RM) {
@ -91,9 +95,10 @@ raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) {
break;
}
} else
OS << "unspecified";
OS << "unspecified (will use target default)";
OS << ", Code Model = ";
OS << "\n"
<< Indent << " Code Model = ";
if (JTMB.CM) {
switch (*JTMB.CM) {
@ -114,9 +119,10 @@ raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) {
break;
}
} else
OS << "unspecified";
OS << "unspecified (will use target default)";
OS << ", Optimization Level = ";
OS << "\n"
<< Indent << " Optimization Level = ";
switch (JTMB.OptLevel) {
case CodeGenOpt::None:
OS << "None";
@ -132,8 +138,7 @@ raw_ostream &operator<<(raw_ostream &OS, const JITTargetMachineBuilder &JTMB) {
break;
}
OS << " }";
return OS;
OS << "\n" << Indent << "}\n";
}
#endif // NDEBUG

View File

@ -922,7 +922,8 @@ Error LLJITBuilderState::prepareForConstruction() {
}
LLVM_DEBUG({
dbgs() << " JITTargetMachineBuilder is " << JTMB << "\n"
dbgs() << " JITTargetMachineBuilder is "
<< JITTargetMachineBuilderPrinter(*JTMB, " ")
<< " Pre-constructed ExecutionSession: " << (ES ? "Yes" : "No")
<< "\n"
<< " DataLayout: ";