21#define DEBUG_TYPE "ve-isel"
22#define PASS_NAME "VE DAG->DAG Pattern Instruction Selection"
35 VEDAGToDAGISel() =
delete;
56 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
58 std::vector<SDValue> &OutOps)
override;
61#include "VEGenDAGISel.inc"
64 SDNode *getGlobalBaseReg();
78char VEDAGToDAGISelLegacy::ID = 0;
93 if (matchADDRrr(
LHS,
Base, Index)) {
100 if (matchADDRrr(Addr,
LHS,
RHS)) {
119 Offset = CurDAG->getTargetConstant(0,
SDLoc(Addr), MVT::i32);
128 Index = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
133 Index = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
134 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
138bool VEDAGToDAGISel::selectADDRzri(SDValue Addr, SDValue &
Base, SDValue &Index,
144bool VEDAGToDAGISel::selectADDRzii(SDValue Addr, SDValue &
Base, SDValue &Index,
155 Base = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
156 Index = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
158 CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(Addr), MVT::i32);
165bool VEDAGToDAGISel::selectADDRri(SDValue Addr, SDValue &
Base,
171 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
175bool VEDAGToDAGISel::selectADDRzi(SDValue Addr, SDValue &
Base,
186 Base = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
188 CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(Addr), MVT::i32);
195bool VEDAGToDAGISel::matchADDRrr(SDValue Addr, SDValue &
Base, SDValue &Index) {
223bool VEDAGToDAGISel::matchADDRri(SDValue Addr, SDValue &
Base, SDValue &
Offset) {
226 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), AddrTy);
227 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
235 if (CurDAG->isBaseWithConstantOffset(Addr)) {
238 if (FrameIndexSDNode *FIN =
241 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), AddrTy);
246 CurDAG->getTargetConstant(CN->
getZExtValue(), SDLoc(Addr), MVT::i32);
253void VEDAGToDAGISel::Select(SDNode *
N) {
254 if (
N->isMachineOpcode()) {
259 switch (
N->getOpcode()) {
263 ReplaceNode(
N,
N->getOperand(0).getNode());
267 case VEISD::VEC_BROADCAST: {
268 MVT SplatResTy =
N->getSimpleValueType(0);
276 bool BCTrueMask = (BConst->getSExtValue() != 0);
283 New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), SDLoc(
N), VE::VM0,
286 New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), SDLoc(
N), VE::VMP0,
292 ReplaceNode(
N,
New.getNode());
297 ReplaceNode(
N, getGlobalBaseReg());
306bool VEDAGToDAGISel::SelectInlineAsmMemoryOperand(
308 std::vector<SDValue> &OutOps) {
310 switch (ConstraintID) {
313 case InlineAsm::ConstraintCode::o:
314 case InlineAsm::ConstraintCode::m:
317 if (selectADDRri(
Op, Op0, Op1)) {
318 OutOps.push_back(Op0);
319 OutOps.push_back(Op1);
323 OutOps.push_back(
Op);
324 OutOps.push_back(CurDAG->getTargetConstant(0, SDLoc(
Op), MVT::i32));
330SDNode *VEDAGToDAGISel::getGlobalBaseReg() {
333 ->getRegister(GlobalBaseReg, TLI->getPointerTy(CurDAG->getDataLayout()))
344 return new VEDAGToDAGISelLegacy(TM);
AMDGPU Register Bank Select
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
uint64_t getZExtValue() const
int64_t getSExtValue() const
FunctionPass class - This class is used to implement most global optimizations.
unsigned getVectorNumElements() const
MVT getVectorElementType() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
SelectionDAGISelPass(std::unique_ptr< SelectionDAGISel > Selector)
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
virtual bool runOnMachineFunction(MachineFunction &mf)
VEDAGToDAGISelPass(VETargetMachine &TM)
Register getGlobalBaseReg(MachineFunction *MF) const
} Optimization
const VEInstrInfo * getInstrInfo() const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ ADD
Simple integer binary arithmetic operators.
@ TargetGlobalAddress
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
@ GlobalBaseReg
The result of the mflr at function entry, used for PIC code.
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
static const unsigned StandardVectorWidth
static const unsigned PackedVectorWidth
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
FunctionPass * createVEDAGToDAGISelLegacyPass(VETargetMachine &TM)
createVEISelDag - This pass converts a legalized DAG into a VE-specific DAG, ready for instruction sc...
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.