2012-02-17 08:55:11 +00:00
|
|
|
//===-- MipsISelDAGToDAG.cpp - A Dag to Dag Inst Selector for Mips --------===//
|
2007-06-06 07:42:06 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-06-06 07:42:06 +00:00
|
|
|
//
|
2011-04-15 21:51:11 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 07:42:06 +00:00
|
|
|
//
|
|
|
|
// This file defines an instruction selector for the MIPS target.
|
|
|
|
//
|
2011-04-15 21:51:11 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 07:42:06 +00:00
|
|
|
|
2013-03-14 18:27:31 +00:00
|
|
|
#include "MipsISelDAGToDAG.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "MCTargetDesc/MipsBaseInfo.h"
|
2014-01-07 11:48:04 +00:00
|
|
|
#include "Mips.h"
|
|
|
|
#include "Mips16ISelDAGToDAG.h"
|
2007-11-05 03:02:32 +00:00
|
|
|
#include "MipsMachineFunction.h"
|
2007-06-06 07:42:06 +00:00
|
|
|
#include "MipsRegisterInfo.h"
|
2014-01-07 11:48:04 +00:00
|
|
|
#include "MipsSEISelDAGToDAG.h"
|
2007-06-06 07:42:06 +00:00
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2007-06-06 07:42:06 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2007-12-31 04:13:23 +00:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2012-02-28 02:55:02 +00:00
|
|
|
#include "llvm/CodeGen/SelectionDAGNodes.h"
|
2014-03-04 11:45:46 +00:00
|
|
|
#include "llvm/IR/CFG.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/GlobalValue.h"
|
|
|
|
#include "llvm/IR/Instructions.h"
|
|
|
|
#include "llvm/IR/Intrinsics.h"
|
|
|
|
#include "llvm/IR/Type.h"
|
2007-06-06 07:42:06 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2009-07-08 20:53:28 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2007-06-06 07:42:06 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 02:41:26 +00:00
|
|
|
#define DEBUG_TYPE "mips-isel"
|
|
|
|
|
2011-04-15 21:51:11 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 07:42:06 +00:00
|
|
|
// Instruction Selector Implementation
|
2011-04-15 21:51:11 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 07:42:06 +00:00
|
|
|
|
2011-04-15 21:51:11 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 07:42:06 +00:00
|
|
|
// MipsDAGToDAGISel - MIPS specific code to select MIPS machine
|
|
|
|
// instructions for SelectionDAG operations.
|
2011-04-15 21:51:11 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2012-03-08 01:51:59 +00:00
|
|
|
|
2012-02-24 22:34:47 +00:00
|
|
|
bool MipsDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
|
2015-01-29 23:27:36 +00:00
|
|
|
Subtarget = &static_cast<const MipsSubtarget &>(MF.getSubtarget());
|
2012-02-24 22:34:47 +00:00
|
|
|
bool Ret = SelectionDAGISel::runOnMachineFunction(MF);
|
2012-02-28 07:46:26 +00:00
|
|
|
|
2013-03-14 18:33:23 +00:00
|
|
|
processFunctionAfterISel(MF);
|
2012-02-24 22:34:47 +00:00
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
2007-06-06 07:42:06 +00:00
|
|
|
|
2007-11-12 19:49:57 +00:00
|
|
|
/// getGlobalBaseReg - Output the instructions required to put the
|
|
|
|
/// GOT address into a register.
|
2009-06-03 20:30:14 +00:00
|
|
|
SDNode *MipsDAGToDAGISel::getGlobalBaseReg() {
|
2012-02-24 22:34:47 +00:00
|
|
|
unsigned GlobalBaseReg = MF->getInfo<MipsFunctionInfo>()->getGlobalBaseReg();
|
2015-07-09 02:09:04 +00:00
|
|
|
return CurDAG->getRegister(GlobalBaseReg, getTargetLowering()->getPointerTy(
|
|
|
|
CurDAG->getDataLayout()))
|
|
|
|
.getNode();
|
2007-11-12 19:49:57 +00:00
|
|
|
}
|
|
|
|
|
2007-06-06 07:42:06 +00:00
|
|
|
/// ComplexPattern used on MipsInstrInfo
|
|
|
|
/// Used on Mips Load/Store instructions
|
2013-02-16 00:14:37 +00:00
|
|
|
bool MipsDAGToDAGISel::selectAddrRegImm(SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset) const {
|
2013-03-14 18:27:31 +00:00
|
|
|
llvm_unreachable("Unimplemented function.");
|
2013-02-15 21:20:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-28 12:04:29 +00:00
|
|
|
bool MipsDAGToDAGISel::selectAddrRegReg(SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-16 00:14:37 +00:00
|
|
|
bool MipsDAGToDAGISel::selectAddrDefault(SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset) const {
|
2013-03-14 18:27:31 +00:00
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
2007-06-06 07:42:06 +00:00
|
|
|
}
|
|
|
|
|
2013-02-16 00:14:37 +00:00
|
|
|
bool MipsDAGToDAGISel::selectIntAddr(SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset) const {
|
2013-03-14 18:27:31 +00:00
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
2012-10-28 06:02:37 +00:00
|
|
|
}
|
|
|
|
|
2013-08-13 20:19:16 +00:00
|
|
|
bool MipsDAGToDAGISel::selectIntAddrMM(SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-04 15:43:17 +00:00
|
|
|
bool MipsDAGToDAGISel::selectIntAddrLSL2MM(SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-03 14:31:21 +00:00
|
|
|
bool MipsDAGToDAGISel::selectIntAddrMSA(SDValue Addr, SDValue &Base,
|
|
|
|
SDValue &Offset) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-14 18:33:23 +00:00
|
|
|
bool MipsDAGToDAGISel::selectAddr16(SDNode *Parent, SDValue N, SDValue &Base,
|
2013-03-14 18:27:31 +00:00
|
|
|
SDValue &Offset, SDValue &Alias) {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
2011-12-20 23:10:57 +00:00
|
|
|
}
|
|
|
|
|
[mips] Correct and improve special-case shuffle instructions.
Summary:
The documentation writes vectors highest-index first whereas LLVM-IR writes
them lowest-index first. As a result, instructions defined in terms of
left_half() and right_half() had the halves reversed.
In addition to correcting them, they have been improved to allow shuffles
that use the same operand twice or in reverse order. For example, ilvev
used to accept masks of the form:
<0, n, 2, n+2, 4, n+4, ...>
but now accepts:
<0, 0, 2, 2, 4, 4, ...>
<n, n, n+2, n+2, n+4, n+4, ...>
<0, n, 2, n+2, 4, n+4, ...>
<n, 0, n+2, 2, n+4, 4, ...>
One further improvement is that splati.[bhwd] is now the preferred instruction
for splat-like operations. The other special shuffles are no longer used
for splats. This lead to the discovery that <0, 0, ...> would not cause
splati.[hwd] to be selected and this has also been fixed.
This fixes the enc-3des test from the test-suite on Mips64r6 with MSA.
Reviewers: vkalintiris
Reviewed By: vkalintiris
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9660
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237689 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-19 12:24:52 +00:00
|
|
|
bool MipsDAGToDAGISel::selectVSplat(SDNode *N, APInt &Imm,
|
|
|
|
unsigned MinSizeInBits) const {
|
2013-09-24 13:33:07 +00:00
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-27 11:48:57 +00:00
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimm1(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimm2(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-24 13:33:07 +00:00
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimm3(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimm4(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimm5(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimm6(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimm8(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsDAGToDAGISel::selectVSplatSimm5(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimmPow2(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-12 10:45:18 +00:00
|
|
|
bool MipsDAGToDAGISel::selectVSplatUimmInvPow2(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-30 14:45:14 +00:00
|
|
|
bool MipsDAGToDAGISel::selectVSplatMaskL(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsDAGToDAGISel::selectVSplatMaskR(SDValue N, SDValue &Imm) const {
|
|
|
|
llvm_unreachable("Unimplemented function.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-06-06 07:42:06 +00:00
|
|
|
/// Select instructions not customized! Used for
|
|
|
|
/// expanded, promoted and normal instructions
|
2010-01-05 01:24:18 +00:00
|
|
|
SDNode* MipsDAGToDAGISel::Select(SDNode *Node) {
|
2007-06-06 07:42:06 +00:00
|
|
|
unsigned Opcode = Node->getOpcode();
|
|
|
|
|
|
|
|
// Dump information about the Node being selected
|
2010-03-02 06:34:30 +00:00
|
|
|
DEBUG(errs() << "Selecting: "; Node->dump(CurDAG); errs() << "\n");
|
2007-06-06 07:42:06 +00:00
|
|
|
|
|
|
|
// If we have a custom node, we already have selected!
|
2008-07-17 19:10:17 +00:00
|
|
|
if (Node->isMachineOpcode()) {
|
2010-03-02 06:34:30 +00:00
|
|
|
DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n");
|
2013-09-22 08:21:56 +00:00
|
|
|
Node->setNodeId(-1);
|
2014-04-25 05:30:21 +00:00
|
|
|
return nullptr;
|
2007-06-06 07:42:06 +00:00
|
|
|
}
|
|
|
|
|
2013-03-14 18:27:31 +00:00
|
|
|
// See if subclasses can handle this node.
|
2013-03-14 18:33:23 +00:00
|
|
|
std::pair<bool, SDNode*> Ret = selectNode(Node);
|
2013-03-14 18:27:31 +00:00
|
|
|
|
|
|
|
if (Ret.first)
|
|
|
|
return Ret.second;
|
2011-12-20 23:10:57 +00:00
|
|
|
|
2007-06-06 07:42:06 +00:00
|
|
|
switch(Opcode) {
|
2011-12-20 22:58:01 +00:00
|
|
|
default: break;
|
|
|
|
|
|
|
|
// Get target GOT address.
|
|
|
|
case ISD::GLOBAL_OFFSET_TABLE:
|
|
|
|
return getGlobalBaseReg();
|
2011-12-20 22:25:50 +00:00
|
|
|
|
2012-09-15 01:52:08 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
case ISD::LOAD:
|
|
|
|
case ISD::STORE:
|
2014-07-10 17:26:51 +00:00
|
|
|
assert((Subtarget->systemSupportsUnalignedAccess() ||
|
2014-05-23 13:18:02 +00:00
|
|
|
cast<MemSDNode>(Node)->getMemoryVT().getSizeInBits() / 8 <=
|
|
|
|
cast<MemSDNode>(Node)->getAlignment()) &&
|
2012-09-15 01:52:08 +00:00
|
|
|
"Unexpected unaligned loads/stores.");
|
|
|
|
break;
|
|
|
|
#endif
|
2007-06-06 07:42:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Select the default instruction
|
2010-01-05 01:24:18 +00:00
|
|
|
SDNode *ResNode = SelectCode(Node);
|
2007-06-06 07:42:06 +00:00
|
|
|
|
2010-03-02 06:34:30 +00:00
|
|
|
DEBUG(errs() << "=> ");
|
2014-04-25 05:30:21 +00:00
|
|
|
if (ResNode == nullptr || ResNode == Node)
|
2010-01-05 01:24:18 +00:00
|
|
|
DEBUG(Node->dump(CurDAG));
|
2007-06-06 07:42:06 +00:00
|
|
|
else
|
|
|
|
DEBUG(ResNode->dump(CurDAG));
|
2009-08-23 06:49:22 +00:00
|
|
|
DEBUG(errs() << "\n");
|
2007-06-06 07:42:06 +00:00
|
|
|
return ResNode;
|
|
|
|
}
|
|
|
|
|
2011-06-21 00:40:49 +00:00
|
|
|
bool MipsDAGToDAGISel::
|
2015-03-13 12:45:09 +00:00
|
|
|
SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID,
|
2011-06-21 00:40:49 +00:00
|
|
|
std::vector<SDValue> &OutOps) {
|
2015-03-24 11:26:34 +00:00
|
|
|
// All memory constraints can at least accept raw pointers.
|
|
|
|
switch(ConstraintID) {
|
|
|
|
default:
|
|
|
|
llvm_unreachable("Unexpected asm memory constraint");
|
|
|
|
case InlineAsm::Constraint_i:
|
|
|
|
case InlineAsm::Constraint_m:
|
|
|
|
case InlineAsm::Constraint_R:
|
|
|
|
case InlineAsm::Constraint_ZC:
|
|
|
|
OutOps.push_back(Op);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2011-06-21 00:40:49 +00:00
|
|
|
}
|