From a12bd277bdbb10fbb6a0ec6a103fa88536e53e30 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Wed, 10 Oct 2018 09:12:36 +0000 Subject: [PATCH] [llvm-exegesis] Remove unused variable, add more semantic to Instruction. Reviewers: courbet Subscribers: tschuett, llvm-commits Differential Revision: https://reviews.llvm.org/D53062 llvm-svn: 344127 --- tools/llvm-exegesis/lib/MCInstrDescView.cpp | 16 ++++++++++++- tools/llvm-exegesis/lib/MCInstrDescView.h | 25 +++++++++++++-------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/tools/llvm-exegesis/lib/MCInstrDescView.cpp b/tools/llvm-exegesis/lib/MCInstrDescView.cpp index 2f09bc1b0eb..75d85873146 100644 --- a/tools/llvm-exegesis/lib/MCInstrDescView.cpp +++ b/tools/llvm-exegesis/lib/MCInstrDescView.cpp @@ -175,6 +175,18 @@ bool Instruction::hasAliasingImplicitRegisters() const { return ImplDefRegs.anyCommon(ImplUseRegs); } +bool Instruction::hasAliasingImplicitRegistersThrough( + const Instruction &OtherInstr) const { + return ImplDefRegs.anyCommon(OtherInstr.ImplUseRegs) && + OtherInstr.ImplDefRegs.anyCommon(ImplUseRegs); +} + +bool Instruction::hasAliasingRegistersThrough( + const Instruction &OtherInstr) const { + return AllDefRegs.anyCommon(OtherInstr.AllUseRegs) && + OtherInstr.AllDefRegs.anyCommon(AllUseRegs); +} + bool Instruction::hasTiedRegisters() const { return llvm::any_of( Variables, [](const Variable &Var) { return Var.hasTiedOperands(); }); @@ -215,8 +227,10 @@ void Instruction::dump(const llvm::MCRegisterInfo &RegInfo, } for (const auto &Var : Variables) { Stream << "- Var" << Var.getIndex(); + Stream << " ("; for (auto OperandIndex : Var.TiedOperands) - Stream << " Op" << OperandIndex; + Stream << "Op" << OperandIndex; + Stream << ")"; Stream << "\n"; } if (hasMemoryOperands()) diff --git a/tools/llvm-exegesis/lib/MCInstrDescView.h b/tools/llvm-exegesis/lib/MCInstrDescView.h index 511ed825387..39e5c4a5f5b 100644 --- a/tools/llvm-exegesis/lib/MCInstrDescView.h +++ b/tools/llvm-exegesis/lib/MCInstrDescView.h @@ -44,7 +44,7 @@ struct Variable { // The indices of the operands tied to this Variable. llvm::SmallVector TiedOperands; - llvm::MCOperand AssignedValue; + // The index of this Variable in Instruction.Variables and its associated // Value in InstructionBuilder.VariableValues. int Index = -1; @@ -99,25 +99,32 @@ struct Instruction { // In case the Variable is tied, the primary (i.e. Def) Operand is returned. const Operand &getPrimaryOperand(const Variable &Var) const; - // Returns whether this instruction has Memory Operands. - // Repeating this instruction executes sequentially with an instruction that - // reads or write the same memory region. - bool hasMemoryOperands() const; + // Whether this instruction is self aliasing through its tied registers. + // Repeating this instruction is guaranteed to executes sequentially. + bool hasTiedRegisters() const; // Whether this instruction is self aliasing through its implicit registers. // Repeating this instruction is guaranteed to executes sequentially. bool hasAliasingImplicitRegisters() const; - // Whether this instruction is self aliasing through its tied registers. - // Repeating this instruction is guaranteed to executes sequentially. - bool hasTiedRegisters() const; - // Whether this instruction is self aliasing through some registers. // Repeating this instruction may execute sequentially by picking aliasing // Use and Def registers. It may also execute in parallel by picking non // aliasing Use and Def registers. bool hasAliasingRegisters() const; + // Whether this instruction's implicit registers alias with OtherInstr's + // implicit registers. + bool hasAliasingImplicitRegistersThrough(const Instruction &OtherInstr) const; + + // Whether this instruction's registers alias with OtherInstr's registers. + bool hasAliasingRegistersThrough(const Instruction &OtherInstr) const; + + // Returns whether this instruction has Memory Operands. + // Repeating this instruction executes sequentially with an instruction that + // reads or write the same memory region. + bool hasMemoryOperands() const; + // Convenient function to help with debugging. void dump(const llvm::MCRegisterInfo &RegInfo, llvm::raw_ostream &Stream) const;