You've already forked linux-packaging-mono
Imported Upstream version 6.4.0.137
Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
parent
e9207cf623
commit
ef583813eb
@ -26,6 +26,7 @@
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/Printable.h"
|
||||
#include <bitset>
|
||||
|
||||
using namespace llvm;
|
||||
@ -262,25 +263,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// An Instruction Converter which completely deletes an instruction.
|
||||
/// For example, IMPLICIT_DEF instructions can be deleted when converting from
|
||||
/// GPR to mask.
|
||||
class InstrDeleter : public InstrConverterBase {
|
||||
public:
|
||||
InstrDeleter(unsigned SrcOpcode) : InstrConverterBase(SrcOpcode) {}
|
||||
|
||||
bool convertInstr(MachineInstr *MI, const TargetInstrInfo *TII,
|
||||
MachineRegisterInfo *MRI) const override {
|
||||
assert(isLegal(MI, TII) && "Cannot convert instruction");
|
||||
return true;
|
||||
}
|
||||
|
||||
double getExtraCost(const MachineInstr *MI,
|
||||
MachineRegisterInfo *MRI) const override {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Key type to be used by the Instruction Converters map.
|
||||
// A converter is identified by <destination domain, source opcode>
|
||||
typedef std::pair<int, unsigned> InstrConverterBaseKeyTy;
|
||||
@ -310,8 +292,12 @@ private:
|
||||
/// Domains which this closure can legally be reassigned to.
|
||||
std::bitset<NumDomains> LegalDstDomains;
|
||||
|
||||
/// An ID to uniquely identify this closure, even when it gets
|
||||
/// moved around
|
||||
unsigned ID;
|
||||
|
||||
public:
|
||||
Closure(std::initializer_list<RegDomain> LegalDstDomainList) {
|
||||
Closure(unsigned ID, std::initializer_list<RegDomain> LegalDstDomainList) : ID(ID) {
|
||||
for (RegDomain D : LegalDstDomainList)
|
||||
LegalDstDomains.set(D);
|
||||
}
|
||||
@ -347,6 +333,27 @@ public:
|
||||
return Instrs;
|
||||
}
|
||||
|
||||
LLVM_DUMP_METHOD void dump(const MachineRegisterInfo *MRI) const {
|
||||
dbgs() << "Registers: ";
|
||||
bool First = true;
|
||||
for (unsigned Reg : Edges) {
|
||||
if (!First)
|
||||
dbgs() << ", ";
|
||||
First = false;
|
||||
dbgs() << printReg(Reg, MRI->getTargetRegisterInfo());
|
||||
}
|
||||
dbgs() << "\n" << "Instructions:";
|
||||
for (MachineInstr *MI : Instrs) {
|
||||
dbgs() << "\n ";
|
||||
MI->print(dbgs());
|
||||
}
|
||||
dbgs() << "\n";
|
||||
}
|
||||
|
||||
unsigned getID() const {
|
||||
return ID;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class X86DomainReassignment : public MachineFunctionPass {
|
||||
@ -358,7 +365,7 @@ class X86DomainReassignment : public MachineFunctionPass {
|
||||
DenseSet<unsigned> EnclosedEdges;
|
||||
|
||||
/// All instructions that are included in some closure.
|
||||
DenseMap<MachineInstr *, Closure *> EnclosedInstrs;
|
||||
DenseMap<MachineInstr *, unsigned> EnclosedInstrs;
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
@ -435,14 +442,14 @@ void X86DomainReassignment::visitRegister(Closure &C, unsigned Reg,
|
||||
void X86DomainReassignment::encloseInstr(Closure &C, MachineInstr *MI) {
|
||||
auto I = EnclosedInstrs.find(MI);
|
||||
if (I != EnclosedInstrs.end()) {
|
||||
if (I->second != &C)
|
||||
if (I->second != C.getID())
|
||||
// Instruction already belongs to another closure, avoid conflicts between
|
||||
// closure and mark this closure as illegal.
|
||||
C.setAllIllegal();
|
||||
return;
|
||||
}
|
||||
|
||||
EnclosedInstrs[MI] = &C;
|
||||
EnclosedInstrs[MI] = C.getID();
|
||||
C.addInstruction(MI);
|
||||
|
||||
// Mark closure as illegal for reassignment to domains, if there is no
|
||||
@ -587,7 +594,7 @@ void X86DomainReassignment::initConverters() {
|
||||
new InstrIgnore(TargetOpcode::PHI);
|
||||
|
||||
Converters[{MaskDomain, TargetOpcode::IMPLICIT_DEF}] =
|
||||
new InstrDeleter(TargetOpcode::IMPLICIT_DEF);
|
||||
new InstrIgnore(TargetOpcode::IMPLICIT_DEF);
|
||||
|
||||
Converters[{MaskDomain, TargetOpcode::INSERT_SUBREG}] =
|
||||
new InstrReplaceWithCopy(TargetOpcode::INSERT_SUBREG, 2);
|
||||
@ -723,6 +730,7 @@ bool X86DomainReassignment::runOnMachineFunction(MachineFunction &MF) {
|
||||
std::vector<Closure> Closures;
|
||||
|
||||
// Go over all virtual registers and calculate a closure.
|
||||
unsigned ClosureID = 0;
|
||||
for (unsigned Idx = 0; Idx < MRI->getNumVirtRegs(); ++Idx) {
|
||||
unsigned Reg = TargetRegisterInfo::index2VirtReg(Idx);
|
||||
|
||||
@ -735,7 +743,7 @@ bool X86DomainReassignment::runOnMachineFunction(MachineFunction &MF) {
|
||||
continue;
|
||||
|
||||
// Calculate closure starting with Reg.
|
||||
Closure C({MaskDomain});
|
||||
Closure C(ClosureID++, {MaskDomain});
|
||||
buildClosure(C, Reg);
|
||||
|
||||
// Collect all closures that can potentially be converted.
|
||||
@ -743,15 +751,16 @@ bool X86DomainReassignment::runOnMachineFunction(MachineFunction &MF) {
|
||||
Closures.push_back(std::move(C));
|
||||
}
|
||||
|
||||
for (Closure &C : Closures)
|
||||
for (Closure &C : Closures) {
|
||||
DEBUG(C.dump(MRI));
|
||||
if (isReassignmentProfitable(C, MaskDomain)) {
|
||||
reassign(C, MaskDomain);
|
||||
++NumClosuresConverted;
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto I : Converters)
|
||||
delete I.second;
|
||||
DeleteContainerSeconds(Converters);
|
||||
|
||||
DEBUG(dbgs() << "***** Machine Function after Domain Reassignment *****\n");
|
||||
DEBUG(MF.print(dbgs()));
|
||||
|
Reference in New Issue
Block a user