mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
GlobalISel: Don't use LLT references
These should always be passed by value
This commit is contained in:
parent
8f84b444b1
commit
8f4091003d
@ -173,7 +173,7 @@ public:
|
||||
: ID(ID), MRI(MRI) {}
|
||||
// Profiling methods.
|
||||
const GISelInstProfileBuilder &addNodeIDOpcode(unsigned Opc) const;
|
||||
const GISelInstProfileBuilder &addNodeIDRegType(const LLT &Ty) const;
|
||||
const GISelInstProfileBuilder &addNodeIDRegType(const LLT Ty) const;
|
||||
const GISelInstProfileBuilder &addNodeIDRegType(const unsigned) const;
|
||||
|
||||
const GISelInstProfileBuilder &
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
// Can't use MIPattern because we don't have a specific constant in mind.
|
||||
auto *SrcMI = MRI.getVRegDef(SrcReg);
|
||||
if (SrcMI->getOpcode() == TargetOpcode::G_CONSTANT) {
|
||||
const LLT &DstTy = MRI.getType(DstReg);
|
||||
const LLT DstTy = MRI.getType(DstReg);
|
||||
if (isInstLegal({TargetOpcode::G_CONSTANT, {DstTy}})) {
|
||||
auto &CstVal = SrcMI->getOperand(1);
|
||||
Builder.buildConstant(
|
||||
@ -125,7 +125,7 @@ public:
|
||||
// Can't use MIPattern because we don't have a specific constant in mind.
|
||||
auto *SrcMI = MRI.getVRegDef(SrcReg);
|
||||
if (SrcMI->getOpcode() == TargetOpcode::G_CONSTANT) {
|
||||
const LLT &DstTy = MRI.getType(DstReg);
|
||||
const LLT DstTy = MRI.getType(DstReg);
|
||||
if (isInstLegal({TargetOpcode::G_CONSTANT, {DstTy}})) {
|
||||
auto &CstVal = SrcMI->getOperand(1);
|
||||
Builder.buildConstant(
|
||||
@ -178,7 +178,7 @@ public:
|
||||
// Can't use MIPattern because we don't have a specific constant in mind.
|
||||
auto *SrcMI = MRI.getVRegDef(SrcReg);
|
||||
if (SrcMI->getOpcode() == TargetOpcode::G_CONSTANT) {
|
||||
const LLT &DstTy = MRI.getType(DstReg);
|
||||
const LLT DstTy = MRI.getType(DstReg);
|
||||
if (isInstLegal({TargetOpcode::G_CONSTANT, {DstTy}})) {
|
||||
auto &CstVal = SrcMI->getOperand(1);
|
||||
Builder.buildConstant(
|
||||
|
@ -153,7 +153,7 @@ struct LegalizeActionStep {
|
||||
LLT NewType;
|
||||
|
||||
LegalizeActionStep(LegalizeAction Action, unsigned TypeIdx,
|
||||
const LLT &NewType)
|
||||
const LLT NewType)
|
||||
: Action(Action), TypeIdx(TypeIdx), NewType(NewType) {}
|
||||
|
||||
bool operator==(const LegalizeActionStep &RHS) const {
|
||||
@ -739,7 +739,7 @@ public:
|
||||
}
|
||||
|
||||
/// Ensure the scalar or element is at least as wide as Ty.
|
||||
LegalizeRuleSet &minScalarOrElt(unsigned TypeIdx, const LLT &Ty) {
|
||||
LegalizeRuleSet &minScalarOrElt(unsigned TypeIdx, const LLT Ty) {
|
||||
using namespace LegalityPredicates;
|
||||
using namespace LegalizeMutations;
|
||||
return actionIf(LegalizeAction::WidenScalar,
|
||||
@ -749,7 +749,7 @@ public:
|
||||
|
||||
/// Ensure the scalar or element is at least as wide as Ty.
|
||||
LegalizeRuleSet &minScalarOrEltIf(LegalityPredicate Predicate,
|
||||
unsigned TypeIdx, const LLT &Ty) {
|
||||
unsigned TypeIdx, const LLT Ty) {
|
||||
using namespace LegalityPredicates;
|
||||
using namespace LegalizeMutations;
|
||||
return actionIf(LegalizeAction::WidenScalar,
|
||||
@ -759,7 +759,7 @@ public:
|
||||
}
|
||||
|
||||
/// Ensure the scalar is at least as wide as Ty.
|
||||
LegalizeRuleSet &minScalar(unsigned TypeIdx, const LLT &Ty) {
|
||||
LegalizeRuleSet &minScalar(unsigned TypeIdx, const LLT Ty) {
|
||||
using namespace LegalityPredicates;
|
||||
using namespace LegalizeMutations;
|
||||
return actionIf(LegalizeAction::WidenScalar,
|
||||
@ -768,7 +768,7 @@ public:
|
||||
}
|
||||
|
||||
/// Ensure the scalar is at most as wide as Ty.
|
||||
LegalizeRuleSet &maxScalarOrElt(unsigned TypeIdx, const LLT &Ty) {
|
||||
LegalizeRuleSet &maxScalarOrElt(unsigned TypeIdx, const LLT Ty) {
|
||||
using namespace LegalityPredicates;
|
||||
using namespace LegalizeMutations;
|
||||
return actionIf(LegalizeAction::NarrowScalar,
|
||||
@ -777,7 +777,7 @@ public:
|
||||
}
|
||||
|
||||
/// Ensure the scalar is at most as wide as Ty.
|
||||
LegalizeRuleSet &maxScalar(unsigned TypeIdx, const LLT &Ty) {
|
||||
LegalizeRuleSet &maxScalar(unsigned TypeIdx, const LLT Ty) {
|
||||
using namespace LegalityPredicates;
|
||||
using namespace LegalizeMutations;
|
||||
return actionIf(LegalizeAction::NarrowScalar,
|
||||
@ -789,7 +789,7 @@ public:
|
||||
/// For example, when the maximum size of one type depends on the size of
|
||||
/// another such as extracting N bits from an M bit container.
|
||||
LegalizeRuleSet &maxScalarIf(LegalityPredicate Predicate, unsigned TypeIdx,
|
||||
const LLT &Ty) {
|
||||
const LLT Ty) {
|
||||
using namespace LegalityPredicates;
|
||||
using namespace LegalizeMutations;
|
||||
return actionIf(
|
||||
@ -801,15 +801,15 @@ public:
|
||||
}
|
||||
|
||||
/// Limit the range of scalar sizes to MinTy and MaxTy.
|
||||
LegalizeRuleSet &clampScalar(unsigned TypeIdx, const LLT &MinTy,
|
||||
const LLT &MaxTy) {
|
||||
LegalizeRuleSet &clampScalar(unsigned TypeIdx, const LLT MinTy,
|
||||
const LLT MaxTy) {
|
||||
assert(MinTy.isScalar() && MaxTy.isScalar() && "Expected scalar types");
|
||||
return minScalar(TypeIdx, MinTy).maxScalar(TypeIdx, MaxTy);
|
||||
}
|
||||
|
||||
/// Limit the range of scalar sizes to MinTy and MaxTy.
|
||||
LegalizeRuleSet &clampScalarOrElt(unsigned TypeIdx, const LLT &MinTy,
|
||||
const LLT &MaxTy) {
|
||||
LegalizeRuleSet &clampScalarOrElt(unsigned TypeIdx, const LLT MinTy,
|
||||
const LLT MaxTy) {
|
||||
return minScalarOrElt(TypeIdx, MinTy).maxScalarOrElt(TypeIdx, MaxTy);
|
||||
}
|
||||
|
||||
@ -855,7 +855,7 @@ public:
|
||||
}
|
||||
|
||||
/// Limit the number of elements in EltTy vectors to at least MinElements.
|
||||
LegalizeRuleSet &clampMinNumElements(unsigned TypeIdx, const LLT &EltTy,
|
||||
LegalizeRuleSet &clampMinNumElements(unsigned TypeIdx, const LLT EltTy,
|
||||
unsigned MinElements) {
|
||||
// Mark the type index as covered:
|
||||
typeIdx(TypeIdx);
|
||||
@ -873,7 +873,7 @@ public:
|
||||
});
|
||||
}
|
||||
/// Limit the number of elements in EltTy vectors to at most MaxElements.
|
||||
LegalizeRuleSet &clampMaxNumElements(unsigned TypeIdx, const LLT &EltTy,
|
||||
LegalizeRuleSet &clampMaxNumElements(unsigned TypeIdx, const LLT EltTy,
|
||||
unsigned MaxElements) {
|
||||
// Mark the type index as covered:
|
||||
typeIdx(TypeIdx);
|
||||
@ -896,12 +896,12 @@ public:
|
||||
/// No effect if the type is not a vector or does not have the same element
|
||||
/// type as the constraints.
|
||||
/// The element type of MinTy and MaxTy must match.
|
||||
LegalizeRuleSet &clampNumElements(unsigned TypeIdx, const LLT &MinTy,
|
||||
const LLT &MaxTy) {
|
||||
LegalizeRuleSet &clampNumElements(unsigned TypeIdx, const LLT MinTy,
|
||||
const LLT MaxTy) {
|
||||
assert(MinTy.getElementType() == MaxTy.getElementType() &&
|
||||
"Expected element types to agree");
|
||||
|
||||
const LLT &EltTy = MinTy.getElementType();
|
||||
const LLT EltTy = MinTy.getElementType();
|
||||
return clampMinNumElements(TypeIdx, EltTy, MinTy.getNumElements())
|
||||
.clampMaxNumElements(TypeIdx, EltTy, MaxTy.getNumElements());
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ template <> struct bind_helper<MachineInstr *> {
|
||||
};
|
||||
|
||||
template <> struct bind_helper<LLT> {
|
||||
static bool bind(const MachineRegisterInfo &MRI, LLT &Ty, Register Reg) {
|
||||
static bool bind(const MachineRegisterInfo &MRI, LLT Ty, Register Reg) {
|
||||
Ty = MRI.getType(Reg);
|
||||
if (Ty.isValid())
|
||||
return true;
|
||||
@ -163,7 +163,7 @@ template <typename Class> struct bind_ty {
|
||||
|
||||
inline bind_ty<Register> m_Reg(Register &R) { return R; }
|
||||
inline bind_ty<MachineInstr *> m_MInstr(MachineInstr *&MI) { return MI; }
|
||||
inline bind_ty<LLT> m_Type(LLT &Ty) { return Ty; }
|
||||
inline bind_ty<LLT> m_Type(LLT Ty) { return Ty; }
|
||||
inline bind_ty<CmpInst::Predicate> m_Pred(CmpInst::Predicate &P) { return P; }
|
||||
inline operand_type_match m_Pred() { return operand_type_match(); }
|
||||
|
||||
@ -365,7 +365,7 @@ m_GFCmp(const Pred &P, const LHS &L, const RHS &R) {
|
||||
// Helper for checking if a Reg is of specific type.
|
||||
struct CheckType {
|
||||
LLT Ty;
|
||||
CheckType(const LLT &Ty) : Ty(Ty) {}
|
||||
CheckType(const LLT Ty) : Ty(Ty) {}
|
||||
|
||||
bool match(const MachineRegisterInfo &MRI, Register Reg) {
|
||||
return MRI.getType(Reg) == Ty;
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
DstOp(unsigned R) : Reg(R), Ty(DstType::Ty_Reg) {}
|
||||
DstOp(Register R) : Reg(R), Ty(DstType::Ty_Reg) {}
|
||||
DstOp(const MachineOperand &Op) : Reg(Op.getReg()), Ty(DstType::Ty_Reg) {}
|
||||
DstOp(const LLT &T) : LLTTy(T), Ty(DstType::Ty_LLT) {}
|
||||
DstOp(const LLT T) : LLTTy(T), Ty(DstType::Ty_LLT) {}
|
||||
DstOp(const TargetRegisterClass *TRC) : RC(TRC), Ty(DstType::Ty_RC) {}
|
||||
|
||||
void addDefToMIB(MachineRegisterInfo &MRI, MachineInstrBuilder &MIB) const {
|
||||
@ -223,13 +223,13 @@ class MachineIRBuilder {
|
||||
MachineIRBuilderState State;
|
||||
|
||||
protected:
|
||||
void validateTruncExt(const LLT &Dst, const LLT &Src, bool IsExtend);
|
||||
void validateTruncExt(const LLT Dst, const LLT Src, bool IsExtend);
|
||||
|
||||
void validateBinaryOp(const LLT &Res, const LLT &Op0, const LLT &Op1);
|
||||
void validateShiftOp(const LLT &Res, const LLT &Op0, const LLT &Op1);
|
||||
void validateBinaryOp(const LLT Res, const LLT Op0, const LLT Op1);
|
||||
void validateShiftOp(const LLT Res, const LLT Op0, const LLT Op1);
|
||||
|
||||
void validateSelectOp(const LLT &ResTy, const LLT &TstTy, const LLT &Op0Ty,
|
||||
const LLT &Op1Ty);
|
||||
void validateSelectOp(const LLT ResTy, const LLT TstTy, const LLT Op0Ty,
|
||||
const LLT Op1Ty);
|
||||
void recordInsertion(MachineInstr *MI) const;
|
||||
|
||||
public:
|
||||
@ -436,7 +436,7 @@ public:
|
||||
///
|
||||
/// \return a MachineInstrBuilder for the newly created instruction.
|
||||
Optional<MachineInstrBuilder> materializePtrAdd(Register &Res, Register Op0,
|
||||
const LLT &ValueTy,
|
||||
const LLT ValueTy,
|
||||
uint64_t Value);
|
||||
|
||||
/// Build and insert \p Res = G_PTR_MASK \p Op0, \p NumBits
|
||||
|
@ -287,7 +287,7 @@ GISelInstProfileBuilder::addNodeIDOpcode(unsigned Opc) const {
|
||||
}
|
||||
|
||||
const GISelInstProfileBuilder &
|
||||
GISelInstProfileBuilder::addNodeIDRegType(const LLT &Ty) const {
|
||||
GISelInstProfileBuilder::addNodeIDRegType(const LLT Ty) const {
|
||||
uint64_t Val = Ty.getUniqueRAWLLTData();
|
||||
ID.AddInteger(Val);
|
||||
return *this;
|
||||
|
@ -295,7 +295,7 @@ namespace {
|
||||
/// Select a preference between two uses. CurrentUse is the current preference
|
||||
/// while *ForCandidate is attributes of the candidate under consideration.
|
||||
PreferredTuple ChoosePreferredUse(PreferredTuple &CurrentUse,
|
||||
const LLT &TyForCandidate,
|
||||
const LLT TyForCandidate,
|
||||
unsigned OpcodeForCandidate,
|
||||
MachineInstr *MIForCandidate) {
|
||||
if (!CurrentUse.Ty.isValid()) {
|
||||
@ -499,7 +499,7 @@ void CombinerHelper::applyCombineExtendingLoads(MachineInstr &MI,
|
||||
UseMI->getOpcode() == TargetOpcode::G_ANYEXT) {
|
||||
Register UseDstReg = UseMI->getOperand(0).getReg();
|
||||
MachineOperand &UseSrcMO = UseMI->getOperand(1);
|
||||
const LLT &UseDstTy = MRI.getType(UseDstReg);
|
||||
const LLT UseDstTy = MRI.getType(UseDstReg);
|
||||
if (UseDstReg != ChosenDstReg) {
|
||||
if (Preferred.Ty == UseDstTy) {
|
||||
// If the use has the same type as the preferred use, then merge
|
||||
@ -1151,7 +1151,7 @@ bool CombinerHelper::optimizeMemcpy(MachineInstr &MI, Register Dst,
|
||||
// Construct MMOs for the accesses.
|
||||
auto *LoadMMO =
|
||||
MF.getMachineMemOperand(&SrcMMO, CurrOffset, CopyTy.getSizeInBytes());
|
||||
auto *StoreMMO =
|
||||
auto *StoreMMO =
|
||||
MF.getMachineMemOperand(&DstMMO, CurrOffset, CopyTy.getSizeInBytes());
|
||||
|
||||
// Create the load.
|
||||
|
@ -604,7 +604,7 @@ void IRTranslator::emitSwitchCase(SwitchCG::CaseBlock &CB,
|
||||
Cond =
|
||||
MIB.buildICmp(CmpInst::ICMP_SLE, i1Ty, CmpOpReg, CondRHS).getReg(0);
|
||||
} else {
|
||||
const LLT &CmpTy = MRI->getType(CmpOpReg);
|
||||
const LLT CmpTy = MRI->getType(CmpOpReg);
|
||||
auto Sub = MIB.buildSub({CmpTy}, CmpOpReg, CondLHS);
|
||||
auto Diff = MIB.buildConstant(CmpTy, High - Low);
|
||||
Cond = MIB.buildICmp(CmpInst::ICMP_ULE, i1Ty, Sub, Diff).getReg(0);
|
||||
@ -1956,7 +1956,7 @@ bool IRTranslator::translateExtractElement(const User &U,
|
||||
if (!Idx)
|
||||
Idx = getOrCreateVReg(*U.getOperand(1));
|
||||
if (MRI->getType(Idx).getSizeInBits() != PreferredVecIdxWidth) {
|
||||
const LLT &VecIdxTy = LLT::scalar(PreferredVecIdxWidth);
|
||||
const LLT VecIdxTy = LLT::scalar(PreferredVecIdxWidth);
|
||||
Idx = MIRBuilder.buildSExtOrTrunc(VecIdxTy, Idx).getReg(0);
|
||||
}
|
||||
MIRBuilder.buildExtractVectorElement(Res, Val, Idx);
|
||||
|
@ -199,14 +199,14 @@ MachineInstrBuilder MachineIRBuilder::buildJumpTable(const LLT PtrTy,
|
||||
.addJumpTableIndex(JTI);
|
||||
}
|
||||
|
||||
void MachineIRBuilder::validateBinaryOp(const LLT &Res, const LLT &Op0,
|
||||
const LLT &Op1) {
|
||||
void MachineIRBuilder::validateBinaryOp(const LLT Res, const LLT Op0,
|
||||
const LLT Op1) {
|
||||
assert((Res.isScalar() || Res.isVector()) && "invalid operand type");
|
||||
assert((Res == Op0 && Res == Op1) && "type mismatch");
|
||||
}
|
||||
|
||||
void MachineIRBuilder::validateShiftOp(const LLT &Res, const LLT &Op0,
|
||||
const LLT &Op1) {
|
||||
void MachineIRBuilder::validateShiftOp(const LLT Res, const LLT Op0,
|
||||
const LLT Op1) {
|
||||
assert((Res.isScalar() || Res.isVector()) && "invalid operand type");
|
||||
assert((Res == Op0) && "type mismatch");
|
||||
}
|
||||
@ -223,7 +223,7 @@ MachineInstrBuilder MachineIRBuilder::buildPtrAdd(const DstOp &Res,
|
||||
|
||||
Optional<MachineInstrBuilder>
|
||||
MachineIRBuilder::materializePtrAdd(Register &Res, Register Op0,
|
||||
const LLT &ValueTy, uint64_t Value) {
|
||||
const LLT ValueTy, uint64_t Value) {
|
||||
assert(Res == 0 && "Res is a result argument");
|
||||
assert(ValueTy.isScalar() && "invalid offset type");
|
||||
|
||||
@ -912,7 +912,7 @@ MachineIRBuilder::buildBlockAddress(Register Res, const BlockAddress *BA) {
|
||||
return buildInstr(TargetOpcode::G_BLOCK_ADDR).addDef(Res).addBlockAddress(BA);
|
||||
}
|
||||
|
||||
void MachineIRBuilder::validateTruncExt(const LLT &DstTy, const LLT &SrcTy,
|
||||
void MachineIRBuilder::validateTruncExt(const LLT DstTy, const LLT SrcTy,
|
||||
bool IsExtend) {
|
||||
#ifndef NDEBUG
|
||||
if (DstTy.isVector()) {
|
||||
@ -931,8 +931,8 @@ void MachineIRBuilder::validateTruncExt(const LLT &DstTy, const LLT &SrcTy,
|
||||
#endif
|
||||
}
|
||||
|
||||
void MachineIRBuilder::validateSelectOp(const LLT &ResTy, const LLT &TstTy,
|
||||
const LLT &Op0Ty, const LLT &Op1Ty) {
|
||||
void MachineIRBuilder::validateSelectOp(const LLT ResTy, const LLT TstTy,
|
||||
const LLT Op0Ty, const LLT Op1Ty) {
|
||||
#ifndef NDEBUG
|
||||
assert((ResTy.isScalar() || ResTy.isVector() || ResTy.isPointer()) &&
|
||||
"invalid operand type");
|
||||
|
Loading…
x
Reference in New Issue
Block a user