15 #ifndef LLVM_CODEGEN_GLOBALISEL_MACHINELEGALIZER_H
16 #define LLVM_CODEGEN_GLOBALISEL_MACHINELEGALIZER_H
28 class MachineRegisterInfo;
42 : Opcode(Opcode), Idx(Idx), Type(Type) {}
108 TablesInitialized =
false;
109 unsigned Opcode = Aspect.
Opcode - FirstOp;
110 if (Actions[Opcode].size() <= Aspect.
Idx)
111 Actions[Opcode].resize(Aspect.
Idx + 1);
112 Actions[Aspect.
Opcode - FirstOp][Aspect.
Idx][Aspect.
Type] = Action;
123 ScalarInVectorActions[std::make_pair(Opcode, ScalarTy)] = Action;
141 std::tuple<LegalizeAction, unsigned, LLT>
153 auto ActionIt = Map.
find(Ty);
154 if (ActionIt == Map.
end())
155 Action = DefaultActions.
find(Aspect.
Opcode)->second;
157 Action = ActionIt->second;
158 }
while(Action !=
Legal);
168 return std::make_pair(Action,
findLegalType(Aspect, Action));
177 if (Aspect.
Idx >= Actions[Aspect.
Opcode - FirstOp].size())
180 auto ActionIt = Map.
find(Aspect.
Type);
181 if (ActionIt == Map.
end())
184 return ActionIt->second;
190 static const int FirstOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_START;
191 static const int LastOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
197 SIVActionMap ScalarInVectorActions;
201 bool TablesInitialized;
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.
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.
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...
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.
LLT findLegalType(const InstrAspect &Aspect, std::function< LLT(LLT)> NextType) const
Iterate the given function (typically something like doubling the width) on Ty until we find a legal ...
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.
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.
iterator find(const KeyT &Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This operation is completely unsupported on the target.
print Print MemDeps of function
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.