blob: fbe4126b2f870c03e5d64c6503af42031246914e [file] [log] [blame]
Eric Christopherab695882010-07-21 22:26:11 +00001//===-- 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 Christopher456144e2010-08-19 00:37:05 +000017#include "ARMBaseInstrInfo.h"
Eric Christopherab695882010-07-21 22:26:11 +000018#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 Christopher0fe7d542010-08-17 01:25:29 +000029#include "llvm/CodeGen/MachineInstrBuilder.h"
30#include "llvm/CodeGen/MachineModuleInfo.h"
Eric Christopherab695882010-07-21 22:26:11 +000031#include "llvm/CodeGen/MachineConstantPool.h"
32#include "llvm/CodeGen/MachineFrameInfo.h"
33#include "llvm/CodeGen/MachineRegisterInfo.h"
34#include "llvm/Support/CallSite.h"
Eric Christopher038fea52010-08-17 00:46:57 +000035#include "llvm/Support/CommandLine.h"
Eric Christopherab695882010-07-21 22:26:11 +000036#include "llvm/Support/ErrorHandling.h"
37#include "llvm/Support/GetElementPtrTypeIterator.h"
Eric Christopher0fe7d542010-08-17 01:25:29 +000038#include "llvm/Target/TargetData.h"
39#include "llvm/Target/TargetInstrInfo.h"
40#include "llvm/Target/TargetLowering.h"
41#include "llvm/Target/TargetMachine.h"
Eric Christopherab695882010-07-21 22:26:11 +000042#include "llvm/Target/TargetOptions.h"
43using namespace llvm;
44
Eric Christopher038fea52010-08-17 00:46:57 +000045static cl::opt<bool>
46EnableARMFastISel("arm-fast-isel",
47 cl::desc("Turn on experimental ARM fast-isel support"),
48 cl::init(false), cl::Hidden);
49
Eric Christopherab695882010-07-21 22:26:11 +000050namespace {
51
52class 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 Christopher0fe7d542010-08-17 01:25:29 +000057 const TargetMachine &TM;
58 const TargetInstrInfo &TII;
59 const TargetLowering &TLI;
Eric Christopher7fe55b72010-08-23 22:32:45 +000060 const ARMFunctionInfo *AFI;
Eric Christopherab695882010-07-21 22:26:11 +000061
62 public:
Eric Christopher0fe7d542010-08-17 01:25:29 +000063 explicit ARMFastISel(FunctionLoweringInfo &funcInfo)
64 : FastISel(funcInfo),
65 TM(funcInfo.MF->getTarget()),
66 TII(*TM.getInstrInfo()),
67 TLI(*TM.getTargetLowering()) {
Eric Christopherab695882010-07-21 22:26:11 +000068 Subtarget = &TM.getSubtarget<ARMSubtarget>();
Eric Christopher7fe55b72010-08-23 22:32:45 +000069 AFI = funcInfo.MF->getInfo<ARMFunctionInfo>();
Eric Christopherab695882010-07-21 22:26:11 +000070 }
71
Eric Christophercb592292010-08-20 00:20:31 +000072 // Code from FastISel.cpp.
Eric Christopher0fe7d542010-08-17 01:25:29 +000073 virtual unsigned FastEmitInst_(unsigned MachineInstOpcode,
74 const TargetRegisterClass *RC);
75 virtual unsigned FastEmitInst_r(unsigned MachineInstOpcode,
76 const TargetRegisterClass *RC,
77 unsigned Op0, bool Op0IsKill);
78 virtual unsigned FastEmitInst_rr(unsigned MachineInstOpcode,
79 const TargetRegisterClass *RC,
80 unsigned Op0, bool Op0IsKill,
81 unsigned Op1, bool Op1IsKill);
82 virtual unsigned FastEmitInst_ri(unsigned MachineInstOpcode,
83 const TargetRegisterClass *RC,
84 unsigned Op0, bool Op0IsKill,
85 uint64_t Imm);
86 virtual unsigned FastEmitInst_rf(unsigned MachineInstOpcode,
87 const TargetRegisterClass *RC,
88 unsigned Op0, bool Op0IsKill,
89 const ConstantFP *FPImm);
90 virtual unsigned FastEmitInst_i(unsigned MachineInstOpcode,
91 const TargetRegisterClass *RC,
92 uint64_t Imm);
93 virtual unsigned FastEmitInst_rri(unsigned MachineInstOpcode,
94 const TargetRegisterClass *RC,
95 unsigned Op0, bool Op0IsKill,
96 unsigned Op1, bool Op1IsKill,
97 uint64_t Imm);
98 virtual unsigned FastEmitInst_extractsubreg(MVT RetVT,
99 unsigned Op0, bool Op0IsKill,
100 uint32_t Idx);
Eric Christophercb592292010-08-20 00:20:31 +0000101
102 // Backend specific FastISel code.
Eric Christopherab695882010-07-21 22:26:11 +0000103 virtual bool TargetSelectInstruction(const Instruction *I);
104
105 #include "ARMGenFastISel.inc"
Eric Christopher83007122010-08-23 21:44:12 +0000106
107 // Instruction selection routines.
108 virtual bool ARMSelectLoad(const Instruction *I);
Eric Christopherab695882010-07-21 22:26:11 +0000109
Eric Christopher83007122010-08-23 21:44:12 +0000110 // Utility routines.
Eric Christopher456144e2010-08-19 00:37:05 +0000111 private:
Eric Christophercb0b04b2010-08-24 00:07:24 +0000112 bool ARMComputeRegOffset(const Value *Obj, unsigned &Reg, int &Offset);
Eric Christopher83007122010-08-23 21:44:12 +0000113
Eric Christopher456144e2010-08-19 00:37:05 +0000114 bool DefinesOptionalPredicate(MachineInstr *MI, bool *CPSR);
115 const MachineInstrBuilder &AddOptionalDefs(const MachineInstrBuilder &MIB);
116};
Eric Christopherab695882010-07-21 22:26:11 +0000117
118} // end anonymous namespace
119
120// #include "ARMGenCallingConv.inc"
121
Eric Christopher456144e2010-08-19 00:37:05 +0000122// DefinesOptionalPredicate - This is different from DefinesPredicate in that
123// we don't care about implicit defs here, just places we'll need to add a
124// default CCReg argument. Sets CPSR if we're setting CPSR instead of CCR.
125bool ARMFastISel::DefinesOptionalPredicate(MachineInstr *MI, bool *CPSR) {
126 const TargetInstrDesc &TID = MI->getDesc();
127 if (!TID.hasOptionalDef())
128 return false;
129
130 // Look to see if our OptionalDef is defining CPSR or CCR.
131 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
132 const MachineOperand &MO = MI->getOperand(i);
Eric Christopherf762fbe2010-08-20 00:36:24 +0000133 if (!MO.isReg() || !MO.isDef()) continue;
134 if (MO.getReg() == ARM::CPSR)
Eric Christopher456144e2010-08-19 00:37:05 +0000135 *CPSR = true;
136 }
137 return true;
138}
139
140// If the machine is predicable go ahead and add the predicate operands, if
141// it needs default CC operands add those.
142const MachineInstrBuilder &
143ARMFastISel::AddOptionalDefs(const MachineInstrBuilder &MIB) {
144 MachineInstr *MI = &*MIB;
145
146 // Do we use a predicate?
147 if (TII.isPredicable(MI))
148 AddDefaultPred(MIB);
149
150 // Do we optionally set a predicate? Preds is size > 0 iff the predicate
151 // defines CPSR. All other OptionalDefines in ARM are the CCR register.
Eric Christopher979e0a12010-08-19 15:35:27 +0000152 bool CPSR = false;
Eric Christopher456144e2010-08-19 00:37:05 +0000153 if (DefinesOptionalPredicate(MI, &CPSR)) {
154 if (CPSR)
155 AddDefaultT1CC(MIB);
156 else
157 AddDefaultCC(MIB);
158 }
159 return MIB;
160}
161
Eric Christopher0fe7d542010-08-17 01:25:29 +0000162unsigned ARMFastISel::FastEmitInst_(unsigned MachineInstOpcode,
163 const TargetRegisterClass* RC) {
164 unsigned ResultReg = createResultReg(RC);
165 const TargetInstrDesc &II = TII.get(MachineInstOpcode);
166
Eric Christopher456144e2010-08-19 00:37:05 +0000167 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg));
Eric Christopher0fe7d542010-08-17 01:25:29 +0000168 return ResultReg;
169}
170
171unsigned ARMFastISel::FastEmitInst_r(unsigned MachineInstOpcode,
172 const TargetRegisterClass *RC,
173 unsigned Op0, bool Op0IsKill) {
174 unsigned ResultReg = createResultReg(RC);
175 const TargetInstrDesc &II = TII.get(MachineInstOpcode);
176
177 if (II.getNumDefs() >= 1)
Eric Christopher456144e2010-08-19 00:37:05 +0000178 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000179 .addReg(Op0, Op0IsKill * RegState::Kill));
180 else {
Eric Christopher456144e2010-08-19 00:37:05 +0000181 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000182 .addReg(Op0, Op0IsKill * RegState::Kill));
Eric Christopher456144e2010-08-19 00:37:05 +0000183 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
Eric Christopher0fe7d542010-08-17 01:25:29 +0000184 TII.get(TargetOpcode::COPY), ResultReg)
185 .addReg(II.ImplicitDefs[0]));
186 }
187 return ResultReg;
188}
189
190unsigned ARMFastISel::FastEmitInst_rr(unsigned MachineInstOpcode,
191 const TargetRegisterClass *RC,
192 unsigned Op0, bool Op0IsKill,
193 unsigned Op1, bool Op1IsKill) {
194 unsigned ResultReg = createResultReg(RC);
195 const TargetInstrDesc &II = TII.get(MachineInstOpcode);
196
197 if (II.getNumDefs() >= 1)
Eric Christopher456144e2010-08-19 00:37:05 +0000198 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000199 .addReg(Op0, Op0IsKill * RegState::Kill)
200 .addReg(Op1, Op1IsKill * RegState::Kill));
201 else {
Eric Christopher456144e2010-08-19 00:37:05 +0000202 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000203 .addReg(Op0, Op0IsKill * RegState::Kill)
204 .addReg(Op1, Op1IsKill * RegState::Kill));
Eric Christopher456144e2010-08-19 00:37:05 +0000205 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
Eric Christopher0fe7d542010-08-17 01:25:29 +0000206 TII.get(TargetOpcode::COPY), ResultReg)
207 .addReg(II.ImplicitDefs[0]));
208 }
209 return ResultReg;
210}
211
212unsigned ARMFastISel::FastEmitInst_ri(unsigned MachineInstOpcode,
213 const TargetRegisterClass *RC,
214 unsigned Op0, bool Op0IsKill,
215 uint64_t Imm) {
216 unsigned ResultReg = createResultReg(RC);
217 const TargetInstrDesc &II = TII.get(MachineInstOpcode);
218
219 if (II.getNumDefs() >= 1)
Eric Christopher456144e2010-08-19 00:37:05 +0000220 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000221 .addReg(Op0, Op0IsKill * RegState::Kill)
222 .addImm(Imm));
223 else {
Eric Christopher456144e2010-08-19 00:37:05 +0000224 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000225 .addReg(Op0, Op0IsKill * RegState::Kill)
226 .addImm(Imm));
Eric Christopher456144e2010-08-19 00:37:05 +0000227 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
Eric Christopher0fe7d542010-08-17 01:25:29 +0000228 TII.get(TargetOpcode::COPY), ResultReg)
229 .addReg(II.ImplicitDefs[0]));
230 }
231 return ResultReg;
232}
233
234unsigned ARMFastISel::FastEmitInst_rf(unsigned MachineInstOpcode,
235 const TargetRegisterClass *RC,
236 unsigned Op0, bool Op0IsKill,
237 const ConstantFP *FPImm) {
238 unsigned ResultReg = createResultReg(RC);
239 const TargetInstrDesc &II = TII.get(MachineInstOpcode);
240
241 if (II.getNumDefs() >= 1)
Eric Christopher456144e2010-08-19 00:37:05 +0000242 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000243 .addReg(Op0, Op0IsKill * RegState::Kill)
244 .addFPImm(FPImm));
245 else {
Eric Christopher456144e2010-08-19 00:37:05 +0000246 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000247 .addReg(Op0, Op0IsKill * RegState::Kill)
248 .addFPImm(FPImm));
Eric Christopher456144e2010-08-19 00:37:05 +0000249 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
Eric Christopher0fe7d542010-08-17 01:25:29 +0000250 TII.get(TargetOpcode::COPY), ResultReg)
251 .addReg(II.ImplicitDefs[0]));
252 }
253 return ResultReg;
254}
255
256unsigned ARMFastISel::FastEmitInst_rri(unsigned MachineInstOpcode,
257 const TargetRegisterClass *RC,
258 unsigned Op0, bool Op0IsKill,
259 unsigned Op1, bool Op1IsKill,
260 uint64_t Imm) {
261 unsigned ResultReg = createResultReg(RC);
262 const TargetInstrDesc &II = TII.get(MachineInstOpcode);
263
264 if (II.getNumDefs() >= 1)
Eric Christopher456144e2010-08-19 00:37:05 +0000265 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000266 .addReg(Op0, Op0IsKill * RegState::Kill)
267 .addReg(Op1, Op1IsKill * RegState::Kill)
268 .addImm(Imm));
269 else {
Eric Christopher456144e2010-08-19 00:37:05 +0000270 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000271 .addReg(Op0, Op0IsKill * RegState::Kill)
272 .addReg(Op1, Op1IsKill * RegState::Kill)
273 .addImm(Imm));
Eric Christopher456144e2010-08-19 00:37:05 +0000274 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
Eric Christopher0fe7d542010-08-17 01:25:29 +0000275 TII.get(TargetOpcode::COPY), ResultReg)
276 .addReg(II.ImplicitDefs[0]));
277 }
278 return ResultReg;
279}
280
281unsigned ARMFastISel::FastEmitInst_i(unsigned MachineInstOpcode,
282 const TargetRegisterClass *RC,
283 uint64_t Imm) {
284 unsigned ResultReg = createResultReg(RC);
285 const TargetInstrDesc &II = TII.get(MachineInstOpcode);
286
287 if (II.getNumDefs() >= 1)
Eric Christopher456144e2010-08-19 00:37:05 +0000288 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000289 .addImm(Imm));
290 else {
Eric Christopher456144e2010-08-19 00:37:05 +0000291 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
Eric Christopher0fe7d542010-08-17 01:25:29 +0000292 .addImm(Imm));
Eric Christopher456144e2010-08-19 00:37:05 +0000293 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
Eric Christopher0fe7d542010-08-17 01:25:29 +0000294 TII.get(TargetOpcode::COPY), ResultReg)
295 .addReg(II.ImplicitDefs[0]));
296 }
297 return ResultReg;
298}
299
300unsigned ARMFastISel::FastEmitInst_extractsubreg(MVT RetVT,
301 unsigned Op0, bool Op0IsKill,
302 uint32_t Idx) {
303 unsigned ResultReg = createResultReg(TLI.getRegClassFor(RetVT));
304 assert(TargetRegisterInfo::isVirtualRegister(Op0) &&
305 "Cannot yet extract from physregs");
Eric Christopher456144e2010-08-19 00:37:05 +0000306 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
Eric Christopher0fe7d542010-08-17 01:25:29 +0000307 DL, TII.get(TargetOpcode::COPY), ResultReg)
308 .addReg(Op0, getKillRegState(Op0IsKill), Idx));
309 return ResultReg;
310}
311
Eric Christophercb0b04b2010-08-24 00:07:24 +0000312// Computes the Reg+Offset to get to an object.
313bool ARMFastISel::ARMComputeRegOffset(const Value *Obj, unsigned &Reg,
Eric Christopher83007122010-08-23 21:44:12 +0000314 int &Offset) {
315 // Some boilerplate from the X86 FastISel.
316 const User *U = NULL;
Eric Christopher83007122010-08-23 21:44:12 +0000317 unsigned Opcode = Instruction::UserOp1;
Eric Christophercb0b04b2010-08-24 00:07:24 +0000318 if (const Instruction *I = dyn_cast<Instruction>(Obj)) {
Eric Christopher83007122010-08-23 21:44:12 +0000319 // Don't walk into other basic blocks; it's possible we haven't
320 // visited them yet, so the instructions may not yet be assigned
321 // virtual registers.
322 if (FuncInfo.MBBMap[I->getParent()] != FuncInfo.MBB)
323 return false;
324
325 Opcode = I->getOpcode();
326 U = I;
Eric Christophercb0b04b2010-08-24 00:07:24 +0000327 } else if (const ConstantExpr *C = dyn_cast<ConstantExpr>(Obj)) {
Eric Christopher83007122010-08-23 21:44:12 +0000328 Opcode = C->getOpcode();
329 U = C;
330 }
331
Eric Christophercb0b04b2010-08-24 00:07:24 +0000332 if (const PointerType *Ty = dyn_cast<PointerType>(Obj->getType()))
Eric Christopher83007122010-08-23 21:44:12 +0000333 if (Ty->getAddressSpace() > 255)
334 // Fast instruction selection doesn't support the special
335 // address spaces.
336 return false;
337
338 switch (Opcode) {
339 default:
340 //errs() << "Failing Opcode is: " << *Op1 << "\n";
341 break;
342 case Instruction::Alloca: {
343 // Do static allocas.
Eric Christophercb0b04b2010-08-24 00:07:24 +0000344 const AllocaInst *A = cast<AllocaInst>(Obj);
Eric Christopher83007122010-08-23 21:44:12 +0000345 DenseMap<const AllocaInst*, int>::iterator SI =
346 FuncInfo.StaticAllocaMap.find(A);
347 if (SI != FuncInfo.StaticAllocaMap.end())
348 Offset =
349 TM.getRegisterInfo()->getFrameIndexReference(*FuncInfo.MF,
350 SI->second, Reg);
351 else
352 return false;
353 return true;
354 }
355 }
Eric Christophercb0b04b2010-08-24 00:07:24 +0000356
357 if (const GlobalValue *GV = dyn_cast<GlobalValue>(Obj)) {
358 //errs() << "Failing GV is: " << GV << "\n";
359 return false;
360 }
361
362 // Try to get this in a register if nothing else has worked.
363 Reg = getRegForValue(Obj);
364 return Reg != 0;
Eric Christopher83007122010-08-23 21:44:12 +0000365}
366
367bool ARMFastISel::ARMSelectLoad(const Instruction *I) {
Eric Christophercb0b04b2010-08-24 00:07:24 +0000368 // Our register and offset with innocuous defaults.
369 unsigned Reg = 0;
370 int Offset = 0;
Eric Christopher83007122010-08-23 21:44:12 +0000371
Eric Christopher8654c712010-08-23 23:14:31 +0000372 // TODO: Think about using loadRegFromStackSlot() here when we can.
373
Eric Christopher83007122010-08-23 21:44:12 +0000374 // See if we can handle this as Reg + Offset
Eric Christophercb0b04b2010-08-24 00:07:24 +0000375 if (!ARMComputeRegOffset(I->getOperand(0), Reg, Offset))
Eric Christopher83007122010-08-23 21:44:12 +0000376 return false;
377
Eric Christopher8654c712010-08-23 23:14:31 +0000378 // Since the offset may be too large for the load instruction
379 // get the reg+offset into a register.
380 // TODO: Optimize this somewhat.
Eric Christopher8654c712010-08-23 23:14:31 +0000381 ARMCC::CondCodes Pred = ARMCC::AL;
382 unsigned PredReg = 0;
383
384 if (!AFI->isThumbFunction())
385 emitARMRegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
Eric Christopher1dfb4d32010-08-23 23:28:04 +0000386 Reg, Reg, Offset, Pred, PredReg,
Eric Christopher8654c712010-08-23 23:14:31 +0000387 static_cast<const ARMBaseInstrInfo&>(TII));
388 else {
389 assert(AFI->isThumb2Function());
390 emitT2RegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
Eric Christopher1dfb4d32010-08-23 23:28:04 +0000391 Reg, Reg, Offset, Pred, PredReg,
Eric Christopher8654c712010-08-23 23:14:31 +0000392 static_cast<const ARMBaseInstrInfo&>(TII));
393 }
Eric Christopher1dfb4d32010-08-23 23:28:04 +0000394
395 // FIXME: There is more than one register class in the world...
Eric Christopher83007122010-08-23 21:44:12 +0000396 unsigned ResultReg = createResultReg(ARM::GPRRegisterClass);
397 AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
398 TII.get(ARM::LDR), ResultReg)
399 .addImm(0).addReg(Reg).addImm(Offset));
400
401 return true;
402}
403
Eric Christopherab695882010-07-21 22:26:11 +0000404bool ARMFastISel::TargetSelectInstruction(const Instruction *I) {
Eric Christopher7fe55b72010-08-23 22:32:45 +0000405 // No Thumb-1 for now.
406 if (AFI->isThumbFunction() && !AFI->isThumb2Function()) return false;
407
Eric Christopherab695882010-07-21 22:26:11 +0000408 switch (I->getOpcode()) {
Eric Christopher83007122010-08-23 21:44:12 +0000409 case Instruction::Load:
410 return ARMSelectLoad(I);
Eric Christopherab695882010-07-21 22:26:11 +0000411 default: break;
412 }
413 return false;
414}
415
416namespace llvm {
417 llvm::FastISel *ARM::createFastISel(FunctionLoweringInfo &funcInfo) {
Eric Christopher038fea52010-08-17 00:46:57 +0000418 if (EnableARMFastISel) return new ARMFastISel(funcInfo);
Evan Cheng09447952010-07-26 18:32:55 +0000419 return 0;
Eric Christopherab695882010-07-21 22:26:11 +0000420 }
421}