40 for (
unsigned i = 0; i < v.size(); ++i) {
41 result.push_back(v[i]);
42 if (i + 1 < v[i].
first && i + 1 < v.size() &&
43 v[i + 1].first != v[i].first + 1)
44 result.push_back({v[i].first + 1, Unsupported});
58 auto Largest = result.back().first;
68 using namespace TargetOpcode;
78 getActionDefinitionsBuilder(G_GLOBAL_VALUE).legalFor({p0});
79 getActionDefinitionsBuilder(G_FRAME_INDEX).legalFor({p0});
81 getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
86 getActionDefinitionsBuilder({G_SDIV, G_UDIV})
88 .clampScalar(0, s32, s32);
90 getActionDefinitionsBuilder({G_SDIV, G_UDIV})
92 .clampScalar(0, s32, s32);
94 for (
unsigned Op : {G_SREM, G_UREM}) {
95 setLegalizeScalarToDifferentSizeStrategy(
Op, 0,
widen_8_16);
104 getActionDefinitionsBuilder({G_SEXT, G_ZEXT, G_ANYEXT})
105 .legalForCartesianProduct({s32}, {s1, s8, s16});
107 getActionDefinitionsBuilder(G_INTTOPTR).legalFor({{p0, s32}});
108 getActionDefinitionsBuilder(G_PTRTOINT).legalFor({{s32, p0}});
110 getActionDefinitionsBuilder({G_ASHR, G_LSHR, G_SHL}).legalFor({s32});
112 getActionDefinitionsBuilder(G_GEP).legalFor({{p0, s32}});
114 getActionDefinitionsBuilder(G_SELECT).legalForCartesianProduct({s32, p0},
117 getActionDefinitionsBuilder(G_BRCOND).legalFor({s1});
119 getActionDefinitionsBuilder(G_CONSTANT)
121 .clampScalar(0, s32, s32);
123 getActionDefinitionsBuilder(G_ICMP)
124 .legalForCartesianProduct({s1}, {s32, p0})
129 auto &LoadStoreBuilder =
130 getActionDefinitionsBuilder({G_LOAD, G_STORE})
131 .legalForCartesianProduct({s1, s8, s16, s32, p0}, {p0});
134 getActionDefinitionsBuilder(G_PHI).legalFor({s32, p0}).minScalar(0, s32);
137 getActionDefinitionsBuilder(
138 {G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FCONSTANT, G_FNEG})
139 .legalFor({s32, s64});
141 LoadStoreBuilder.legalFor({{s64, p0}});
142 PhiBuilder.legalFor({s64});
144 getActionDefinitionsBuilder(G_FCMP).legalForCartesianProduct({s1},
147 getActionDefinitionsBuilder(G_MERGE_VALUES).legalFor({{s64, s32}});
148 getActionDefinitionsBuilder(G_UNMERGE_VALUES).legalFor({{s32, s64}});
150 getActionDefinitionsBuilder(G_FPEXT).legalFor({{s64, s32}});
151 getActionDefinitionsBuilder(G_FPTRUNC).legalFor({{s32, s64}});
153 getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
154 .legalForCartesianProduct({s32}, {s32, s64});
155 getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
156 .legalForCartesianProduct({s32, s64}, {s32});
158 getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV})
159 .libcallFor({s32, s64});
161 LoadStoreBuilder.maxScalar(0, s32);
163 for (
auto Ty : {s32, s64})
164 setAction({G_FNEG, Ty},
Lower);
166 getActionDefinitionsBuilder(G_FCONSTANT).customFor({s32, s64});
168 getActionDefinitionsBuilder(G_FCMP).customForCartesianProduct({s1},
172 setFCmpLibcallsAEABI();
174 setFCmpLibcallsGNU();
176 getActionDefinitionsBuilder(G_FPEXT).libcallFor({{s64, s32}});
177 getActionDefinitionsBuilder(G_FPTRUNC).libcallFor({{s32, s64}});
179 getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
180 .libcallForCartesianProduct({s32}, {s32, s64});
181 getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
182 .libcallForCartesianProduct({s32, s64}, {s32});
186 getActionDefinitionsBuilder(G_FMA).legalFor({s32, s64});
188 getActionDefinitionsBuilder(G_FMA).libcallFor({s32, s64});
190 getActionDefinitionsBuilder({G_FREM, G_FPOW}).libcallFor({s32, s64});
196 void ARMLegalizerInfo::setFCmpLibcallsAEABI() {
203 {RTLIB::OGE_F32, CmpInst::BAD_ICMP_PREDICATE}};
205 {RTLIB::OGT_F32, CmpInst::BAD_ICMP_PREDICATE}};
207 {RTLIB::OLE_F32, CmpInst::BAD_ICMP_PREDICATE}};
209 {RTLIB::OLT_F32, CmpInst::BAD_ICMP_PREDICATE}};
217 {RTLIB::UO_F32, CmpInst::BAD_ICMP_PREDICATE}};
219 {RTLIB::OGT_F32, CmpInst::BAD_ICMP_PREDICATE},
220 {RTLIB::OLT_F32, CmpInst::BAD_ICMP_PREDICATE}};
222 {RTLIB::OEQ_F32, CmpInst::BAD_ICMP_PREDICATE},
223 {RTLIB::UO_F32, CmpInst::BAD_ICMP_PREDICATE}};
227 {RTLIB::OEQ_F64, CmpInst::BAD_ICMP_PREDICATE}};
229 {RTLIB::OGE_F64, CmpInst::BAD_ICMP_PREDICATE}};
231 {RTLIB::OGT_F64, CmpInst::BAD_ICMP_PREDICATE}};
233 {RTLIB::OLE_F64, CmpInst::BAD_ICMP_PREDICATE}};
235 {RTLIB::OLT_F64, CmpInst::BAD_ICMP_PREDICATE}};
243 {RTLIB::UO_F64, CmpInst::BAD_ICMP_PREDICATE}};
245 {RTLIB::OGT_F64, CmpInst::BAD_ICMP_PREDICATE},
246 {RTLIB::OLT_F64, CmpInst::BAD_ICMP_PREDICATE}};
248 {RTLIB::OEQ_F64, CmpInst::BAD_ICMP_PREDICATE},
249 {RTLIB::UO_F64, CmpInst::BAD_ICMP_PREDICATE}};
252 void ARMLegalizerInfo::setFCmpLibcallsGNU() {
269 {RTLIB::OLT_F32, CmpInst::ICMP_SLT}};
271 {RTLIB::UO_F32, CmpInst::ICMP_NE}};
287 {RTLIB::OLT_F64, CmpInst::ICMP_SLT}};
289 {RTLIB::UO_F64, CmpInst::ICMP_NE}};
294 unsigned Size)
const {
306 using namespace TargetOpcode;
322 MI.
getOpcode() == G_SREM ? RTLIB::SDIVREM_I32 : RTLIB::UDIVREM_I32;
348 "Mismatched operands for G_FCMP");
354 auto Libcalls = getFCmpLibcalls(
Predicate, OpSize);
356 if (Libcalls.empty()) {
359 "Predicate needs libcalls, but none specified");
366 assert((OpSize == 32 || OpSize == 64) &&
"Unsupported operand size");
371 for (
auto Libcall : Libcalls) {
375 {{MI.getOperand(2).getReg(), ArgTy},
376 {MI.getOperand(3).getReg(), ArgTy}});
381 auto ProcessedResult =
393 MIRBuilder.
buildTrunc(ProcessedResult, LibcallResult);
399 MIRBuilder.
buildICmp(ResultPred, ProcessedResult, LibcallResult, Zero);
420 MI.eraseFromParent();
bool isFPPredicate() const
MachineInstrBuilder buildOr(unsigned Dst, unsigned Src0, unsigned Src1)
Build and insert Res = G_OR Op0, Op1.
void push_back(const T &Elt)
bool isTargetGNUAEABI() const
static Type * getDoubleTy(LLVMContext &C)
Compute iterated dominance frontiers using a linear time algorithm.
The operation should be implemented in terms of a wider scalar base-type.
unsigned getReg() const
getReg - Returns the register number.
static bool AEABI(const ARMSubtarget &ST)
MachineInstrBuilder buildUnmerge(ArrayRef< unsigned > Res, unsigned Op)
Build and insert Res0, ...
std::vector< SizeAndAction > SizeAndActionsVec
0 1 0 0 True if ordered and less than
Function Alias Analysis Results
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
1 1 1 0 True if unordered or not equal
bool isTargetMuslAEABI() const
const ARMBaseInstrInfo * getInstrInfo() const override
1 0 0 1 True if unordered or equal
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static Type * getFloatTy(LLVMContext &C)
const ConstantFP * getFPImm() const
Class to represent struct types.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
0 1 0 1 True if ordered and less than or equal
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
This operation is completely unsupported on the target.
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
LegalizerHelper::LegalizeResult createLibcall(MachineIRBuilder &MIRBuilder, RTLIB::Libcall Libcall, const CallLowering::ArgInfo &Result, ArrayRef< CallLowering::ArgInfo > Args)
Helper function that creates the given libcall.
bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder) const override
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
The operation itself must be expressed in terms of simpler actions on this target.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
static LegalizerInfo::SizeAndActionsVec widen_8_16(const LegalizerInfo::SizeAndActionsVec &v)
bool hasDivideInARMMode() const
unsigned const MachineRegisterInfo * MRI
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
This file declares the targeting of the Machinelegalizer class for ARM.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
ARMLegalizerInfo(const ARMSubtarget &ST)
0 1 1 1 True if ordered (no nans)
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
1 1 1 1 Always true (always folded)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
1 1 0 1 True if unordered, less than, or equal
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
LLT getLLTForType(Type &Ty, const DataLayout &DL)
Construct a low-level type based on an LLVM type.
const APFloat & getValueAPF() const
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
0 0 1 0 True if ordered and greater than
bool useSoftFloat() const
bool isTargetAEABI() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
1 1 0 0 True if unordered or less than
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
The operation should be implemented as a call to some kind of runtime support library.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
The target wants to do something special with this combination of operand and type.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
MachineInstrBuilder buildTrunc(unsigned Res, unsigned Op)
Build and insert Res = G_TRUNC Op.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool isIntPredicate() const
MachineInstrBuilder buildConstant(unsigned Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
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.
Instruction has been legalized and the MachineFunction changed.
static IntegerType * getInt32Ty(LLVMContext &C)
0 1 1 0 True if ordered and operands are unequal
static void addAndInterleaveWithUnsupported(LegalizerInfo::SizeAndActionsVec &result, const LegalizerInfo::SizeAndActionsVec &v)
FIXME: The following static functions are SizeChangeStrategy functions that are meant to temporarily ...
MachineFunction & getMF()
Getter for the function we currently build.
1 0 1 0 True if unordered or greater than
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
0 0 0 1 True if ordered and equal
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
1 0 1 1 True if unordered, greater than, or equal
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
APInt bitcastToAPInt() const
This file describes how to lower LLVM calls to machine code calls.
const MachineOperand & getOperand(unsigned i) const
0 0 1 1 True if ordered and greater than or equal
MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_ICMP Pred, Op0, Op1.
0 0 0 0 Always false (always folded)
unsigned getPredicate() const