30#define DEBUG_TYPE "mips-isel"
31#define PASS_NAME "MIPS DAG->DAG Pattern Instruction Selection"
53 processFunctionAfterISel(
MF);
148 unsigned MinSizeInBits)
const {
154 unsigned ImmBitSize)
const {
178bool MipsDAGToDAGISel::selectVSplatImmEq1(
SDValue N)
const {
185bool MipsDAGToDAGISel::selectVecAddAsVecSubIfProfitable(
SDNode *Node) {
188 EVT VT =
Node->getValueType(0);
198 APInt SplatValue, SplatUndef;
199 unsigned SplatBitSize;
202 if (!BVN->isConstantSplat(SplatValue, SplatUndef, SplatBitSize, HasAnyUndefs,
206 auto IsInlineConstant = [](
const APInt &
Imm) {
return Imm.isIntN(5); };
208 if (IsInlineConstant(SplatValue))
211 APInt NegSplatValue = 0 - SplatValue;
212 if (!IsInlineConstant(NegSplatValue))
219 assert(NegC &&
"Constant-folding failed!");
239 bool MadeChange =
false;
251 (
BaseReg->getReg() != Mips::GP &&
BaseReg->getReg() != Mips::GP_64) ||
257 if (TrueValue.
getOpcode() != MipsISD::GPRel &&
258 FalseValue.
getOpcode() != MipsISD::GPRel)
262 EVT VT =
Node.getValueType(0);
268 CurDAG->ReplaceAllUsesOfValueWith(
SDValue(&Node, 0), NewSel);
273 CurDAG->RemoveDeadNodes();
278void MipsDAGToDAGISel::Select(
SDNode *Node) {
279 unsigned Opcode =
Node->getOpcode();
282 if (
Node->isMachineOpcode()) {
296 if (
Node->getSimpleValueType(0).isVector() &&
297 selectVecAddAsVecSubIfProfitable(Node))
312 "Unexpected unaligned loads/stores.");
321bool MipsDAGToDAGISel::SelectInlineAsmMemoryOperand(
323 std::vector<SDValue> &OutOps) {
325 switch(ConstraintID) {
331 OutOps.push_back(
Op);
337bool MipsDAGToDAGISel::isUnneededShiftMask(
SDNode *
N,
338 unsigned ShAmtBits)
const {
341 const APInt &
RHS =
N->getConstantOperandAPInt(1);
342 if (
RHS.countr_one() >= ShAmtBits) {
346 <<
" Need optimize 'and & shl/srl/sra' and operand value bits is "
347 <<
RHS.countr_one() <<
"\n");
351 KnownBits
Known =
CurDAG->computeKnownBits(
N->getOperand(0));
352 return (
Known.Zero |
RHS).countr_one() >= ShAmtBits;
358 std::unique_ptr<SelectionDAGISel> S)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Class for arbitrary precision integers.
Represent the analysis usage information of a pass.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MipsDAGToDAGISelLegacy(std::unique_ptr< SelectionDAGISel > S)
bool runOnMachineFunction(MachineFunction &MF) override
const MipsSubtarget * Subtarget
Keep a pointer to the MipsSubtarget around so that we can make the right decision when generating cod...
SDNode * getGlobalBaseReg()
getGlobalBaseReg - Output the instructions required to put the GOT address into a register.
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
Wrapper class representing virtual and physical registers.
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
SelectionDAGISelLegacy(char &ID, std::unique_ptr< SelectionDAGISel > S)
virtual void PreprocessISelDAG()
PreprocessISelDAG - This hook allows targets to hack on the graph before instruction selection starts...
void ReplaceNode(SDNode *F, SDNode *T)
Replace all uses of F with T, then remove F from the DAG.
virtual bool runOnMachineFunction(MachineFunction &mf)
const TargetLowering * getTargetLowering() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ GLOBAL_OFFSET_TABLE
The address of the GOT.
@ AND
Bitwise operators - logical and, logical or, logical xor.
NodeAddr< NodeBase * > Node
BaseReg
Stack frame base register. Bit 0 of FREInfo.Info.
This is an optimization pass for GlobalISel generic memory operations.
@ Known
Known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
DWARFExpression::Operation Op
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool isVector() const
Return true if this is a vector value type.