Misha Brukman | 2a8350a | 2005-02-05 02:24:26 +0000 | [diff] [blame] | 1 | //===- AlphaISelPattern.cpp - A pattern matching inst selector for Alpha --===// |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines a pattern matching instruction selector for Alpha. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "Alpha.h" |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 15 | #include "AlphaRegisterInfo.h" |
| 16 | #include "llvm/Constants.h" // FIXME: REMOVE |
| 17 | #include "llvm/Function.h" |
| 18 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 19 | #include "llvm/CodeGen/MachineConstantPool.h" // FIXME: REMOVE |
| 20 | #include "llvm/CodeGen/MachineFunction.h" |
| 21 | #include "llvm/CodeGen/MachineFrameInfo.h" |
| 22 | #include "llvm/CodeGen/SelectionDAG.h" |
| 23 | #include "llvm/CodeGen/SelectionDAGISel.h" |
| 24 | #include "llvm/CodeGen/SSARegMap.h" |
| 25 | #include "llvm/Target/TargetData.h" |
| 26 | #include "llvm/Target/TargetLowering.h" |
| 27 | #include "llvm/Support/MathExtras.h" |
| 28 | #include "llvm/ADT/Statistic.h" |
| 29 | #include <set> |
Andrew Lenharth | 684f229 | 2005-01-30 00:35:27 +0000 | [diff] [blame] | 30 | #include <algorithm> |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 31 | using namespace llvm; |
| 32 | |
| 33 | //===----------------------------------------------------------------------===// |
| 34 | // AlphaTargetLowering - Alpha Implementation of the TargetLowering interface |
| 35 | namespace { |
| 36 | class AlphaTargetLowering : public TargetLowering { |
| 37 | int VarArgsFrameIndex; // FrameIndex for start of varargs area. |
| 38 | unsigned GP; //GOT vreg |
| 39 | public: |
| 40 | AlphaTargetLowering(TargetMachine &TM) : TargetLowering(TM) { |
| 41 | // Set up the TargetLowering object. |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 42 | //I am having problems with shr n ubyte 1 |
Andrew Lenharth | 879ef22 | 2005-02-02 17:00:21 +0000 | [diff] [blame] | 43 | setShiftAmountType(MVT::i64); |
| 44 | setSetCCResultType(MVT::i64); |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 45 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 46 | addRegisterClass(MVT::i64, Alpha::GPRCRegisterClass); |
| 47 | addRegisterClass(MVT::f64, Alpha::FPRCRegisterClass); |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 48 | addRegisterClass(MVT::f32, Alpha::FPRCRegisterClass); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 49 | |
Andrew Lenharth | d2bb960 | 2005-01-27 07:50:35 +0000 | [diff] [blame] | 50 | setOperationAction(ISD::EXTLOAD , MVT::i1 , Promote); |
Andrew Lenharth | 2f8fb77 | 2005-01-25 00:35:34 +0000 | [diff] [blame] | 51 | |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 52 | setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 53 | setOperationAction(ISD::ZEXTLOAD , MVT::i32 , Expand); |
Andrew Lenharth | 2f8fb77 | 2005-01-25 00:35:34 +0000 | [diff] [blame] | 54 | |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 55 | setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 56 | setOperationAction(ISD::SEXTLOAD , MVT::i8 , Expand); |
| 57 | setOperationAction(ISD::SEXTLOAD , MVT::i16 , Expand); |
| 58 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 59 | //what is the sign expansion of 1? 1 or -1? |
| 60 | setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); |
Andrew Lenharth | 0298118 | 2005-01-26 01:24:38 +0000 | [diff] [blame] | 61 | |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 62 | setOperationAction(ISD::SREM , MVT::f32 , Expand); |
| 63 | setOperationAction(ISD::SREM , MVT::f64 , Expand); |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 64 | |
Andrew Lenharth | 8d163d2 | 2005-02-02 05:49:42 +0000 | [diff] [blame] | 65 | setOperationAction(ISD::MEMMOVE , MVT::Other, Expand); |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 66 | setOperationAction(ISD::MEMSET , MVT::Other, Expand); |
| 67 | setOperationAction(ISD::MEMCPY , MVT::Other, Expand); |
| 68 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 69 | computeRegisterProperties(); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 70 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 71 | addLegalFPImmediate(+0.0); //F31 |
| 72 | addLegalFPImmediate(-0.0); //-F31 |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /// LowerArguments - This hook must be implemented to indicate how we should |
| 76 | /// lower the arguments for the specified function, into the specified DAG. |
| 77 | virtual std::vector<SDOperand> |
| 78 | LowerArguments(Function &F, SelectionDAG &DAG); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 79 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 80 | /// LowerCallTo - This hook lowers an abstract call to a function into an |
| 81 | /// actual call. |
| 82 | virtual std::pair<SDOperand, SDOperand> |
| 83 | LowerCallTo(SDOperand Chain, const Type *RetTy, SDOperand Callee, |
| 84 | ArgListTy &Args, SelectionDAG &DAG); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 85 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 86 | virtual std::pair<SDOperand, SDOperand> |
| 87 | LowerVAStart(SDOperand Chain, SelectionDAG &DAG); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 88 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 89 | virtual std::pair<SDOperand,SDOperand> |
| 90 | LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList, |
| 91 | const Type *ArgTy, SelectionDAG &DAG); |
| 92 | |
| 93 | virtual std::pair<SDOperand, SDOperand> |
| 94 | LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain, unsigned Depth, |
| 95 | SelectionDAG &DAG); |
| 96 | |
| 97 | void restoreGP(MachineBasicBlock* BB) |
| 98 | { |
| 99 | BuildMI(BB, Alpha::BIS, 2, Alpha::R29).addReg(GP).addReg(GP); |
| 100 | } |
| 101 | }; |
| 102 | } |
| 103 | |
| 104 | //http://www.cs.arizona.edu/computer.help/policy/DIGITAL_unix/AA-PY8AC-TET1_html/callCH3.html#BLOCK21 |
| 105 | |
| 106 | //For now, just use variable size stack frame format |
| 107 | |
| 108 | //In a standard call, the first six items are passed in registers $16 |
| 109 | //- $21 and/or registers $f16 - $f21. (See Section 4.1.2 for details |
| 110 | //of argument-to-register correspondence.) The remaining items are |
| 111 | //collected in a memory argument list that is a naturally aligned |
| 112 | //array of quadwords. In a standard call, this list, if present, must |
| 113 | //be passed at 0(SP). |
| 114 | //7 ... n 0(SP) ... (n-7)*8(SP) |
| 115 | |
| 116 | std::vector<SDOperand> |
| 117 | AlphaTargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) |
| 118 | { |
| 119 | std::vector<SDOperand> ArgValues; |
| 120 | |
| 121 | // //#define FP $15 |
| 122 | // //#define RA $26 |
| 123 | // //#define PV $27 |
| 124 | // //#define GP $29 |
| 125 | // //#define SP $30 |
| 126 | |
| 127 | // assert(0 && "TODO"); |
| 128 | MachineFunction &MF = DAG.getMachineFunction(); |
Andrew Lenharth | 0538034 | 2005-02-07 05:07:00 +0000 | [diff] [blame] | 129 | MachineFrameInfo*MFI = MF.getFrameInfo(); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 130 | |
| 131 | GP = MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64)); |
| 132 | MachineBasicBlock& BB = MF.front(); |
| 133 | |
| 134 | //Handle the return address |
| 135 | //BuildMI(&BB, Alpha::IDEF, 0, Alpha::R26); |
| 136 | |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 137 | unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18, |
| 138 | Alpha::R19, Alpha::R20, Alpha::R21}; |
| 139 | unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, |
| 140 | Alpha::F19, Alpha::F20, Alpha::F21}; |
Andrew Lenharth | 2c9e38c | 2005-02-06 21:07:31 +0000 | [diff] [blame] | 141 | unsigned argVreg[6]; |
| 142 | unsigned argPreg[6]; |
| 143 | unsigned argOpc[6]; |
| 144 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 145 | int count = 0; |
Andrew Lenharth | 2c9e38c | 2005-02-06 21:07:31 +0000 | [diff] [blame] | 146 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 147 | for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 148 | { |
| 149 | SDOperand newroot, argt; |
| 150 | if (count < 6) { |
| 151 | switch (getValueType(I->getType())) { |
| 152 | default: |
| 153 | std::cerr << "Unknown Type " << getValueType(I->getType()) << "\n"; |
| 154 | abort(); |
| 155 | case MVT::f64: |
| 156 | case MVT::f32: |
| 157 | BuildMI(&BB, Alpha::IDEF, 0, args_float[count]); |
| 158 | argVreg[count] = |
| 159 | MF.getSSARegMap()->createVirtualRegister( |
| 160 | getRegClassFor(getValueType(I->getType()))); |
| 161 | argPreg[count] = args_float[count]; |
| 162 | argOpc[count] = Alpha::CPYS; |
| 163 | argt = newroot = DAG.getCopyFromReg(argVreg[count], |
| 164 | getValueType(I->getType()), |
| 165 | DAG.getRoot()); |
| 166 | break; |
| 167 | case MVT::i1: |
| 168 | case MVT::i8: |
| 169 | case MVT::i16: |
| 170 | case MVT::i32: |
| 171 | case MVT::i64: |
| 172 | BuildMI(&BB, Alpha::IDEF, 0, args_int[count]); |
| 173 | argVreg[count] = |
| 174 | MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64)); |
| 175 | argPreg[count] = args_int[count]; |
| 176 | argOpc[count] = Alpha::BIS; |
| 177 | argt = newroot = |
| 178 | DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot()); |
| 179 | if (getValueType(I->getType()) != MVT::i64) |
| 180 | argt = |
| 181 | DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot); |
| 182 | break; |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 183 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 184 | ++count; |
| 185 | } else { //more args |
| 186 | // Create the frame index object for this incoming parameter... |
| 187 | int FI = MFI->CreateFixedObject(8, 8 * (count - 6)); |
| 188 | |
| 189 | // Create the SelectionDAG nodes corresponding to a load |
| 190 | //from this parameter |
| 191 | SDOperand FIN = DAG.getFrameIndex(FI, MVT::i64); |
| 192 | argt = newroot = DAG.getLoad(getValueType(I->getType()), |
| 193 | DAG.getEntryNode(), FIN); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 194 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 195 | DAG.setRoot(newroot.getValue(1)); |
| 196 | ArgValues.push_back(argt); |
| 197 | } |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 198 | |
| 199 | BuildMI(&BB, Alpha::IDEF, 0, Alpha::R29); |
| 200 | BuildMI(&BB, Alpha::BIS, 2, GP).addReg(Alpha::R29).addReg(Alpha::R29); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 201 | for (int i = 0; i < count; ++i) { |
| 202 | if (argPreg[i] == Alpha::F16 || argPreg[i] == Alpha::F17 || |
| 203 | argPreg[i] == Alpha::F18 || argPreg[i] == Alpha::F19 || |
| 204 | argPreg[i] == Alpha::F20 || argPreg[i] == Alpha::F21) |
Andrew Lenharth | 2c9e38c | 2005-02-06 21:07:31 +0000 | [diff] [blame] | 205 | { |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 206 | assert(argOpc[i] == Alpha::CPYS && "Using BIS for a float??"); |
Andrew Lenharth | 2c9e38c | 2005-02-06 21:07:31 +0000 | [diff] [blame] | 207 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 208 | BuildMI(&BB, argOpc[i], 2, |
| 209 | argVreg[i]).addReg(argPreg[i]).addReg(argPreg[i]); |
| 210 | } |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 211 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 212 | return ArgValues; |
| 213 | } |
| 214 | |
| 215 | std::pair<SDOperand, SDOperand> |
| 216 | AlphaTargetLowering::LowerCallTo(SDOperand Chain, |
| 217 | const Type *RetTy, SDOperand Callee, |
| 218 | ArgListTy &Args, SelectionDAG &DAG) { |
| 219 | int NumBytes = 0; |
Andrew Lenharth | 684f229 | 2005-01-30 00:35:27 +0000 | [diff] [blame] | 220 | if (Args.size() > 6) |
| 221 | NumBytes = (Args.size() - 6) * 8; |
| 222 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 223 | Chain = DAG.getNode(ISD::ADJCALLSTACKDOWN, MVT::Other, Chain, |
| 224 | DAG.getConstant(NumBytes, getPointerTy())); |
| 225 | std::vector<SDOperand> args_to_use; |
| 226 | for (unsigned i = 0, e = Args.size(); i != e; ++i) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 227 | { |
| 228 | switch (getValueType(Args[i].second)) { |
| 229 | default: assert(0 && "Unexpected ValueType for argument!"); |
| 230 | case MVT::i1: |
| 231 | case MVT::i8: |
| 232 | case MVT::i16: |
| 233 | case MVT::i32: |
| 234 | // Promote the integer to 64 bits. If the input type is signed use a |
| 235 | // sign extend, otherwise use a zero extend. |
| 236 | if (Args[i].second->isSigned()) |
| 237 | Args[i].first = DAG.getNode(ISD::SIGN_EXTEND, MVT::i64, Args[i].first); |
| 238 | else |
| 239 | Args[i].first = DAG.getNode(ISD::ZERO_EXTEND, MVT::i64, Args[i].first); |
| 240 | break; |
| 241 | case MVT::i64: |
| 242 | case MVT::f64: |
| 243 | case MVT::f32: |
| 244 | break; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 245 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 246 | args_to_use.push_back(Args[i].first); |
| 247 | } |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 248 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 249 | std::vector<MVT::ValueType> RetVals; |
| 250 | MVT::ValueType RetTyVT = getValueType(RetTy); |
| 251 | if (RetTyVT != MVT::isVoid) |
| 252 | RetVals.push_back(RetTyVT); |
| 253 | RetVals.push_back(MVT::Other); |
| 254 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 255 | SDOperand TheCall = SDOperand(DAG.getCall(RetVals, |
| 256 | Chain, Callee, args_to_use), 0); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 257 | Chain = TheCall.getValue(RetTyVT != MVT::isVoid); |
| 258 | Chain = DAG.getNode(ISD::ADJCALLSTACKUP, MVT::Other, Chain, |
| 259 | DAG.getConstant(NumBytes, getPointerTy())); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 260 | return std::make_pair(TheCall, Chain); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | std::pair<SDOperand, SDOperand> |
| 264 | AlphaTargetLowering::LowerVAStart(SDOperand Chain, SelectionDAG &DAG) { |
| 265 | //vastart just returns the address of the VarArgsFrameIndex slot. |
| 266 | return std::make_pair(DAG.getFrameIndex(VarArgsFrameIndex, MVT::i64), Chain); |
| 267 | } |
| 268 | |
| 269 | std::pair<SDOperand,SDOperand> AlphaTargetLowering:: |
| 270 | LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList, |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 271 | const Type *ArgTy, SelectionDAG &DAG) { |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 272 | abort(); |
| 273 | } |
| 274 | |
| 275 | |
| 276 | std::pair<SDOperand, SDOperand> AlphaTargetLowering:: |
| 277 | LowerFrameReturnAddress(bool isFrameAddress, SDOperand Chain, unsigned Depth, |
| 278 | SelectionDAG &DAG) { |
| 279 | abort(); |
| 280 | } |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | namespace { |
| 287 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 288 | //===--------------------------------------------------------------------===// |
| 289 | /// ISel - Alpha specific code to select Alpha machine instructions for |
| 290 | /// SelectionDAG operations. |
| 291 | //===--------------------------------------------------------------------===// |
| 292 | class ISel : public SelectionDAGISel { |
| 293 | |
| 294 | /// AlphaLowering - This object fully describes how to lower LLVM code to an |
| 295 | /// Alpha-specific SelectionDAG. |
| 296 | AlphaTargetLowering AlphaLowering; |
| 297 | |
| 298 | |
| 299 | /// ExprMap - As shared expressions are codegen'd, we keep track of which |
| 300 | /// vreg the value is produced in, so we only emit one copy of each compiled |
| 301 | /// tree. |
| 302 | static const unsigned notIn = (unsigned)(-1); |
| 303 | std::map<SDOperand, unsigned> ExprMap; |
| 304 | |
| 305 | //CCInvMap sometimes (SetNE) we have the inverse CC code for free |
| 306 | std::map<SDOperand, unsigned> CCInvMap; |
| 307 | |
| 308 | public: |
| 309 | ISel(TargetMachine &TM) : SelectionDAGISel(AlphaLowering), AlphaLowering(TM) |
| 310 | {} |
| 311 | |
| 312 | /// InstructionSelectBasicBlock - This callback is invoked by |
| 313 | /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. |
| 314 | virtual void InstructionSelectBasicBlock(SelectionDAG &DAG) { |
| 315 | // Codegen the basic block. |
| 316 | Select(DAG.getRoot()); |
| 317 | |
| 318 | // Clear state used for selection. |
| 319 | ExprMap.clear(); |
| 320 | CCInvMap.clear(); |
| 321 | } |
| 322 | |
| 323 | unsigned SelectExpr(SDOperand N); |
| 324 | unsigned SelectExprFP(SDOperand N, unsigned Result); |
| 325 | void Select(SDOperand N); |
| 326 | |
| 327 | void SelectAddr(SDOperand N, unsigned& Reg, long& offset); |
| 328 | void SelectBranchCC(SDOperand N); |
| 329 | }; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 330 | } |
| 331 | |
Andrew Lenharth | 6583890 | 2005-02-06 16:22:15 +0000 | [diff] [blame] | 332 | static unsigned GetSymVersion(unsigned opcode) |
| 333 | { |
| 334 | switch (opcode) { |
| 335 | default: assert(0 && "unknown load or store"); return 0; |
| 336 | case Alpha::LDQ: return Alpha::LDQ_SYM; |
| 337 | case Alpha::LDS: return Alpha::LDS_SYM; |
| 338 | case Alpha::LDT: return Alpha::LDT_SYM; |
| 339 | case Alpha::LDL: return Alpha::LDL_SYM; |
| 340 | case Alpha::LDBU: return Alpha::LDBU_SYM; |
| 341 | case Alpha::LDWU: return Alpha::LDWU_SYM; |
| 342 | case Alpha::LDW: return Alpha::LDW_SYM; |
| 343 | case Alpha::LDB: return Alpha::LDB_SYM; |
| 344 | case Alpha::STQ: return Alpha::STQ_SYM; |
| 345 | case Alpha::STS: return Alpha::STS_SYM; |
| 346 | case Alpha::STT: return Alpha::STT_SYM; |
| 347 | case Alpha::STL: return Alpha::STL_SYM; |
| 348 | case Alpha::STW: return Alpha::STW_SYM; |
| 349 | case Alpha::STB: return Alpha::STB_SYM; |
| 350 | } |
| 351 | } |
| 352 | |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 353 | //Check to see if the load is a constant offset from a base register |
| 354 | void ISel::SelectAddr(SDOperand N, unsigned& Reg, long& offset) |
| 355 | { |
| 356 | unsigned opcode = N.getOpcode(); |
| 357 | if (opcode == ISD::ADD) { |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 358 | if(N.getOperand(1).getOpcode() == ISD::Constant && |
| 359 | cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 32767) |
| 360 | { //Normal imm add |
| 361 | Reg = SelectExpr(N.getOperand(0)); |
| 362 | offset = cast<ConstantSDNode>(N.getOperand(1))->getValue(); |
| 363 | return; |
| 364 | } |
| 365 | else if(N.getOperand(0).getOpcode() == ISD::Constant && |
| 366 | cast<ConstantSDNode>(N.getOperand(0))->getValue() <= 32767) |
| 367 | { |
| 368 | Reg = SelectExpr(N.getOperand(1)); |
| 369 | offset = cast<ConstantSDNode>(N.getOperand(0))->getValue(); |
| 370 | return; |
| 371 | } |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 372 | } |
| 373 | Reg = SelectExpr(N); |
| 374 | offset = 0; |
| 375 | return; |
| 376 | } |
| 377 | |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 378 | void ISel::SelectBranchCC(SDOperand N) |
| 379 | { |
| 380 | assert(N.getOpcode() == ISD::BRCOND && "Not a BranchCC???"); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 381 | MachineBasicBlock *Dest = |
| 382 | cast<BasicBlockSDNode>(N.getOperand(2))->getBasicBlock(); |
| 383 | unsigned Opc = Alpha::WTF; |
| 384 | |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 385 | Select(N.getOperand(0)); //chain |
| 386 | SDOperand CC = N.getOperand(1); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 387 | |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 388 | if (CC.getOpcode() == ISD::SETCC) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 389 | { |
| 390 | SetCCSDNode* SetCC = dyn_cast<SetCCSDNode>(CC.Val); |
| 391 | if (MVT::isInteger(SetCC->getOperand(0).getValueType())) { |
| 392 | //Dropping the CC is only useful if we are comparing to 0 |
| 393 | bool isZero0 = false; |
| 394 | bool isZero1 = false; |
| 395 | bool isNE = false; |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 396 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 397 | if(SetCC->getOperand(0).getOpcode() == ISD::Constant && |
| 398 | cast<ConstantSDNode>(SetCC->getOperand(0))->getValue() == 0) |
| 399 | isZero0 = true; |
| 400 | if(SetCC->getOperand(1).getOpcode() == ISD::Constant && |
| 401 | cast<ConstantSDNode>(SetCC->getOperand(1))->getValue() == 0) |
| 402 | isZero1 = true; |
| 403 | if(SetCC->getCondition() == ISD::SETNE) |
| 404 | isNE = true; |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 405 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 406 | if (isZero0) { |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 407 | switch (SetCC->getCondition()) { |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 408 | default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); |
| 409 | case ISD::SETEQ: Opc = Alpha::BEQ; break; |
| 410 | case ISD::SETLT: Opc = Alpha::BGT; break; |
| 411 | case ISD::SETLE: Opc = Alpha::BGE; break; |
| 412 | case ISD::SETGT: Opc = Alpha::BLT; break; |
| 413 | case ISD::SETGE: Opc = Alpha::BLE; break; |
| 414 | case ISD::SETULT: Opc = Alpha::BNE; break; |
| 415 | case ISD::SETUGT: assert(0 && "0 > (unsigned) x is never true"); break; |
| 416 | case ISD::SETULE: assert(0 && "0 <= (unsigned) x is always true"); break; |
| 417 | case ISD::SETUGE: Opc = Alpha::BEQ; break; //Technically you could have this CC |
| 418 | case ISD::SETNE: Opc = Alpha::BNE; break; |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 419 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 420 | unsigned Tmp1 = SelectExpr(SetCC->getOperand(1)); |
| 421 | BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); |
| 422 | return; |
| 423 | } else if (isZero1) { |
| 424 | switch (SetCC->getCondition()) { |
| 425 | default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); |
| 426 | case ISD::SETEQ: Opc = Alpha::BEQ; break; |
| 427 | case ISD::SETLT: Opc = Alpha::BLT; break; |
| 428 | case ISD::SETLE: Opc = Alpha::BLE; break; |
| 429 | case ISD::SETGT: Opc = Alpha::BGT; break; |
| 430 | case ISD::SETGE: Opc = Alpha::BGE; break; |
| 431 | case ISD::SETULT: assert(0 && "x (unsigned) < 0 is never true"); break; |
| 432 | case ISD::SETUGT: Opc = Alpha::BNE; break; |
| 433 | case ISD::SETULE: Opc = Alpha::BEQ; break; //Technically you could have this CC |
| 434 | case ISD::SETUGE: assert(0 && "x (unsgined >= 0 is always true"); break; |
| 435 | case ISD::SETNE: Opc = Alpha::BNE; break; |
| 436 | } |
| 437 | unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); |
| 438 | BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); |
| 439 | return; |
| 440 | } else { |
| 441 | unsigned Tmp1 = SelectExpr(CC); |
| 442 | if (isNE) |
| 443 | BuildMI(BB, Alpha::BEQ, 2).addReg(CCInvMap[CC]).addMBB(Dest); |
| 444 | else |
| 445 | BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 446 | return; |
| 447 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 448 | } else { //FP |
| 449 | //Any comparison between 2 values should be codegened as an folded branch, as moving |
| 450 | //CC to the integer register is very expensive |
| 451 | //for a cmp b: c = a - b; |
| 452 | //a = b: c = 0 |
| 453 | //a < b: c < 0 |
| 454 | //a > b: c > 0 |
| 455 | unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); |
| 456 | unsigned Tmp2 = SelectExpr(SetCC->getOperand(1)); |
| 457 | unsigned Tmp3 = MakeReg(MVT::f64); |
| 458 | BuildMI(BB, Alpha::SUBT, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); |
| 459 | |
| 460 | switch (SetCC->getCondition()) { |
| 461 | default: CC.Val->dump(); assert(0 && "Unknown FP comparison!"); |
| 462 | case ISD::SETEQ: Opc = Alpha::FBEQ; break; |
| 463 | case ISD::SETLT: Opc = Alpha::FBLT; break; |
| 464 | case ISD::SETLE: Opc = Alpha::FBLE; break; |
| 465 | case ISD::SETGT: Opc = Alpha::FBGT; break; |
| 466 | case ISD::SETGE: Opc = Alpha::FBGE; break; |
| 467 | case ISD::SETNE: Opc = Alpha::FBNE; break; |
| 468 | } |
| 469 | BuildMI(BB, Opc, 2).addReg(Tmp3).addMBB(Dest); |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 470 | return; |
| 471 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 472 | abort(); //Should never be reached |
| 473 | } else { |
| 474 | //Giveup and do the stupid thing |
| 475 | unsigned Tmp1 = SelectExpr(CC); |
| 476 | BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); |
| 477 | return; |
| 478 | } |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 479 | abort(); //Should never be reached |
| 480 | } |
| 481 | |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 482 | unsigned ISel::SelectExprFP(SDOperand N, unsigned Result) |
| 483 | { |
| 484 | unsigned Tmp1, Tmp2, Tmp3; |
| 485 | unsigned Opc = 0; |
| 486 | SDNode *Node = N.Val; |
| 487 | MVT::ValueType DestType = N.getValueType(); |
| 488 | unsigned opcode = N.getOpcode(); |
| 489 | |
| 490 | switch (opcode) { |
| 491 | default: |
| 492 | Node->dump(); |
| 493 | assert(0 && "Node not handled!\n"); |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 494 | |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 495 | case ISD::SELECT: |
| 496 | { |
| 497 | Tmp1 = SelectExpr(N.getOperand(0)); //Cond |
| 498 | Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE |
| 499 | Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE |
Andrew Lenharth | d4bdd54 | 2005-02-05 16:41:03 +0000 | [diff] [blame] | 500 | |
| 501 | |
| 502 | // Spill the cond to memory and reload it from there. |
| 503 | unsigned Size = MVT::getSizeInBits(MVT::f64)/8; |
| 504 | MachineFunction *F = BB->getParent(); |
| 505 | int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); |
| 506 | unsigned Tmp4 = MakeReg(MVT::f64); |
| 507 | BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); |
| 508 | BuildMI(BB, Alpha::LDT, 2, Tmp4).addFrameIndex(FrameIdx).addReg(Alpha::F31); |
| 509 | //now ideally, we don't have to do anything to the flag... |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 510 | // Get the condition into the zero flag. |
Andrew Lenharth | d4bdd54 | 2005-02-05 16:41:03 +0000 | [diff] [blame] | 511 | BuildMI(BB, Alpha::FCMOVEQ, 2, Result).addReg(Tmp2).addReg(Tmp3).addReg(Tmp4); |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 512 | return Result; |
| 513 | } |
| 514 | |
Andrew Lenharth | c1faced | 2005-02-01 01:37:24 +0000 | [diff] [blame] | 515 | case ISD::FP_ROUND: |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 516 | assert (DestType == MVT::f32 && |
| 517 | N.getOperand(0).getValueType() == MVT::f64 && |
| 518 | "only f64 to f32 conversion supported here"); |
Andrew Lenharth | c1faced | 2005-02-01 01:37:24 +0000 | [diff] [blame] | 519 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 520 | BuildMI(BB, Alpha::CVTTS, 1, Result).addReg(Tmp1); |
| 521 | return Result; |
| 522 | |
Andrew Lenharth | 7b2a527 | 2005-01-30 20:42:36 +0000 | [diff] [blame] | 523 | case ISD::FP_EXTEND: |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 524 | assert (DestType == MVT::f64 && |
| 525 | N.getOperand(0).getValueType() == MVT::f32 && |
| 526 | "only f32 to f64 conversion supported here"); |
Andrew Lenharth | 7b2a527 | 2005-01-30 20:42:36 +0000 | [diff] [blame] | 527 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 528 | BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); |
| 529 | return Result; |
| 530 | |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 531 | case ISD::CopyFromReg: |
| 532 | { |
| 533 | // Make sure we generate both values. |
| 534 | if (Result != notIn) |
| 535 | ExprMap[N.getValue(1)] = notIn; // Generate the token |
| 536 | else |
| 537 | Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); |
| 538 | |
| 539 | SDOperand Chain = N.getOperand(0); |
| 540 | |
| 541 | Select(Chain); |
| 542 | unsigned r = dyn_cast<RegSDNode>(Node)->getReg(); |
| 543 | //std::cerr << "CopyFromReg " << Result << " = " << r << "\n"; |
| 544 | BuildMI(BB, Alpha::CPYS, 2, Result).addReg(r).addReg(r); |
| 545 | return Result; |
| 546 | } |
| 547 | |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 548 | case ISD::LOAD: |
| 549 | { |
| 550 | // Make sure we generate both values. |
| 551 | if (Result != notIn) |
| 552 | ExprMap[N.getValue(1)] = notIn; // Generate the token |
| 553 | else |
| 554 | Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); |
Andrew Lenharth | 12dd262 | 2005-02-03 21:01:15 +0000 | [diff] [blame] | 555 | |
Andrew Lenharth | 2921916 | 2005-02-07 06:31:44 +0000 | [diff] [blame] | 556 | DestType = N.getValue(0).getValueType(); |
Andrew Lenharth | 12dd262 | 2005-02-03 21:01:15 +0000 | [diff] [blame] | 557 | |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 558 | SDOperand Chain = N.getOperand(0); |
| 559 | SDOperand Address = N.getOperand(1); |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 560 | Select(Chain); |
Andrew Lenharth | 6583890 | 2005-02-06 16:22:15 +0000 | [diff] [blame] | 561 | Opc = DestType == MVT::f64 ? Alpha::LDT : Alpha::LDS; |
| 562 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 563 | if (Address.getOpcode() == ISD::GlobalAddress) { |
| 564 | AlphaLowering.restoreGP(BB); |
| 565 | Opc = GetSymVersion(Opc); |
| 566 | BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal()); |
| 567 | } |
Andrew Lenharth | e76797c | 2005-02-01 20:40:27 +0000 | [diff] [blame] | 568 | else if (ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Address)) { |
Andrew Lenharth | d4bdd54 | 2005-02-05 16:41:03 +0000 | [diff] [blame] | 569 | AlphaLowering.restoreGP(BB); |
Andrew Lenharth | 6583890 | 2005-02-06 16:22:15 +0000 | [diff] [blame] | 570 | Opc = GetSymVersion(Opc); |
Andrew Lenharth | 97127a1 | 2005-02-05 17:41:39 +0000 | [diff] [blame] | 571 | BuildMI(BB, Opc, 1, Result).addConstantPoolIndex(CP->getIndex()); |
Andrew Lenharth | e76797c | 2005-02-01 20:40:27 +0000 | [diff] [blame] | 572 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 573 | else if(Address.getOpcode() == ISD::FrameIndex) { |
| 574 | Tmp1 = cast<FrameIndexSDNode>(Address)->getIndex(); |
| 575 | BuildMI(BB, Opc, 2, Result).addFrameIndex(Tmp1).addReg(Alpha::F31); |
| 576 | } else { |
| 577 | long offset; |
| 578 | SelectAddr(Address, Tmp1, offset); |
| 579 | BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1); |
| 580 | } |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 581 | return Result; |
| 582 | } |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 583 | case ISD::ConstantFP: |
| 584 | if (ConstantFPSDNode *CN = dyn_cast<ConstantFPSDNode>(N)) { |
| 585 | if (CN->isExactlyValue(+0.0)) { |
| 586 | BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F31).addReg(Alpha::F31); |
Andrew Lenharth | 12dd262 | 2005-02-03 21:01:15 +0000 | [diff] [blame] | 587 | } else if ( CN->isExactlyValue(-0.0)) { |
| 588 | BuildMI(BB, Alpha::CPYSN, 2, Result).addReg(Alpha::F31).addReg(Alpha::F31); |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 589 | } else { |
| 590 | abort(); |
| 591 | } |
| 592 | } |
| 593 | return Result; |
| 594 | |
| 595 | case ISD::MUL: |
| 596 | case ISD::ADD: |
| 597 | case ISD::SUB: |
| 598 | case ISD::SDIV: |
| 599 | switch( opcode ) { |
| 600 | case ISD::MUL: Opc = DestType == MVT::f64 ? Alpha::MULT : Alpha::MULS; break; |
| 601 | case ISD::ADD: Opc = DestType == MVT::f64 ? Alpha::ADDT : Alpha::ADDS; break; |
| 602 | case ISD::SUB: Opc = DestType == MVT::f64 ? Alpha::SUBT : Alpha::SUBS; break; |
| 603 | case ISD::SDIV: Opc = DestType == MVT::f64 ? Alpha::DIVT : Alpha::DIVS; break; |
| 604 | }; |
| 605 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 606 | Tmp2 = SelectExpr(N.getOperand(1)); |
| 607 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); |
| 608 | return Result; |
| 609 | |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 610 | case ISD::EXTLOAD: |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 611 | { |
| 612 | //include a conversion sequence for float loads to double |
| 613 | if (Result != notIn) |
| 614 | ExprMap[N.getValue(1)] = notIn; // Generate the token |
| 615 | else |
| 616 | Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); |
| 617 | |
Andrew Lenharth | a549deb | 2005-02-07 05:33:15 +0000 | [diff] [blame] | 618 | Tmp1 = MakeReg(MVT::f32); |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 619 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 620 | assert(cast<MVTSDNode>(Node)->getExtraValueType() == MVT::f32 && |
| 621 | "EXTLOAD not from f32"); |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 622 | assert(Node->getValueType(0) == MVT::f64 && "EXTLOAD not to f64"); |
| 623 | |
| 624 | SDOperand Chain = N.getOperand(0); |
| 625 | SDOperand Address = N.getOperand(1); |
| 626 | Select(Chain); |
| 627 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 628 | if (Address.getOpcode() == ISD::GlobalAddress) { |
| 629 | AlphaLowering.restoreGP(BB); |
| 630 | BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal()); |
| 631 | } |
| 632 | else if (ConstantPoolSDNode *CP = |
| 633 | dyn_cast<ConstantPoolSDNode>(N.getOperand(1))) |
| 634 | { |
| 635 | AlphaLowering.restoreGP(BB); |
| 636 | BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addConstantPoolIndex(CP->getIndex()); |
| 637 | } |
| 638 | else if(Address.getOpcode() == ISD::FrameIndex) { |
| 639 | Tmp2 = cast<FrameIndexSDNode>(Address)->getIndex(); |
| 640 | BuildMI(BB, Alpha::LDS, 2, Tmp1).addFrameIndex(Tmp2).addReg(Alpha::F31); |
| 641 | } else { |
| 642 | long offset; |
| 643 | SelectAddr(Address, Tmp2, offset); |
| 644 | BuildMI(BB, Alpha::LDS, 1, Tmp1).addImm(offset).addReg(Tmp2); |
| 645 | } |
Andrew Lenharth | 2921916 | 2005-02-07 06:31:44 +0000 | [diff] [blame] | 646 | BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); |
Andrew Lenharth | 12dd262 | 2005-02-03 21:01:15 +0000 | [diff] [blame] | 647 | return Result; |
| 648 | } |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 649 | |
Andrew Lenharth | e76797c | 2005-02-01 20:40:27 +0000 | [diff] [blame] | 650 | case ISD::UINT_TO_FP: |
| 651 | case ISD::SINT_TO_FP: |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 652 | { |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 653 | assert (N.getOperand(0).getValueType() == MVT::i64 |
| 654 | && "only quads can be loaded from"); |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 655 | Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register |
Andrew Lenharth | 7efadce | 2005-01-31 01:44:26 +0000 | [diff] [blame] | 656 | Tmp2 = MakeReg(MVT::f64); |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 657 | |
| 658 | //The hard way: |
| 659 | // Spill the integer to memory and reload it from there. |
| 660 | unsigned Size = MVT::getSizeInBits(MVT::i64)/8; |
| 661 | MachineFunction *F = BB->getParent(); |
| 662 | int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, Size); |
| 663 | |
Andrew Lenharth | 7efadce | 2005-01-31 01:44:26 +0000 | [diff] [blame] | 664 | BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); |
| 665 | BuildMI(BB, Alpha::LDT, 2, Tmp2).addFrameIndex(FrameIdx).addReg(Alpha::F31); |
| 666 | Opc = DestType == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS; |
| 667 | BuildMI(BB, Opc, 1, Result).addReg(Tmp2); |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 668 | |
| 669 | //The easy way: doesn't work |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 670 | // //so these instructions are not supported on ev56 |
| 671 | // Opc = DestType == MVT::f64 ? Alpha::ITOFT : Alpha::ITOFS; |
| 672 | // BuildMI(BB, Opc, 1, Tmp2).addReg(Tmp1); |
| 673 | // Opc = DestType == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS; |
| 674 | // BuildMI(BB, Opc, 1, Result).addReg(Tmp1); |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 675 | |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 676 | return Result; |
| 677 | } |
| 678 | } |
| 679 | assert(0 && "should not get here"); |
| 680 | return 0; |
| 681 | } |
| 682 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 683 | unsigned ISel::SelectExpr(SDOperand N) { |
| 684 | unsigned Result; |
| 685 | unsigned Tmp1, Tmp2, Tmp3; |
| 686 | unsigned Opc = 0; |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 687 | unsigned opcode = N.getOpcode(); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 688 | |
| 689 | SDNode *Node = N.Val; |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 690 | MVT::ValueType DestType = N.getValueType(); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 691 | |
| 692 | unsigned &Reg = ExprMap[N]; |
| 693 | if (Reg) return Reg; |
| 694 | |
| 695 | if (N.getOpcode() != ISD::CALL) |
| 696 | Reg = Result = (N.getValueType() != MVT::Other) ? |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 697 | MakeReg(N.getValueType()) : notIn; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 698 | else { |
| 699 | // If this is a call instruction, make sure to prepare ALL of the result |
| 700 | // values as well as the chain. |
| 701 | if (Node->getNumValues() == 1) |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 702 | Reg = Result = notIn; // Void call, just a chain. |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 703 | else { |
| 704 | Result = MakeReg(Node->getValueType(0)); |
| 705 | ExprMap[N.getValue(0)] = Result; |
| 706 | for (unsigned i = 1, e = N.Val->getNumValues()-1; i != e; ++i) |
| 707 | ExprMap[N.getValue(i)] = MakeReg(Node->getValueType(i)); |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 708 | ExprMap[SDOperand(Node, Node->getNumValues()-1)] = notIn; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 709 | } |
| 710 | } |
| 711 | |
Andrew Lenharth | 22088bb | 2005-02-02 15:05:33 +0000 | [diff] [blame] | 712 | if (DestType == MVT::f64 || DestType == MVT::f32 || |
Andrew Lenharth | 06342c3 | 2005-02-07 06:21:37 +0000 | [diff] [blame] | 713 | ( |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 714 | (opcode == ISD::LOAD || opcode == ISD::CopyFromReg || |
| 715 | opcode == ISD::EXTLOAD) && |
| 716 | (N.getValue(0).getValueType() == MVT::f32 || |
| 717 | N.getValue(0).getValueType() == MVT::f64) |
Andrew Lenharth | 06342c3 | 2005-02-07 06:21:37 +0000 | [diff] [blame] | 718 | ) |
| 719 | ) |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 720 | return SelectExprFP(N, Result); |
| 721 | |
| 722 | switch (opcode) { |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 723 | default: |
| 724 | Node->dump(); |
| 725 | assert(0 && "Node not handled!\n"); |
| 726 | |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 727 | case ISD::ConstantPool: |
| 728 | Tmp1 = cast<ConstantPoolSDNode>(N)->getIndex(); |
| 729 | AlphaLowering.restoreGP(BB); |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 730 | BuildMI(BB, Alpha::LDQ_SYM, 1, Result).addConstantPoolIndex(Tmp1); |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 731 | return Result; |
| 732 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 733 | case ISD::FrameIndex: |
| 734 | Tmp1 = cast<FrameIndexSDNode>(N)->getIndex(); |
Andrew Lenharth | 684f229 | 2005-01-30 00:35:27 +0000 | [diff] [blame] | 735 | BuildMI(BB, Alpha::LDA, 2, Result).addFrameIndex(Tmp1).addReg(Alpha::F31); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 736 | return Result; |
| 737 | |
| 738 | case ISD::EXTLOAD: |
Andrew Lenharth | f311e8b | 2005-02-07 05:18:02 +0000 | [diff] [blame] | 739 | case ISD::ZEXTLOAD: |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 740 | case ISD::SEXTLOAD: |
Andrew Lenharth | a549deb | 2005-02-07 05:33:15 +0000 | [diff] [blame] | 741 | case ISD::LOAD: |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 742 | { |
| 743 | // Make sure we generate both values. |
| 744 | if (Result != notIn) |
| 745 | ExprMap[N.getValue(1)] = notIn; // Generate the token |
| 746 | else |
| 747 | Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 748 | |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 749 | SDOperand Chain = N.getOperand(0); |
| 750 | SDOperand Address = N.getOperand(1); |
| 751 | Select(Chain); |
| 752 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 753 | assert(Node->getValueType(0) == MVT::i64 && |
| 754 | "Unknown type to sign extend to."); |
Andrew Lenharth | 0382401 | 2005-02-07 05:55:55 +0000 | [diff] [blame] | 755 | if (opcode == ISD::LOAD) |
| 756 | Opc = Alpha::LDQ; |
| 757 | else |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 758 | switch (cast<MVTSDNode>(Node)->getExtraValueType()) { |
| 759 | default: Node->dump(); assert(0 && "Bad sign extend!"); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 760 | case MVT::i32: Opc = Alpha::LDL; |
| 761 | assert(opcode != ISD::ZEXTLOAD && "Not sext"); break; |
| 762 | case MVT::i16: Opc = Alpha::LDWU; |
| 763 | assert(opcode != ISD::SEXTLOAD && "Not zext"); break; |
Andrew Lenharth | f311e8b | 2005-02-07 05:18:02 +0000 | [diff] [blame] | 764 | case MVT::i1: //FIXME: Treat i1 as i8 since there are problems otherwise |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 765 | case MVT::i8: Opc = Alpha::LDBU; |
| 766 | assert(opcode != ISD::SEXTLOAD && "Not zext"); break; |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 767 | } |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 768 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 769 | if (Address.getOpcode() == ISD::GlobalAddress) { |
| 770 | AlphaLowering.restoreGP(BB); |
| 771 | Opc = GetSymVersion(Opc); |
| 772 | BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal()); |
| 773 | } |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 774 | else if (ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Address)) { |
| 775 | AlphaLowering.restoreGP(BB); |
Andrew Lenharth | 6583890 | 2005-02-06 16:22:15 +0000 | [diff] [blame] | 776 | Opc = GetSymVersion(Opc); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 777 | BuildMI(BB, Opc, 1, Result).addConstantPoolIndex(CP->getIndex()); |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 778 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 779 | else if(Address.getOpcode() == ISD::FrameIndex) { |
| 780 | Tmp1 = cast<FrameIndexSDNode>(Address)->getIndex(); |
| 781 | BuildMI(BB, Opc, 2, Result).addFrameIndex(Tmp1).addReg(Alpha::F31); |
| 782 | } else { |
| 783 | long offset; |
| 784 | SelectAddr(Address, Tmp1, offset); |
| 785 | BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1); |
| 786 | } |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 787 | return Result; |
Andrew Lenharth | 2f8fb77 | 2005-01-25 00:35:34 +0000 | [diff] [blame] | 788 | } |
Andrew Lenharth | 2f8fb77 | 2005-01-25 00:35:34 +0000 | [diff] [blame] | 789 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 790 | case ISD::GlobalAddress: |
| 791 | AlphaLowering.restoreGP(BB); |
| 792 | BuildMI(BB, Alpha::LOAD_ADDR, 1, Result) |
| 793 | .addGlobalAddress(cast<GlobalAddressSDNode>(N)->getGlobal()); |
| 794 | return Result; |
| 795 | |
| 796 | case ISD::CALL: |
| 797 | { |
| 798 | Select(N.getOperand(0)); |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 799 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 800 | // The chain for this call is now lowered. |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 801 | ExprMap.insert(std::make_pair(N.getValue(Node->getNumValues()-1), notIn)); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 802 | |
| 803 | //grab the arguments |
| 804 | std::vector<unsigned> argvregs; |
Andrew Lenharth | 7b2a527 | 2005-01-30 20:42:36 +0000 | [diff] [blame] | 805 | //assert(Node->getNumOperands() < 8 && "Only 6 args supported"); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 806 | for(int i = 2, e = Node->getNumOperands(); i < e; ++i) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 807 | argvregs.push_back(SelectExpr(N.getOperand(i))); |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 808 | |
Andrew Lenharth | 684f229 | 2005-01-30 00:35:27 +0000 | [diff] [blame] | 809 | //in reg args |
| 810 | for(int i = 0, e = std::min(6, (int)argvregs.size()); i < e; ++i) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 811 | { |
| 812 | unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18, |
| 813 | Alpha::R19, Alpha::R20, Alpha::R21}; |
| 814 | unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, |
| 815 | Alpha::F19, Alpha::F20, Alpha::F21}; |
| 816 | switch(N.getOperand(i+2).getValueType()) { |
| 817 | default: |
| 818 | Node->dump(); |
| 819 | N.getOperand(i).Val->dump(); |
| 820 | std::cerr << "Type for " << i << " is: " << |
| 821 | N.getOperand(i+2).getValueType() << "\n"; |
| 822 | assert(0 && "Unknown value type for call"); |
| 823 | case MVT::i1: |
| 824 | case MVT::i8: |
| 825 | case MVT::i16: |
| 826 | case MVT::i32: |
| 827 | case MVT::i64: |
| 828 | BuildMI(BB, Alpha::BIS, 2, args_int[i]).addReg(argvregs[i]).addReg(argvregs[i]); |
| 829 | break; |
| 830 | case MVT::f32: |
| 831 | case MVT::f64: |
| 832 | BuildMI(BB, Alpha::CPYS, 2, args_float[i]).addReg(argvregs[i]).addReg(argvregs[i]); |
| 833 | break; |
Andrew Lenharth | 684f229 | 2005-01-30 00:35:27 +0000 | [diff] [blame] | 834 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 835 | } |
Andrew Lenharth | 684f229 | 2005-01-30 00:35:27 +0000 | [diff] [blame] | 836 | //in mem args |
| 837 | for (int i = 6, e = argvregs.size(); i < e; ++i) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 838 | { |
| 839 | switch(N.getOperand(i+2).getValueType()) { |
| 840 | default: |
| 841 | Node->dump(); |
| 842 | N.getOperand(i).Val->dump(); |
| 843 | std::cerr << "Type for " << i << " is: " << |
| 844 | N.getOperand(i+2).getValueType() << "\n"; |
| 845 | assert(0 && "Unknown value type for call"); |
| 846 | case MVT::i1: |
| 847 | case MVT::i8: |
| 848 | case MVT::i16: |
| 849 | case MVT::i32: |
| 850 | case MVT::i64: |
| 851 | BuildMI(BB, Alpha::STQ, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); |
| 852 | break; |
| 853 | case MVT::f32: |
| 854 | BuildMI(BB, Alpha::STS, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); |
| 855 | break; |
| 856 | case MVT::f64: |
| 857 | BuildMI(BB, Alpha::STT, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); |
| 858 | break; |
Andrew Lenharth | 684f229 | 2005-01-30 00:35:27 +0000 | [diff] [blame] | 859 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 860 | } |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 861 | //build the right kind of call |
| 862 | if (GlobalAddressSDNode *GASD = |
Andrew Lenharth | 7b2a527 | 2005-01-30 20:42:36 +0000 | [diff] [blame] | 863 | dyn_cast<GlobalAddressSDNode>(N.getOperand(1))) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 864 | { |
| 865 | if (GASD->getGlobal()->isExternal()) { |
| 866 | //use safe calling convention |
Andrew Lenharth | 7b2a527 | 2005-01-30 20:42:36 +0000 | [diff] [blame] | 867 | AlphaLowering.restoreGP(BB); |
| 868 | BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 869 | } else { |
| 870 | //use PC relative branch call |
| 871 | BuildMI(BB, Alpha::BSR, 1, Alpha::R26).addGlobalAddress(GASD->getGlobal(),true); |
| 872 | } |
| 873 | } |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 874 | else if (ExternalSymbolSDNode *ESSDN = |
Andrew Lenharth | 7b2a527 | 2005-01-30 20:42:36 +0000 | [diff] [blame] | 875 | dyn_cast<ExternalSymbolSDNode>(N.getOperand(1))) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 876 | { |
| 877 | AlphaLowering.restoreGP(BB); |
| 878 | BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); |
| 879 | } else { |
| 880 | //no need to restore GP as we are doing an indirect call |
| 881 | Tmp1 = SelectExpr(N.getOperand(1)); |
| 882 | BuildMI(BB, Alpha::BIS, 2, Alpha::R27).addReg(Tmp1).addReg(Tmp1); |
| 883 | BuildMI(BB, Alpha::JSR, 2, Alpha::R26).addReg(Alpha::R27).addImm(0); |
| 884 | } |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 885 | |
| 886 | //push the result into a virtual register |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 887 | |
| 888 | switch (Node->getValueType(0)) { |
| 889 | default: Node->dump(); assert(0 && "Unknown value type for call result!"); |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 890 | case MVT::Other: return notIn; |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 891 | case MVT::i1: |
| 892 | case MVT::i8: |
| 893 | case MVT::i16: |
| 894 | case MVT::i32: |
| 895 | case MVT::i64: |
| 896 | BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R0).addReg(Alpha::R0); |
| 897 | break; |
| 898 | case MVT::f32: |
| 899 | case MVT::f64: |
| 900 | BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F0).addReg(Alpha::F0); |
| 901 | break; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 902 | } |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 903 | return Result+N.ResNo; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 904 | } |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 905 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 906 | case ISD::SIGN_EXTEND: |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 907 | abort(); |
| 908 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 909 | case ISD::SIGN_EXTEND_INREG: |
| 910 | { |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 911 | //Alpha has instructions for a bunch of signed 32 bit stuff |
| 912 | if( dyn_cast<MVTSDNode>(Node)->getExtraValueType() == MVT::i32) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 913 | { |
| 914 | switch (N.getOperand(0).getOpcode()) { |
| 915 | case ISD::ADD: |
| 916 | case ISD::SUB: |
| 917 | case ISD::MUL: |
| 918 | { |
| 919 | bool isAdd = N.getOperand(0).getOpcode() == ISD::ADD; |
| 920 | bool isMul = N.getOperand(0).getOpcode() == ISD::MUL; |
| 921 | //FIXME: first check for Scaled Adds and Subs! |
| 922 | if(N.getOperand(0).getOperand(1).getOpcode() == ISD::Constant && |
| 923 | cast<ConstantSDNode>(N.getOperand(0).getOperand(1))->getValue() <= 255) |
| 924 | { //Normal imm add/sub |
| 925 | Opc = isAdd ? Alpha::ADDLi : (isMul ? Alpha::MULLi : Alpha::SUBLi); |
| 926 | Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); |
| 927 | Tmp2 = cast<ConstantSDNode>(N.getOperand(0).getOperand(1))->getValue(); |
| 928 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 929 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 930 | else |
| 931 | { //Normal add/sub |
| 932 | Opc = isAdd ? Alpha::ADDL : (isMul ? Alpha::MULLi : Alpha::SUBL); |
| 933 | Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); |
| 934 | Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); |
| 935 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); |
| 936 | } |
| 937 | return Result; |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 938 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 939 | default: break; //Fall Though; |
| 940 | } |
| 941 | } //Every thing else fall though too, including unhandled opcodes above |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 942 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 943 | MVTSDNode* MVN = dyn_cast<MVTSDNode>(Node); |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 944 | //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 945 | switch(MVN->getExtraValueType()) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 946 | { |
| 947 | default: |
| 948 | Node->dump(); |
| 949 | assert(0 && "Sign Extend InReg not there yet"); |
| 950 | break; |
| 951 | case MVT::i32: |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 952 | { |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 953 | BuildMI(BB, Alpha::ADDLi, 2, Result).addReg(Tmp1).addImm(0); |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 954 | break; |
| 955 | } |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 956 | case MVT::i16: |
| 957 | BuildMI(BB, Alpha::SEXTW, 1, Result).addReg(Tmp1); |
| 958 | break; |
| 959 | case MVT::i8: |
| 960 | BuildMI(BB, Alpha::SEXTB, 1, Result).addReg(Tmp1); |
| 961 | break; |
| 962 | } |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 963 | return Result; |
| 964 | } |
| 965 | case ISD::ZERO_EXTEND_INREG: |
| 966 | { |
| 967 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 968 | MVTSDNode* MVN = dyn_cast<MVTSDNode>(Node); |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 969 | //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 970 | switch(MVN->getExtraValueType()) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 971 | { |
| 972 | default: |
| 973 | Node->dump(); |
| 974 | assert(0 && "Zero Extend InReg not there yet"); |
| 975 | break; |
| 976 | case MVT::i32: Tmp2 = 0xf0; break; |
| 977 | case MVT::i16: Tmp2 = 0xfc; break; |
| 978 | case MVT::i8: Tmp2 = 0xfe; break; |
| 979 | case MVT::i1: //handle this one special |
| 980 | BuildMI(BB, Alpha::ANDi, 2, Result).addReg(Tmp1).addImm(1); |
| 981 | return Result; |
| 982 | } |
Andrew Lenharth | 2f8fb77 | 2005-01-25 00:35:34 +0000 | [diff] [blame] | 983 | BuildMI(BB, Alpha::ZAPi, 2, Result).addReg(Tmp1).addImm(Tmp2); |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 984 | return Result; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 985 | } |
| 986 | |
| 987 | case ISD::SETCC: |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 988 | { |
| 989 | if (SetCCSDNode *SetCC = dyn_cast<SetCCSDNode>(Node)) { |
| 990 | if (MVT::isInteger(SetCC->getOperand(0).getValueType())) { |
| 991 | bool isConst1 = false; |
| 992 | bool isConst2 = false; |
| 993 | int dir; |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 994 | |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 995 | //Tmp1 = SelectExpr(N.getOperand(0)); |
| 996 | if(N.getOperand(0).getOpcode() == ISD::Constant && |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 997 | cast<ConstantSDNode>(N.getOperand(0))->getValue() <= 255) |
| 998 | isConst1 = true; |
| 999 | if(N.getOperand(1).getOpcode() == ISD::Constant && |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 1000 | cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 255) |
| 1001 | isConst2 = true; |
| 1002 | |
| 1003 | switch (SetCC->getCondition()) { |
| 1004 | default: Node->dump(); assert(0 && "Unknown integer comparison!"); |
| 1005 | case ISD::SETEQ: Opc = Alpha::CMPEQ; dir=0; break; |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1006 | case ISD::SETLT: |
| 1007 | Opc = isConst2 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 1; break; |
| 1008 | case ISD::SETLE: |
| 1009 | Opc = isConst2 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 1; break; |
| 1010 | case ISD::SETGT: |
| 1011 | Opc = isConst1 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 2; break; |
| 1012 | case ISD::SETGE: |
| 1013 | Opc = isConst1 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 2; break; |
| 1014 | case ISD::SETULT: |
| 1015 | Opc = isConst2 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 1; break; |
| 1016 | case ISD::SETUGT: |
| 1017 | Opc = isConst1 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 2; break; |
| 1018 | case ISD::SETULE: |
| 1019 | Opc = isConst2 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 1; break; |
| 1020 | case ISD::SETUGE: |
| 1021 | Opc = isConst1 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 2; break; |
Andrew Lenharth | d2bb960 | 2005-01-27 07:50:35 +0000 | [diff] [blame] | 1022 | case ISD::SETNE: {//Handle this one special |
| 1023 | //std::cerr << "Alpha does not have a setne.\n"; |
| 1024 | //abort(); |
| 1025 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1026 | Tmp2 = SelectExpr(N.getOperand(1)); |
| 1027 | Tmp3 = MakeReg(MVT::i64); |
| 1028 | BuildMI(BB, Alpha::CMPEQ, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 1029 | //Remeber we have the Inv for this CC |
| 1030 | CCInvMap[N] = Tmp3; |
Andrew Lenharth | d2bb960 | 2005-01-27 07:50:35 +0000 | [diff] [blame] | 1031 | //and invert |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 1032 | BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Alpha::R31).addReg(Tmp3); |
Andrew Lenharth | d2bb960 | 2005-01-27 07:50:35 +0000 | [diff] [blame] | 1033 | return Result; |
| 1034 | } |
| 1035 | } |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 1036 | if (dir == 1) { |
| 1037 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1038 | if (isConst2) { |
| 1039 | Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue(); |
| 1040 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); |
| 1041 | } else { |
| 1042 | Tmp2 = SelectExpr(N.getOperand(1)); |
| 1043 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); |
| 1044 | } |
| 1045 | } else if (dir == 2) { |
| 1046 | Tmp1 = SelectExpr(N.getOperand(1)); |
Andrew Lenharth | 6b9870a | 2005-01-28 14:06:46 +0000 | [diff] [blame] | 1047 | if (isConst1) { |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 1048 | Tmp2 = cast<ConstantSDNode>(N.getOperand(0))->getValue(); |
| 1049 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); |
| 1050 | } else { |
| 1051 | Tmp2 = SelectExpr(N.getOperand(0)); |
| 1052 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); |
| 1053 | } |
| 1054 | } else { //dir == 0 |
| 1055 | if (isConst1) { |
| 1056 | Tmp1 = cast<ConstantSDNode>(N.getOperand(0))->getValue(); |
| 1057 | Tmp2 = SelectExpr(N.getOperand(1)); |
| 1058 | BuildMI(BB, Alpha::CMPEQi, 2, Result).addReg(Tmp2).addImm(Tmp1); |
| 1059 | } else if (isConst2) { |
| 1060 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1061 | Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue(); |
| 1062 | BuildMI(BB, Alpha::CMPEQi, 2, Result).addReg(Tmp1).addImm(Tmp2); |
| 1063 | } else { |
| 1064 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1065 | Tmp2 = SelectExpr(N.getOperand(1)); |
| 1066 | BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp1).addReg(Tmp2); |
| 1067 | } |
Andrew Lenharth | d4bdd54 | 2005-02-05 16:41:03 +0000 | [diff] [blame] | 1068 | } |
| 1069 | } else { |
| 1070 | //assert(SetCC->getOperand(0).getValueType() != MVT::f32 && "SetCC f32 should have been promoted"); |
| 1071 | bool rev = false; |
| 1072 | bool inv = false; |
| 1073 | |
| 1074 | switch (SetCC->getCondition()) { |
| 1075 | default: Node->dump(); assert(0 && "Unknown FP comparison!"); |
| 1076 | case ISD::SETEQ: Opc = Alpha::CMPTEQ; break; |
| 1077 | case ISD::SETLT: Opc = Alpha::CMPTLT; break; |
| 1078 | case ISD::SETLE: Opc = Alpha::CMPTLE; break; |
| 1079 | case ISD::SETGT: Opc = Alpha::CMPTLT; rev = true; break; |
| 1080 | case ISD::SETGE: Opc = Alpha::CMPTLE; rev = true; break; |
| 1081 | case ISD::SETNE: Opc = Alpha::CMPTEQ; inv = true; break; |
| 1082 | } |
| 1083 | |
| 1084 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1085 | Tmp2 = SelectExpr(N.getOperand(1)); |
| 1086 | //Can only compare doubles, and dag won't promote for me |
| 1087 | if (SetCC->getOperand(0).getValueType() == MVT::f32) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1088 | { |
| 1089 | Tmp3 = MakeReg(MVT::f64); |
| 1090 | BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp1); |
| 1091 | Tmp1 = Tmp3; |
| 1092 | } |
Andrew Lenharth | d4bdd54 | 2005-02-05 16:41:03 +0000 | [diff] [blame] | 1093 | if (SetCC->getOperand(1).getValueType() == MVT::f32) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1094 | { |
| 1095 | Tmp3 = MakeReg(MVT::f64); |
| 1096 | BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp2); |
| 1097 | Tmp1 = Tmp2; |
| 1098 | } |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 1099 | |
Andrew Lenharth | d4bdd54 | 2005-02-05 16:41:03 +0000 | [diff] [blame] | 1100 | if (rev) std::swap(Tmp1, Tmp2); |
| 1101 | Tmp3 = MakeReg(MVT::f64); |
| 1102 | //do the comparison |
| 1103 | BuildMI(BB, Opc, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); |
| 1104 | |
| 1105 | //now arrange for Result (int) to have a 1 or 0 |
| 1106 | |
| 1107 | // Spill the FP to memory and reload it from there. |
| 1108 | unsigned Size = MVT::getSizeInBits(MVT::f64)/8; |
| 1109 | MachineFunction *F = BB->getParent(); |
| 1110 | int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); |
| 1111 | unsigned Tmp4 = MakeReg(MVT::f64); |
| 1112 | BuildMI(BB, Alpha::CVTTQ, 1, Tmp4).addReg(Tmp3); |
| 1113 | BuildMI(BB, Alpha::STT, 3).addReg(Tmp4).addFrameIndex(FrameIdx).addReg(Alpha::F31); |
| 1114 | unsigned Tmp5 = MakeReg(MVT::i64); |
| 1115 | BuildMI(BB, Alpha::LDQ, 2, Tmp5).addFrameIndex(FrameIdx).addReg(Alpha::F31); |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 1116 | |
Andrew Lenharth | d4bdd54 | 2005-02-05 16:41:03 +0000 | [diff] [blame] | 1117 | //now, set result based on Tmp5 |
| 1118 | //Set Tmp6 if fp cmp was false |
| 1119 | unsigned Tmp6 = MakeReg(MVT::i64); |
| 1120 | BuildMI(BB, Alpha::CMPEQ, 2, Tmp6).addReg(Tmp5).addReg(Alpha::R31); |
| 1121 | //and invert |
| 1122 | BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp6).addReg(Alpha::R31); |
| 1123 | |
| 1124 | } |
| 1125 | // else |
| 1126 | // { |
| 1127 | // Node->dump(); |
| 1128 | // assert(0 && "Not a setcc in setcc"); |
| 1129 | // } |
Andrew Lenharth | 9818c05 | 2005-02-05 13:19:12 +0000 | [diff] [blame] | 1130 | } |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 1131 | return Result; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1132 | } |
Andrew Lenharth | 3d65d31 | 2005-01-27 03:49:45 +0000 | [diff] [blame] | 1133 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1134 | case ISD::CopyFromReg: |
| 1135 | { |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1136 | // Make sure we generate both values. |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 1137 | if (Result != notIn) |
| 1138 | ExprMap[N.getValue(1)] = notIn; // Generate the token |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1139 | else |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1140 | Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1141 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1142 | SDOperand Chain = N.getOperand(0); |
| 1143 | |
| 1144 | Select(Chain); |
| 1145 | unsigned r = dyn_cast<RegSDNode>(Node)->getReg(); |
| 1146 | //std::cerr << "CopyFromReg " << Result << " = " << r << "\n"; |
| 1147 | BuildMI(BB, Alpha::BIS, 2, Result).addReg(r).addReg(r); |
| 1148 | return Result; |
| 1149 | } |
| 1150 | |
Andrew Lenharth | 2d6f022 | 2005-01-24 19:44:07 +0000 | [diff] [blame] | 1151 | //Most of the plain arithmetic and logic share the same form, and the same |
| 1152 | //constant immediate test |
| 1153 | case ISD::AND: |
| 1154 | case ISD::OR: |
| 1155 | case ISD::XOR: |
| 1156 | case ISD::SHL: |
| 1157 | case ISD::SRL: |
Andrew Lenharth | 2c59435 | 2005-01-29 15:42:07 +0000 | [diff] [blame] | 1158 | case ISD::SRA: |
Andrew Lenharth | 2d6f022 | 2005-01-24 19:44:07 +0000 | [diff] [blame] | 1159 | case ISD::MUL: |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1160 | assert (DestType == MVT::i64 && "Only do arithmetic on i64s!"); |
| 1161 | if(N.getOperand(1).getOpcode() == ISD::Constant && |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1162 | cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 255) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1163 | { |
| 1164 | switch(opcode) { |
| 1165 | case ISD::AND: Opc = Alpha::ANDi; break; |
| 1166 | case ISD::OR: Opc = Alpha::BISi; break; |
| 1167 | case ISD::XOR: Opc = Alpha::XORi; break; |
| 1168 | case ISD::SHL: Opc = Alpha::SLi; break; |
| 1169 | case ISD::SRL: Opc = Alpha::SRLi; break; |
| 1170 | case ISD::SRA: Opc = Alpha::SRAi; break; |
| 1171 | case ISD::MUL: Opc = Alpha::MULQi; break; |
| 1172 | }; |
| 1173 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1174 | Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue(); |
| 1175 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); |
| 1176 | } else { |
| 1177 | switch(opcode) { |
| 1178 | case ISD::AND: Opc = Alpha::AND; break; |
| 1179 | case ISD::OR: Opc = Alpha::BIS; break; |
| 1180 | case ISD::XOR: Opc = Alpha::XOR; break; |
| 1181 | case ISD::SHL: Opc = Alpha::SL; break; |
| 1182 | case ISD::SRL: Opc = Alpha::SRL; break; |
| 1183 | case ISD::SRA: Opc = Alpha::SRA; break; |
| 1184 | case ISD::MUL: Opc = Alpha::MULQ; break; |
| 1185 | }; |
| 1186 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1187 | Tmp2 = SelectExpr(N.getOperand(1)); |
| 1188 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); |
| 1189 | } |
Andrew Lenharth | 2d6f022 | 2005-01-24 19:44:07 +0000 | [diff] [blame] | 1190 | return Result; |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1191 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1192 | case ISD::ADD: |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1193 | case ISD::SUB: |
Andrew Lenharth | 2f8fb77 | 2005-01-25 00:35:34 +0000 | [diff] [blame] | 1194 | { |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1195 | bool isAdd = opcode == ISD::ADD; |
| 1196 | |
| 1197 | //FIXME: first check for Scaled Adds and Subs! |
| 1198 | if(N.getOperand(1).getOpcode() == ISD::Constant && |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1199 | cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 255) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1200 | { //Normal imm add/sub |
| 1201 | Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; |
| 1202 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1203 | Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue(); |
| 1204 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); |
| 1205 | } |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1206 | else if(N.getOperand(1).getOpcode() == ISD::Constant && |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1207 | cast<ConstantSDNode>(N.getOperand(1))->getValue() <= 32767) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1208 | { //LDA //FIXME: expand the above condition a bit |
| 1209 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1210 | Tmp2 = cast<ConstantSDNode>(N.getOperand(1))->getValue(); |
| 1211 | if (!isAdd) |
| 1212 | Tmp2 = -Tmp2; |
| 1213 | BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); |
| 1214 | } else { |
| 1215 | //Normal add/sub |
| 1216 | Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ; |
| 1217 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1218 | Tmp2 = SelectExpr(N.getOperand(1)); |
| 1219 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); |
| 1220 | } |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 1221 | return Result; |
| 1222 | } |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1223 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1224 | case ISD::UREM: |
Andrew Lenharth | 0298118 | 2005-01-26 01:24:38 +0000 | [diff] [blame] | 1225 | case ISD::SREM: |
| 1226 | case ISD::SDIV: |
| 1227 | case ISD::UDIV: |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1228 | //FIXME: alpha really doesn't support any of these operations, |
| 1229 | // the ops are expanded into special library calls with |
| 1230 | // special calling conventions |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1231 | //Restore GP because it is a call after all... |
Andrew Lenharth | 40831c5 | 2005-01-28 06:57:18 +0000 | [diff] [blame] | 1232 | switch(opcode) { |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1233 | case ISD::UREM: AlphaLowering.restoreGP(BB); Opc = Alpha::REMQU; break; |
| 1234 | case ISD::SREM: AlphaLowering.restoreGP(BB); Opc = Alpha::REMQ; break; |
| 1235 | case ISD::UDIV: AlphaLowering.restoreGP(BB); Opc = Alpha::DIVQU; break; |
| 1236 | case ISD::SDIV: AlphaLowering.restoreGP(BB); Opc = Alpha::DIVQ; break; |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 1237 | } |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1238 | Tmp1 = SelectExpr(N.getOperand(0)); |
| 1239 | Tmp2 = SelectExpr(N.getOperand(1)); |
Andrew Lenharth | 0298118 | 2005-01-26 01:24:38 +0000 | [diff] [blame] | 1240 | BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1241 | return Result; |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 1242 | |
Andrew Lenharth | e76797c | 2005-02-01 20:40:27 +0000 | [diff] [blame] | 1243 | case ISD::FP_TO_UINT: |
Andrew Lenharth | 7efadce | 2005-01-31 01:44:26 +0000 | [diff] [blame] | 1244 | case ISD::FP_TO_SINT: |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1245 | { |
Andrew Lenharth | 7efadce | 2005-01-31 01:44:26 +0000 | [diff] [blame] | 1246 | assert (DestType == MVT::i64 && "only quads can be loaded to"); |
| 1247 | MVT::ValueType SrcType = N.getOperand(0).getValueType(); |
Andrew Lenharth | 0382401 | 2005-02-07 05:55:55 +0000 | [diff] [blame] | 1248 | assert (SrcType == MVT::f32 || SrcType == MVT::f64); |
Andrew Lenharth | 7efadce | 2005-01-31 01:44:26 +0000 | [diff] [blame] | 1249 | Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register |
| 1250 | |
| 1251 | //The hard way: |
| 1252 | // Spill the integer to memory and reload it from there. |
| 1253 | unsigned Size = MVT::getSizeInBits(MVT::f64)/8; |
| 1254 | MachineFunction *F = BB->getParent(); |
| 1255 | int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); |
| 1256 | |
| 1257 | //CVTTQ STT LDQ |
| 1258 | //CVTST CVTTQ STT LDQ |
| 1259 | if (SrcType == MVT::f32) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1260 | { |
| 1261 | Tmp2 = MakeReg(MVT::f64); |
| 1262 | BuildMI(BB, Alpha::CVTST, 1, Tmp2).addReg(Tmp1); |
| 1263 | Tmp1 = Tmp2; |
| 1264 | } |
Andrew Lenharth | 7efadce | 2005-01-31 01:44:26 +0000 | [diff] [blame] | 1265 | Tmp2 = MakeReg(MVT::f64); |
| 1266 | BuildMI(BB, Alpha::CVTTQ, 1, Tmp2).addReg(Tmp1); |
| 1267 | BuildMI(BB, Alpha::STT, 3).addReg(Tmp2).addFrameIndex(FrameIdx).addReg(Alpha::F31); |
| 1268 | BuildMI(BB, Alpha::LDQ, 2, Result).addFrameIndex(FrameIdx).addReg(Alpha::F31); |
| 1269 | |
| 1270 | return Result; |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1271 | } |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 1272 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1273 | // // case ISD::FP_TO_UINT: |
Andrew Lenharth | 3e98fde | 2005-01-26 21:54:09 +0000 | [diff] [blame] | 1274 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1275 | case ISD::SELECT: |
| 1276 | { |
Andrew Lenharth | e76797c | 2005-02-01 20:40:27 +0000 | [diff] [blame] | 1277 | Tmp1 = SelectExpr(N.getOperand(0)); //Cond |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1278 | Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE |
| 1279 | Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1280 | // Get the condition into the zero flag. |
Andrew Lenharth | e76797c | 2005-02-01 20:40:27 +0000 | [diff] [blame] | 1281 | BuildMI(BB, Alpha::CMOVEQ, 2, Result).addReg(Tmp2).addReg(Tmp3).addReg(Tmp1); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1282 | return Result; |
| 1283 | } |
| 1284 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1285 | case ISD::Constant: |
| 1286 | { |
Andrew Lenharth | 22d5a41 | 2005-02-02 00:51:15 +0000 | [diff] [blame] | 1287 | unsigned long val = cast<ConstantSDNode>(N)->getValue(); |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1288 | if (val < 32000 && (long)val > -32000) |
| 1289 | BuildMI(BB, Alpha::LOAD_IMM, 1, Result).addImm(val); |
| 1290 | else { |
| 1291 | MachineConstantPool *CP = BB->getParent()->getConstantPool(); |
| 1292 | ConstantUInt *C = ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , val); |
| 1293 | unsigned CPI = CP->getConstantPoolIndex(C); |
| 1294 | AlphaLowering.restoreGP(BB); |
| 1295 | BuildMI(BB, Alpha::LDQ_SYM, 1, Result).addConstantPoolIndex(CPI); |
| 1296 | } |
| 1297 | return Result; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1298 | } |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | return 0; |
| 1302 | } |
| 1303 | |
| 1304 | void ISel::Select(SDOperand N) { |
| 1305 | unsigned Tmp1, Tmp2, Opc; |
Andrew Lenharth | 760270d | 2005-02-07 23:02:23 +0000 | [diff] [blame] | 1306 | unsigned opcode = N.getOpcode(); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1307 | |
Andrew Lenharth | 6b9870a | 2005-01-28 14:06:46 +0000 | [diff] [blame] | 1308 | // FIXME: Disable for our current expansion model! |
Andrew Lenharth | cc1b16f | 2005-01-28 23:17:54 +0000 | [diff] [blame] | 1309 | if (/*!N->hasOneUse() &&*/ !ExprMap.insert(std::make_pair(N, notIn)).second) |
Andrew Lenharth | 6b9870a | 2005-01-28 14:06:46 +0000 | [diff] [blame] | 1310 | return; // Already selected. |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1311 | |
| 1312 | SDNode *Node = N.Val; |
Andrew Lenharth | 760270d | 2005-02-07 23:02:23 +0000 | [diff] [blame] | 1313 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1314 | |
Andrew Lenharth | 760270d | 2005-02-07 23:02:23 +0000 | [diff] [blame] | 1315 | switch (opcode) { |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1316 | |
| 1317 | default: |
| 1318 | Node->dump(); std::cerr << "\n"; |
| 1319 | assert(0 && "Node not handled yet!"); |
| 1320 | |
| 1321 | case ISD::BRCOND: { |
Andrew Lenharth | 445171a | 2005-02-08 00:40:03 +0000 | [diff] [blame] | 1322 | SelectBranchCC(N); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1323 | return; |
| 1324 | } |
| 1325 | |
| 1326 | case ISD::BR: { |
| 1327 | MachineBasicBlock *Dest = |
| 1328 | cast<BasicBlockSDNode>(N.getOperand(1))->getBasicBlock(); |
| 1329 | |
| 1330 | Select(N.getOperand(0)); |
| 1331 | BuildMI(BB, Alpha::BR, 1, Alpha::R31).addMBB(Dest); |
| 1332 | return; |
| 1333 | } |
| 1334 | |
| 1335 | case ISD::ImplicitDef: |
| 1336 | Select(N.getOperand(0)); |
| 1337 | BuildMI(BB, Alpha::IDEF, 0, cast<RegSDNode>(N)->getReg()); |
| 1338 | return; |
| 1339 | |
| 1340 | case ISD::EntryToken: return; // Noop |
| 1341 | |
| 1342 | case ISD::TokenFactor: |
| 1343 | for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) |
| 1344 | Select(Node->getOperand(i)); |
| 1345 | |
| 1346 | //N.Val->dump(); std::cerr << "\n"; |
| 1347 | //assert(0 && "Node not handled yet!"); |
| 1348 | |
| 1349 | return; |
| 1350 | |
| 1351 | case ISD::CopyToReg: |
| 1352 | Select(N.getOperand(0)); |
| 1353 | Tmp1 = SelectExpr(N.getOperand(1)); |
| 1354 | Tmp2 = cast<RegSDNode>(N)->getReg(); |
| 1355 | |
| 1356 | if (Tmp1 != Tmp2) { |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1357 | if (N.getOperand(1).getValueType() == MVT::f64 || |
| 1358 | N.getOperand(1).getValueType() == MVT::f32) |
Andrew Lenharth | 2921916 | 2005-02-07 06:31:44 +0000 | [diff] [blame] | 1359 | BuildMI(BB, Alpha::CPYS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1); |
| 1360 | else |
| 1361 | BuildMI(BB, Alpha::BIS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1362 | } |
| 1363 | return; |
| 1364 | |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1365 | case ISD::RET: |
| 1366 | switch (N.getNumOperands()) { |
| 1367 | default: |
| 1368 | std::cerr << N.getNumOperands() << "\n"; |
| 1369 | for (unsigned i = 0; i < N.getNumOperands(); ++i) |
| 1370 | std::cerr << N.getOperand(i).getValueType() << "\n"; |
| 1371 | Node->dump(); |
| 1372 | assert(0 && "Unknown return instruction!"); |
| 1373 | case 2: |
| 1374 | Select(N.getOperand(0)); |
| 1375 | Tmp1 = SelectExpr(N.getOperand(1)); |
| 1376 | switch (N.getOperand(1).getValueType()) { |
| 1377 | default: Node->dump(); |
| 1378 | assert(0 && "All other types should have been promoted!!"); |
| 1379 | case MVT::f64: |
| 1380 | case MVT::f32: |
| 1381 | BuildMI(BB, Alpha::CPYS, 2, Alpha::F0).addReg(Tmp1).addReg(Tmp1); |
| 1382 | break; |
| 1383 | case MVT::i32: |
| 1384 | case MVT::i64: |
| 1385 | BuildMI(BB, Alpha::BIS, 2, Alpha::R0).addReg(Tmp1).addReg(Tmp1); |
| 1386 | break; |
| 1387 | } |
| 1388 | break; |
| 1389 | case 1: |
| 1390 | Select(N.getOperand(0)); |
| 1391 | break; |
| 1392 | } |
| 1393 | //Tmp2 = AlphaLowering.getRetAddr(); |
| 1394 | //BuildMI(BB, Alpha::BIS, 2, Alpha::R26).addReg(Tmp2).addReg(Tmp2); |
| 1395 | BuildMI(BB, Alpha::RETURN, 0); // Just emit a 'ret' instruction |
| 1396 | return; |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1397 | |
Andrew Lenharth | f311e8b | 2005-02-07 05:18:02 +0000 | [diff] [blame] | 1398 | case ISD::TRUNCSTORE: |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1399 | case ISD::STORE: |
Andrew Lenharth | b014d3e | 2005-02-02 17:32:39 +0000 | [diff] [blame] | 1400 | { |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 1401 | SDOperand Chain = N.getOperand(0); |
| 1402 | SDOperand Value = N.getOperand(1); |
| 1403 | SDOperand Address = N.getOperand(2); |
| 1404 | Select(Chain); |
| 1405 | |
| 1406 | Tmp1 = SelectExpr(Value); //value |
Andrew Lenharth | 760270d | 2005-02-07 23:02:23 +0000 | [diff] [blame] | 1407 | |
| 1408 | if (opcode == ISD::STORE) { |
| 1409 | switch(Value.getValueType()) { |
| 1410 | default: assert(0 && "unknown Type in store"); |
| 1411 | case MVT::i64: Opc = Alpha::STQ; break; |
| 1412 | case MVT::f64: Opc = Alpha::STT; break; |
| 1413 | case MVT::f32: Opc = Alpha::STS; break; |
| 1414 | } |
| 1415 | } else { //ISD::TRUNCSTORE |
| 1416 | switch(cast<MVTSDNode>(Node)->getExtraValueType()) { |
| 1417 | default: assert(0 && "unknown Type in store"); |
| 1418 | case MVT::i1: //FIXME: DAG does not promote this load |
| 1419 | case MVT::i8: Opc = Alpha::STB; break; |
| 1420 | case MVT::i16: Opc = Alpha::STW; break; |
| 1421 | case MVT::i32: Opc = Alpha::STL; break; |
| 1422 | } |
Andrew Lenharth | 6583890 | 2005-02-06 16:22:15 +0000 | [diff] [blame] | 1423 | } |
Andrew Lenharth | 760270d | 2005-02-07 23:02:23 +0000 | [diff] [blame] | 1424 | |
Andrew Lenharth | 9e8d109 | 2005-02-06 15:40:40 +0000 | [diff] [blame] | 1425 | if (Address.getOpcode() == ISD::GlobalAddress) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1426 | { |
| 1427 | AlphaLowering.restoreGP(BB); |
| 1428 | Opc = GetSymVersion(Opc); |
| 1429 | BuildMI(BB, Opc, 2).addReg(Tmp1).addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal()); |
| 1430 | } |
Andrew Lenharth | 0538034 | 2005-02-07 05:07:00 +0000 | [diff] [blame] | 1431 | else if(Address.getOpcode() == ISD::FrameIndex) |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1432 | { |
| 1433 | Tmp2 = cast<FrameIndexSDNode>(Address)->getIndex(); |
| 1434 | BuildMI(BB, Opc, 3).addReg(Tmp1).addFrameIndex(Tmp2).addReg(Alpha::F31); |
| 1435 | } |
Andrew Lenharth | b014d3e | 2005-02-02 17:32:39 +0000 | [diff] [blame] | 1436 | else |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1437 | { |
| 1438 | long offset; |
| 1439 | SelectAddr(Address, Tmp2, offset); |
| 1440 | BuildMI(BB, Opc, 3).addReg(Tmp1).addImm(offset).addReg(Tmp2); |
| 1441 | } |
Andrew Lenharth | b014d3e | 2005-02-02 17:32:39 +0000 | [diff] [blame] | 1442 | return; |
| 1443 | } |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1444 | |
| 1445 | case ISD::EXTLOAD: |
| 1446 | case ISD::SEXTLOAD: |
| 1447 | case ISD::ZEXTLOAD: |
| 1448 | case ISD::LOAD: |
| 1449 | case ISD::CopyFromReg: |
| 1450 | case ISD::CALL: |
Andrew Lenharth | 63f2ab2 | 2005-02-10 06:25:22 +0000 | [diff] [blame^] | 1451 | // case ISD::DYNAMIC_STACKALLOC: |
Andrew Lenharth | 6b9870a | 2005-01-28 14:06:46 +0000 | [diff] [blame] | 1452 | ExprMap.erase(N); |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1453 | SelectExpr(N); |
| 1454 | return; |
| 1455 | |
Andrew Lenharth | 304d0f3 | 2005-01-22 23:41:55 +0000 | [diff] [blame] | 1456 | case ISD::ADJCALLSTACKDOWN: |
| 1457 | case ISD::ADJCALLSTACKUP: |
| 1458 | Select(N.getOperand(0)); |
| 1459 | Tmp1 = cast<ConstantSDNode>(N.getOperand(1))->getValue(); |
| 1460 | |
| 1461 | Opc = N.getOpcode() == ISD::ADJCALLSTACKDOWN ? Alpha::ADJUSTSTACKDOWN : |
| 1462 | Alpha::ADJUSTSTACKUP; |
| 1463 | BuildMI(BB, Opc, 1).addImm(Tmp1); |
| 1464 | return; |
| 1465 | } |
| 1466 | assert(0 && "Should not be reached!"); |
| 1467 | } |
| 1468 | |
| 1469 | |
| 1470 | /// createAlphaPatternInstructionSelector - This pass converts an LLVM function |
| 1471 | /// into a machine code representation using pattern matching and a machine |
| 1472 | /// description file. |
| 1473 | /// |
| 1474 | FunctionPass *llvm::createAlphaPatternInstructionSelector(TargetMachine &TM) { |
| 1475 | return new ISel(TM); |
| 1476 | } |