Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 1 | //===-- ARMFastISel.cpp - ARM FastISel implementation ---------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the ARM-specific support for the FastISel class. Some |
| 11 | // of the target-specific code is generated by tablegen in the file |
| 12 | // ARMGenFastISel.inc, which is #included here. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #include "ARM.h" |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 17 | #include "ARMBaseInstrInfo.h" |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 18 | #include "ARMRegisterInfo.h" |
| 19 | #include "ARMTargetMachine.h" |
| 20 | #include "ARMSubtarget.h" |
| 21 | #include "llvm/CallingConv.h" |
| 22 | #include "llvm/DerivedTypes.h" |
| 23 | #include "llvm/GlobalVariable.h" |
| 24 | #include "llvm/Instructions.h" |
| 25 | #include "llvm/IntrinsicInst.h" |
| 26 | #include "llvm/CodeGen/Analysis.h" |
| 27 | #include "llvm/CodeGen/FastISel.h" |
| 28 | #include "llvm/CodeGen/FunctionLoweringInfo.h" |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 29 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 30 | #include "llvm/CodeGen/MachineModuleInfo.h" |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 31 | #include "llvm/CodeGen/MachineConstantPool.h" |
| 32 | #include "llvm/CodeGen/MachineFrameInfo.h" |
| 33 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
| 34 | #include "llvm/Support/CallSite.h" |
Eric Christopher | 038fea5 | 2010-08-17 00:46:57 +0000 | [diff] [blame] | 35 | #include "llvm/Support/CommandLine.h" |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 36 | #include "llvm/Support/ErrorHandling.h" |
| 37 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 38 | #include "llvm/Target/TargetData.h" |
| 39 | #include "llvm/Target/TargetInstrInfo.h" |
| 40 | #include "llvm/Target/TargetLowering.h" |
| 41 | #include "llvm/Target/TargetMachine.h" |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 42 | #include "llvm/Target/TargetOptions.h" |
| 43 | using namespace llvm; |
| 44 | |
Eric Christopher | 038fea5 | 2010-08-17 00:46:57 +0000 | [diff] [blame] | 45 | static cl::opt<bool> |
| 46 | EnableARMFastISel("arm-fast-isel", |
| 47 | cl::desc("Turn on experimental ARM fast-isel support"), |
| 48 | cl::init(false), cl::Hidden); |
| 49 | |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 50 | namespace { |
| 51 | |
| 52 | class ARMFastISel : public FastISel { |
| 53 | |
| 54 | /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can |
| 55 | /// make the right decision when generating code for different targets. |
| 56 | const ARMSubtarget *Subtarget; |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 57 | const TargetMachine &TM; |
| 58 | const TargetInstrInfo &TII; |
| 59 | const TargetLowering &TLI; |
Eric Christopher | 7fe55b7 | 2010-08-23 22:32:45 +0000 | [diff] [blame] | 60 | const ARMFunctionInfo *AFI; |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 61 | |
Eric Christopher | eaa204b | 2010-09-02 01:39:14 +0000 | [diff] [blame^] | 62 | // Convenience variable to avoid checking all the time. |
| 63 | bool isThumb; |
| 64 | |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 65 | public: |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 66 | explicit ARMFastISel(FunctionLoweringInfo &funcInfo) |
| 67 | : FastISel(funcInfo), |
| 68 | TM(funcInfo.MF->getTarget()), |
| 69 | TII(*TM.getInstrInfo()), |
| 70 | TLI(*TM.getTargetLowering()) { |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 71 | Subtarget = &TM.getSubtarget<ARMSubtarget>(); |
Eric Christopher | 7fe55b7 | 2010-08-23 22:32:45 +0000 | [diff] [blame] | 72 | AFI = funcInfo.MF->getInfo<ARMFunctionInfo>(); |
Eric Christopher | eaa204b | 2010-09-02 01:39:14 +0000 | [diff] [blame^] | 73 | isThumb = AFI->isThumbFunction(); |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Eric Christopher | cb59229 | 2010-08-20 00:20:31 +0000 | [diff] [blame] | 76 | // Code from FastISel.cpp. |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 77 | virtual unsigned FastEmitInst_(unsigned MachineInstOpcode, |
| 78 | const TargetRegisterClass *RC); |
| 79 | virtual unsigned FastEmitInst_r(unsigned MachineInstOpcode, |
| 80 | const TargetRegisterClass *RC, |
| 81 | unsigned Op0, bool Op0IsKill); |
| 82 | virtual unsigned FastEmitInst_rr(unsigned MachineInstOpcode, |
| 83 | const TargetRegisterClass *RC, |
| 84 | unsigned Op0, bool Op0IsKill, |
| 85 | unsigned Op1, bool Op1IsKill); |
| 86 | virtual unsigned FastEmitInst_ri(unsigned MachineInstOpcode, |
| 87 | const TargetRegisterClass *RC, |
| 88 | unsigned Op0, bool Op0IsKill, |
| 89 | uint64_t Imm); |
| 90 | virtual unsigned FastEmitInst_rf(unsigned MachineInstOpcode, |
| 91 | const TargetRegisterClass *RC, |
| 92 | unsigned Op0, bool Op0IsKill, |
| 93 | const ConstantFP *FPImm); |
| 94 | virtual unsigned FastEmitInst_i(unsigned MachineInstOpcode, |
| 95 | const TargetRegisterClass *RC, |
| 96 | uint64_t Imm); |
| 97 | virtual unsigned FastEmitInst_rri(unsigned MachineInstOpcode, |
| 98 | const TargetRegisterClass *RC, |
| 99 | unsigned Op0, bool Op0IsKill, |
| 100 | unsigned Op1, bool Op1IsKill, |
| 101 | uint64_t Imm); |
| 102 | virtual unsigned FastEmitInst_extractsubreg(MVT RetVT, |
| 103 | unsigned Op0, bool Op0IsKill, |
| 104 | uint32_t Idx); |
Eric Christopher | cb59229 | 2010-08-20 00:20:31 +0000 | [diff] [blame] | 105 | |
| 106 | // Backend specific FastISel code. |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 107 | virtual bool TargetSelectInstruction(const Instruction *I); |
| 108 | |
| 109 | #include "ARMGenFastISel.inc" |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 110 | |
| 111 | // Instruction selection routines. |
| 112 | virtual bool ARMSelectLoad(const Instruction *I); |
Eric Christopher | 543cf05 | 2010-09-01 22:16:27 +0000 | [diff] [blame] | 113 | virtual bool ARMSelectStore(const Instruction *I); |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 114 | |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 115 | // Utility routines. |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 116 | private: |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 117 | bool isTypeLegal(const Type *Ty, EVT &VT); |
Eric Christopher | 4e68c7c | 2010-09-01 18:01:32 +0000 | [diff] [blame] | 118 | bool isLoadTypeLegal(const Type *Ty, EVT &VT); |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 119 | bool ARMEmitLoad(EVT VT, unsigned &ResultReg, unsigned Reg, int Offset); |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 120 | bool ARMEmitStore(EVT VT, unsigned SrcReg, unsigned Reg, int Offset); |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 121 | bool ARMLoadAlloca(const Instruction *I); |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 122 | bool ARMStoreAlloca(const Instruction *I, unsigned SrcReg); |
Eric Christopher | cb0b04b | 2010-08-24 00:07:24 +0000 | [diff] [blame] | 123 | bool ARMComputeRegOffset(const Value *Obj, unsigned &Reg, int &Offset); |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 124 | bool ARMMaterializeConstant(const ConstantInt *Val, unsigned &Reg); |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 125 | |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 126 | bool DefinesOptionalPredicate(MachineInstr *MI, bool *CPSR); |
| 127 | const MachineInstrBuilder &AddOptionalDefs(const MachineInstrBuilder &MIB); |
| 128 | }; |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 129 | |
| 130 | } // end anonymous namespace |
| 131 | |
| 132 | // #include "ARMGenCallingConv.inc" |
| 133 | |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 134 | // DefinesOptionalPredicate - This is different from DefinesPredicate in that |
| 135 | // we don't care about implicit defs here, just places we'll need to add a |
| 136 | // default CCReg argument. Sets CPSR if we're setting CPSR instead of CCR. |
| 137 | bool ARMFastISel::DefinesOptionalPredicate(MachineInstr *MI, bool *CPSR) { |
| 138 | const TargetInstrDesc &TID = MI->getDesc(); |
| 139 | if (!TID.hasOptionalDef()) |
| 140 | return false; |
| 141 | |
| 142 | // Look to see if our OptionalDef is defining CPSR or CCR. |
| 143 | for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { |
| 144 | const MachineOperand &MO = MI->getOperand(i); |
Eric Christopher | f762fbe | 2010-08-20 00:36:24 +0000 | [diff] [blame] | 145 | if (!MO.isReg() || !MO.isDef()) continue; |
| 146 | if (MO.getReg() == ARM::CPSR) |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 147 | *CPSR = true; |
| 148 | } |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | // If the machine is predicable go ahead and add the predicate operands, if |
| 153 | // it needs default CC operands add those. |
| 154 | const MachineInstrBuilder & |
| 155 | ARMFastISel::AddOptionalDefs(const MachineInstrBuilder &MIB) { |
| 156 | MachineInstr *MI = &*MIB; |
| 157 | |
| 158 | // Do we use a predicate? |
| 159 | if (TII.isPredicable(MI)) |
| 160 | AddDefaultPred(MIB); |
| 161 | |
| 162 | // Do we optionally set a predicate? Preds is size > 0 iff the predicate |
| 163 | // defines CPSR. All other OptionalDefines in ARM are the CCR register. |
Eric Christopher | 979e0a1 | 2010-08-19 15:35:27 +0000 | [diff] [blame] | 164 | bool CPSR = false; |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 165 | if (DefinesOptionalPredicate(MI, &CPSR)) { |
| 166 | if (CPSR) |
| 167 | AddDefaultT1CC(MIB); |
| 168 | else |
| 169 | AddDefaultCC(MIB); |
| 170 | } |
| 171 | return MIB; |
| 172 | } |
| 173 | |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 174 | unsigned ARMFastISel::FastEmitInst_(unsigned MachineInstOpcode, |
| 175 | const TargetRegisterClass* RC) { |
| 176 | unsigned ResultReg = createResultReg(RC); |
| 177 | const TargetInstrDesc &II = TII.get(MachineInstOpcode); |
| 178 | |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 179 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)); |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 180 | return ResultReg; |
| 181 | } |
| 182 | |
| 183 | unsigned ARMFastISel::FastEmitInst_r(unsigned MachineInstOpcode, |
| 184 | const TargetRegisterClass *RC, |
| 185 | unsigned Op0, bool Op0IsKill) { |
| 186 | unsigned ResultReg = createResultReg(RC); |
| 187 | const TargetInstrDesc &II = TII.get(MachineInstOpcode); |
| 188 | |
| 189 | if (II.getNumDefs() >= 1) |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 190 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 191 | .addReg(Op0, Op0IsKill * RegState::Kill)); |
| 192 | else { |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 193 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 194 | .addReg(Op0, Op0IsKill * RegState::Kill)); |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 195 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 196 | TII.get(TargetOpcode::COPY), ResultReg) |
| 197 | .addReg(II.ImplicitDefs[0])); |
| 198 | } |
| 199 | return ResultReg; |
| 200 | } |
| 201 | |
| 202 | unsigned ARMFastISel::FastEmitInst_rr(unsigned MachineInstOpcode, |
| 203 | const TargetRegisterClass *RC, |
| 204 | unsigned Op0, bool Op0IsKill, |
| 205 | unsigned Op1, bool Op1IsKill) { |
| 206 | unsigned ResultReg = createResultReg(RC); |
| 207 | const TargetInstrDesc &II = TII.get(MachineInstOpcode); |
| 208 | |
| 209 | if (II.getNumDefs() >= 1) |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 210 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 211 | .addReg(Op0, Op0IsKill * RegState::Kill) |
| 212 | .addReg(Op1, Op1IsKill * RegState::Kill)); |
| 213 | else { |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 214 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 215 | .addReg(Op0, Op0IsKill * RegState::Kill) |
| 216 | .addReg(Op1, Op1IsKill * RegState::Kill)); |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 217 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 218 | TII.get(TargetOpcode::COPY), ResultReg) |
| 219 | .addReg(II.ImplicitDefs[0])); |
| 220 | } |
| 221 | return ResultReg; |
| 222 | } |
| 223 | |
| 224 | unsigned ARMFastISel::FastEmitInst_ri(unsigned MachineInstOpcode, |
| 225 | const TargetRegisterClass *RC, |
| 226 | unsigned Op0, bool Op0IsKill, |
| 227 | uint64_t Imm) { |
| 228 | unsigned ResultReg = createResultReg(RC); |
| 229 | const TargetInstrDesc &II = TII.get(MachineInstOpcode); |
| 230 | |
| 231 | if (II.getNumDefs() >= 1) |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 232 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 233 | .addReg(Op0, Op0IsKill * RegState::Kill) |
| 234 | .addImm(Imm)); |
| 235 | else { |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 236 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 237 | .addReg(Op0, Op0IsKill * RegState::Kill) |
| 238 | .addImm(Imm)); |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 239 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 240 | TII.get(TargetOpcode::COPY), ResultReg) |
| 241 | .addReg(II.ImplicitDefs[0])); |
| 242 | } |
| 243 | return ResultReg; |
| 244 | } |
| 245 | |
| 246 | unsigned ARMFastISel::FastEmitInst_rf(unsigned MachineInstOpcode, |
| 247 | const TargetRegisterClass *RC, |
| 248 | unsigned Op0, bool Op0IsKill, |
| 249 | const ConstantFP *FPImm) { |
| 250 | unsigned ResultReg = createResultReg(RC); |
| 251 | const TargetInstrDesc &II = TII.get(MachineInstOpcode); |
| 252 | |
| 253 | if (II.getNumDefs() >= 1) |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 254 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 255 | .addReg(Op0, Op0IsKill * RegState::Kill) |
| 256 | .addFPImm(FPImm)); |
| 257 | else { |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 258 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 259 | .addReg(Op0, Op0IsKill * RegState::Kill) |
| 260 | .addFPImm(FPImm)); |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 261 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 262 | TII.get(TargetOpcode::COPY), ResultReg) |
| 263 | .addReg(II.ImplicitDefs[0])); |
| 264 | } |
| 265 | return ResultReg; |
| 266 | } |
| 267 | |
| 268 | unsigned ARMFastISel::FastEmitInst_rri(unsigned MachineInstOpcode, |
| 269 | const TargetRegisterClass *RC, |
| 270 | unsigned Op0, bool Op0IsKill, |
| 271 | unsigned Op1, bool Op1IsKill, |
| 272 | uint64_t Imm) { |
| 273 | unsigned ResultReg = createResultReg(RC); |
| 274 | const TargetInstrDesc &II = TII.get(MachineInstOpcode); |
| 275 | |
| 276 | if (II.getNumDefs() >= 1) |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 277 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 278 | .addReg(Op0, Op0IsKill * RegState::Kill) |
| 279 | .addReg(Op1, Op1IsKill * RegState::Kill) |
| 280 | .addImm(Imm)); |
| 281 | else { |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 282 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 283 | .addReg(Op0, Op0IsKill * RegState::Kill) |
| 284 | .addReg(Op1, Op1IsKill * RegState::Kill) |
| 285 | .addImm(Imm)); |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 286 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 287 | TII.get(TargetOpcode::COPY), ResultReg) |
| 288 | .addReg(II.ImplicitDefs[0])); |
| 289 | } |
| 290 | return ResultReg; |
| 291 | } |
| 292 | |
| 293 | unsigned ARMFastISel::FastEmitInst_i(unsigned MachineInstOpcode, |
| 294 | const TargetRegisterClass *RC, |
| 295 | uint64_t Imm) { |
| 296 | unsigned ResultReg = createResultReg(RC); |
| 297 | const TargetInstrDesc &II = TII.get(MachineInstOpcode); |
| 298 | |
| 299 | if (II.getNumDefs() >= 1) |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 300 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 301 | .addImm(Imm)); |
| 302 | else { |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 303 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 304 | .addImm(Imm)); |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 305 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 306 | TII.get(TargetOpcode::COPY), ResultReg) |
| 307 | .addReg(II.ImplicitDefs[0])); |
| 308 | } |
| 309 | return ResultReg; |
| 310 | } |
| 311 | |
| 312 | unsigned ARMFastISel::FastEmitInst_extractsubreg(MVT RetVT, |
| 313 | unsigned Op0, bool Op0IsKill, |
| 314 | uint32_t Idx) { |
| 315 | unsigned ResultReg = createResultReg(TLI.getRegClassFor(RetVT)); |
| 316 | assert(TargetRegisterInfo::isVirtualRegister(Op0) && |
| 317 | "Cannot yet extract from physregs"); |
Eric Christopher | 456144e | 2010-08-19 00:37:05 +0000 | [diff] [blame] | 318 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, |
Eric Christopher | 0fe7d54 | 2010-08-17 01:25:29 +0000 | [diff] [blame] | 319 | DL, TII.get(TargetOpcode::COPY), ResultReg) |
| 320 | .addReg(Op0, getKillRegState(Op0IsKill), Idx)); |
| 321 | return ResultReg; |
| 322 | } |
| 323 | |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 324 | bool ARMFastISel::isTypeLegal(const Type *Ty, EVT &VT) { |
| 325 | VT = TLI.getValueType(Ty, true); |
| 326 | |
| 327 | // Only handle simple types. |
| 328 | if (VT == MVT::Other || !VT.isSimple()) return false; |
Eric Christopher | 4e68c7c | 2010-09-01 18:01:32 +0000 | [diff] [blame] | 329 | |
Eric Christopher | dc90804 | 2010-08-31 01:28:42 +0000 | [diff] [blame] | 330 | // Handle all legal types, i.e. a register that will directly hold this |
| 331 | // value. |
| 332 | return TLI.isTypeLegal(VT); |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 333 | } |
| 334 | |
Eric Christopher | 4e68c7c | 2010-09-01 18:01:32 +0000 | [diff] [blame] | 335 | bool ARMFastISel::isLoadTypeLegal(const Type *Ty, EVT &VT) { |
| 336 | if (isTypeLegal(Ty, VT)) return true; |
| 337 | |
| 338 | // If this is a type than can be sign or zero-extended to a basic operation |
| 339 | // go ahead and accept it now. |
| 340 | if (VT == MVT::i8 || VT == MVT::i16) |
| 341 | return true; |
| 342 | |
| 343 | return false; |
| 344 | } |
| 345 | |
Eric Christopher | cb0b04b | 2010-08-24 00:07:24 +0000 | [diff] [blame] | 346 | // Computes the Reg+Offset to get to an object. |
| 347 | bool ARMFastISel::ARMComputeRegOffset(const Value *Obj, unsigned &Reg, |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 348 | int &Offset) { |
| 349 | // Some boilerplate from the X86 FastISel. |
| 350 | const User *U = NULL; |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 351 | unsigned Opcode = Instruction::UserOp1; |
Eric Christopher | cb0b04b | 2010-08-24 00:07:24 +0000 | [diff] [blame] | 352 | if (const Instruction *I = dyn_cast<Instruction>(Obj)) { |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 353 | // Don't walk into other basic blocks; it's possible we haven't |
| 354 | // visited them yet, so the instructions may not yet be assigned |
| 355 | // virtual registers. |
| 356 | if (FuncInfo.MBBMap[I->getParent()] != FuncInfo.MBB) |
| 357 | return false; |
| 358 | |
| 359 | Opcode = I->getOpcode(); |
| 360 | U = I; |
Eric Christopher | cb0b04b | 2010-08-24 00:07:24 +0000 | [diff] [blame] | 361 | } else if (const ConstantExpr *C = dyn_cast<ConstantExpr>(Obj)) { |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 362 | Opcode = C->getOpcode(); |
| 363 | U = C; |
| 364 | } |
| 365 | |
Eric Christopher | cb0b04b | 2010-08-24 00:07:24 +0000 | [diff] [blame] | 366 | if (const PointerType *Ty = dyn_cast<PointerType>(Obj->getType())) |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 367 | if (Ty->getAddressSpace() > 255) |
| 368 | // Fast instruction selection doesn't support the special |
| 369 | // address spaces. |
| 370 | return false; |
| 371 | |
| 372 | switch (Opcode) { |
| 373 | default: |
| 374 | //errs() << "Failing Opcode is: " << *Op1 << "\n"; |
| 375 | break; |
| 376 | case Instruction::Alloca: { |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 377 | assert(false && "Alloca should have been handled earlier!"); |
| 378 | return false; |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 379 | } |
| 380 | } |
Eric Christopher | cb0b04b | 2010-08-24 00:07:24 +0000 | [diff] [blame] | 381 | |
| 382 | if (const GlobalValue *GV = dyn_cast<GlobalValue>(Obj)) { |
| 383 | //errs() << "Failing GV is: " << GV << "\n"; |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 384 | (void)GV; |
Eric Christopher | cb0b04b | 2010-08-24 00:07:24 +0000 | [diff] [blame] | 385 | return false; |
| 386 | } |
| 387 | |
| 388 | // Try to get this in a register if nothing else has worked. |
| 389 | Reg = getRegForValue(Obj); |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 390 | if (Reg == 0) return false; |
| 391 | |
| 392 | // Since the offset may be too large for the load instruction |
| 393 | // get the reg+offset into a register. |
| 394 | // TODO: Verify the additions work, otherwise we'll need to add the |
| 395 | // offset instead of 0 to the instructions and do all sorts of operand |
| 396 | // munging. |
| 397 | // TODO: Optimize this somewhat. |
| 398 | if (Offset != 0) { |
| 399 | ARMCC::CondCodes Pred = ARMCC::AL; |
| 400 | unsigned PredReg = 0; |
| 401 | |
Eric Christopher | eaa204b | 2010-09-02 01:39:14 +0000 | [diff] [blame^] | 402 | if (!isThumb) |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 403 | emitARMRegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
| 404 | Reg, Reg, Offset, Pred, PredReg, |
| 405 | static_cast<const ARMBaseInstrInfo&>(TII)); |
| 406 | else { |
| 407 | assert(AFI->isThumb2Function()); |
| 408 | emitT2RegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
| 409 | Reg, Reg, Offset, Pred, PredReg, |
| 410 | static_cast<const ARMBaseInstrInfo&>(TII)); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | return true; |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 415 | } |
| 416 | |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 417 | bool ARMFastISel::ARMLoadAlloca(const Instruction *I) { |
| 418 | Value *Op0 = I->getOperand(0); |
| 419 | |
| 420 | // Verify it's an alloca. |
Eric Christopher | e24d66f | 2010-08-24 22:07:27 +0000 | [diff] [blame] | 421 | if (const AllocaInst *AI = dyn_cast<AllocaInst>(Op0)) { |
| 422 | DenseMap<const AllocaInst*, int>::iterator SI = |
| 423 | FuncInfo.StaticAllocaMap.find(AI); |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 424 | |
Eric Christopher | e24d66f | 2010-08-24 22:07:27 +0000 | [diff] [blame] | 425 | if (SI != FuncInfo.StaticAllocaMap.end()) { |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 426 | TargetRegisterClass* RC = TLI.getRegClassFor(TLI.getPointerTy()); |
| 427 | unsigned ResultReg = createResultReg(RC); |
Eric Christopher | e24d66f | 2010-08-24 22:07:27 +0000 | [diff] [blame] | 428 | TII.loadRegFromStackSlot(*FuncInfo.MBB, *FuncInfo.InsertPt, |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 429 | ResultReg, SI->second, RC, |
Eric Christopher | e24d66f | 2010-08-24 22:07:27 +0000 | [diff] [blame] | 430 | TM.getRegisterInfo()); |
| 431 | UpdateValueMap(I, ResultReg); |
| 432 | return true; |
| 433 | } |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 434 | } |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 435 | return false; |
| 436 | } |
| 437 | |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 438 | bool ARMFastISel::ARMEmitLoad(EVT VT, unsigned &ResultReg, |
| 439 | unsigned Reg, int Offset) { |
| 440 | |
| 441 | assert(VT.isSimple() && "Non-simple types are invalid here!"); |
Eric Christopher | dc90804 | 2010-08-31 01:28:42 +0000 | [diff] [blame] | 442 | unsigned Opc; |
| 443 | |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 444 | switch (VT.getSimpleVT().SimpleTy) { |
Eric Christopher | 548d1bb | 2010-08-30 23:48:26 +0000 | [diff] [blame] | 445 | default: |
| 446 | assert(false && "Trying to emit for an unhandled type!"); |
| 447 | return false; |
Eric Christopher | 4e68c7c | 2010-09-01 18:01:32 +0000 | [diff] [blame] | 448 | case MVT::i16: |
| 449 | Opc = isThumb ? ARM::tLDRH : ARM::LDRH; |
| 450 | VT = MVT::i32; |
| 451 | break; |
| 452 | case MVT::i8: |
| 453 | Opc = isThumb ? ARM::tLDRB : ARM::LDRB; |
| 454 | VT = MVT::i32; |
| 455 | break; |
Eric Christopher | dc90804 | 2010-08-31 01:28:42 +0000 | [diff] [blame] | 456 | case MVT::i32: |
| 457 | Opc = isThumb ? ARM::tLDR : ARM::LDR; |
| 458 | break; |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 459 | } |
Eric Christopher | dc90804 | 2010-08-31 01:28:42 +0000 | [diff] [blame] | 460 | |
| 461 | ResultReg = createResultReg(TLI.getRegClassFor(VT)); |
| 462 | |
| 463 | // TODO: Fix the Addressing modes so that these can share some code. |
| 464 | // Since this is a Thumb1 load this will work in Thumb1 or 2 mode. |
| 465 | if (isThumb) |
| 466 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
| 467 | TII.get(Opc), ResultReg) |
| 468 | .addReg(Reg).addImm(Offset).addReg(0)); |
| 469 | else |
| 470 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
| 471 | TII.get(Opc), ResultReg) |
| 472 | .addReg(Reg).addReg(0).addImm(Offset)); |
| 473 | |
| 474 | return true; |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 475 | } |
| 476 | |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 477 | bool ARMFastISel::ARMMaterializeConstant(const ConstantInt *CI, unsigned &Reg) { |
| 478 | unsigned Opc; |
| 479 | bool Signed = true; |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 480 | EVT VT = TLI.getValueType(CI->getType(), true); |
| 481 | |
| 482 | switch (VT.getSimpleVT().SimpleTy) { |
| 483 | default: return false; |
| 484 | case MVT::i1: Signed = false; // FALLTHROUGH to handle as i8. |
| 485 | case MVT::i8: |
| 486 | case MVT::i16: |
| 487 | case MVT::i32: |
| 488 | Opc = isThumb ? ARM::t2MOVi32imm : ARM::MOVi32imm; break; |
| 489 | } |
| 490 | |
| 491 | Reg = createResultReg(TLI.getRegClassFor(VT)); |
| 492 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(Opc), |
| 493 | Reg) |
| 494 | .addImm(Signed ? (uint64_t) CI->getSExtValue() : |
| 495 | CI->getZExtValue())); |
| 496 | |
| 497 | return true; |
| 498 | } |
| 499 | |
| 500 | bool ARMFastISel::ARMStoreAlloca(const Instruction *I, unsigned SrcReg) { |
Eric Christopher | 543cf05 | 2010-09-01 22:16:27 +0000 | [diff] [blame] | 501 | Value *Op1 = I->getOperand(1); |
| 502 | |
| 503 | // Verify it's an alloca. |
| 504 | if (const AllocaInst *AI = dyn_cast<AllocaInst>(Op1)) { |
| 505 | DenseMap<const AllocaInst*, int>::iterator SI = |
| 506 | FuncInfo.StaticAllocaMap.find(AI); |
| 507 | |
| 508 | if (SI != FuncInfo.StaticAllocaMap.end()) { |
| 509 | TargetRegisterClass* RC = TLI.getRegClassFor(TLI.getPointerTy()); |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 510 | assert(SrcReg != 0 && "Nothing to store!"); |
Eric Christopher | 543cf05 | 2010-09-01 22:16:27 +0000 | [diff] [blame] | 511 | TII.storeRegToStackSlot(*FuncInfo.MBB, *FuncInfo.InsertPt, |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 512 | SrcReg, true /*isKill*/, SI->second, RC, |
Eric Christopher | 543cf05 | 2010-09-01 22:16:27 +0000 | [diff] [blame] | 513 | TM.getRegisterInfo()); |
| 514 | return true; |
| 515 | } |
| 516 | } |
| 517 | return false; |
| 518 | } |
| 519 | |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 520 | bool ARMFastISel::ARMEmitStore(EVT VT, unsigned SrcReg, |
| 521 | unsigned DstReg, int Offset) { |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 522 | unsigned StrOpc; |
| 523 | switch (VT.getSimpleVT().SimpleTy) { |
| 524 | default: return false; |
| 525 | case MVT::i1: |
| 526 | case MVT::i8: StrOpc = isThumb ? ARM::tSTRB : ARM::STRB; break; |
| 527 | case MVT::i16: StrOpc = isThumb ? ARM::tSTRH : ARM::STRH; break; |
| 528 | case MVT::i32: StrOpc = isThumb ? ARM::tSTR : ARM::STR; break; |
| 529 | } |
| 530 | |
| 531 | if (isThumb) |
| 532 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
| 533 | TII.get(StrOpc), SrcReg) |
| 534 | .addReg(DstReg).addImm(Offset).addReg(0)); |
| 535 | else |
| 536 | AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, |
| 537 | TII.get(StrOpc), SrcReg) |
| 538 | .addReg(DstReg).addReg(0).addImm(Offset)); |
| 539 | |
| 540 | return true; |
| 541 | } |
| 542 | |
| 543 | bool ARMFastISel::ARMSelectStore(const Instruction *I) { |
| 544 | Value *Op0 = I->getOperand(0); |
| 545 | unsigned SrcReg = 0; |
| 546 | |
Eric Christopher | 543cf05 | 2010-09-01 22:16:27 +0000 | [diff] [blame] | 547 | // Yay type legalization |
| 548 | EVT VT; |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 549 | if (!isLoadTypeLegal(I->getOperand(0)->getType(), VT)) |
Eric Christopher | 543cf05 | 2010-09-01 22:16:27 +0000 | [diff] [blame] | 550 | return false; |
| 551 | |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 552 | // First see if we're a constant that we want to store, we'll need to |
| 553 | // materialize that into a register. |
| 554 | // Handle 'null' like i32/i64 0. |
| 555 | if (isa<ConstantPointerNull>(Op0)) |
| 556 | Op0 = Constant::getNullValue(TD.getIntPtrType(Op0->getContext())); |
| 557 | |
| 558 | // If this is a store of a simple constant, materialize the constant into |
| 559 | // a register then emit the store into the location. |
| 560 | if (const ConstantInt *CI = dyn_cast<ConstantInt>(Op0)) |
| 561 | if (!ARMMaterializeConstant(CI, SrcReg)) |
| 562 | return false; |
| 563 | |
| 564 | // If Reg is still 0, try to get the value into a register. |
| 565 | if (SrcReg == 0) |
| 566 | SrcReg = getRegForValue(Op0); |
| 567 | if (SrcReg == 0) |
| 568 | return false; |
| 569 | |
| 570 | // If we're an alloca we know we have a frame index and can emit the store |
| 571 | // quickly. |
| 572 | if (ARMStoreAlloca(I, SrcReg)) |
| 573 | return true; |
| 574 | |
| 575 | // Our register and offset with innocuous defaults. |
| 576 | unsigned Reg = 0; |
| 577 | int Offset = 0; |
| 578 | |
| 579 | // See if we can handle this as Reg + Offset |
| 580 | if (!ARMComputeRegOffset(I->getOperand(1), Reg, Offset)) |
| 581 | return false; |
| 582 | |
| 583 | if (!ARMEmitStore(VT, SrcReg, Reg, Offset /* 0 */)) return false; |
| 584 | |
Eric Christopher | 543cf05 | 2010-09-01 22:16:27 +0000 | [diff] [blame] | 585 | return false; |
| 586 | |
| 587 | } |
| 588 | |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 589 | bool ARMFastISel::ARMSelectLoad(const Instruction *I) { |
Eric Christopher | 882d62e | 2010-08-24 01:10:52 +0000 | [diff] [blame] | 590 | // If we're an alloca we know we have a frame index and can emit the load |
| 591 | // directly in short order. |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 592 | if (ARMLoadAlloca(I)) |
| 593 | return true; |
Eric Christopher | 61c3f9a | 2010-08-25 08:43:57 +0000 | [diff] [blame] | 594 | |
| 595 | // Verify we have a legal type before going any further. |
| 596 | EVT VT; |
Eric Christopher | 4e68c7c | 2010-09-01 18:01:32 +0000 | [diff] [blame] | 597 | if (!isLoadTypeLegal(I->getType(), VT)) |
Eric Christopher | 61c3f9a | 2010-08-25 08:43:57 +0000 | [diff] [blame] | 598 | return false; |
| 599 | |
| 600 | // Our register and offset with innocuous defaults. |
| 601 | unsigned Reg = 0; |
| 602 | int Offset = 0; |
Eric Christopher | 8654c71 | 2010-08-23 23:14:31 +0000 | [diff] [blame] | 603 | |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 604 | // See if we can handle this as Reg + Offset |
Eric Christopher | cb0b04b | 2010-08-24 00:07:24 +0000 | [diff] [blame] | 605 | if (!ARMComputeRegOffset(I->getOperand(0), Reg, Offset)) |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 606 | return false; |
Eric Christopher | 1dfb4d3 | 2010-08-23 23:28:04 +0000 | [diff] [blame] | 607 | |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 608 | unsigned ResultReg; |
Eric Christopher | 318b6ee | 2010-09-02 00:53:56 +0000 | [diff] [blame] | 609 | if (!ARMEmitLoad(VT, ResultReg, Reg, Offset /* 0 */)) return false; |
Eric Christopher | b1cc848 | 2010-08-25 07:23:49 +0000 | [diff] [blame] | 610 | |
Eric Christopher | f06f309 | 2010-08-24 00:50:47 +0000 | [diff] [blame] | 611 | UpdateValueMap(I, ResultReg); |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 612 | return true; |
| 613 | } |
| 614 | |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 615 | bool ARMFastISel::TargetSelectInstruction(const Instruction *I) { |
Eric Christopher | 7fe55b7 | 2010-08-23 22:32:45 +0000 | [diff] [blame] | 616 | // No Thumb-1 for now. |
Eric Christopher | eaa204b | 2010-09-02 01:39:14 +0000 | [diff] [blame^] | 617 | if (isThumb && !AFI->isThumb2Function()) return false; |
Eric Christopher | 7fe55b7 | 2010-08-23 22:32:45 +0000 | [diff] [blame] | 618 | |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 619 | switch (I->getOpcode()) { |
Eric Christopher | 8300712 | 2010-08-23 21:44:12 +0000 | [diff] [blame] | 620 | case Instruction::Load: |
| 621 | return ARMSelectLoad(I); |
Eric Christopher | 543cf05 | 2010-09-01 22:16:27 +0000 | [diff] [blame] | 622 | case Instruction::Store: |
| 623 | return ARMSelectStore(I); |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 624 | default: break; |
| 625 | } |
| 626 | return false; |
| 627 | } |
| 628 | |
| 629 | namespace llvm { |
| 630 | llvm::FastISel *ARM::createFastISel(FunctionLoweringInfo &funcInfo) { |
Eric Christopher | 038fea5 | 2010-08-17 00:46:57 +0000 | [diff] [blame] | 631 | if (EnableARMFastISel) return new ARMFastISel(funcInfo); |
Evan Cheng | 0944795 | 2010-07-26 18:32:55 +0000 | [diff] [blame] | 632 | return 0; |
Eric Christopher | ab69588 | 2010-07-21 22:26:11 +0000 | [diff] [blame] | 633 | } |
| 634 | } |