#include "X86.h"
#include "X86InstrInfo.h"
#include "X86Subtarget.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Printable.h"
#include <bitset>
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumClosuresConverted, "Number of closures converted by the pass");
static cl::opt<bool> DisableX86DomainReassignment(
"disable-x86-domain-reassignment", cl::Hidden,
cl::desc("X86: Disable Virtual Register Reassignment."), cl::init(false));
namespace {
enum RegDomain { … };
static bool isMask(const TargetRegisterClass *RC,
const TargetRegisterInfo *TRI) { … }
static RegDomain getDomain(const TargetRegisterClass *RC,
const TargetRegisterInfo *TRI) { … }
static const TargetRegisterClass *getDstRC(const TargetRegisterClass *SrcRC,
RegDomain Domain) { … }
class InstrConverterBase { … };
class InstrIgnore : public InstrConverterBase { … };
class InstrReplacer : public InstrConverterBase { … };
class InstrReplacerDstCOPY : public InstrConverterBase { … };
class InstrCOPYReplacer : public InstrReplacer { … };
class InstrReplaceWithCopy : public InstrConverterBase { … };
InstrConverterBaseKeyTy;
InstrConverterBaseMap;
class Closure { … };
class X86DomainReassignment : public MachineFunctionPass { … };
char X86DomainReassignment::ID = …;
}
bool X86DomainReassignment::visitRegister(Closure &C, Register Reg,
RegDomain &Domain,
SmallVectorImpl<unsigned> &Worklist) { … }
bool X86DomainReassignment::encloseInstr(Closure &C, MachineInstr *MI) { … }
double X86DomainReassignment::calculateCost(const Closure &C,
RegDomain DstDomain) const { … }
bool X86DomainReassignment::isReassignmentProfitable(const Closure &C,
RegDomain Domain) const { … }
void X86DomainReassignment::reassign(const Closure &C, RegDomain Domain) const { … }
static bool usedAsAddr(const MachineInstr &MI, Register Reg,
const TargetInstrInfo *TII) { … }
void X86DomainReassignment::buildClosure(Closure &C, Register Reg) { … }
void X86DomainReassignment::initConverters() { … }
bool X86DomainReassignment::runOnMachineFunction(MachineFunction &MF) { … }
INITIALIZE_PASS(…)
FunctionPass *llvm::createX86DomainReassignmentPass() { … }