16 #include "llvm/IR/IntrinsicsMips.h" 29 std::initializer_list<TypesAndMemOps> SupportedValues) {
30 for (
auto &Val : SupportedValues) {
31 if (Val.ValTy != Query.
Types[0])
33 if (Val.PtrTy != Query.
Types[1])
35 if (Val.MemSize != Query.
MMODescrs[0].SizeInBits)
37 if (Val.MustBeNaturallyAligned &&
46 std::initializer_list<LLT> SupportedValues) {
47 for (
auto &Val : SupportedValues)
48 if (Val == Query.
Types[N])
54 using namespace TargetOpcode;
65 getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL})
69 if (ST.
hasMSA() &&
CheckTyN(0, Query, {v16s8, v8s16, v4s32, v2s64}))
73 .clampScalar(0, s32, s32);
75 getActionDefinitionsBuilder({G_UADDO, G_UADDE, G_USUBO, G_USUBE, G_UMULO})
76 .lowerFor({{s32, s1}});
78 getActionDefinitionsBuilder(G_UMULH)
82 getActionDefinitionsBuilder({G_LOAD, G_STORE})
92 {v8s16, p0, 128,
false},
93 {v4s32, p0, 128,
false},
94 {v2s64, p0, 128,
false}}))
100 getActionDefinitionsBuilder(G_IMPLICIT_DEF)
101 .legalFor({s32, s64});
103 getActionDefinitionsBuilder(G_UNMERGE_VALUES)
104 .legalFor({{s32, s64}});
106 getActionDefinitionsBuilder(G_MERGE_VALUES)
107 .legalFor({{s64, s32}});
109 getActionDefinitionsBuilder({G_ZEXTLOAD, G_SEXTLOAD})
110 .legalForTypesWithMemDesc({{s32, p0, 8, 8},
112 .clampScalar(0, s32, s32);
114 getActionDefinitionsBuilder({G_ZEXT, G_SEXT})
118 getActionDefinitionsBuilder(G_TRUNC)
122 getActionDefinitionsBuilder(G_SELECT)
123 .legalForCartesianProduct({p0, s32, s64}, {s32})
127 getActionDefinitionsBuilder(G_BRCOND)
131 getActionDefinitionsBuilder(G_BRJT)
132 .legalFor({{p0, s32}});
134 getActionDefinitionsBuilder(G_BRINDIRECT)
137 getActionDefinitionsBuilder(G_PHI)
138 .legalFor({p0, s32, s64})
141 getActionDefinitionsBuilder({G_AND, G_OR, G_XOR})
143 .clampScalar(0, s32, s32);
145 getActionDefinitionsBuilder({G_SDIV, G_SREM, G_UDIV, G_UREM})
149 if (ST.
hasMSA() &&
CheckTyN(0, Query, {v16s8, v8s16, v4s32, v2s64}))
156 getActionDefinitionsBuilder({G_SHL, G_ASHR, G_LSHR})
157 .legalFor({{s32, s32}})
158 .clampScalar(1, s32, s32)
159 .clampScalar(0, s32, s32);
161 getActionDefinitionsBuilder(G_ICMP)
162 .legalForCartesianProduct({s32}, {s32, p0})
163 .clampScalar(1, s32, s32)
166 getActionDefinitionsBuilder(G_CONSTANT)
168 .clampScalar(0, s32, s32);
170 getActionDefinitionsBuilder({G_PTR_ADD, G_INTTOPTR})
171 .legalFor({{p0, s32}});
173 getActionDefinitionsBuilder(G_PTRTOINT)
174 .legalFor({{s32, p0}});
176 getActionDefinitionsBuilder(G_FRAME_INDEX)
179 getActionDefinitionsBuilder({G_GLOBAL_VALUE, G_JUMP_TABLE})
182 getActionDefinitionsBuilder(G_DYN_STACKALLOC)
183 .lowerFor({{p0, s32}});
185 getActionDefinitionsBuilder(G_VASTART)
188 getActionDefinitionsBuilder(G_BSWAP)
201 getActionDefinitionsBuilder(G_BITREVERSE)
206 getActionDefinitionsBuilder(G_FCONSTANT)
207 .legalFor({s32, s64});
209 getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FABS, G_FSQRT})
213 if (ST.
hasMSA() &&
CheckTyN(0, Query, {v16s8, v8s16, v4s32, v2s64}))
218 getActionDefinitionsBuilder(G_FCMP)
219 .legalFor({{s32, s32}, {s32, s64}})
222 getActionDefinitionsBuilder({G_FCEIL, G_FFLOOR})
223 .libcallFor({s32, s64});
225 getActionDefinitionsBuilder(G_FPEXT)
226 .legalFor({{s64, s32}});
228 getActionDefinitionsBuilder(G_FPTRUNC)
229 .legalFor({{s32, s64}});
232 getActionDefinitionsBuilder(G_FPTOSI)
233 .legalForCartesianProduct({s32}, {s64, s32})
234 .libcallForCartesianProduct({s64}, {s64, s32})
237 getActionDefinitionsBuilder(G_FPTOUI)
238 .libcallForCartesianProduct({s64}, {s64, s32})
239 .lowerForCartesianProduct({s32}, {s64, s32})
243 getActionDefinitionsBuilder(G_SITOFP)
244 .legalForCartesianProduct({s64, s32}, {s32})
245 .libcallForCartesianProduct({s64, s32}, {s64})
248 getActionDefinitionsBuilder(G_UITOFP)
249 .libcallForCartesianProduct({s64, s32}, {s64})
250 .customForCartesianProduct({s64, s32}, {s32})
253 getActionDefinitionsBuilder(G_SEXT_INREG).lower();
264 using namespace TargetOpcode;
281 if (DstTy != s32 && DstTy != s64)
301 MIRBuilder.
buildFSub(Dst, Bitcast, TwoP52FP);
320 assert(ST.
hasMSA() &&
"MSA intrinsic not supported on target without MSA.");
335 assert(ST.
hasMSA() &&
"MSA intrinsic not supported on target without MSA.");
347 assert(ST.
hasMSA() &&
"MSA intrinsic not supported on target without MSA.");
366 case Intrinsic::memcpy:
367 case Intrinsic::memset:
368 case Intrinsic::memmove:
374 case Intrinsic::trap: {
379 case Intrinsic::vacopy: {
391 case Intrinsic::mips_addv_b:
392 case Intrinsic::mips_addv_h:
393 case Intrinsic::mips_addv_w:
394 case Intrinsic::mips_addv_d:
396 case Intrinsic::mips_addvi_b:
398 case Intrinsic::mips_addvi_h:
400 case Intrinsic::mips_addvi_w:
402 case Intrinsic::mips_addvi_d:
404 case Intrinsic::mips_subv_b:
405 case Intrinsic::mips_subv_h:
406 case Intrinsic::mips_subv_w:
407 case Intrinsic::mips_subv_d:
409 case Intrinsic::mips_subvi_b:
411 case Intrinsic::mips_subvi_h:
413 case Intrinsic::mips_subvi_w:
415 case Intrinsic::mips_subvi_d:
417 case Intrinsic::mips_mulv_b:
418 case Intrinsic::mips_mulv_h:
419 case Intrinsic::mips_mulv_w:
420 case Intrinsic::mips_mulv_d:
422 case Intrinsic::mips_div_s_b:
423 case Intrinsic::mips_div_s_h:
424 case Intrinsic::mips_div_s_w:
425 case Intrinsic::mips_div_s_d:
427 case Intrinsic::mips_mod_s_b:
428 case Intrinsic::mips_mod_s_h:
429 case Intrinsic::mips_mod_s_w:
430 case Intrinsic::mips_mod_s_d:
432 case Intrinsic::mips_div_u_b:
433 case Intrinsic::mips_div_u_h:
434 case Intrinsic::mips_div_u_w:
435 case Intrinsic::mips_div_u_d:
437 case Intrinsic::mips_mod_u_b:
438 case Intrinsic::mips_mod_u_h:
439 case Intrinsic::mips_mod_u_w:
440 case Intrinsic::mips_mod_u_d:
442 case Intrinsic::mips_fadd_w:
443 case Intrinsic::mips_fadd_d:
445 case Intrinsic::mips_fsub_w:
446 case Intrinsic::mips_fsub_d:
448 case Intrinsic::mips_fmul_w:
449 case Intrinsic::mips_fmul_d:
451 case Intrinsic::mips_fdiv_w:
452 case Intrinsic::mips_fdiv_d:
454 case Intrinsic::mips_fmax_a_w:
456 case Intrinsic::mips_fmax_a_d:
458 case Intrinsic::mips_fsqrt_w:
460 case Intrinsic::mips_fsqrt_d:
const RegisterBankInfo * getRegBankInfo() const override
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
const MachineInstrBuilder & add(const MachineOperand &MO) const
static LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
This class represents lattice values for constants.
MipsLegalizerInfo(const MipsSubtarget &ST)
The LegalityQuery object bundles together all the information that's needed to decide whether a given...
const MipsInstrInfo * getInstrInfo() const override
This file declares the targeting of the Machinelegalizer class for Mips.
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
unsigned const TargetRegisterInfo * TRI
bool legalizeIntrinsic(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder) const override
Return true if MI is either legal or has been legalized and false if not legal.
MachineInstrBuilder buildFPTrunc(const DstOp &Res, const SrcOp &Op, Optional< unsigned > FLags=None)
Build and insert Res = G_FPTRUNC Op.
Holds all the information related to register banks.
const HexagonInstrInfo * TII
static bool MSA2OpIntrinsicToGeneric(MachineInstr &MI, unsigned Opcode, MachineIRBuilder &MIRBuilder, const MipsSubtarget &ST)
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineInstrBuilder buildFSub(const DstOp &Dst, const SrcOp &Src0, const SrcOp &Src1)
Build and insert Res = G_FSUB Op0, Op1.
MachineFunction & getMF()
Getter for the function we currently build.
static bool CheckTyN(unsigned N, const LegalityQuery &Query, std::initializer_list< LLT > SupportedValues)
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Abstract class that contains various methods for clients to notify about changes. ...
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
Helper class to build MachineInstr.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
TRAP - Trapping instruction.
LegalizerHelper::LegalizeResult createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstr &MI)
Create a libcall to memcpy et al.
Some kind of error has occurred and we could not legalize this instruction.
This class contains a discriminated union of information about pointers in memory operands...
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
The memory access writes data.
MachineInstrBuilder buildLoad(const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
virtual MachineInstrBuilder buildFConstant(const DstOp &Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
const MipsRegisterInfo * getRegisterInfo() const override
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
static bool SelectMSA3OpIntrinsic(MachineInstr &MI, unsigned Opcode, MachineIRBuilder &MIRBuilder, const MipsSubtarget &ST)
const TargetInstrInfo & getTII()
bool constrainSelectedInstRegOperands(MachineInstr &I, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
Mutate the newly-selected instruction I to constrain its (possibly generic) virtual register operands...
double BitsToDouble(uint64_t Bits)
This function takes a 64-bit integer and returns the bit equivalent double.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
bool MustBeNaturallyAligned
Representation of each machine instruction.
bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder, GISelChangeObserver &Observer) const override
MachineInstrBuilder buildStore(const SrcOp &Val, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
static bool MSA3OpIntrinsicToGeneric(MachineInstr &MI, unsigned Opcode, MachineIRBuilder &MIRBuilder, const MipsSubtarget &ST)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getIntrinsicID() const
Returns the Intrinsic::ID for this instruction.
static bool CheckTy0Ty1MemSizeAlign(const LegalityQuery &Query, std::initializer_list< TypesAndMemOps > SupportedValues)
static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
Register getReg() const
getReg - Returns the register number.
ArrayRef< MemDesc > MMODescrs
Operations which require memory can use this to place requirements on the memory type for each MMO...
const MachineOperand & getOperand(unsigned i) const
bool constrainAllUses(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI) const
Wrapper class representing virtual and physical registers.