15 #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
16 #define LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
33 class MachineIRBuilder;
34 class MachineRegisterInfo;
46 : Opcode(Opcode), Idx(Idx), Type(Type) {}
126 TablesInitialized =
false;
127 unsigned Opcode = Aspect.
Opcode - FirstOp;
128 if (Actions[Opcode].size() <= Aspect.
Idx)
129 Actions[Opcode].resize(Aspect.
Idx + 1);
130 Actions[Aspect.
Opcode - FirstOp][Aspect.
Idx][Aspect.
Type] = Action;
141 ScalarInVectorActions[std::make_pair(Opcode, ScalarTy)] = Action;
158 std::tuple<LegalizeAction, unsigned, LLT>
170 auto ActionIt = Map.
find(Ty);
171 if (ActionIt == Map.
end()) {
172 auto DefaultIt = DefaultActions.
find(Aspect.
Opcode);
173 if (DefaultIt == DefaultActions.
end())
175 Action = DefaultIt->second;
177 Action = ActionIt->second;
190 return std::make_pair(LegalizeAction::Unsupported,
LLT());
191 return std::make_pair(Action, *LegalType);
200 if (Aspect.
Idx >= Actions[Aspect.
Opcode - FirstOp].size())
203 auto ActionIt = Map.
find(Aspect.
Type);
204 if (ActionIt == Map.
end())
207 return ActionIt->second;
217 static const int FirstOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_START;
218 static const int LastOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
224 SIVActionMap ScalarInVectorActions;
228 bool TablesInitialized =
false;
233 #endif // LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
InstrAspect(unsigned Opcode, unsigned Idx, LLT Type)
bool operator==(const InstrAspect &RHS) const
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.
An efficient, type-erasing, non-owning reference to a callable.
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.
InstrAspect(unsigned Opcode, LLT Type)
void computeTables()
Compute any ancillary tables needed to quickly decide how an operation should be handled.
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 ...
The instances of the Type class are immutable: once they are created, they are never changed...
Helper class to build MachineInstr.
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
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.
virtual ~LegalizerInfo()=default
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
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...
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.
static bool needsLegalizingToDifferentSize(const LegalizeAction Action)
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.
LegalizeAction findInActions(const InstrAspect &Aspect) const
Find the specified Aspect in the primary (explicitly set) Actions table.
void setScalarInVectorAction(unsigned Opcode, LLT ScalarTy, LegalizeAction Action)
If an operation on a given vector type (say <M x="" in>="">) isn't explicitly specified, we proceed in 2 stages.
bool isLegal(const MachineInstr &MI, const MachineRegisterInfo &MRI) const
void setAction(const InstrAspect &Aspect, LegalizeAction Action)
More friendly way to set an action for common types that have an LLT representation.