1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

[llvm-exegesis] Move namespace exegesis inside llvm::

Summary:
This allows simplifying references of llvm::foo with foo when the needs
come in the future.

Reviewers: courbet, gchatelet

Reviewed By: gchatelet

Subscribers: javed.absar, tschuett, llvm-commits

Differential Revision: https://reviews.llvm.org/D53455

llvm-svn: 344922
This commit is contained in:
Fangrui Song 2018-10-22 17:10:47 +00:00
parent 6f08b710ee
commit edf37d23b8
47 changed files with 156 additions and 60 deletions

View File

@ -11,6 +11,7 @@
#include "AArch64.h"
#include "AArch64RegisterInfo.h"
namespace llvm {
namespace exegesis {
namespace {
@ -90,3 +91,4 @@ void InitializeAArch64ExegesisTarget() {
}
} // namespace exegesis
} // namespace llvm

View File

@ -15,6 +15,7 @@
#include <unordered_set>
#include <vector>
namespace llvm {
namespace exegesis {
static const char kCsvSep = ',';
@ -796,3 +797,4 @@ std::vector<std::pair<uint16_t, float>> computeIdealizedProcResPressure(
}
} // namespace exegesis
} // namespace llvm

View File

@ -30,6 +30,7 @@
#include <string>
#include <unordered_map>
namespace llvm {
namespace exegesis {
// A helper class to analyze benchmark results for a target.
@ -135,5 +136,6 @@ std::vector<std::pair<uint16_t, float>> computeIdealizedProcResPressure(
llvm::SmallVector<llvm::MCWriteProcResEntry, 8> WPRS);
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_CLUSTERING_H

View File

@ -23,6 +23,7 @@
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/Support/MemoryBuffer.h"
namespace llvm {
namespace exegesis {
static constexpr const char ModuleID[] = "ExegesisInfoTest";
@ -295,3 +296,4 @@ ExecutableFunction::ExecutableFunction(
}
} // namespace exegesis
} // namespace llvm

View File

@ -32,6 +32,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
namespace llvm {
namespace exegesis {
class ExegesisTarget;
@ -82,5 +83,6 @@ struct ExecutableFunction {
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_ASSEMBLER_H

View File

@ -15,6 +15,7 @@
#include <string>
#include <vector>
namespace llvm {
namespace exegesis {
// A collection of instructions that are to be assembled, executed and measured.
@ -35,5 +36,6 @@ struct BenchmarkCode {
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKCODE_H

View File

@ -22,6 +22,10 @@ static constexpr const char kIntegerPrefix[] = "i_0x";
static constexpr const char kDoublePrefix[] = "f_";
static constexpr const char kInvalidOperand[] = "INVALID";
namespace llvm {
namespace {
// A mutable struct holding an LLVMState that can be passed through the
// serialization process to encode/decode registers and instructions.
struct YamlContext {
@ -141,13 +145,13 @@ private:
return 0;
}
const exegesis::LLVMState *State;
const llvm::exegesis::LLVMState *State;
std::string LastError;
llvm::raw_string_ostream ErrorStream;
};
} // namespace
// Defining YAML traits for IO.
namespace llvm {
namespace yaml {
static YamlContext &getTypedContext(void *Ctx) {
@ -294,7 +298,6 @@ struct MappingContextTraits<exegesis::InstructionBenchmark, YamlContext> {
};
} // namespace yaml
} // namespace llvm
namespace exegesis {
@ -384,3 +387,4 @@ void PerInstructionStats::push(const BenchmarkMeasure &BM) {
}
} // namespace exegesis
} // namespace llvm

View File

@ -28,6 +28,7 @@
#include <unordered_map>
#include <vector>
namespace llvm {
namespace exegesis {
struct InstructionBenchmarkKey {
@ -111,5 +112,6 @@ private:
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H

View File

@ -22,6 +22,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Program.h"
namespace llvm {
namespace exegesis {
BenchmarkFailure::BenchmarkFailure(const llvm::Twine &S)
@ -173,3 +174,4 @@ BenchmarkRunner::writeObjectFile(const BenchmarkCode &BC,
BenchmarkRunner::FunctionExecutor::~FunctionExecutor() {}
} // namespace exegesis
} // namespace llvm

View File

@ -27,6 +27,7 @@
#include <memory>
#include <vector>
namespace llvm {
namespace exegesis {
// A class representing failures that happened during Benchmark, they are used
@ -90,5 +91,6 @@ private:
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRUNNER_H

View File

@ -11,6 +11,7 @@
#include <string>
#include <unordered_set>
namespace llvm {
namespace exegesis {
// The clustering problem has the following characteristics:
@ -170,3 +171,4 @@ InstructionBenchmarkClustering::create(
}
} // namespace exegesis
} // namespace llvm

View File

@ -19,6 +19,7 @@
#include "llvm/Support/Error.h"
#include <vector>
namespace llvm {
namespace exegesis {
class InstructionBenchmarkClustering {
@ -109,5 +110,6 @@ private:
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_CLUSTERING_H

View File

@ -9,6 +9,7 @@
#include "CodeTemplate.h"
namespace llvm {
namespace exegesis {
CodeTemplate::CodeTemplate(CodeTemplate &&) = default;
@ -115,3 +116,4 @@ getExecutionModeBits(ExecutionMode Execution) {
}
} // namespace exegesis
} // namespace llvm

View File

@ -19,6 +19,7 @@
#include "MCInstrDescView.h"
#include "llvm/ADT/BitmaskEnum.h"
namespace llvm {
namespace exegesis {
// A template for an Instruction holding values for each of its Variables.
@ -125,5 +126,6 @@ struct CodeTemplate {
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_CODETEMPLATE_H

View File

@ -17,6 +17,7 @@
#include "llvm/MC/MCInstBuilder.h"
#include "llvm/Support/FormatVariadic.h"
namespace llvm {
namespace exegesis {
struct ExecutionClass {
@ -200,3 +201,4 @@ LatencyBenchmarkRunner::runMeasurements(
}
} // namespace exegesis
} // namespace llvm

View File

@ -19,6 +19,7 @@
#include "MCInstrDescView.h"
#include "SnippetGenerator.h"
namespace llvm {
namespace exegesis {
class LatencySnippetGenerator : public SnippetGenerator {
@ -43,5 +44,6 @@ private:
virtual const char *getCounterName() const;
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_LATENCY_H

View File

@ -19,6 +19,7 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
namespace llvm {
namespace exegesis {
LLVMState::LLVMState(const std::string &Triple, const std::string &CpuName) {
@ -71,3 +72,4 @@ bool LLVMState::canAssemble(const llvm::MCInst &Inst) const {
}
} // namespace exegesis
} // namespace llvm

View File

@ -25,6 +25,7 @@
#include <memory>
#include <string>
namespace llvm {
namespace exegesis {
class ExegesisTarget;
@ -64,5 +65,6 @@ private:
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_LLVMSTATE_H

View File

@ -15,6 +15,7 @@
#include "llvm/ADT/STLExtras.h"
namespace llvm {
namespace exegesis {
unsigned Variable::getIndex() const {
@ -343,3 +344,4 @@ void DumpMCInst(const llvm::MCRegisterInfo &MCRegisterInfo,
}
} // namespace exegesis
} // namespace llvm

View File

@ -29,6 +29,7 @@
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
namespace llvm {
namespace exegesis {
// A variable represents the value associated to an Operand or a set of Operands
@ -191,5 +192,6 @@ void DumpMCInst(const llvm::MCRegisterInfo &MCRegisterInfo,
const llvm::MCInst &MCInst, llvm::raw_ostream &OS);
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_MCINSTRDESCVIEW_H

View File

@ -17,6 +17,7 @@
#endif
#include <cassert>
namespace llvm {
namespace exegesis {
namespace pfm {
@ -136,3 +137,4 @@ int64_t Counter::read() const { return 42; }
} // namespace pfm
} // namespace exegesis
} // namespace llvm

View File

@ -23,6 +23,7 @@
struct perf_event_attr;
namespace llvm {
namespace exegesis {
namespace pfm {
@ -102,5 +103,6 @@ void Measure(
} // namespace pfm
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_PERFHELPER_H

View File

@ -9,6 +9,7 @@
#include "RegisterAliasing.h"
namespace llvm {
namespace exegesis {
llvm::BitVector getAliasedBits(const llvm::MCRegisterInfo &RegInfo,
@ -81,3 +82,4 @@ RegisterAliasingTrackerCache::getRegisterClass(unsigned RegClassIndex) const {
}
} // namespace exegesis
} // namespace llvm

View File

@ -22,6 +22,7 @@
#include "llvm/ADT/PackedVector.h"
#include "llvm/MC/MCRegisterInfo.h"
namespace llvm {
namespace exegesis {
// Returns the registers that are aliased by the ones set in SourceBits.
@ -104,5 +105,6 @@ private:
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_ALIASINGTRACKER_H

View File

@ -10,6 +10,7 @@
#include "RegisterValue.h"
#include "llvm/ADT/APFloat.h"
namespace llvm {
namespace exegesis {
static llvm::APFloat getFloatValue(const llvm::fltSemantics &FltSemantics,
@ -47,3 +48,4 @@ llvm::APInt bitcastFloatValue(const llvm::fltSemantics &FltSemantics,
}
} // namespace exegesis
} // namespace llvm

View File

@ -17,6 +17,7 @@
#include <llvm/ADT/APFloat.h>
#include <llvm/ADT/APInt.h>
namespace llvm {
namespace exegesis {
// A simple object storing the value for a particular register.
@ -43,3 +44,4 @@ llvm::APInt bitcastFloatValue(const llvm::fltSemantics &FltSemantics,
PredefinedValues Value);
} // namespace exegesis
} // namespace llvm

View File

@ -20,6 +20,7 @@
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Program.h"
namespace llvm {
namespace exegesis {
std::vector<CodeTemplate> getSingleton(CodeTemplate &&CT) {
@ -222,3 +223,4 @@ void randomizeUnsetVariables(const llvm::BitVector &ForbiddenRegs,
}
} // namespace exegesis
} // namespace llvm

View File

@ -28,6 +28,7 @@
#include <memory>
#include <vector>
namespace llvm {
namespace exegesis {
std::vector<CodeTemplate> getSingleton(CodeTemplate &&CT);
@ -92,5 +93,6 @@ void randomizeUnsetVariables(const llvm::BitVector &ForbiddenRegs,
InstructionTemplate &IT);
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_SNIPPETGENERATOR_H

View File

@ -11,6 +11,7 @@
#include "Latency.h"
#include "Uops.h"
namespace llvm {
namespace exegesis {
ExegesisTarget::~ExegesisTarget() {} // anchor.
@ -109,3 +110,4 @@ const ExegesisTarget &ExegesisTarget::getDefault() {
}
} // namespace exegesis
} // namespace llvm

View File

@ -28,6 +28,7 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCRegisterInfo.h"
namespace llvm {
namespace exegesis {
class ExegesisTarget {
@ -100,5 +101,6 @@ private:
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_TARGET_H

View File

@ -78,6 +78,7 @@
// In that case we just use a greedy register assignment and hope for the
// best.
namespace llvm {
namespace exegesis {
static llvm::SmallVector<const Variable *, 8>
@ -252,3 +253,4 @@ UopsBenchmarkRunner::runMeasurements(const FunctionExecutor &Executor) const {
constexpr const size_t UopsSnippetGenerator::kMinNumDifferentAddresses;
} // namespace exegesis
} // namespace llvm

View File

@ -18,6 +18,7 @@
#include "BenchmarkRunner.h"
#include "SnippetGenerator.h"
namespace llvm {
namespace exegesis {
class UopsSnippetGenerator : public SnippetGenerator {
@ -73,5 +74,6 @@ private:
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H

View File

@ -17,6 +17,7 @@
#include "X86Subtarget.h"
#include "llvm/MC/MCInstBuilder.h"
namespace llvm {
namespace exegesis {
namespace {
@ -423,3 +424,4 @@ void InitializeX86ExegesisTarget() {
}
} // namespace exegesis
} // namespace llvm

View File

@ -38,63 +38,63 @@
#include <algorithm>
#include <string>
static llvm::cl::opt<int>
OpcodeIndex("opcode-index", llvm::cl::desc("opcode to measure, by index"),
llvm::cl::init(0));
static llvm::cl::opt<std::string> OpcodeNames(
"opcode-name",
llvm::cl::desc("comma-separated list of opcodes to measure, by name"),
llvm::cl::init(""));
static llvm::cl::opt<std::string>
SnippetsFile("snippets-file", llvm::cl::desc("code snippets to measure"),
llvm::cl::init(""));
static llvm::cl::opt<std::string>
BenchmarkFile("benchmarks-file", llvm::cl::desc(""), llvm::cl::init(""));
static llvm::cl::opt<exegesis::InstructionBenchmark::ModeE> BenchmarkMode(
"mode", llvm::cl::desc("the mode to run"),
llvm::cl::values(clEnumValN(exegesis::InstructionBenchmark::Latency,
"latency", "Instruction Latency"),
clEnumValN(exegesis::InstructionBenchmark::Uops, "uops",
"Uop Decomposition"),
// When not asking for a specific benchmark mode, we'll
// analyse the results.
clEnumValN(exegesis::InstructionBenchmark::Unknown,
"analysis", "Analysis")));
static llvm::cl::opt<unsigned>
NumRepetitions("num-repetitions",
llvm::cl::desc("number of time to repeat the asm snippet"),
llvm::cl::init(10000));
static llvm::cl::opt<bool> IgnoreInvalidSchedClass(
"ignore-invalid-sched-class",
llvm::cl::desc("ignore instructions that do not define a sched class"),
llvm::cl::init(false));
static llvm::cl::opt<unsigned> AnalysisNumPoints(
"analysis-numpoints",
llvm::cl::desc("minimum number of points in an analysis cluster"),
llvm::cl::init(3));
static llvm::cl::opt<float>
AnalysisEpsilon("analysis-epsilon",
llvm::cl::desc("dbscan epsilon for analysis clustering"),
llvm::cl::init(0.1));
static llvm::cl::opt<std::string>
AnalysisClustersOutputFile("analysis-clusters-output-file",
llvm::cl::desc(""), llvm::cl::init("-"));
static llvm::cl::opt<std::string>
AnalysisInconsistenciesOutputFile("analysis-inconsistencies-output-file",
llvm::cl::desc(""), llvm::cl::init("-"));
namespace llvm {
namespace exegesis {
static llvm::ExitOnError ExitOnErr;
static cl::opt<int> OpcodeIndex("opcode-index",
cl::desc("opcode to measure, by index"),
cl::init(0));
static cl::opt<std::string>
OpcodeNames("opcode-name",
cl::desc("comma-separated list of opcodes to measure, by name"),
cl::init(""));
static cl::opt<std::string> SnippetsFile("snippets-file",
cl::desc("code snippets to measure"),
cl::init(""));
static cl::opt<std::string> BenchmarkFile("benchmarks-file", cl::desc(""),
cl::init(""));
static cl::opt<exegesis::InstructionBenchmark::ModeE>
BenchmarkMode("mode", cl::desc("the mode to run"),
cl::values(clEnumValN(exegesis::InstructionBenchmark::Latency,
"latency", "Instruction Latency"),
clEnumValN(exegesis::InstructionBenchmark::Uops,
"uops", "Uop Decomposition"),
// When not asking for a specific benchmark mode,
// we'll analyse the results.
clEnumValN(exegesis::InstructionBenchmark::Unknown,
"analysis", "Analysis")));
static cl::opt<unsigned>
NumRepetitions("num-repetitions",
cl::desc("number of time to repeat the asm snippet"),
cl::init(10000));
static cl::opt<bool> IgnoreInvalidSchedClass(
"ignore-invalid-sched-class",
cl::desc("ignore instructions that do not define a sched class"),
cl::init(false));
static cl::opt<unsigned> AnalysisNumPoints(
"analysis-numpoints",
cl::desc("minimum number of points in an analysis cluster"), cl::init(3));
static cl::opt<float>
AnalysisEpsilon("analysis-epsilon",
cl::desc("dbscan epsilon for analysis clustering"),
cl::init(0.1));
static cl::opt<std::string>
AnalysisClustersOutputFile("analysis-clusters-output-file", cl::desc(""),
cl::init("-"));
static cl::opt<std::string>
AnalysisInconsistenciesOutputFile("analysis-inconsistencies-output-file",
cl::desc(""), cl::init("-"));
static ExitOnError ExitOnErr;
#ifdef LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET
void LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET();
@ -430,9 +430,11 @@ static void analysisMain() {
}
} // namespace exegesis
} // namespace llvm
int main(int Argc, char **Argv) {
llvm::cl::ParseCommandLineOptions(Argc, Argv, "");
using namespace llvm;
cl::ParseCommandLineOptions(Argc, Argv, "");
exegesis::ExitOnErr.setExitCodeMapper([](const llvm::Error &Err) {
if (Err.isA<llvm::StringError>())
@ -440,7 +442,7 @@ int main(int Argc, char **Argv) {
return EXIT_FAILURE;
});
if (BenchmarkMode == exegesis::InstructionBenchmark::Unknown) {
if (exegesis::BenchmarkMode == exegesis::InstructionBenchmark::Unknown) {
exegesis::analysisMain();
} else {
exegesis::benchmarkMain();

View File

@ -9,6 +9,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
void InitializeAArch64ExegesisTarget();
@ -60,3 +61,4 @@ TEST_F(AArch64TargetTest, SetRegToConstant) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -10,6 +10,7 @@
#include "../Common/AssemblerUtils.h"
#include "ARMInstrInfo.h"
namespace llvm {
namespace exegesis {
namespace {
@ -47,3 +48,4 @@ TEST_F(ARMMachineFunctionGeneratorTest, DISABLED_JitFunctionADDrr) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -11,6 +11,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
namespace {
@ -29,3 +30,4 @@ TEST(ScratchSpaceTest, Works) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -14,6 +14,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
namespace {
@ -104,3 +105,4 @@ TEST(ClusteringTest, Ordering) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -24,6 +24,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
class MachineFunctionGeneratorBaseTest : public ::testing::Test {
@ -89,5 +90,6 @@ private:
};
} // namespace exegesis
} // namespace llvm
#endif

View File

@ -12,6 +12,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
namespace pfm {
namespace {
@ -45,3 +46,4 @@ TEST(PerfHelperTest, FunctionalTest) {
} // namespace
} // namespace pfm
} // namespace exegesis
} // namespace llvm

View File

@ -11,6 +11,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
namespace {
@ -69,3 +70,4 @@ TEST(RegisterValueTest, Double) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -8,6 +8,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
namespace {
@ -100,3 +101,4 @@ TEST_F(AnalysisTest, ComputeIdealizedProcResPressure_1P1_1P05_2P0156) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -10,6 +10,7 @@
#include "../Common/AssemblerUtils.h"
#include "X86InstrInfo.h"
namespace llvm {
namespace exegesis {
void InitializeX86ExegesisTarget();
@ -63,3 +64,4 @@ TEST_F(X86MachineFunctionGeneratorTest, DISABLED_JitFunctionMOV32ri) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -25,6 +25,7 @@ using ::testing::get;
using ::testing::Pointwise;
using ::testing::Property;
namespace llvm {
namespace exegesis {
bool operator==(const BenchmarkMeasure &A, const BenchmarkMeasure &B) {
@ -136,3 +137,4 @@ TEST(BenchmarkResultTest, PerInstructionStats) {
}
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -9,6 +9,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
namespace {
@ -89,3 +90,4 @@ TEST_F(RegisterAliasingTest, TrackRegisterClassCache) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -17,6 +17,7 @@
#include <unordered_set>
namespace llvm {
namespace exegesis {
void InitializeX86ExegesisTarget();
@ -413,3 +414,4 @@ TEST_F(FakeSnippetGeneratorTest, ComputeRegisterInitialValuesAdd64rr) {
} // namespace
} // namespace exegesis
} // namespace llvm

View File

@ -35,6 +35,7 @@ bool operator==(const MCInst &a, const MCInst &b) {
} // namespace llvm
namespace llvm {
namespace exegesis {
void InitializeX86ExegesisTarget();
@ -376,3 +377,4 @@ TEST_F(Core2TargetTest, SetRegToFP1_4Bits) {
} // namespace
} // namespace exegesis
} // namespace llvm