Replace M_REMATERIALIZIBLE and the newly-added isOtherReMaterializableLoad
[oota-llvm.git] / lib / Target / ARM / ARMInstrInfo.cpp
1 //===- ARMInstrInfo.cpp - ARM Instruction Information -----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the "Instituto Nokia de Tecnologia" and
6 // is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 // This file contains the ARM implementation of the TargetInstrInfo class.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "ARMInstrInfo.h"
16 #include "ARM.h"
17 #include "ARMAddressingModes.h"
18 #include "ARMGenInstrInfo.inc"
19 #include "ARMMachineFunctionInfo.h"
20 #include "llvm/CodeGen/LiveVariables.h"
21 #include "llvm/CodeGen/MachineInstrBuilder.h"
22 #include "llvm/CodeGen/MachineJumpTableInfo.h"
23 #include "llvm/Target/TargetAsmInfo.h"
24 #include "llvm/Support/CommandLine.h"
25 using namespace llvm;
26
27 static cl::opt<bool> EnableARM3Addr("enable-arm-3-addr-conv", cl::Hidden,
28                                   cl::desc("Enable ARM 2-addr to 3-addr conv"));
29
30 ARMInstrInfo::ARMInstrInfo(const ARMSubtarget &STI)
31   : TargetInstrInfo(ARMInsts, sizeof(ARMInsts)/sizeof(ARMInsts[0])),
32     RI(*this, STI) {
33 }
34
35 const TargetRegisterClass *ARMInstrInfo::getPointerRegClass() const {
36   return &ARM::GPRRegClass;
37 }
38
39 /// Return true if the instruction is a register to register move and
40 /// leave the source and dest operands in the passed parameters.
41 ///
42 bool ARMInstrInfo::isMoveInstr(const MachineInstr &MI,
43                                unsigned &SrcReg, unsigned &DstReg) const {
44   MachineOpCode oc = MI.getOpcode();
45   switch (oc) {
46   default:
47     return false;
48   case ARM::FCPYS:
49   case ARM::FCPYD:
50     SrcReg = MI.getOperand(1).getReg();
51     DstReg = MI.getOperand(0).getReg();
52     return true;
53   case ARM::MOVr:
54   case ARM::tMOVr:
55     assert(MI.getInstrDescriptor()->numOperands >= 2 &&
56            MI.getOperand(0).isRegister() &&
57            MI.getOperand(1).isRegister() &&
58            "Invalid ARM MOV instruction");
59     SrcReg = MI.getOperand(1).getReg();
60     DstReg = MI.getOperand(0).getReg();
61     return true;
62   }
63 }
64
65 unsigned ARMInstrInfo::isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const{
66   switch (MI->getOpcode()) {
67   default: break;
68   case ARM::LDR:
69     if (MI->getOperand(1).isFrameIndex() &&
70         MI->getOperand(2).isReg() &&
71         MI->getOperand(3).isImmediate() && 
72         MI->getOperand(2).getReg() == 0 &&
73         MI->getOperand(3).getImmedValue() == 0) {
74       FrameIndex = MI->getOperand(1).getFrameIndex();
75       return MI->getOperand(0).getReg();
76     }
77     break;
78   case ARM::FLDD:
79   case ARM::FLDS:
80     if (MI->getOperand(1).isFrameIndex() &&
81         MI->getOperand(2).isImmediate() && 
82         MI->getOperand(2).getImmedValue() == 0) {
83       FrameIndex = MI->getOperand(1).getFrameIndex();
84       return MI->getOperand(0).getReg();
85     }
86     break;
87   case ARM::tRestore:
88     if (MI->getOperand(1).isFrameIndex() &&
89         MI->getOperand(2).isImmediate() && 
90         MI->getOperand(2).getImmedValue() == 0) {
91       FrameIndex = MI->getOperand(1).getFrameIndex();
92       return MI->getOperand(0).getReg();
93     }
94     break;
95   }
96   return 0;
97 }
98
99 unsigned ARMInstrInfo::isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const {
100   switch (MI->getOpcode()) {
101   default: break;
102   case ARM::STR:
103     if (MI->getOperand(1).isFrameIndex() &&
104         MI->getOperand(2).isReg() &&
105         MI->getOperand(3).isImmediate() && 
106         MI->getOperand(2).getReg() == 0 &&
107         MI->getOperand(3).getImmedValue() == 0) {
108       FrameIndex = MI->getOperand(1).getFrameIndex();
109       return MI->getOperand(0).getReg();
110     }
111     break;
112   case ARM::FSTD:
113   case ARM::FSTS:
114     if (MI->getOperand(1).isFrameIndex() &&
115         MI->getOperand(2).isImmediate() && 
116         MI->getOperand(2).getImmedValue() == 0) {
117       FrameIndex = MI->getOperand(1).getFrameIndex();
118       return MI->getOperand(0).getReg();
119     }
120     break;
121   case ARM::tSpill:
122     if (MI->getOperand(1).isFrameIndex() &&
123         MI->getOperand(2).isImmediate() && 
124         MI->getOperand(2).getImmedValue() == 0) {
125       FrameIndex = MI->getOperand(1).getFrameIndex();
126       return MI->getOperand(0).getReg();
127     }
128     break;
129   }
130   return 0;
131 }
132
133 bool ARMInstrInfo::isTriviallyReMaterializable(MachineInstr *MI) const {
134   switch (MI->getOpcode()) {
135   default: break;
136   case ARM::LDRcp:
137   case ARM::MOVi:
138   case ARM::MVNi:
139   case ARM::MOVi2pieces:
140   case ARM::tLDRcp:
141     // These instructions are always trivially rematerializable.
142     return true;
143   }
144   return false;
145 }
146
147 static unsigned getUnindexedOpcode(unsigned Opc) {
148   switch (Opc) {
149   default: break;
150   case ARM::LDR_PRE:
151   case ARM::LDR_POST:
152     return ARM::LDR;
153   case ARM::LDRH_PRE:
154   case ARM::LDRH_POST:
155     return ARM::LDRH;
156   case ARM::LDRB_PRE:
157   case ARM::LDRB_POST:
158     return ARM::LDRB;
159   case ARM::LDRSH_PRE:
160   case ARM::LDRSH_POST:
161     return ARM::LDRSH;
162   case ARM::LDRSB_PRE:
163   case ARM::LDRSB_POST:
164     return ARM::LDRSB;
165   case ARM::STR_PRE:
166   case ARM::STR_POST:
167     return ARM::STR;
168   case ARM::STRH_PRE:
169   case ARM::STRH_POST:
170     return ARM::STRH;
171   case ARM::STRB_PRE:
172   case ARM::STRB_POST:
173     return ARM::STRB;
174   }
175   return 0;
176 }
177
178 MachineInstr *
179 ARMInstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
180                                     MachineBasicBlock::iterator &MBBI,
181                                     LiveVariables &LV) const {
182   if (!EnableARM3Addr)
183     return NULL;
184
185   MachineInstr *MI = MBBI;
186   unsigned TSFlags = MI->getInstrDescriptor()->TSFlags;
187   bool isPre = false;
188   switch ((TSFlags & ARMII::IndexModeMask) >> ARMII::IndexModeShift) {
189   default: return NULL;
190   case ARMII::IndexModePre:
191     isPre = true;
192     break;
193   case ARMII::IndexModePost:
194     break;
195   }
196
197   // Try spliting an indexed load / store to a un-indexed one plus an add/sub
198   // operation.
199   unsigned MemOpc = getUnindexedOpcode(MI->getOpcode());
200   if (MemOpc == 0)
201     return NULL;
202
203   MachineInstr *UpdateMI = NULL;
204   MachineInstr *MemMI = NULL;
205   unsigned AddrMode = (TSFlags & ARMII::AddrModeMask);
206   const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
207   unsigned NumOps = TID->numOperands;
208   bool isLoad = (TID->Flags & M_LOAD_FLAG) != 0;
209   const MachineOperand &WB = isLoad ? MI->getOperand(1) : MI->getOperand(0);
210   const MachineOperand &Base = MI->getOperand(2);
211   const MachineOperand &Offset = MI->getOperand(NumOps-3);
212   unsigned WBReg = WB.getReg();
213   unsigned BaseReg = Base.getReg();
214   unsigned OffReg = Offset.getReg();
215   unsigned OffImm = MI->getOperand(NumOps-2).getImm();
216   ARMCC::CondCodes Pred = (ARMCC::CondCodes)MI->getOperand(NumOps-1).getImm();
217   switch (AddrMode) {
218   default:
219     assert(false && "Unknown indexed op!");
220     return NULL;
221   case ARMII::AddrMode2: {
222     bool isSub = ARM_AM::getAM2Op(OffImm) == ARM_AM::sub;
223     unsigned Amt = ARM_AM::getAM2Offset(OffImm);
224     if (OffReg == 0) {
225       int SOImmVal = ARM_AM::getSOImmVal(Amt);
226       if (SOImmVal == -1)
227         // Can't encode it in a so_imm operand. This transformation will
228         // add more than 1 instruction. Abandon!
229         return NULL;
230       UpdateMI = BuildMI(get(isSub ? ARM::SUBri : ARM::ADDri), WBReg)
231         .addReg(BaseReg).addImm(SOImmVal).addImm(Pred);
232     } else if (Amt != 0) {
233       ARM_AM::ShiftOpc ShOpc = ARM_AM::getAM2ShiftOpc(OffImm);
234       unsigned SOOpc = ARM_AM::getSORegOpc(ShOpc, Amt);
235       UpdateMI = BuildMI(get(isSub ? ARM::SUBrs : ARM::ADDrs), WBReg)
236         .addReg(BaseReg).addReg(OffReg).addReg(0).addImm(SOOpc).addImm(Pred);
237     } else 
238       UpdateMI = BuildMI(get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg)
239         .addReg(BaseReg).addReg(OffReg).addImm(Pred);
240     break;
241   }
242   case ARMII::AddrMode3 : {
243     bool isSub = ARM_AM::getAM3Op(OffImm) == ARM_AM::sub;
244     unsigned Amt = ARM_AM::getAM3Offset(OffImm);
245     if (OffReg == 0)
246       // Immediate is 8-bits. It's guaranteed to fit in a so_imm operand.
247       UpdateMI = BuildMI(get(isSub ? ARM::SUBri : ARM::ADDri), WBReg)
248         .addReg(BaseReg).addImm(Amt).addImm(Pred);
249     else
250       UpdateMI = BuildMI(get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg)
251         .addReg(BaseReg).addReg(OffReg).addImm(Pred);
252     break;
253   }
254   }
255
256   std::vector<MachineInstr*> NewMIs;
257   if (isPre) {
258     if (isLoad)
259       MemMI = BuildMI(get(MemOpc), MI->getOperand(0).getReg())
260         .addReg(WBReg).addReg(0).addImm(0).addImm(Pred);
261     else
262       MemMI = BuildMI(get(MemOpc)).addReg(MI->getOperand(1).getReg())
263         .addReg(WBReg).addReg(0).addImm(0).addImm(Pred);
264     NewMIs.push_back(MemMI);
265     NewMIs.push_back(UpdateMI);
266   } else {
267     if (isLoad)
268       MemMI = BuildMI(get(MemOpc), MI->getOperand(0).getReg())
269         .addReg(BaseReg).addReg(0).addImm(0).addImm(Pred);
270     else
271       MemMI = BuildMI(get(MemOpc)).addReg(MI->getOperand(1).getReg())
272         .addReg(BaseReg).addReg(0).addImm(0).addImm(Pred);
273     if (WB.isDead())
274       UpdateMI->getOperand(0).setIsDead();
275     NewMIs.push_back(UpdateMI);
276     NewMIs.push_back(MemMI);
277   }
278   
279   // Transfer LiveVariables states, kill / dead info.
280   for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
281     MachineOperand &MO = MI->getOperand(i);
282     if (MO.isRegister() && MO.getReg() &&
283         MRegisterInfo::isVirtualRegister(MO.getReg())) {
284       unsigned Reg = MO.getReg();
285       LiveVariables::VarInfo &VI = LV.getVarInfo(Reg);
286       if (MO.isDef()) {
287         MachineInstr *NewMI = (Reg == WBReg) ? UpdateMI : MemMI;
288         if (MO.isDead())
289           LV.addVirtualRegisterDead(Reg, NewMI);
290         // Update the defining instruction.
291         if (VI.DefInst == MI)
292           VI.DefInst = NewMI;
293       }
294       if (MO.isUse() && MO.isKill()) {
295         for (unsigned j = 0; j < 2; ++j) {
296           // Look at the two new MI's in reverse order.
297           MachineInstr *NewMI = NewMIs[j];
298           int NIdx = NewMI->findRegisterUseOperandIdx(Reg);
299           if (NIdx == -1)
300             continue;
301           LV.addVirtualRegisterKilled(Reg, NewMI);
302           if (VI.removeKill(MI))
303             VI.Kills.push_back(NewMI);
304           break;
305         }
306       }
307     }
308   }
309
310   MFI->insert(MBBI, NewMIs[1]);
311   MFI->insert(MBBI, NewMIs[0]);
312   return NewMIs[0];
313 }
314
315 // Branch analysis.
316 bool ARMInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
317                                  MachineBasicBlock *&FBB,
318                                  std::vector<MachineOperand> &Cond) const {
319   // If the block has no terminators, it just falls into the block after it.
320   MachineBasicBlock::iterator I = MBB.end();
321   if (I == MBB.begin() || !isUnpredicatedTerminator(--I))
322     return false;
323   
324   // Get the last instruction in the block.
325   MachineInstr *LastInst = I;
326   
327   // If there is only one terminator instruction, process it.
328   unsigned LastOpc = LastInst->getOpcode();
329   if (I == MBB.begin() ||
330       isPredicated(--I) || !isUnpredicatedTerminator(I)) {
331     if (LastOpc == ARM::B || LastOpc == ARM::tB) {
332       TBB = LastInst->getOperand(0).getMachineBasicBlock();
333       return false;
334     }
335     if (LastOpc == ARM::Bcc || LastOpc == ARM::tBcc) {
336       // Block ends with fall-through condbranch.
337       TBB = LastInst->getOperand(0).getMachineBasicBlock();
338       Cond.push_back(LastInst->getOperand(1));
339       return false;
340     }
341     return true;  // Can't handle indirect branch.
342   }
343   
344   // Get the instruction before it if it is a terminator.
345   MachineInstr *SecondLastInst = I;
346   
347   // If there are three terminators, we don't know what sort of block this is.
348   if (SecondLastInst && I != MBB.begin() &&
349       !isPredicated(--I) && isUnpredicatedTerminator(I))
350     return true;
351   
352   // If the block ends with ARM::B/ARM::tB and a ARM::Bcc/ARM::tBcc, handle it.
353   unsigned SecondLastOpc = SecondLastInst->getOpcode();
354   if ((SecondLastOpc == ARM::Bcc && LastOpc == ARM::B) ||
355       (SecondLastOpc == ARM::tBcc && LastOpc == ARM::tB)) {
356     TBB =  SecondLastInst->getOperand(0).getMachineBasicBlock();
357     Cond.push_back(SecondLastInst->getOperand(1));
358     FBB = LastInst->getOperand(0).getMachineBasicBlock();
359     return false;
360   }
361   
362   // If the block ends with two B's or tB's, handle it.  The second one is not
363   // executed, so remove it.
364   if ((SecondLastOpc == ARM::B || SecondLastOpc==ARM::tB) &&
365       (LastOpc == ARM::B || LastOpc == ARM::tB)) {
366     TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
367     I = LastInst;
368     I->eraseFromParent();
369     return false;
370   }
371
372   // Otherwise, can't handle this.
373   return true;
374 }
375
376
377 unsigned ARMInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
378   MachineFunction &MF = *MBB.getParent();
379   ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
380   int BOpc   = AFI->isThumbFunction() ? ARM::tB : ARM::B;
381   int BccOpc = AFI->isThumbFunction() ? ARM::tBcc : ARM::Bcc;
382
383   MachineBasicBlock::iterator I = MBB.end();
384   if (I == MBB.begin()) return 0;
385   --I;
386   if (I->getOpcode() != BOpc && I->getOpcode() != BccOpc)
387     return 0;
388   
389   // Remove the branch.
390   I->eraseFromParent();
391   
392   I = MBB.end();
393   
394   if (I == MBB.begin()) return 1;
395   --I;
396   if (I->getOpcode() != BccOpc)
397     return 1;
398   
399   // Remove the branch.
400   I->eraseFromParent();
401   return 2;
402 }
403
404 unsigned ARMInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
405                                 MachineBasicBlock *FBB,
406                                 const std::vector<MachineOperand> &Cond) const {
407   MachineFunction &MF = *MBB.getParent();
408   ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
409   int BOpc   = AFI->isThumbFunction() ? ARM::tB : ARM::B;
410   int BccOpc = AFI->isThumbFunction() ? ARM::tBcc : ARM::Bcc;
411
412   // Shouldn't be a fall through.
413   assert(TBB && "InsertBranch must not be told to insert a fallthrough");
414   assert((Cond.size() == 1 || Cond.size() == 0) &&
415          "ARM branch conditions have two components!");
416   
417   if (FBB == 0) {
418     if (Cond.empty()) // Unconditional branch?
419       BuildMI(&MBB, get(BOpc)).addMBB(TBB);
420     else
421       BuildMI(&MBB, get(BccOpc)).addMBB(TBB).addImm(Cond[0].getImm());
422     return 1;
423   }
424   
425   // Two-way conditional branch.
426   BuildMI(&MBB, get(BccOpc)).addMBB(TBB).addImm(Cond[0].getImm());
427   BuildMI(&MBB, get(BOpc)).addMBB(FBB);
428   return 2;
429 }
430
431 bool ARMInstrInfo::BlockHasNoFallThrough(MachineBasicBlock &MBB) const {
432   if (MBB.empty()) return false;
433   
434   switch (MBB.back().getOpcode()) {
435   case ARM::BX_RET:   // Return.
436   case ARM::LDM_RET:
437   case ARM::tBX_RET:
438   case ARM::tBX_RET_vararg:
439   case ARM::tPOP_RET:
440   case ARM::B:
441   case ARM::tB:       // Uncond branch.
442   case ARM::tBR_JTr:
443   case ARM::BR_JTr:   // Jumptable branch.
444   case ARM::BR_JTm:   // Jumptable branch through mem.
445   case ARM::BR_JTadd: // Jumptable branch add to pc.
446     return true;
447   default: return false;
448   }
449 }
450
451 bool ARMInstrInfo::
452 ReverseBranchCondition(std::vector<MachineOperand> &Cond) const {
453   ARMCC::CondCodes CC = (ARMCC::CondCodes)(int)Cond[0].getImm();
454   Cond[0].setImm(ARMCC::getOppositeCondition(CC));
455   return false;
456 }
457
458 bool ARMInstrInfo::isPredicated(const MachineInstr *MI) const {
459   int PIdx = MI->findFirstPredOperandIdx();
460   return PIdx != -1 && MI->getOperand(PIdx).getImmedValue() != ARMCC::AL;
461 }
462
463 bool ARMInstrInfo::PredicateInstruction(MachineInstr *MI,
464                                 const std::vector<MachineOperand> &Pred) const {
465   unsigned Opc = MI->getOpcode();
466   if (Opc == ARM::B || Opc == ARM::tB) {
467     MI->setInstrDescriptor(get(Opc == ARM::B ? ARM::Bcc : ARM::tBcc));
468     MI->addImmOperand(Pred[0].getImmedValue());
469     return true;
470   }
471
472   int PIdx = MI->findFirstPredOperandIdx();
473   if (PIdx != -1) {
474     MachineOperand &PMO = MI->getOperand(PIdx);
475     PMO.setImm(Pred[0].getImmedValue());
476     return true;
477   }
478   return false;
479 }
480
481 bool
482 ARMInstrInfo::SubsumesPredicate(const std::vector<MachineOperand> &Pred1,
483                                 const std::vector<MachineOperand> &Pred2) const{
484   if (Pred1.size() > 1 || Pred2.size() > 1)
485     return false;
486
487   ARMCC::CondCodes CC1 = (ARMCC::CondCodes)Pred1[0].getImmedValue();
488   ARMCC::CondCodes CC2 = (ARMCC::CondCodes)Pred2[0].getImmedValue();
489   if (CC1 == CC2)
490     return true;
491
492   switch (CC1) {
493   default:
494     return false;
495   case ARMCC::AL:
496     return true;
497   case ARMCC::HS:
498     return CC2 == ARMCC::HI;
499   case ARMCC::LS:
500     return CC2 == ARMCC::LO || CC2 == ARMCC::EQ;
501   case ARMCC::GE:
502     return CC2 == ARMCC::GT;
503   case ARMCC::LE:
504     return CC2 == ARMCC::LT;
505   }
506 }
507
508 /// FIXME: Works around a gcc miscompilation with -fstrict-aliasing
509 static unsigned getNumJTEntries(const std::vector<MachineJumpTableEntry> &JT,
510                                 unsigned JTI) DISABLE_INLINE;
511 static unsigned getNumJTEntries(const std::vector<MachineJumpTableEntry> &JT,
512                                 unsigned JTI) {
513   return JT[JTI].MBBs.size();
514 }
515
516 /// GetInstSize - Return the size of the specified MachineInstr.
517 ///
518 unsigned ARM::GetInstSize(MachineInstr *MI) {
519   MachineBasicBlock &MBB = *MI->getParent();
520   const MachineFunction *MF = MBB.getParent();
521   const TargetAsmInfo *TAI = MF->getTarget().getTargetAsmInfo();
522
523   // Basic size info comes from the TSFlags field.
524   const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
525   unsigned TSFlags = TID->TSFlags;
526   
527   switch ((TSFlags & ARMII::SizeMask) >> ARMII::SizeShift) {
528   default:
529     // If this machine instr is an inline asm, measure it.
530     if (MI->getOpcode() == ARM::INLINEASM)
531       return TAI->getInlineAsmLength(MI->getOperand(0).getSymbolName());
532     if (MI->getOpcode() == ARM::LABEL)
533       return 0;
534     assert(0 && "Unknown or unset size field for instr!");
535     break;
536   case ARMII::Size8Bytes: return 8;          // Arm instruction x 2.
537   case ARMII::Size4Bytes: return 4;          // Arm instruction.
538   case ARMII::Size2Bytes: return 2;          // Thumb instruction.
539   case ARMII::SizeSpecial: {
540     switch (MI->getOpcode()) {
541     case ARM::CONSTPOOL_ENTRY:
542       // If this machine instr is a constant pool entry, its size is recorded as
543       // operand #2.
544       return MI->getOperand(2).getImm();
545     case ARM::BR_JTr:
546     case ARM::BR_JTm:
547     case ARM::BR_JTadd:
548     case ARM::tBR_JTr: {
549       // These are jumptable branches, i.e. a branch followed by an inlined
550       // jumptable. The size is 4 + 4 * number of entries.
551       unsigned NumOps = TID->numOperands;
552       MachineOperand JTOP =
553         MI->getOperand(NumOps - ((TID->Flags & M_PREDICABLE) ? 3 : 2));
554       unsigned JTI = JTOP.getJumpTableIndex();
555       MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
556       const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
557       assert(JTI < JT.size());
558       // Thumb instructions are 2 byte aligned, but JT entries are 4 byte
559       // 4 aligned. The assembler / linker may add 2 byte padding just before
560       // the JT entries.  The size does not include this padding; the
561       // constant islands pass does separate bookkeeping for it.
562       // FIXME: If we know the size of the function is less than (1 << 16) *2
563       // bytes, we can use 16-bit entries instead. Then there won't be an
564       // alignment issue.
565       return getNumJTEntries(JT, JTI) * 4 + 
566              (MI->getOpcode()==ARM::tBR_JTr ? 2 : 4);
567     }
568     default:
569       // Otherwise, pseudo-instruction sizes are zero.
570       return 0;
571     }
572   }
573   }
574 }
575
576 /// GetFunctionSize - Returns the size of the specified MachineFunction.
577 ///
578 unsigned ARM::GetFunctionSize(MachineFunction &MF) {
579   unsigned FnSize = 0;
580   for (MachineFunction::iterator MBBI = MF.begin(), E = MF.end();
581        MBBI != E; ++MBBI) {
582     MachineBasicBlock &MBB = *MBBI;
583     for (MachineBasicBlock::iterator I = MBB.begin(),E = MBB.end(); I != E; ++I)
584       FnSize += ARM::GetInstSize(I);
585   }
586   return FnSize;
587 }