[llvm] r344130 - [llvm-exegesis][NFC] Simplify code now that Instruction has more semantic
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 10 02:45:17 PDT 2018
Author: gchatelet
Date: Wed Oct 10 02:45:17 2018
New Revision: 344130
URL: http://llvm.org/viewvc/llvm-project?rev=344130&view=rev
Log:
[llvm-exegesis][NFC] Simplify code now that Instruction has more semantic
Reviewers: courbet
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D53065
Modified:
llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp
llvm/trunk/tools/llvm-exegesis/lib/Latency.h
llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp
llvm/trunk/tools/llvm-exegesis/lib/Uops.h
Modified: llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp?rev=344130&r1=344129&r2=344130&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp Wed Oct 10 02:45:17 2018
@@ -20,28 +20,8 @@
namespace exegesis {
-static bool hasUnknownOperand(const llvm::MCOperandInfo &OpInfo) {
- return OpInfo.OperandType == llvm::MCOI::OPERAND_UNKNOWN;
-}
-
-// FIXME: Handle memory, see PR36905.
-static bool hasMemoryOperand(const llvm::MCOperandInfo &OpInfo) {
- return OpInfo.OperandType == llvm::MCOI::OPERAND_MEMORY;
-}
-
LatencySnippetGenerator::~LatencySnippetGenerator() = default;
-llvm::Error LatencySnippetGenerator::isInfeasible(
- const llvm::MCInstrDesc &MCInstrDesc) const {
- if (llvm::any_of(MCInstrDesc.operands(), hasUnknownOperand))
- return llvm::make_error<BenchmarkFailure>(
- "Infeasible : has unknown operands");
- if (llvm::any_of(MCInstrDesc.operands(), hasMemoryOperand))
- return llvm::make_error<BenchmarkFailure>(
- "Infeasible : has memory operands");
- return llvm::Error::success();
-}
-
llvm::Expected<CodeTemplate>
LatencySnippetGenerator::generateTwoInstructionPrototype(
const Instruction &Instr) const {
@@ -53,11 +33,9 @@ LatencySnippetGenerator::generateTwoInst
if (OtherOpcode == Instr.Description->Opcode)
continue;
const auto &OtherInstrDesc = State.getInstrInfo().get(OtherOpcode);
- if (auto E = isInfeasible(OtherInstrDesc)) {
- llvm::consumeError(std::move(E));
- continue;
- }
const Instruction OtherInstr(OtherInstrDesc, RATC);
+ if (OtherInstr.hasMemoryOperands())
+ continue;
const AliasingConfigurations Forward(Instr, OtherInstr);
const AliasingConfigurations Back(OtherInstr, Instr);
if (Forward.empty() || Back.empty())
@@ -81,10 +59,10 @@ LatencySnippetGenerator::generateTwoInst
llvm::Expected<CodeTemplate>
LatencySnippetGenerator::generateCodeTemplate(unsigned Opcode) const {
- const auto &InstrDesc = State.getInstrInfo().get(Opcode);
- if (auto E = isInfeasible(InstrDesc))
- return std::move(E);
- const Instruction Instr(InstrDesc, RATC);
+ const Instruction Instr(State.getInstrInfo().get(Opcode), RATC);
+ if (Instr.hasMemoryOperands())
+ return llvm::make_error<BenchmarkFailure>(
+ "Infeasible : has memory operands");
if (auto CT = generateSelfAliasingCodeTemplate(Instr))
return CT;
else
Modified: llvm/trunk/tools/llvm-exegesis/lib/Latency.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Latency.h?rev=344130&r1=344129&r2=344130&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Latency.h (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Latency.h Wed Oct 10 02:45:17 2018
@@ -30,8 +30,6 @@ public:
generateCodeTemplate(unsigned Opcode) const override;
private:
- llvm::Error isInfeasible(const llvm::MCInstrDesc &MCInstrDesc) const;
-
llvm::Expected<CodeTemplate>
generateTwoInstructionPrototype(const Instruction &Instr) const;
};
Modified: llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp?rev=344130&r1=344129&r2=344130&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp Wed Oct 10 02:45:17 2018
@@ -81,18 +81,6 @@
namespace exegesis {
-static bool hasUnknownOperand(const llvm::MCOperandInfo &OpInfo) {
- return OpInfo.OperandType == llvm::MCOI::OPERAND_UNKNOWN;
-}
-
-llvm::Error
-UopsSnippetGenerator::isInfeasible(const llvm::MCInstrDesc &MCInstrDesc) const {
- if (llvm::any_of(MCInstrDesc.operands(), hasUnknownOperand))
- return llvm::make_error<BenchmarkFailure>(
- "Infeasible : has unknown operands");
- return llvm::Error::success();
-}
-
static llvm::SmallVector<const Variable *, 8>
getVariablesWithTiedOperands(const Instruction &Instr) {
llvm::SmallVector<const Variable *, 8> Result;
@@ -109,6 +97,7 @@ static void remove(llvm::BitVector &a, c
}
UopsBenchmarkRunner::~UopsBenchmarkRunner() = default;
+
UopsSnippetGenerator::~UopsSnippetGenerator() = default;
void UopsSnippetGenerator::instantiateMemoryOperands(
@@ -137,10 +126,10 @@ void UopsSnippetGenerator::instantiateMe
llvm::Expected<CodeTemplate>
UopsSnippetGenerator::generateCodeTemplate(unsigned Opcode) const {
- const auto &InstrDesc = State.getInstrInfo().get(Opcode);
- if (auto E = isInfeasible(InstrDesc))
- return std::move(E);
- const Instruction Instr(InstrDesc, RATC);
+ const Instruction Instr(State.getInstrInfo().get(Opcode), RATC);
+ if (Instr.hasMemoryOperands())
+ return llvm::make_error<BenchmarkFailure>(
+ "Infeasible : has unknown operands");
const auto &ET = State.getExegesisTarget();
CodeTemplate CT;
Modified: llvm/trunk/tools/llvm-exegesis/lib/Uops.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Uops.h?rev=344130&r1=344129&r2=344130&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Uops.h (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Uops.h Wed Oct 10 02:45:17 2018
@@ -31,8 +31,6 @@ public:
static constexpr const size_t kMinNumDifferentAddresses = 6;
private:
- llvm::Error isInfeasible(const llvm::MCInstrDesc &MCInstrDesc) const;
-
// Instantiates memory operands within a snippet.
// To make computations as parallel as possible, we generate independant
// memory locations for instructions that load and store. If there are less
More information about the llvm-commits
mailing list