38 DefaultActions[TargetOpcode::G_IMPLICIT_DEF] =
NarrowScalar;
42 DefaultActions[TargetOpcode::G_ANYEXT] =
Legal;
43 DefaultActions[TargetOpcode::G_TRUNC] =
Legal;
45 DefaultActions[TargetOpcode::G_INTRINSIC] =
Legal;
46 DefaultActions[TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS] =
Legal;
52 DefaultActions[TargetOpcode::G_BRCOND] =
WidenScalar;
55 DefaultActions[TargetOpcode::G_FNEG] =
Lower;
59 for (
unsigned Opcode = 0; Opcode <= LastOp - FirstOp; ++Opcode) {
60 for (
unsigned Idx = 0; Idx != Actions[Opcode].size(); ++Idx) {
61 for (
auto &Action : Actions[Opcode][Idx]) {
62 LLT Ty = Action.first;
66 auto &Entry = MaxLegalVectorElts[std::make_pair(Opcode + FirstOp,
73 TablesInitialized =
true;
80 std::pair<LegalizerInfo::LegalizeAction, LLT>
82 assert(TablesInitialized &&
"backend forgot to call computeTables");
88 if (Aspect.
Opcode == TargetOpcode::G_MERGE_VALUES ||
89 Aspect.
Opcode == TargetOpcode::G_UNMERGE_VALUES)
90 return std::make_pair(
Legal, Aspect.
Type);
105 unsigned Opcode = Aspect.
Opcode;
107 auto DefaultAction = DefaultActions.
find(Aspect.
Opcode);
108 if (DefaultAction != DefaultActions.
end() && DefaultAction->second ==
Legal)
109 return std::make_pair(
Legal, Ty);
111 if (DefaultAction != DefaultActions.
end() && DefaultAction->second ==
Lower)
112 return std::make_pair(
Lower, Ty);
114 if (DefaultAction == DefaultActions.
end() ||
123 auto ScalarAction = ScalarInVectorActions.
find(std::make_pair(Opcode, EltTy));
124 if (ScalarAction != ScalarInVectorActions.
end() &&
125 ScalarAction->second !=
Legal)
130 auto MaxLegalElts = MaxLegalVectorElts.lookup(std::make_pair(Opcode, EltTy));
131 if (MaxLegalElts > NumElts)
134 if (MaxLegalElts == 0) {
143 std::tuple<LegalizerInfo::LegalizeAction, unsigned, LLT>
149 if (!OpInfo[i].isGenericType())
155 if (SeenTypes[TypeIdx])
158 SeenTypes.
set(TypeIdx);
162 if (Action.first !=
Legal)
163 return std::make_tuple(Action.first, TypeIdx, Action.second);
165 return std::make_tuple(
Legal, 0,
LLT{});
LLT doubleElements() const
Get a low-level type with twice the size of the original, by doubling the number of vector elements o...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
LLT getType(unsigned VReg) const
Get the low-level type of VReg or LLT{} if VReg is not a generic (target independent) virtual registe...
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
std::pair< LegalizeAction, LLT > getAction(const InstrAspect &Aspect) const
Determine what action should be taken to legalize the given generic instruction opcode, type-index and type.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Optional< LLT > findLegalType(const InstrAspect &Aspect, LegalizeAction Action) const
Find what type it's actually OK to perform the given operation on, given the general approach we've d...
Sentinel value for when no action was found in the specified table.
void computeTables()
Compute any ancillary tables needed to quickly decide how an operation should be handled.
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
LLT doubleScalarSize() const
Get a low-level type with twice the size of the original, by doubling the size of the scalar type inv...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
iterator find(const_arg_type_t< KeyT > Val)
The target wants to do something special with this combination of operand and type.
unsigned const MachineRegisterInfo * MRI
The (vector) operation should be implemented by splitting it into sub-vectors where the operation is ...
const MachineOperand & getOperand(unsigned i) const
Helper class to build MachineInstr.
unsigned getGenericTypeIndex() const
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
The (vector) operation should be implemented by widening the input vector and ignoring the lanes adde...
std::pair< LegalizeAction, LLT > findLegalAction(const InstrAspect &Aspect, LegalizeAction Action) const
Legalization is decided based on an instruction's opcode, which type slot we're considering, and what the existing type is.
virtual bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder) const
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
The operation should be synthesized from multiple instructions acting on a narrower scalar base-type...
The operation should be implemented as a call to some kind of runtime support library.
The operation should be implemented in terms of a wider scalar base-type.
The operation itself must be expressed in terms of simpler actions on this target.
The operation is expected to be selectable directly by the target, and no transformation is necessary...
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
LLT halfScalarSize() const
Get a low-level type with half the size of the original, by halving the size of the scalar type invol...
LLT halfElements() const
Get a low-level type with half the size of the original, by halving the number of vector elements of ...
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Optional< LLT > findLegalizableSize(const InstrAspect &Aspect, function_ref< LLT(LLT)> NextType) const
Iterate the given function (typically something like doubling the width) on Ty until we find a legal ...
This operation is completely unsupported on the target.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const MCOperandInfo * OpInfo
LegalizeAction findInActions(const InstrAspect &Aspect) const
Find the specified Aspect in the primary (explicitly set) Actions table.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
This holds information about one operand of a machine instruction, indicating the register class for ...
bool isLegal(const MachineInstr &MI, const MachineRegisterInfo &MRI) const