1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===-- AlphaISelDAGToDAG.cpp - Alpha pattern matching inst selector ------===// 2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// The LLVM Compiler Infrastructure 4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source 6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details. 7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===// 9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file defines a pattern matching instruction selector for Alpha, 11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// converting from a legalized dag to a Alpha dag. 12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===// 14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "Alpha.h" 16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "AlphaTargetMachine.h" 17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/CodeGen/MachineInstrBuilder.h" 18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/CodeGen/MachineFrameInfo.h" 19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/CodeGen/MachineFunction.h" 20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/CodeGen/MachineRegisterInfo.h" 21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/CodeGen/SelectionDAG.h" 22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/CodeGen/SelectionDAGISel.h" 23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Target/TargetOptions.h" 24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Constants.h" 25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/DerivedTypes.h" 26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/GlobalValue.h" 27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Intrinsics.h" 28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/LLVMContext.h" 29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Support/Compiler.h" 30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Support/Debug.h" 31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Support/ErrorHandling.h" 32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Support/MathExtras.h" 33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Support/raw_ostream.h" 34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include <algorithm> 35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanusing namespace llvm; 36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace { 38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman //===--------------------------------------------------------------------===// 40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// AlphaDAGToDAGISel - Alpha specific code to select Alpha machine 41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// instructions for SelectionDAG operations. 42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman class AlphaDAGToDAGISel : public SelectionDAGISel { 43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static const int64_t IMM_LOW = -32768; 44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static const int64_t IMM_HIGH = 32767; 45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static const int64_t IMM_MULT = 65536; 46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static const int64_t IMM_FULLHIGH = IMM_HIGH + IMM_HIGH * IMM_MULT; 47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static const int64_t IMM_FULLLOW = IMM_LOW + IMM_LOW * IMM_MULT; 48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static int64_t get_ldah16(int64_t x) { 50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int64_t y = x / IMM_MULT; 51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (x % IMM_MULT > IMM_HIGH) 52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ++y; 53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return y; 54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 56894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static int64_t get_lda16(int64_t x) { 57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return x - get_ldah16(x) * IMM_MULT; 58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// get_zapImm - Return a zap mask if X is a valid immediate for a zapnot 61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// instruction (if not, return 0). Note that this code accepts partial 62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// zap masks. For example (and LHS, 1) is a valid zap, as long we know 63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// that the bits 1-7 of LHS are already zero. If LHS is non-null, we are 64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// in checking mode. If LHS is null, we assume that the mask has already 65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// been validated before. 66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t get_zapImm(SDValue LHS, uint64_t Constant) const { 67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t BitsToCheck = 0; 68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned Result = 0; 69894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for (unsigned i = 0; i != 8; ++i) { 70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (((Constant >> 8*i) & 0xFF) == 0) { 71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // nothing to do. 72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else { 73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Result |= 1 << i; 74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (((Constant >> 8*i) & 0xFF) == 0xFF) { 75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // If the entire byte is set, zapnot the byte. 76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else if (LHS.getNode() == 0) { 77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Otherwise, if the mask was previously validated, we know its okay 78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // to zapnot this entire byte even though all the bits aren't set. 79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else { 80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Otherwise we don't know that the it's okay to zapnot this entire 81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // byte. Only do this iff we can prove that the missing bits are 82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // already null, so the bytezap doesn't need to really null them. 8319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman BitsToCheck |= ~Constant & (0xFFULL << 8*i); 84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 87894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // If there are missing bits in a byte (for example, X & 0xEF00), check to 89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // see if the missing bits (0x1000) are already known zero if not, the zap 90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // isn't okay to do, as it won't clear all the required bits. 91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (BitsToCheck && 92894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman !CurDAG->MaskedValueIsZero(LHS, 93894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman APInt(LHS.getValueSizeInBits(), 94894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman BitsToCheck))) 95894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return 0; 96894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 97894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return Result; 98894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 99894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static uint64_t get_zapImm(uint64_t x) { 101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned build = 0; 102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for(int i = 0; i != 8; ++i) { 103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ((x & 0x00FF) == 0x00FF) 104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman build |= 1 << i; 105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else if ((x & 0x00FF) != 0) 106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return 0; 107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman x >>= 8; 108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return build; 110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 112894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static uint64_t getNearPower2(uint64_t x) { 114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (!x) return 0; 115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned at = CountLeadingZeros_64(x); 116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t complow = 1ULL << (63 - at); 11719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman uint64_t comphigh = complow << 1; 11819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if (x - complow <= comphigh - x) 119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return complow; 120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return comphigh; 122894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static bool chkRemNearPower2(uint64_t x, uint64_t r, bool swap) { 125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t y = getNearPower2(x); 126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (swap) 127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return (y - x) == r; 128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return (x - y) == r; 130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman public: 133894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman explicit AlphaDAGToDAGISel(AlphaTargetMachine &TM) 134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman : SelectionDAGISel(TM) 135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman {} 136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// getI64Imm - Return a target constant with the specified value, of type 138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// i64. 139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman inline SDValue getI64Imm(int64_t Imm) { 140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->getTargetConstant(Imm, MVT::i64); 141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Select - Convert the specified operand from a target-independent to a 144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // target-specific node if it hasn't already been changed. 145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDNode *Select(SDNode *N); 146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual const char *getPassName() const { 148894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return "Alpha DAG->DAG Pattern Instruction Selection"; 149894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for 152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// inline asm expressions. 153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, 154894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman char ConstraintCode, 155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman std::vector<SDValue> &OutOps) { 156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue Op0; 157894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman switch (ConstraintCode) { 158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: return true; 159894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case 'm': // memory 160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Op0 = Op; 161894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 164894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman OutOps.push_back(Op0); 165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return false; 166894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 168894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// Include the pieces autogenerated from the target description. 169894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "AlphaGenDAGISel.inc" 170894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanprivate: 172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// getTargetMachine - Return a reference to the TargetMachine, casted 173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// to the target-specific type. 174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const AlphaTargetMachine &getTargetMachine() { 175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return static_cast<const AlphaTargetMachine &>(TM); 176894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 177894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// getInstrInfo - Return a reference to the TargetInstrInfo, casted 179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// to the target-specific type. 180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const AlphaInstrInfo *getInstrInfo() { 181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return getTargetMachine().getInstrInfo(); 182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDNode *getGlobalBaseReg(); 185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDNode *getGlobalRetAddr(); 186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void SelectCALL(SDNode *Op); 187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman }; 189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// getGlobalBaseReg - Output the instructions required to put the 192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// GOT address into a register. 193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// 194894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanSDNode *AlphaDAGToDAGISel::getGlobalBaseReg() { 195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned GlobalBaseReg = getInstrInfo()->getGlobalBaseReg(MF); 196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->getRegister(GlobalBaseReg, TLI.getPointerTy()).getNode(); 197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// getGlobalRetAddr - Grab the return address. 200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// 201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanSDNode *AlphaDAGToDAGISel::getGlobalRetAddr() { 202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned GlobalRetAddr = getInstrInfo()->getGlobalRetAddr(MF); 203894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->getRegister(GlobalRetAddr, TLI.getPointerTy()).getNode(); 204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// Select - Convert the specified operand from a target-independent to a 207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// target-specific node if it hasn't already been changed. 208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanSDNode *AlphaDAGToDAGISel::Select(SDNode *N) { 209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (N->isMachineOpcode()) 210894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return NULL; // Already selected. 211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman DebugLoc dl = N->getDebugLoc(); 212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 213894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman switch (N->getOpcode()) { 214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: break; 215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case AlphaISD::CALL: 216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SelectCALL(N); 217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return NULL; 218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::FrameIndex: { 220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int FI = cast<FrameIndexSDNode>(N)->getIndex(); 221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->SelectNodeTo(N, Alpha::LDA, MVT::i64, 222894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CurDAG->getTargetFrameIndex(FI, MVT::i32), 223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman getI64Imm(0)); 224894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::GLOBAL_OFFSET_TABLE: 226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return getGlobalBaseReg(); 227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case AlphaISD::GlobalRetAddr: 228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return getGlobalRetAddr(); 229894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case AlphaISD::DivCall: { 231894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue Chain = CurDAG->getEntryNode(); 232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue N0 = N->getOperand(0); 233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue N1 = N->getOperand(1); 234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue N2 = N->getOperand(2); 235894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain = CurDAG->getCopyToReg(Chain, dl, Alpha::R24, N1, 236894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue(0,0)); 237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain = CurDAG->getCopyToReg(Chain, dl, Alpha::R25, N2, 238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain.getValue(1)); 239894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain = CurDAG->getCopyToReg(Chain, dl, Alpha::R27, N0, 240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain.getValue(1)); 241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDNode *CNode = 24219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman CurDAG->getMachineNode(Alpha::JSRs, dl, MVT::Other, MVT::Glue, 243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain, Chain.getValue(1)); 244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain = CurDAG->getCopyFromReg(Chain, dl, Alpha::R27, MVT::i64, 245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue(CNode, 1)); 246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->SelectNodeTo(N, Alpha::BISr, MVT::i64, Chain, Chain); 247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::READCYCLECOUNTER: { 250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue Chain = N->getOperand(0); 251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->getMachineNode(Alpha::RPCC, dl, MVT::i64, MVT::Other, 252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain); 253894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 254894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::Constant: { 256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t uval = cast<ConstantSDNode>(N)->getZExtValue(); 257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 258894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (uval == 0) { 259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue Result = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), dl, 260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Alpha::R31, MVT::i64); 261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ReplaceUses(SDValue(N, 0), Result); 262894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return NULL; 263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int64_t val = (int64_t)uval; 266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int32_t val32 = (int32_t)val; 267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (val <= IMM_HIGH + IMM_HIGH * IMM_MULT && 268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman val >= IMM_LOW + IMM_LOW * IMM_MULT) 269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; //(LDAH (LDA)) 270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if ((uval >> 32) == 0 && //empty upper bits 271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman val32 <= IMM_HIGH + IMM_HIGH * IMM_MULT) 272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // val32 >= IMM_LOW + IMM_LOW * IMM_MULT) //always true 273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; //(zext (LDAH (LDA))) 274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman //Else use the constant pool 275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ConstantInt *C = ConstantInt::get( 276894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Type::getInt64Ty(*CurDAG->getContext()), uval); 277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue CPI = CurDAG->getTargetConstantPool(C, MVT::i64); 278894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDNode *Tmp = CurDAG->getMachineNode(Alpha::LDAHr, dl, MVT::i64, CPI, 279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue(getGlobalBaseReg(), 0)); 280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->SelectNodeTo(N, Alpha::LDQr, MVT::i64, MVT::Other, 281894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CPI, SDValue(Tmp, 0), CurDAG->getEntryNode()); 282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::TargetConstantFP: 284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::ConstantFP: { 285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ConstantFPSDNode *CN = cast<ConstantFPSDNode>(N); 286894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool isDouble = N->getValueType(0) == MVT::f64; 287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman EVT T = isDouble ? MVT::f64 : MVT::f32; 288894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (CN->getValueAPF().isPosZero()) { 289894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->SelectNodeTo(N, isDouble ? Alpha::CPYST : Alpha::CPYSS, 290894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman T, CurDAG->getRegister(Alpha::F31, T), 291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CurDAG->getRegister(Alpha::F31, T)); 292894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else if (CN->getValueAPF().isNegZero()) { 293894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->SelectNodeTo(N, isDouble ? Alpha::CPYSNT : Alpha::CPYSNS, 294894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman T, CurDAG->getRegister(Alpha::F31, T), 295894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CurDAG->getRegister(Alpha::F31, T)); 296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else { 297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman report_fatal_error("Unhandled FP constant type"); 298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 300894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 302894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETCC: 303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (N->getOperand(0).getNode()->getValueType(0).isFloatingPoint()) { 304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ISD::CondCode CC = cast<CondCodeSDNode>(N->getOperand(2))->get(); 305894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned Opc = Alpha::WTF; 307894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool rev = false; 308894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool inv = false; 309894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman switch(CC) { 310894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: DEBUG(N->dump(CurDAG)); llvm_unreachable("Unknown FP comparison!"); 311894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETEQ: case ISD::SETOEQ: case ISD::SETUEQ: 312894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Opc = Alpha::CMPTEQ; break; 313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETLT: case ISD::SETOLT: case ISD::SETULT: 314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Opc = Alpha::CMPTLT; break; 315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETLE: case ISD::SETOLE: case ISD::SETULE: 316894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Opc = Alpha::CMPTLE; break; 317894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETGT: case ISD::SETOGT: case ISD::SETUGT: 318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Opc = Alpha::CMPTLT; rev = true; break; 319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETGE: case ISD::SETOGE: case ISD::SETUGE: 320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Opc = Alpha::CMPTLE; rev = true; break; 321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETNE: case ISD::SETONE: case ISD::SETUNE: 322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Opc = Alpha::CMPTEQ; inv = true; break; 323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETO: 324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Opc = Alpha::CMPTUN; inv = true; break; 325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETUO: 326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Opc = Alpha::CMPTUN; break; 327894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman }; 328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue tmp1 = N->getOperand(rev?1:0); 329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue tmp2 = N->getOperand(rev?0:1); 330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDNode *cmp = CurDAG->getMachineNode(Opc, dl, MVT::f64, tmp1, tmp2); 331894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (inv) 332894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman cmp = CurDAG->getMachineNode(Alpha::CMPTEQ, dl, 333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MVT::f64, SDValue(cmp, 0), 334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CurDAG->getRegister(Alpha::F31, MVT::f64)); 335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman switch(CC) { 336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETUEQ: case ISD::SETULT: case ISD::SETULE: 337894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::SETUNE: case ISD::SETUGT: case ISD::SETUGE: 338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDNode* cmp2 = CurDAG->getMachineNode(Alpha::CMPTUN, dl, MVT::f64, 340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman tmp1, tmp2); 341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman cmp = CurDAG->getMachineNode(Alpha::ADDT, dl, MVT::f64, 342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue(cmp2, 0), SDValue(cmp, 0)); 343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 344894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: break; 346894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDNode* LD = CurDAG->getMachineNode(Alpha::FTOIT, dl, 349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MVT::i64, SDValue(cmp, 0)); 350894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->getMachineNode(Alpha::CMPULT, dl, MVT::i64, 351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CurDAG->getRegister(Alpha::R31, MVT::i64), 352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue(LD,0)); 353894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman case ISD::AND: { 357894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ConstantSDNode* SC = NULL; 358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ConstantSDNode* MC = NULL; 359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (N->getOperand(0).getOpcode() == ISD::SRL && 360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman (MC = dyn_cast<ConstantSDNode>(N->getOperand(1))) && 361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman (SC = dyn_cast<ConstantSDNode>(N->getOperand(0).getOperand(1)))) { 362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t sval = SC->getZExtValue(); 363894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t mval = MC->getZExtValue(); 364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // If the result is a zap, let the autogened stuff handle it. 365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (get_zapImm(N->getOperand(0), mval)) 366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 367894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // given mask X, and shift S, we want to see if there is any zap in the 368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // mask if we play around with the botton S bits 369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t dontcare = (~0ULL) >> (64 - sval); 370894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman uint64_t mask = mval << sval; 371894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (get_zapImm(mask | dontcare)) 373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman mask = mask | dontcare; 374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (get_zapImm(mask)) { 376894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue Z = 377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue(CurDAG->getMachineNode(Alpha::ZAPNOTi, dl, MVT::i64, 378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman N->getOperand(0).getOperand(0), 379894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman getI64Imm(get_zapImm(mask))), 0); 380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return CurDAG->getMachineNode(Alpha::SRLr, dl, MVT::i64, Z, 381894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman getI64Imm(sval)); 382894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 383894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 386894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 388894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 389894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return SelectCode(N); 390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 391894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanvoid AlphaDAGToDAGISel::SelectCALL(SDNode *N) { 393894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman //TODO: add flag stuff to prevent nondeturministic breakage! 394894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue Chain = N->getOperand(0); 396894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue Addr = N->getOperand(1); 397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue InFlag = N->getOperand(N->getNumOperands() - 1); 398894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman DebugLoc dl = N->getDebugLoc(); 399894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if (Addr.getOpcode() == AlphaISD::GPRelLo) { 401894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue GOT = SDValue(getGlobalBaseReg(), 0); 402894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain = CurDAG->getCopyToReg(Chain, dl, Alpha::R29, GOT, InFlag); 403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman InFlag = Chain.getValue(1); 404894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain = SDValue(CurDAG->getMachineNode(Alpha::BSR, dl, MVT::Other, 40519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman MVT::Glue, Addr.getOperand(0), 406894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain, InFlag), 0); 407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } else { 408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain = CurDAG->getCopyToReg(Chain, dl, Alpha::R27, Addr, InFlag); 409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman InFlag = Chain.getValue(1); 410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Chain = SDValue(CurDAG->getMachineNode(Alpha::JSR, dl, MVT::Other, 41119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman MVT::Glue, Chain, InFlag), 0); 412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 413894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman InFlag = Chain.getValue(1); 414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ReplaceUses(SDValue(N, 0), Chain); 416894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ReplaceUses(SDValue(N, 1), InFlag); 417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 418894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// createAlphaISelDag - This pass converts a legalized DAG into a 421894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// Alpha-specific DAG, ready for instruction scheduling. 422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// 423894018228b0e0bdbd7aa7e8f47d4a9458789ca82John BaumanFunctionPass *llvm::createAlphaISelDag(AlphaTargetMachine &TM) { 424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return new AlphaDAGToDAGISel(TM); 425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 426