blob: 17e7d4479db5ce4b376f553281762655b43ba783 [file] [log] [blame]
Evan Cheng148b6a42007-07-05 21:15:40 +00001//===-- ARM/ARMCodeEmitter.cpp - Convert ARM code to machine code ---------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Cheng148b6a42007-07-05 21:15:40 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the pass that transforms the ARM machine instructions into
11// relocatable machine code.
12//
13//===----------------------------------------------------------------------===//
14
Evan Cheng0f282432008-10-29 23:55:43 +000015#define DEBUG_TYPE "jit"
Evan Cheng7602e112008-09-02 06:52:38 +000016#include "ARM.h"
17#include "ARMAddressingModes.h"
Evan Cheng0f282432008-10-29 23:55:43 +000018#include "ARMConstantPoolValue.h"
Evan Cheng148b6a42007-07-05 21:15:40 +000019#include "ARMInstrInfo.h"
Evan Cheng7602e112008-09-02 06:52:38 +000020#include "ARMRelocations.h"
Evan Cheng148b6a42007-07-05 21:15:40 +000021#include "ARMSubtarget.h"
22#include "ARMTargetMachine.h"
Jim Grosbachbc6d8762008-10-28 18:25:49 +000023#include "llvm/Constants.h"
24#include "llvm/DerivedTypes.h"
Evan Cheng42d5ee062008-09-13 01:15:21 +000025#include "llvm/Function.h"
Evan Cheng148b6a42007-07-05 21:15:40 +000026#include "llvm/PassManager.h"
27#include "llvm/CodeGen/MachineCodeEmitter.h"
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000028#include "llvm/CodeGen/JITCodeEmitter.h"
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000029#include "llvm/CodeGen/ObjectCodeEmitter.h"
Evan Cheng057d0c32008-09-18 07:28:19 +000030#include "llvm/CodeGen/MachineConstantPool.h"
Evan Cheng148b6a42007-07-05 21:15:40 +000031#include "llvm/CodeGen/MachineFunctionPass.h"
32#include "llvm/CodeGen/MachineInstr.h"
Evan Cheng4df60f52008-11-07 09:06:08 +000033#include "llvm/CodeGen/MachineJumpTableInfo.h"
Daniel Dunbar003de662009-09-21 05:58:35 +000034#include "llvm/CodeGen/MachineModuleInfo.h"
Evan Cheng148b6a42007-07-05 21:15:40 +000035#include "llvm/CodeGen/Passes.h"
Evan Cheng148b6a42007-07-05 21:15:40 +000036#include "llvm/ADT/Statistic.h"
Evan Cheng42d5ee062008-09-13 01:15:21 +000037#include "llvm/Support/Debug.h"
Torok Edwinab7c09b2009-07-08 18:01:40 +000038#include "llvm/Support/ErrorHandling.h"
39#include "llvm/Support/raw_ostream.h"
Evan Cheng4df60f52008-11-07 09:06:08 +000040#ifndef NDEBUG
41#include <iomanip>
42#endif
Evan Cheng148b6a42007-07-05 21:15:40 +000043using namespace llvm;
44
45STATISTIC(NumEmitted, "Number of machine instructions emitted");
46
47namespace {
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000048
49 class ARMCodeEmitter {
50 public:
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000051 /// getBinaryCodeForInstr - This function, generated by the
52 /// CodeEmitterGenerator using TableGen, produces the binary encoding for
53 /// machine instructions.
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000054 unsigned getBinaryCodeForInstr(const MachineInstr &MI);
55 };
56
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +000057 template<class CodeEmitter>
Nick Lewycky6726b6d2009-10-25 06:33:48 +000058 class Emitter : public MachineFunctionPass, public ARMCodeEmitter {
Evan Cheng057d0c32008-09-18 07:28:19 +000059 ARMJITInfo *JTI;
60 const ARMInstrInfo *II;
61 const TargetData *TD;
Evan Cheng08669742009-09-10 01:23:53 +000062 const ARMSubtarget *Subtarget;
Evan Cheng057d0c32008-09-18 07:28:19 +000063 TargetMachine &TM;
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +000064 CodeEmitter &MCE;
Evan Cheng938b9d82008-10-31 19:55:13 +000065 const std::vector<MachineConstantPoolEntry> *MCPEs;
Evan Cheng4df60f52008-11-07 09:06:08 +000066 const std::vector<MachineJumpTableEntry> *MJTEs;
67 bool IsPIC;
68
Daniel Dunbar003de662009-09-21 05:58:35 +000069 void getAnalysisUsage(AnalysisUsage &AU) const {
70 AU.addRequired<MachineModuleInfo>();
71 MachineFunctionPass::getAnalysisUsage(AU);
72 }
73
Evan Cheng148b6a42007-07-05 21:15:40 +000074 public:
75 static char ID;
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +000076 explicit Emitter(TargetMachine &tm, CodeEmitter &mce)
Evan Cheng057d0c32008-09-18 07:28:19 +000077 : MachineFunctionPass(&ID), JTI(0), II(0), TD(0), TM(tm),
Evan Cheng4df60f52008-11-07 09:06:08 +000078 MCE(mce), MCPEs(0), MJTEs(0),
79 IsPIC(TM.getRelocationModel() == Reloc::PIC_) {}
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +000080 Emitter(TargetMachine &tm, CodeEmitter &mce,
Evan Cheng148b6a42007-07-05 21:15:40 +000081 const ARMInstrInfo &ii, const TargetData &td)
Evan Cheng057d0c32008-09-18 07:28:19 +000082 : MachineFunctionPass(&ID), JTI(0), II(&ii), TD(&td), TM(tm),
Evan Cheng4df60f52008-11-07 09:06:08 +000083 MCE(mce), MCPEs(0), MJTEs(0),
84 IsPIC(TM.getRelocationModel() == Reloc::PIC_) {}
Evan Cheng148b6a42007-07-05 21:15:40 +000085
86 bool runOnMachineFunction(MachineFunction &MF);
87
88 virtual const char *getPassName() const {
89 return "ARM Machine Code Emitter";
90 }
91
92 void emitInstruction(const MachineInstr &MI);
Evan Cheng7602e112008-09-02 06:52:38 +000093
94 private:
Evan Cheng057d0c32008-09-18 07:28:19 +000095
Evan Cheng83b5cf02008-11-05 23:22:34 +000096 void emitWordLE(unsigned Binary);
97
Evan Chengcb5201f2008-11-11 22:19:31 +000098 void emitDWordLE(uint64_t Binary);
99
Evan Cheng057d0c32008-09-18 07:28:19 +0000100 void emitConstPoolInstruction(const MachineInstr &MI);
101
Evan Cheng90922132008-11-06 02:25:39 +0000102 void emitMOVi2piecesInstruction(const MachineInstr &MI);
103
Evan Cheng4df60f52008-11-07 09:06:08 +0000104 void emitLEApcrelJTInstruction(const MachineInstr &MI);
105
Evan Chenga9562552008-11-14 20:09:11 +0000106 void emitPseudoMoveInstruction(const MachineInstr &MI);
107
Evan Cheng83b5cf02008-11-05 23:22:34 +0000108 void addPCLabel(unsigned LabelID);
109
Evan Cheng057d0c32008-09-18 07:28:19 +0000110 void emitPseudoInstruction(const MachineInstr &MI);
111
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000112 unsigned getMachineSoRegOpValue(const MachineInstr &MI,
Evan Cheng49a9f292008-09-12 22:45:55 +0000113 const TargetInstrDesc &TID,
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000114 const MachineOperand &MO,
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000115 unsigned OpIdx);
116
Evan Cheng90922132008-11-06 02:25:39 +0000117 unsigned getMachineSoImmOpValue(unsigned SoImm);
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000118
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000119 unsigned getAddrModeSBit(const MachineInstr &MI,
120 const TargetInstrDesc &TID) const;
Evan Cheng49a9f292008-09-12 22:45:55 +0000121
Evan Cheng83b5cf02008-11-05 23:22:34 +0000122 void emitDataProcessingInstruction(const MachineInstr &MI,
Evan Cheng437c1732008-11-07 22:30:53 +0000123 unsigned ImplicitRd = 0,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000124 unsigned ImplicitRn = 0);
Evan Cheng7602e112008-09-02 06:52:38 +0000125
Evan Cheng83b5cf02008-11-05 23:22:34 +0000126 void emitLoadStoreInstruction(const MachineInstr &MI,
Evan Cheng4df60f52008-11-07 09:06:08 +0000127 unsigned ImplicitRd = 0,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000128 unsigned ImplicitRn = 0);
Evan Chengedda31c2008-11-05 18:35:52 +0000129
Evan Cheng83b5cf02008-11-05 23:22:34 +0000130 void emitMiscLoadStoreInstruction(const MachineInstr &MI,
131 unsigned ImplicitRn = 0);
Evan Chengedda31c2008-11-05 18:35:52 +0000132
133 void emitLoadStoreMultipleInstruction(const MachineInstr &MI);
134
Evan Chengfbc9d412008-11-06 01:21:28 +0000135 void emitMulFrmInstruction(const MachineInstr &MI);
Evan Chengedda31c2008-11-05 18:35:52 +0000136
Evan Cheng97f48c32008-11-06 22:15:19 +0000137 void emitExtendInstruction(const MachineInstr &MI);
138
Evan Cheng8b59db32008-11-07 01:41:35 +0000139 void emitMiscArithInstruction(const MachineInstr &MI);
140
Evan Chengedda31c2008-11-05 18:35:52 +0000141 void emitBranchInstruction(const MachineInstr &MI);
142
Evan Cheng437c1732008-11-07 22:30:53 +0000143 void emitInlineJumpTable(unsigned JTIndex);
Evan Cheng4df60f52008-11-07 09:06:08 +0000144
Evan Chengedda31c2008-11-05 18:35:52 +0000145 void emitMiscBranchInstruction(const MachineInstr &MI);
Evan Cheng7602e112008-09-02 06:52:38 +0000146
Evan Cheng96581d32008-11-11 02:11:05 +0000147 void emitVFPArithInstruction(const MachineInstr &MI);
148
Evan Cheng78be83d2008-11-11 19:40:26 +0000149 void emitVFPConversionInstruction(const MachineInstr &MI);
150
Evan Chengcd8e66a2008-11-11 21:48:44 +0000151 void emitVFPLoadStoreInstruction(const MachineInstr &MI);
152
153 void emitVFPLoadStoreMultipleInstruction(const MachineInstr &MI);
154
155 void emitMiscInstruction(const MachineInstr &MI);
156
Evan Cheng7602e112008-09-02 06:52:38 +0000157 /// getMachineOpValue - Return binary encoding of operand. If the machine
158 /// operand requires relocation, record the relocation and return zero.
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000159 unsigned getMachineOpValue(const MachineInstr &MI,const MachineOperand &MO);
Evan Cheng7602e112008-09-02 06:52:38 +0000160 unsigned getMachineOpValue(const MachineInstr &MI, unsigned OpIdx) {
161 return getMachineOpValue(MI, MI.getOperand(OpIdx));
162 }
Evan Cheng7602e112008-09-02 06:52:38 +0000163
Evan Cheng83b5cf02008-11-05 23:22:34 +0000164 /// getShiftOp - Return the shift opcode (bit[6:5]) of the immediate value.
Evan Cheng7602e112008-09-02 06:52:38 +0000165 ///
Evan Cheng83b5cf02008-11-05 23:22:34 +0000166 unsigned getShiftOp(unsigned Imm) const ;
Evan Cheng7602e112008-09-02 06:52:38 +0000167
168 /// Routines that handle operands which add machine relocations which are
Evan Cheng437c1732008-11-07 22:30:53 +0000169 /// fixed up by the relocation stage.
Evan Cheng057d0c32008-09-18 07:28:19 +0000170 void emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
Jeffrey Yasskin2d274412009-11-07 08:51:52 +0000171 bool MayNeedFarStub, bool Indirect,
172 intptr_t ACPV = 0);
Evan Cheng0ff94f72007-08-07 01:37:15 +0000173 void emitExternalSymbolAddress(const char *ES, unsigned Reloc);
Evan Cheng437c1732008-11-07 22:30:53 +0000174 void emitConstPoolAddress(unsigned CPI, unsigned Reloc);
175 void emitJumpTableAddress(unsigned JTIndex, unsigned Reloc);
176 void emitMachineBasicBlock(MachineBasicBlock *BB, unsigned Reloc,
177 intptr_t JTBase = 0);
Evan Cheng148b6a42007-07-05 21:15:40 +0000178 };
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000179 template <class CodeEmitter>
180 char Emitter<CodeEmitter>::ID = 0;
Evan Cheng148b6a42007-07-05 21:15:40 +0000181}
182
183/// createARMCodeEmitterPass - Return a pass that emits the collected ARM code
184/// to the specified MCE object.
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000185
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +0000186FunctionPass *llvm::createARMCodeEmitterPass(ARMBaseTargetMachine &TM,
187 MachineCodeEmitter &MCE) {
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000188 return new Emitter<MachineCodeEmitter>(TM, MCE);
189}
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +0000190FunctionPass *llvm::createARMJITCodeEmitterPass(ARMBaseTargetMachine &TM,
191 JITCodeEmitter &JCE) {
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000192 return new Emitter<JITCodeEmitter>(TM, JCE);
Evan Cheng148b6a42007-07-05 21:15:40 +0000193}
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +0000194FunctionPass *llvm::createARMObjectCodeEmitterPass(ARMBaseTargetMachine &TM,
195 ObjectCodeEmitter &OCE) {
196 return new Emitter<ObjectCodeEmitter>(TM, OCE);
197}
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +0000198
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000199template<class CodeEmitter>
200bool Emitter<CodeEmitter>::runOnMachineFunction(MachineFunction &MF) {
Evan Cheng148b6a42007-07-05 21:15:40 +0000201 assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
202 MF.getTarget().getRelocationModel() != Reloc::Static) &&
203 "JIT relocation model must be set to static or default!");
Evan Cheng08669742009-09-10 01:23:53 +0000204 JTI = ((ARMTargetMachine&)MF.getTarget()).getJITInfo();
Evan Cheng148b6a42007-07-05 21:15:40 +0000205 II = ((ARMTargetMachine&)MF.getTarget()).getInstrInfo();
206 TD = ((ARMTargetMachine&)MF.getTarget()).getTargetData();
Evan Cheng08669742009-09-10 01:23:53 +0000207 Subtarget = &TM.getSubtarget<ARMSubtarget>();
Evan Cheng938b9d82008-10-31 19:55:13 +0000208 MCPEs = &MF.getConstantPool()->getConstants();
Evan Cheng4df60f52008-11-07 09:06:08 +0000209 MJTEs = &MF.getJumpTableInfo()->getJumpTables();
210 IsPIC = TM.getRelocationModel() == Reloc::PIC_;
Evan Cheng3cc82232008-11-08 07:38:22 +0000211 JTI->Initialize(MF, IsPIC);
Daniel Dunbar003de662009-09-21 05:58:35 +0000212 MCE.setModuleInfo(&getAnalysis<MachineModuleInfo>());
Evan Cheng148b6a42007-07-05 21:15:40 +0000213
214 do {
Jim Grosbach764ab522009-08-11 15:33:49 +0000215 DEBUG(errs() << "JITTing function '"
Daniel Dunbarce63ffb2009-07-25 00:23:56 +0000216 << MF.getFunction()->getName() << "'\n");
Evan Cheng148b6a42007-07-05 21:15:40 +0000217 MCE.startFunction(MF);
Jim Grosbach764ab522009-08-11 15:33:49 +0000218 for (MachineFunction::iterator MBB = MF.begin(), E = MF.end();
Evan Cheng148b6a42007-07-05 21:15:40 +0000219 MBB != E; ++MBB) {
220 MCE.StartMachineBasicBlock(MBB);
221 for (MachineBasicBlock::const_iterator I = MBB->begin(), E = MBB->end();
222 I != E; ++I)
223 emitInstruction(*I);
224 }
225 } while (MCE.finishFunction(MF));
226
227 return false;
228}
229
Evan Cheng83b5cf02008-11-05 23:22:34 +0000230/// getShiftOp - Return the shift opcode (bit[6:5]) of the immediate value.
Evan Cheng7602e112008-09-02 06:52:38 +0000231///
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000232template<class CodeEmitter>
233unsigned Emitter<CodeEmitter>::getShiftOp(unsigned Imm) const {
Evan Cheng83b5cf02008-11-05 23:22:34 +0000234 switch (ARM_AM::getAM2ShiftOpc(Imm)) {
Torok Edwinc23197a2009-07-14 16:55:14 +0000235 default: llvm_unreachable("Unknown shift opc!");
Evan Cheng7602e112008-09-02 06:52:38 +0000236 case ARM_AM::asr: return 2;
237 case ARM_AM::lsl: return 0;
238 case ARM_AM::lsr: return 1;
Evan Cheng0ff94f72007-08-07 01:37:15 +0000239 case ARM_AM::ror:
Evan Cheng7602e112008-09-02 06:52:38 +0000240 case ARM_AM::rrx: return 3;
Evan Cheng0ff94f72007-08-07 01:37:15 +0000241 }
Evan Cheng7602e112008-09-02 06:52:38 +0000242 return 0;
Evan Cheng0ff94f72007-08-07 01:37:15 +0000243}
244
Evan Cheng7602e112008-09-02 06:52:38 +0000245/// getMachineOpValue - Return binary encoding of operand. If the machine
246/// operand requires relocation, record the relocation and return zero.
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000247template<class CodeEmitter>
248unsigned Emitter<CodeEmitter>::getMachineOpValue(const MachineInstr &MI,
249 const MachineOperand &MO) {
Dan Gohmand735b802008-10-03 15:45:36 +0000250 if (MO.isReg())
Evan Cheng7602e112008-09-02 06:52:38 +0000251 return ARMRegisterInfo::getRegisterNumbering(MO.getReg());
Dan Gohmand735b802008-10-03 15:45:36 +0000252 else if (MO.isImm())
Evan Cheng7602e112008-09-02 06:52:38 +0000253 return static_cast<unsigned>(MO.getImm());
Dan Gohmand735b802008-10-03 15:45:36 +0000254 else if (MO.isGlobal())
Evan Cheng08669742009-09-10 01:23:53 +0000255 emitGlobalAddress(MO.getGlobal(), ARM::reloc_arm_branch, true, false);
Dan Gohmand735b802008-10-03 15:45:36 +0000256 else if (MO.isSymbol())
Evan Cheng10332512008-11-08 07:22:33 +0000257 emitExternalSymbolAddress(MO.getSymbolName(), ARM::reloc_arm_branch);
Evan Cheng580c0df2008-11-12 01:02:24 +0000258 else if (MO.isCPI()) {
259 const TargetInstrDesc &TID = MI.getDesc();
260 // For VFP load, the immediate offset is multiplied by 4.
261 unsigned Reloc = ((TID.TSFlags & ARMII::FormMask) == ARMII::VFPLdStFrm)
262 ? ARM::reloc_arm_vfp_cp_entry : ARM::reloc_arm_cp_entry;
263 emitConstPoolAddress(MO.getIndex(), Reloc);
264 } else if (MO.isJTI())
Chris Lattner8aa797a2007-12-30 23:10:15 +0000265 emitJumpTableAddress(MO.getIndex(), ARM::reloc_arm_relative);
Dan Gohmand735b802008-10-03 15:45:36 +0000266 else if (MO.isMBB())
Evan Cheng4df60f52008-11-07 09:06:08 +0000267 emitMachineBasicBlock(MO.getMBB(), ARM::reloc_arm_branch);
Evan Cheng2aa0e642008-09-13 01:55:59 +0000268 else {
Torok Edwindac237e2009-07-08 20:53:28 +0000269#ifndef NDEBUG
Chris Lattner705e07f2009-08-23 03:41:05 +0000270 errs() << MO;
Torok Edwindac237e2009-07-08 20:53:28 +0000271#endif
Torok Edwinc23197a2009-07-14 16:55:14 +0000272 llvm_unreachable(0);
Evan Cheng2aa0e642008-09-13 01:55:59 +0000273 }
Evan Cheng7602e112008-09-02 06:52:38 +0000274 return 0;
Evan Cheng0ff94f72007-08-07 01:37:15 +0000275}
276
Evan Cheng057d0c32008-09-18 07:28:19 +0000277/// emitGlobalAddress - Emit the specified address to the code stream.
Evan Cheng0ff94f72007-08-07 01:37:15 +0000278///
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000279template<class CodeEmitter>
280void Emitter<CodeEmitter>::emitGlobalAddress(GlobalValue *GV, unsigned Reloc,
Jeffrey Yasskin2d274412009-11-07 08:51:52 +0000281 bool MayNeedFarStub, bool Indirect,
Evan Cheng08669742009-09-10 01:23:53 +0000282 intptr_t ACPV) {
283 MachineRelocation MR = Indirect
284 ? MachineRelocation::getIndirectSymbol(MCE.getCurrentPCOffset(), Reloc,
Jeffrey Yasskin2d274412009-11-07 08:51:52 +0000285 GV, ACPV, MayNeedFarStub)
Evan Cheng08669742009-09-10 01:23:53 +0000286 : MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
Jeffrey Yasskin2d274412009-11-07 08:51:52 +0000287 GV, ACPV, MayNeedFarStub);
Evan Cheng08669742009-09-10 01:23:53 +0000288 MCE.addRelocation(MR);
Evan Cheng0ff94f72007-08-07 01:37:15 +0000289}
290
291/// emitExternalSymbolAddress - Arrange for the address of an external symbol to
292/// be emitted to the current location in the function, and allow it to be PC
293/// relative.
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000294template<class CodeEmitter>
295void Emitter<CodeEmitter>::emitExternalSymbolAddress(const char *ES,
296 unsigned Reloc) {
Evan Cheng0ff94f72007-08-07 01:37:15 +0000297 MCE.addRelocation(MachineRelocation::getExtSym(MCE.getCurrentPCOffset(),
298 Reloc, ES));
299}
300
301/// emitConstPoolAddress - Arrange for the address of an constant pool
302/// to be emitted to the current location in the function, and allow it to be PC
303/// relative.
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000304template<class CodeEmitter>
305void Emitter<CodeEmitter>::emitConstPoolAddress(unsigned CPI,
306 unsigned Reloc) {
Evan Cheng0f282432008-10-29 23:55:43 +0000307 // Tell JIT emitter we'll resolve the address.
Evan Cheng0ff94f72007-08-07 01:37:15 +0000308 MCE.addRelocation(MachineRelocation::getConstPool(MCE.getCurrentPCOffset(),
Evan Cheng437c1732008-11-07 22:30:53 +0000309 Reloc, CPI, 0, true));
Evan Cheng0ff94f72007-08-07 01:37:15 +0000310}
311
312/// emitJumpTableAddress - Arrange for the address of a jump table to
313/// be emitted to the current location in the function, and allow it to be PC
314/// relative.
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000315template<class CodeEmitter>
Jim Grosbach764ab522009-08-11 15:33:49 +0000316void Emitter<CodeEmitter>::emitJumpTableAddress(unsigned JTIndex,
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000317 unsigned Reloc) {
Evan Cheng0ff94f72007-08-07 01:37:15 +0000318 MCE.addRelocation(MachineRelocation::getJumpTable(MCE.getCurrentPCOffset(),
Evan Cheng437c1732008-11-07 22:30:53 +0000319 Reloc, JTIndex, 0, true));
Evan Cheng0ff94f72007-08-07 01:37:15 +0000320}
321
Raul Herbster9c1a3822007-08-30 23:29:26 +0000322/// emitMachineBasicBlock - Emit the specified address basic block.
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000323template<class CodeEmitter>
324void Emitter<CodeEmitter>::emitMachineBasicBlock(MachineBasicBlock *BB,
325 unsigned Reloc, intptr_t JTBase) {
Raul Herbster9c1a3822007-08-30 23:29:26 +0000326 MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(),
Evan Cheng437c1732008-11-07 22:30:53 +0000327 Reloc, BB, JTBase));
Raul Herbster9c1a3822007-08-30 23:29:26 +0000328}
Evan Cheng0ff94f72007-08-07 01:37:15 +0000329
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000330template<class CodeEmitter>
331void Emitter<CodeEmitter>::emitWordLE(unsigned Binary) {
Chris Lattner893e1c92009-08-23 06:49:22 +0000332 DEBUG(errs() << " 0x";
333 errs().write_hex(Binary) << "\n");
Evan Cheng83b5cf02008-11-05 23:22:34 +0000334 MCE.emitWordLE(Binary);
335}
336
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000337template<class CodeEmitter>
338void Emitter<CodeEmitter>::emitDWordLE(uint64_t Binary) {
Chris Lattner893e1c92009-08-23 06:49:22 +0000339 DEBUG(errs() << " 0x";
340 errs().write_hex(Binary) << "\n");
Evan Chengcb5201f2008-11-11 22:19:31 +0000341 MCE.emitDWordLE(Binary);
342}
343
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000344template<class CodeEmitter>
345void Emitter<CodeEmitter>::emitInstruction(const MachineInstr &MI) {
Chris Lattner705e07f2009-08-23 03:41:05 +0000346 DEBUG(errs() << "JIT: " << (void*)MCE.getCurrentPCValue() << ":\t" << MI);
Evan Cheng42d5ee062008-09-13 01:15:21 +0000347
Devang Patelaf0e2722009-10-06 02:19:11 +0000348 MCE.processDebugLoc(MI.getDebugLoc(), true);
Jeffrey Yasskin75402822009-07-17 18:49:39 +0000349
Evan Cheng148b6a42007-07-05 21:15:40 +0000350 NumEmitted++; // Keep track of the # of mi's emitted
Evan Chengedda31c2008-11-05 18:35:52 +0000351 switch (MI.getDesc().TSFlags & ARMII::FormMask) {
Evan Chengffa6d962008-11-13 23:36:57 +0000352 default: {
Torok Edwinc23197a2009-07-14 16:55:14 +0000353 llvm_unreachable("Unhandled instruction encoding format!");
Evan Chengedda31c2008-11-05 18:35:52 +0000354 break;
Evan Chengffa6d962008-11-13 23:36:57 +0000355 }
Evan Chengedda31c2008-11-05 18:35:52 +0000356 case ARMII::Pseudo:
Evan Cheng057d0c32008-09-18 07:28:19 +0000357 emitPseudoInstruction(MI);
Evan Chengedda31c2008-11-05 18:35:52 +0000358 break;
359 case ARMII::DPFrm:
360 case ARMII::DPSoRegFrm:
361 emitDataProcessingInstruction(MI);
362 break;
Evan Cheng148cad82008-11-13 07:34:59 +0000363 case ARMII::LdFrm:
364 case ARMII::StFrm:
Evan Chengedda31c2008-11-05 18:35:52 +0000365 emitLoadStoreInstruction(MI);
366 break;
Evan Cheng148cad82008-11-13 07:34:59 +0000367 case ARMII::LdMiscFrm:
368 case ARMII::StMiscFrm:
Evan Chengedda31c2008-11-05 18:35:52 +0000369 emitMiscLoadStoreInstruction(MI);
370 break;
Evan Cheng3c4a4ff2008-11-12 07:18:38 +0000371 case ARMII::LdStMulFrm:
Evan Chengedda31c2008-11-05 18:35:52 +0000372 emitLoadStoreMultipleInstruction(MI);
373 break;
Evan Chengfbc9d412008-11-06 01:21:28 +0000374 case ARMII::MulFrm:
375 emitMulFrmInstruction(MI);
Evan Chengedda31c2008-11-05 18:35:52 +0000376 break;
Evan Cheng97f48c32008-11-06 22:15:19 +0000377 case ARMII::ExtFrm:
378 emitExtendInstruction(MI);
379 break;
Evan Cheng8b59db32008-11-07 01:41:35 +0000380 case ARMII::ArithMiscFrm:
381 emitMiscArithInstruction(MI);
382 break;
Evan Cheng12c3a532008-11-06 17:48:05 +0000383 case ARMII::BrFrm:
Evan Chengedda31c2008-11-05 18:35:52 +0000384 emitBranchInstruction(MI);
385 break;
Evan Cheng12c3a532008-11-06 17:48:05 +0000386 case ARMII::BrMiscFrm:
Evan Chengedda31c2008-11-05 18:35:52 +0000387 emitMiscBranchInstruction(MI);
388 break;
Evan Cheng96581d32008-11-11 02:11:05 +0000389 // VFP instructions.
390 case ARMII::VFPUnaryFrm:
391 case ARMII::VFPBinaryFrm:
392 emitVFPArithInstruction(MI);
393 break;
Evan Cheng78be83d2008-11-11 19:40:26 +0000394 case ARMII::VFPConv1Frm:
395 case ARMII::VFPConv2Frm:
Evan Cheng0a0ab132008-11-11 22:46:12 +0000396 case ARMII::VFPConv3Frm:
Evan Cheng80a11982008-11-12 06:41:41 +0000397 case ARMII::VFPConv4Frm:
398 case ARMII::VFPConv5Frm:
Evan Cheng78be83d2008-11-11 19:40:26 +0000399 emitVFPConversionInstruction(MI);
400 break;
Evan Chengcd8e66a2008-11-11 21:48:44 +0000401 case ARMII::VFPLdStFrm:
402 emitVFPLoadStoreInstruction(MI);
403 break;
404 case ARMII::VFPLdStMulFrm:
405 emitVFPLoadStoreMultipleInstruction(MI);
406 break;
407 case ARMII::VFPMiscFrm:
408 emitMiscInstruction(MI);
409 break;
Evan Chengedda31c2008-11-05 18:35:52 +0000410 }
Devang Patelaf0e2722009-10-06 02:19:11 +0000411 MCE.processDebugLoc(MI.getDebugLoc(), false);
Evan Cheng0ff94f72007-08-07 01:37:15 +0000412}
413
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000414template<class CodeEmitter>
415void Emitter<CodeEmitter>::emitConstPoolInstruction(const MachineInstr &MI) {
Evan Cheng437c1732008-11-07 22:30:53 +0000416 unsigned CPI = MI.getOperand(0).getImm(); // CP instruction index.
417 unsigned CPIndex = MI.getOperand(1).getIndex(); // Actual cp entry index.
Evan Cheng938b9d82008-10-31 19:55:13 +0000418 const MachineConstantPoolEntry &MCPE = (*MCPEs)[CPIndex];
Jim Grosbach764ab522009-08-11 15:33:49 +0000419
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000420 // Remember the CONSTPOOL_ENTRY address for later relocation.
421 JTI->addConstantPoolEntryAddr(CPI, MCE.getCurrentPCValue());
422
423 // Emit constpool island entry. In most cases, the actual values will be
424 // resolved and relocated after code emission.
425 if (MCPE.isMachineConstantPoolEntry()) {
426 ARMConstantPoolValue *ACPV =
427 static_cast<ARMConstantPoolValue*>(MCPE.Val.MachineCPVal);
428
Chris Lattner705e07f2009-08-23 03:41:05 +0000429 DEBUG(errs() << " ** ARM constant pool #" << CPI << " @ "
430 << (void*)MCE.getCurrentPCValue() << " " << *ACPV << '\n');
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000431
Bob Wilson28989a82009-11-02 16:59:06 +0000432 assert(ACPV->isGlobalValue() && "unsupported constant pool value");
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000433 GlobalValue *GV = ACPV->getGV();
434 if (GV) {
Evan Cheng08669742009-09-10 01:23:53 +0000435 Reloc::Model RelocM = TM.getRelocationModel();
Evan Chenge4e4ed32009-08-28 23:18:09 +0000436 emitGlobalAddress(GV, ARM::reloc_arm_machine_cp_entry,
Evan Cheng08669742009-09-10 01:23:53 +0000437 isa<Function>(GV),
438 Subtarget->GVIsIndirectSymbol(GV, RelocM),
439 (intptr_t)ACPV);
Evan Cheng25e04782008-11-04 00:50:32 +0000440 } else {
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000441 emitExternalSymbolAddress(ACPV->getSymbol(), ARM::reloc_arm_absolute);
442 }
Evan Cheng83b5cf02008-11-05 23:22:34 +0000443 emitWordLE(0);
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000444 } else {
445 Constant *CV = MCPE.Val.ConstVal;
446
Daniel Dunbarce63ffb2009-07-25 00:23:56 +0000447 DEBUG({
448 errs() << " ** Constant pool #" << CPI << " @ "
449 << (void*)MCE.getCurrentPCValue() << " ";
450 if (const Function *F = dyn_cast<Function>(CV))
451 errs() << F->getName();
452 else
453 errs() << *CV;
454 errs() << '\n';
455 });
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000456
457 if (GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
Evan Cheng08669742009-09-10 01:23:53 +0000458 emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa<Function>(GV), false);
Evan Cheng83b5cf02008-11-05 23:22:34 +0000459 emitWordLE(0);
Evan Chengcb5201f2008-11-11 22:19:31 +0000460 } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000461 uint32_t Val = *(uint32_t*)CI->getValue().getRawData();
Evan Cheng83b5cf02008-11-05 23:22:34 +0000462 emitWordLE(Val);
Evan Chengcb5201f2008-11-11 22:19:31 +0000463 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
Chris Lattnercf0fe8d2009-10-05 05:54:46 +0000464 if (CFP->getType()->isFloatTy())
Evan Chengcb5201f2008-11-11 22:19:31 +0000465 emitWordLE(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
Chris Lattnercf0fe8d2009-10-05 05:54:46 +0000466 else if (CFP->getType()->isDoubleTy())
Evan Chengcb5201f2008-11-11 22:19:31 +0000467 emitDWordLE(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
468 else {
Torok Edwinc23197a2009-07-14 16:55:14 +0000469 llvm_unreachable("Unable to handle this constantpool entry!");
Evan Chengcb5201f2008-11-11 22:19:31 +0000470 }
471 } else {
Torok Edwinc23197a2009-07-14 16:55:14 +0000472 llvm_unreachable("Unable to handle this constantpool entry!");
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000473 }
474 }
475}
476
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000477template<class CodeEmitter>
478void Emitter<CodeEmitter>::emitMOVi2piecesInstruction(const MachineInstr &MI) {
Evan Cheng90922132008-11-06 02:25:39 +0000479 const MachineOperand &MO0 = MI.getOperand(0);
480 const MachineOperand &MO1 = MI.getOperand(1);
Evan Chenge7cbe412009-07-08 21:03:57 +0000481 assert(MO1.isImm() && ARM_AM::getSOImmVal(MO1.isImm()) != -1 &&
482 "Not a valid so_imm value!");
Evan Cheng90922132008-11-06 02:25:39 +0000483 unsigned V1 = ARM_AM::getSOImmTwoPartFirst(MO1.getImm());
484 unsigned V2 = ARM_AM::getSOImmTwoPartSecond(MO1.getImm());
485
486 // Emit the 'mov' instruction.
487 unsigned Binary = 0xd << 21; // mov: Insts{24-21} = 0b1101
488
489 // Set the conditional execution predicate.
Evan Cheng97f48c32008-11-06 22:15:19 +0000490 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
Evan Cheng90922132008-11-06 02:25:39 +0000491
492 // Encode Rd.
493 Binary |= getMachineOpValue(MI, MO0) << ARMII::RegRdShift;
494
495 // Encode so_imm.
496 // Set bit I(25) to identify this is the immediate form of <shifter_op>
497 Binary |= 1 << ARMII::I_BitShift;
Evan Chenge7cbe412009-07-08 21:03:57 +0000498 Binary |= getMachineSoImmOpValue(V1);
Evan Cheng90922132008-11-06 02:25:39 +0000499 emitWordLE(Binary);
500
501 // Now the 'orr' instruction.
502 Binary = 0xc << 21; // orr: Insts{24-21} = 0b1100
503
504 // Set the conditional execution predicate.
Evan Cheng97f48c32008-11-06 22:15:19 +0000505 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
Evan Cheng90922132008-11-06 02:25:39 +0000506
507 // Encode Rd.
508 Binary |= getMachineOpValue(MI, MO0) << ARMII::RegRdShift;
509
510 // Encode Rn.
511 Binary |= getMachineOpValue(MI, MO0) << ARMII::RegRnShift;
512
513 // Encode so_imm.
514 // Set bit I(25) to identify this is the immediate form of <shifter_op>
515 Binary |= 1 << ARMII::I_BitShift;
Evan Chenge7cbe412009-07-08 21:03:57 +0000516 Binary |= getMachineSoImmOpValue(V2);
Evan Cheng90922132008-11-06 02:25:39 +0000517 emitWordLE(Binary);
518}
519
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000520template<class CodeEmitter>
521void Emitter<CodeEmitter>::emitLEApcrelJTInstruction(const MachineInstr &MI) {
Evan Cheng4df60f52008-11-07 09:06:08 +0000522 // It's basically add r, pc, (LJTI - $+8)
Jim Grosbach764ab522009-08-11 15:33:49 +0000523
Evan Cheng4df60f52008-11-07 09:06:08 +0000524 const TargetInstrDesc &TID = MI.getDesc();
525
526 // Emit the 'add' instruction.
527 unsigned Binary = 0x4 << 21; // add: Insts{24-31} = 0b0100
528
529 // Set the conditional execution predicate
530 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
531
532 // Encode S bit if MI modifies CPSR.
533 Binary |= getAddrModeSBit(MI, TID);
534
535 // Encode Rd.
536 Binary |= getMachineOpValue(MI, 0) << ARMII::RegRdShift;
537
538 // Encode Rn which is PC.
539 Binary |= ARMRegisterInfo::getRegisterNumbering(ARM::PC) << ARMII::RegRnShift;
540
541 // Encode the displacement.
Evan Cheng4df60f52008-11-07 09:06:08 +0000542 Binary |= 1 << ARMII::I_BitShift;
543 emitJumpTableAddress(MI.getOperand(1).getIndex(), ARM::reloc_arm_jt_base);
544
545 emitWordLE(Binary);
546}
547
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000548template<class CodeEmitter>
549void Emitter<CodeEmitter>::emitPseudoMoveInstruction(const MachineInstr &MI) {
Evan Chenga9562552008-11-14 20:09:11 +0000550 unsigned Opcode = MI.getDesc().Opcode;
551
552 // Part of binary is determined by TableGn.
553 unsigned Binary = getBinaryCodeForInstr(MI);
554
555 // Set the conditional execution predicate
556 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
557
558 // Encode S bit if MI modifies CPSR.
559 if (Opcode == ARM::MOVsrl_flag || Opcode == ARM::MOVsra_flag)
560 Binary |= 1 << ARMII::S_BitShift;
561
562 // Encode register def if there is one.
563 Binary |= getMachineOpValue(MI, 0) << ARMII::RegRdShift;
564
565 // Encode the shift operation.
566 switch (Opcode) {
567 default: break;
568 case ARM::MOVrx:
569 // rrx
570 Binary |= 0x6 << 4;
571 break;
572 case ARM::MOVsrl_flag:
573 // lsr #1
574 Binary |= (0x2 << 4) | (1 << 7);
575 break;
576 case ARM::MOVsra_flag:
577 // asr #1
578 Binary |= (0x4 << 4) | (1 << 7);
579 break;
580 }
581
582 // Encode register Rm.
583 Binary |= getMachineOpValue(MI, 1);
584
585 emitWordLE(Binary);
586}
587
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000588template<class CodeEmitter>
589void Emitter<CodeEmitter>::addPCLabel(unsigned LabelID) {
Chris Lattner893e1c92009-08-23 06:49:22 +0000590 DEBUG(errs() << " ** LPC" << LabelID << " @ "
591 << (void*)MCE.getCurrentPCValue() << '\n');
Evan Cheng83b5cf02008-11-05 23:22:34 +0000592 JTI->addPCLabelAddr(LabelID, MCE.getCurrentPCValue());
593}
594
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000595template<class CodeEmitter>
596void Emitter<CodeEmitter>::emitPseudoInstruction(const MachineInstr &MI) {
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000597 unsigned Opcode = MI.getDesc().Opcode;
598 switch (Opcode) {
599 default:
Evan Cheng5adb66a2009-09-28 09:14:39 +0000600 llvm_unreachable("ARMCodeEmitter::emitPseudoInstruction");
601 // FIXME: Add support for MOVimm32.
Evan Chengffa6d962008-11-13 23:36:57 +0000602 case TargetInstrInfo::INLINEASM: {
Evan Chenge3066ab2008-11-19 23:21:33 +0000603 // We allow inline assembler nodes with empty bodies - they can
604 // implicitly define registers, which is ok for JIT.
605 if (MI.getOperand(0).getSymbolName()[0]) {
Torok Edwin29fd0562009-07-12 07:15:17 +0000606 llvm_report_error("JIT does not support inline asm!");
Evan Chenge3066ab2008-11-19 23:21:33 +0000607 }
Evan Chengffa6d962008-11-13 23:36:57 +0000608 break;
609 }
610 case TargetInstrInfo::DBG_LABEL:
611 case TargetInstrInfo::EH_LABEL:
612 MCE.emitLabel(MI.getOperand(0).getImm());
613 break;
614 case TargetInstrInfo::IMPLICIT_DEF:
Jakob Stoklund Olesen26207e52009-09-28 20:32:26 +0000615 case TargetInstrInfo::KILL:
Evan Chengffa6d962008-11-13 23:36:57 +0000616 // Do nothing.
617 break;
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000618 case ARM::CONSTPOOL_ENTRY:
619 emitConstPoolInstruction(MI);
620 break;
621 case ARM::PICADD: {
Evan Cheng25e04782008-11-04 00:50:32 +0000622 // Remember of the address of the PC label for relocation later.
Evan Cheng83b5cf02008-11-05 23:22:34 +0000623 addPCLabel(MI.getOperand(2).getImm());
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000624 // PICADD is just an add instruction that implicitly read pc.
Evan Cheng437c1732008-11-07 22:30:53 +0000625 emitDataProcessingInstruction(MI, 0, ARM::PC);
Evan Cheng83b5cf02008-11-05 23:22:34 +0000626 break;
627 }
628 case ARM::PICLDR:
629 case ARM::PICLDRB:
630 case ARM::PICSTR:
631 case ARM::PICSTRB: {
632 // Remember of the address of the PC label for relocation later.
633 addPCLabel(MI.getOperand(2).getImm());
634 // These are just load / store instructions that implicitly read pc.
Evan Cheng4df60f52008-11-07 09:06:08 +0000635 emitLoadStoreInstruction(MI, 0, ARM::PC);
Evan Cheng83b5cf02008-11-05 23:22:34 +0000636 break;
637 }
638 case ARM::PICLDRH:
639 case ARM::PICLDRSH:
640 case ARM::PICLDRSB:
641 case ARM::PICSTRH: {
642 // Remember of the address of the PC label for relocation later.
643 addPCLabel(MI.getOperand(2).getImm());
644 // These are just load / store instructions that implicitly read pc.
645 emitMiscLoadStoreInstruction(MI, ARM::PC);
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000646 break;
647 }
Evan Cheng90922132008-11-06 02:25:39 +0000648 case ARM::MOVi2pieces:
649 // Two instructions to materialize a constant.
650 emitMOVi2piecesInstruction(MI);
651 break;
Evan Cheng4df60f52008-11-07 09:06:08 +0000652 case ARM::LEApcrelJT:
653 // Materialize jumptable address.
654 emitLEApcrelJTInstruction(MI);
655 break;
Evan Chenga9562552008-11-14 20:09:11 +0000656 case ARM::MOVrx:
657 case ARM::MOVsrl_flag:
658 case ARM::MOVsra_flag:
659 emitPseudoMoveInstruction(MI);
660 break;
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000661 }
662}
663
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000664template<class CodeEmitter>
665unsigned Emitter<CodeEmitter>::getMachineSoRegOpValue(
666 const MachineInstr &MI,
Evan Cheng49a9f292008-09-12 22:45:55 +0000667 const TargetInstrDesc &TID,
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000668 const MachineOperand &MO,
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000669 unsigned OpIdx) {
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000670 unsigned Binary = getMachineOpValue(MI, MO);
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000671
672 const MachineOperand &MO1 = MI.getOperand(OpIdx + 1);
673 const MachineOperand &MO2 = MI.getOperand(OpIdx + 2);
674 ARM_AM::ShiftOpc SOpc = ARM_AM::getSORegShOp(MO2.getImm());
675
676 // Encode the shift opcode.
677 unsigned SBits = 0;
678 unsigned Rs = MO1.getReg();
679 if (Rs) {
680 // Set shift operand (bit[7:4]).
681 // LSL - 0001
682 // LSR - 0011
683 // ASR - 0101
684 // ROR - 0111
685 // RRX - 0110 and bit[11:8] clear.
686 switch (SOpc) {
Torok Edwinc23197a2009-07-14 16:55:14 +0000687 default: llvm_unreachable("Unknown shift opc!");
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000688 case ARM_AM::lsl: SBits = 0x1; break;
689 case ARM_AM::lsr: SBits = 0x3; break;
690 case ARM_AM::asr: SBits = 0x5; break;
691 case ARM_AM::ror: SBits = 0x7; break;
692 case ARM_AM::rrx: SBits = 0x6; break;
693 }
694 } else {
695 // Set shift operand (bit[6:4]).
696 // LSL - 000
697 // LSR - 010
698 // ASR - 100
699 // ROR - 110
700 switch (SOpc) {
Torok Edwinc23197a2009-07-14 16:55:14 +0000701 default: llvm_unreachable("Unknown shift opc!");
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000702 case ARM_AM::lsl: SBits = 0x0; break;
703 case ARM_AM::lsr: SBits = 0x2; break;
704 case ARM_AM::asr: SBits = 0x4; break;
705 case ARM_AM::ror: SBits = 0x6; break;
706 }
707 }
708 Binary |= SBits << 4;
709 if (SOpc == ARM_AM::rrx)
710 return Binary;
711
712 // Encode the shift operation Rs or shift_imm (except rrx).
713 if (Rs) {
714 // Encode Rs bit[11:8].
715 assert(ARM_AM::getSORegOffset(MO2.getImm()) == 0);
716 return Binary |
717 (ARMRegisterInfo::getRegisterNumbering(Rs) << ARMII::RegRsShift);
718 }
719
720 // Encode shift_imm bit[11:7].
721 return Binary | ARM_AM::getSORegOffset(MO2.getImm()) << 7;
722}
723
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000724template<class CodeEmitter>
725unsigned Emitter<CodeEmitter>::getMachineSoImmOpValue(unsigned SoImm) {
Evan Chenge7cbe412009-07-08 21:03:57 +0000726 int SoImmVal = ARM_AM::getSOImmVal(SoImm);
727 assert(SoImmVal != -1 && "Not a valid so_imm value!");
728
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000729 // Encode rotate_imm.
Evan Chenge7cbe412009-07-08 21:03:57 +0000730 unsigned Binary = (ARM_AM::getSOImmValRot((unsigned)SoImmVal) >> 1)
Evan Cheng97f48c32008-11-06 22:15:19 +0000731 << ARMII::SoRotImmShift;
732
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000733 // Encode immed_8.
Evan Chenge7cbe412009-07-08 21:03:57 +0000734 Binary |= ARM_AM::getSOImmValImm((unsigned)SoImmVal);
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000735 return Binary;
736}
737
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000738template<class CodeEmitter>
739unsigned Emitter<CodeEmitter>::getAddrModeSBit(const MachineInstr &MI,
740 const TargetInstrDesc &TID) const {
Evan Cheng97c573d2008-11-20 02:25:51 +0000741 for (unsigned i = MI.getNumOperands(), e = TID.getNumOperands(); i != e; --i){
Evan Cheng49a9f292008-09-12 22:45:55 +0000742 const MachineOperand &MO = MI.getOperand(i-1);
Dan Gohmand735b802008-10-03 15:45:36 +0000743 if (MO.isReg() && MO.isDef() && MO.getReg() == ARM::CPSR)
Evan Cheng49a9f292008-09-12 22:45:55 +0000744 return 1 << ARMII::S_BitShift;
745 }
746 return 0;
747}
748
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000749template<class CodeEmitter>
750void Emitter<CodeEmitter>::emitDataProcessingInstruction(
751 const MachineInstr &MI,
Evan Cheng437c1732008-11-07 22:30:53 +0000752 unsigned ImplicitRd,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000753 unsigned ImplicitRn) {
Evan Chengedda31c2008-11-05 18:35:52 +0000754 const TargetInstrDesc &TID = MI.getDesc();
Evan Chengedda31c2008-11-05 18:35:52 +0000755
Evan Cheng36a0aeb2009-07-06 22:23:46 +0000756 if (TID.Opcode == ARM::BFC) {
Benjamin Kramerd5fe92e2009-08-03 13:33:33 +0000757 llvm_report_error("ARMv6t2 JIT is not yet supported.");
Evan Cheng36a0aeb2009-07-06 22:23:46 +0000758 }
759
Evan Chengedda31c2008-11-05 18:35:52 +0000760 // Part of binary is determined by TableGn.
761 unsigned Binary = getBinaryCodeForInstr(MI);
762
Jim Grosbach33412622008-10-07 19:05:35 +0000763 // Set the conditional execution predicate
Evan Cheng97f48c32008-11-06 22:15:19 +0000764 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000765
Evan Cheng49a9f292008-09-12 22:45:55 +0000766 // Encode S bit if MI modifies CPSR.
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000767 Binary |= getAddrModeSBit(MI, TID);
Evan Cheng49a9f292008-09-12 22:45:55 +0000768
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000769 // Encode register def if there is one.
Evan Cheng49a9f292008-09-12 22:45:55 +0000770 unsigned NumDefs = TID.getNumDefs();
Evan Chenga964b7d2008-09-12 23:15:39 +0000771 unsigned OpIdx = 0;
Evan Cheng437c1732008-11-07 22:30:53 +0000772 if (NumDefs)
773 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift;
774 else if (ImplicitRd)
775 // Special handling for implicit use (e.g. PC).
776 Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRd)
777 << ARMII::RegRdShift);
Evan Cheng7602e112008-09-02 06:52:38 +0000778
Evan Chengd87293c2008-11-06 08:47:38 +0000779 // If this is a two-address operand, skip it. e.g. MOVCCr operand 1.
780 if (TID.getOperandConstraint(OpIdx, TOI::TIED_TO) != -1)
781 ++OpIdx;
782
Jim Grosbachefd30ba2008-10-01 18:16:49 +0000783 // Encode first non-shifter register operand if there is one.
Evan Chengedda31c2008-11-05 18:35:52 +0000784 bool isUnary = TID.TSFlags & ARMII::UnaryDP;
785 if (!isUnary) {
Evan Cheng83b5cf02008-11-05 23:22:34 +0000786 if (ImplicitRn)
787 // Special handling for implicit use (e.g. PC).
788 Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRn)
Evan Chengedda31c2008-11-05 18:35:52 +0000789 << ARMII::RegRnShift);
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000790 else {
791 Binary |= getMachineOpValue(MI, OpIdx) << ARMII::RegRnShift;
792 ++OpIdx;
793 }
Evan Cheng7602e112008-09-02 06:52:38 +0000794 }
795
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000796 // Encode shifter operand.
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000797 const MachineOperand &MO = MI.getOperand(OpIdx);
Evan Chengedda31c2008-11-05 18:35:52 +0000798 if ((TID.TSFlags & ARMII::FormMask) == ARMII::DPSoRegFrm) {
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000799 // Encode SoReg.
Evan Cheng83b5cf02008-11-05 23:22:34 +0000800 emitWordLE(Binary | getMachineSoRegOpValue(MI, TID, MO, OpIdx));
Evan Chengedda31c2008-11-05 18:35:52 +0000801 return;
802 }
Evan Chengeb4ed4b2008-10-31 19:10:44 +0000803
Evan Chengedda31c2008-11-05 18:35:52 +0000804 if (MO.isReg()) {
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000805 // Encode register Rm.
Evan Cheng83b5cf02008-11-05 23:22:34 +0000806 emitWordLE(Binary | ARMRegisterInfo::getRegisterNumbering(MO.getReg()));
Evan Chengedda31c2008-11-05 18:35:52 +0000807 return;
808 }
Evan Cheng7602e112008-09-02 06:52:38 +0000809
Evan Cheng5f1db7b2008-09-12 22:01:15 +0000810 // Encode so_imm.
Evan Chenge7cbe412009-07-08 21:03:57 +0000811 Binary |= getMachineSoImmOpValue((unsigned)MO.getImm());
Evan Chengedda31c2008-11-05 18:35:52 +0000812
Evan Cheng83b5cf02008-11-05 23:22:34 +0000813 emitWordLE(Binary);
Evan Cheng7602e112008-09-02 06:52:38 +0000814}
815
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000816template<class CodeEmitter>
817void Emitter<CodeEmitter>::emitLoadStoreInstruction(
818 const MachineInstr &MI,
Evan Cheng4df60f52008-11-07 09:06:08 +0000819 unsigned ImplicitRd,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000820 unsigned ImplicitRn) {
Evan Cheng05c356e2008-11-08 01:44:13 +0000821 const TargetInstrDesc &TID = MI.getDesc();
Evan Cheng148cad82008-11-13 07:34:59 +0000822 unsigned Form = TID.TSFlags & ARMII::FormMask;
823 bool IsPrePost = (TID.TSFlags & ARMII::IndexModeMask) != 0;
Evan Cheng05c356e2008-11-08 01:44:13 +0000824
Evan Chengedda31c2008-11-05 18:35:52 +0000825 // Part of binary is determined by TableGn.
826 unsigned Binary = getBinaryCodeForInstr(MI);
827
Jim Grosbach33412622008-10-07 19:05:35 +0000828 // Set the conditional execution predicate
Evan Cheng97f48c32008-11-06 22:15:19 +0000829 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
Evan Cheng057d0c32008-09-18 07:28:19 +0000830
Evan Cheng4df60f52008-11-07 09:06:08 +0000831 unsigned OpIdx = 0;
Evan Cheng148cad82008-11-13 07:34:59 +0000832
833 // Operand 0 of a pre- and post-indexed store is the address base
834 // writeback. Skip it.
835 bool Skipped = false;
836 if (IsPrePost && Form == ARMII::StFrm) {
837 ++OpIdx;
838 Skipped = true;
839 }
840
841 // Set first operand
Evan Cheng4df60f52008-11-07 09:06:08 +0000842 if (ImplicitRd)
843 // Special handling for implicit use (e.g. PC).
844 Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRd)
845 << ARMII::RegRdShift);
846 else
847 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift;
Evan Cheng7602e112008-09-02 06:52:38 +0000848
849 // Set second operand
Evan Cheng83b5cf02008-11-05 23:22:34 +0000850 if (ImplicitRn)
851 // Special handling for implicit use (e.g. PC).
852 Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRn)
853 << ARMII::RegRnShift);
Evan Cheng4df60f52008-11-07 09:06:08 +0000854 else
855 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRnShift;
Evan Cheng7602e112008-09-02 06:52:38 +0000856
Evan Cheng05c356e2008-11-08 01:44:13 +0000857 // If this is a two-address operand, skip it. e.g. LDR_PRE.
Evan Cheng148cad82008-11-13 07:34:59 +0000858 if (!Skipped && TID.getOperandConstraint(OpIdx, TOI::TIED_TO) != -1)
Evan Cheng05c356e2008-11-08 01:44:13 +0000859 ++OpIdx;
860
Evan Cheng83b5cf02008-11-05 23:22:34 +0000861 const MachineOperand &MO2 = MI.getOperand(OpIdx);
Evan Chengd87293c2008-11-06 08:47:38 +0000862 unsigned AM2Opc = (ImplicitRn == ARM::PC)
Evan Cheng83b5cf02008-11-05 23:22:34 +0000863 ? 0 : MI.getOperand(OpIdx+1).getImm();
Evan Cheng7602e112008-09-02 06:52:38 +0000864
Evan Chenge7de7e32008-09-13 01:44:01 +0000865 // Set bit U(23) according to sign of immed value (positive or negative).
Evan Cheng83b5cf02008-11-05 23:22:34 +0000866 Binary |= ((ARM_AM::getAM2Op(AM2Opc) == ARM_AM::add ? 1 : 0) <<
Evan Chenge7de7e32008-09-13 01:44:01 +0000867 ARMII::U_BitShift);
Evan Cheng7602e112008-09-02 06:52:38 +0000868 if (!MO2.getReg()) { // is immediate
Evan Cheng83b5cf02008-11-05 23:22:34 +0000869 if (ARM_AM::getAM2Offset(AM2Opc))
Evan Cheng7602e112008-09-02 06:52:38 +0000870 // Set the value of offset_12 field
Evan Cheng83b5cf02008-11-05 23:22:34 +0000871 Binary |= ARM_AM::getAM2Offset(AM2Opc);
872 emitWordLE(Binary);
Evan Chengedda31c2008-11-05 18:35:52 +0000873 return;
Evan Cheng7602e112008-09-02 06:52:38 +0000874 }
875
876 // Set bit I(25), because this is not in immediate enconding.
877 Binary |= 1 << ARMII::I_BitShift;
878 assert(TargetRegisterInfo::isPhysicalRegister(MO2.getReg()));
879 // Set bit[3:0] to the corresponding Rm register
880 Binary |= ARMRegisterInfo::getRegisterNumbering(MO2.getReg());
881
Evan Cheng70632912008-11-12 07:34:37 +0000882 // If this instr is in scaled register offset/index instruction, set
Evan Cheng7602e112008-09-02 06:52:38 +0000883 // shift_immed(bit[11:7]) and shift(bit[6:5]) fields.
Evan Cheng83b5cf02008-11-05 23:22:34 +0000884 if (unsigned ShImm = ARM_AM::getAM2Offset(AM2Opc)) {
Evan Cheng70632912008-11-12 07:34:37 +0000885 Binary |= getShiftOp(AM2Opc) << ARMII::ShiftImmShift; // shift
886 Binary |= ShImm << ARMII::ShiftShift; // shift_immed
Evan Cheng7602e112008-09-02 06:52:38 +0000887 }
888
Evan Cheng83b5cf02008-11-05 23:22:34 +0000889 emitWordLE(Binary);
Evan Cheng7602e112008-09-02 06:52:38 +0000890}
891
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000892template<class CodeEmitter>
893void Emitter<CodeEmitter>::emitMiscLoadStoreInstruction(const MachineInstr &MI,
894 unsigned ImplicitRn) {
Evan Cheng05c356e2008-11-08 01:44:13 +0000895 const TargetInstrDesc &TID = MI.getDesc();
Evan Cheng148cad82008-11-13 07:34:59 +0000896 unsigned Form = TID.TSFlags & ARMII::FormMask;
897 bool IsPrePost = (TID.TSFlags & ARMII::IndexModeMask) != 0;
Evan Cheng05c356e2008-11-08 01:44:13 +0000898
Evan Chengedda31c2008-11-05 18:35:52 +0000899 // Part of binary is determined by TableGn.
900 unsigned Binary = getBinaryCodeForInstr(MI);
901
Jim Grosbach33412622008-10-07 19:05:35 +0000902 // Set the conditional execution predicate
Evan Cheng97f48c32008-11-06 22:15:19 +0000903 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
Evan Cheng057d0c32008-09-18 07:28:19 +0000904
Evan Cheng148cad82008-11-13 07:34:59 +0000905 unsigned OpIdx = 0;
906
907 // Operand 0 of a pre- and post-indexed store is the address base
908 // writeback. Skip it.
909 bool Skipped = false;
910 if (IsPrePost && Form == ARMII::StMiscFrm) {
911 ++OpIdx;
912 Skipped = true;
913 }
914
Evan Cheng7602e112008-09-02 06:52:38 +0000915 // Set first operand
Evan Cheng148cad82008-11-13 07:34:59 +0000916 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift;
Evan Cheng7602e112008-09-02 06:52:38 +0000917
Evan Cheng358dec52009-06-15 08:28:29 +0000918 // Skip LDRD and STRD's second operand.
919 if (TID.Opcode == ARM::LDRD || TID.Opcode == ARM::STRD)
920 ++OpIdx;
921
Evan Cheng7602e112008-09-02 06:52:38 +0000922 // Set second operand
Evan Cheng83b5cf02008-11-05 23:22:34 +0000923 if (ImplicitRn)
924 // Special handling for implicit use (e.g. PC).
925 Binary |= (ARMRegisterInfo::getRegisterNumbering(ImplicitRn)
926 << ARMII::RegRnShift);
Evan Cheng4df60f52008-11-07 09:06:08 +0000927 else
928 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRnShift;
Evan Cheng7602e112008-09-02 06:52:38 +0000929
Evan Cheng05c356e2008-11-08 01:44:13 +0000930 // If this is a two-address operand, skip it. e.g. LDRH_POST.
Evan Cheng148cad82008-11-13 07:34:59 +0000931 if (!Skipped && TID.getOperandConstraint(OpIdx, TOI::TIED_TO) != -1)
Evan Cheng05c356e2008-11-08 01:44:13 +0000932 ++OpIdx;
933
Evan Cheng83b5cf02008-11-05 23:22:34 +0000934 const MachineOperand &MO2 = MI.getOperand(OpIdx);
Evan Chengd87293c2008-11-06 08:47:38 +0000935 unsigned AM3Opc = (ImplicitRn == ARM::PC)
Evan Cheng83b5cf02008-11-05 23:22:34 +0000936 ? 0 : MI.getOperand(OpIdx+1).getImm();
Evan Cheng7602e112008-09-02 06:52:38 +0000937
Evan Chenge7de7e32008-09-13 01:44:01 +0000938 // Set bit U(23) according to sign of immed value (positive or negative)
Evan Cheng83b5cf02008-11-05 23:22:34 +0000939 Binary |= ((ARM_AM::getAM3Op(AM3Opc) == ARM_AM::add ? 1 : 0) <<
Evan Cheng7602e112008-09-02 06:52:38 +0000940 ARMII::U_BitShift);
941
942 // If this instr is in register offset/index encoding, set bit[3:0]
943 // to the corresponding Rm register.
944 if (MO2.getReg()) {
945 Binary |= ARMRegisterInfo::getRegisterNumbering(MO2.getReg());
Evan Cheng83b5cf02008-11-05 23:22:34 +0000946 emitWordLE(Binary);
Evan Chengedda31c2008-11-05 18:35:52 +0000947 return;
Evan Cheng7602e112008-09-02 06:52:38 +0000948 }
949
Evan Chengd87293c2008-11-06 08:47:38 +0000950 // This instr is in immediate offset/index encoding, set bit 22 to 1.
Evan Cheng97f48c32008-11-06 22:15:19 +0000951 Binary |= 1 << ARMII::AM3_I_BitShift;
Evan Cheng83b5cf02008-11-05 23:22:34 +0000952 if (unsigned ImmOffs = ARM_AM::getAM3Offset(AM3Opc)) {
Evan Cheng7602e112008-09-02 06:52:38 +0000953 // Set operands
Evan Cheng70632912008-11-12 07:34:37 +0000954 Binary |= (ImmOffs >> 4) << ARMII::ImmHiShift; // immedH
955 Binary |= (ImmOffs & 0xF); // immedL
Evan Cheng7602e112008-09-02 06:52:38 +0000956 }
957
Evan Cheng83b5cf02008-11-05 23:22:34 +0000958 emitWordLE(Binary);
Evan Cheng7602e112008-09-02 06:52:38 +0000959}
960
Evan Chengcd8e66a2008-11-11 21:48:44 +0000961static unsigned getAddrModeUPBits(unsigned Mode) {
962 unsigned Binary = 0;
Evan Cheng7602e112008-09-02 06:52:38 +0000963
964 // Set addressing mode by modifying bits U(23) and P(24)
965 // IA - Increment after - bit U = 1 and bit P = 0
966 // IB - Increment before - bit U = 1 and bit P = 1
967 // DA - Decrement after - bit U = 0 and bit P = 0
968 // DB - Decrement before - bit U = 0 and bit P = 1
Evan Cheng7602e112008-09-02 06:52:38 +0000969 switch (Mode) {
Torok Edwinc23197a2009-07-14 16:55:14 +0000970 default: llvm_unreachable("Unknown addressing sub-mode!");
Evan Cheng10bf7342009-09-09 23:55:03 +0000971 case ARM_AM::da: break;
Evan Cheng97f48c32008-11-06 22:15:19 +0000972 case ARM_AM::db: Binary |= 0x1 << ARMII::P_BitShift; break;
973 case ARM_AM::ia: Binary |= 0x1 << ARMII::U_BitShift; break;
974 case ARM_AM::ib: Binary |= 0x3 << ARMII::U_BitShift; break;
Evan Cheng7602e112008-09-02 06:52:38 +0000975 }
976
Evan Chengcd8e66a2008-11-11 21:48:44 +0000977 return Binary;
978}
979
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +0000980template<class CodeEmitter>
981void Emitter<CodeEmitter>::emitLoadStoreMultipleInstruction(
982 const MachineInstr &MI) {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000983 // Part of binary is determined by TableGn.
984 unsigned Binary = getBinaryCodeForInstr(MI);
985
986 // Set the conditional execution predicate
987 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
988
989 // Set base address operand
990 Binary |= getMachineOpValue(MI, 0) << ARMII::RegRnShift;
991
992 // Set addressing mode by modifying bits U(23) and P(24)
993 const MachineOperand &MO = MI.getOperand(1);
994 Binary |= getAddrModeUPBits(ARM_AM::getAM4SubMode(MO.getImm()));
995
Evan Cheng7602e112008-09-02 06:52:38 +0000996 // Set bit W(21)
997 if (ARM_AM::getAM4WBFlag(MO.getImm()))
Evan Cheng97f48c32008-11-06 22:15:19 +0000998 Binary |= 0x1 << ARMII::W_BitShift;
Evan Cheng7602e112008-09-02 06:52:38 +0000999
1000 // Set registers
Evan Cheng7c043d72009-10-01 01:39:21 +00001001 for (unsigned i = 5, e = MI.getNumOperands(); i != e; ++i) {
Evan Cheng7602e112008-09-02 06:52:38 +00001002 const MachineOperand &MO = MI.getOperand(i);
Evan Chengcd8e66a2008-11-11 21:48:44 +00001003 if (!MO.isReg() || MO.isImplicit())
1004 break;
Evan Cheng7602e112008-09-02 06:52:38 +00001005 unsigned RegNum = ARMRegisterInfo::getRegisterNumbering(MO.getReg());
1006 assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
1007 RegNum < 16);
1008 Binary |= 0x1 << RegNum;
1009 }
1010
Evan Cheng83b5cf02008-11-05 23:22:34 +00001011 emitWordLE(Binary);
Evan Cheng7602e112008-09-02 06:52:38 +00001012}
1013
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001014template<class CodeEmitter>
1015void Emitter<CodeEmitter>::emitMulFrmInstruction(const MachineInstr &MI) {
Evan Chengedda31c2008-11-05 18:35:52 +00001016 const TargetInstrDesc &TID = MI.getDesc();
1017
1018 // Part of binary is determined by TableGn.
1019 unsigned Binary = getBinaryCodeForInstr(MI);
1020
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +00001021 // Set the conditional execution predicate
Evan Cheng97f48c32008-11-06 22:15:19 +00001022 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +00001023
1024 // Encode S bit if MI modifies CPSR.
1025 Binary |= getAddrModeSBit(MI, TID);
1026
1027 // 32x32->64bit operations have two destination registers. The number
1028 // of register definitions will tell us if that's what we're dealing with.
Evan Cheng97f48c32008-11-06 22:15:19 +00001029 unsigned OpIdx = 0;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +00001030 if (TID.getNumDefs() == 2)
1031 Binary |= getMachineOpValue (MI, OpIdx++) << ARMII::RegRdLoShift;
1032
1033 // Encode Rd
1034 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdHiShift;
1035
1036 // Encode Rm
1037 Binary |= getMachineOpValue(MI, OpIdx++);
1038
1039 // Encode Rs
1040 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRsShift;
1041
Evan Chengfbc9d412008-11-06 01:21:28 +00001042 // Many multiple instructions (e.g. MLA) have three src operands. Encode
1043 // it as Rn (for multiply, that's in the same offset as RdLo.
Evan Cheng97f48c32008-11-06 22:15:19 +00001044 if (TID.getNumOperands() > OpIdx &&
1045 !TID.OpInfo[OpIdx].isPredicate() &&
1046 !TID.OpInfo[OpIdx].isOptionalDef())
1047 Binary |= getMachineOpValue(MI, OpIdx) << ARMII::RegRdLoShift;
1048
1049 emitWordLE(Binary);
1050}
1051
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001052template<class CodeEmitter>
1053void Emitter<CodeEmitter>::emitExtendInstruction(const MachineInstr &MI) {
Evan Cheng97f48c32008-11-06 22:15:19 +00001054 const TargetInstrDesc &TID = MI.getDesc();
1055
1056 // Part of binary is determined by TableGn.
1057 unsigned Binary = getBinaryCodeForInstr(MI);
1058
1059 // Set the conditional execution predicate
1060 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
1061
1062 unsigned OpIdx = 0;
1063
1064 // Encode Rd
1065 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift;
1066
1067 const MachineOperand &MO1 = MI.getOperand(OpIdx++);
1068 const MachineOperand &MO2 = MI.getOperand(OpIdx);
1069 if (MO2.isReg()) {
1070 // Two register operand form.
1071 // Encode Rn.
1072 Binary |= getMachineOpValue(MI, MO1) << ARMII::RegRnShift;
1073
1074 // Encode Rm.
1075 Binary |= getMachineOpValue(MI, MO2);
1076 ++OpIdx;
1077 } else {
1078 Binary |= getMachineOpValue(MI, MO1);
1079 }
1080
1081 // Encode rot imm (0, 8, 16, or 24) if it has a rotate immediate operand.
1082 if (MI.getOperand(OpIdx).isImm() &&
1083 !TID.OpInfo[OpIdx].isPredicate() &&
1084 !TID.OpInfo[OpIdx].isOptionalDef())
1085 Binary |= (getMachineOpValue(MI, OpIdx) / 8) << ARMII::ExtRotImmShift;
Evan Chengfbc9d412008-11-06 01:21:28 +00001086
Evan Cheng83b5cf02008-11-05 23:22:34 +00001087 emitWordLE(Binary);
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +00001088}
1089
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001090template<class CodeEmitter>
1091void Emitter<CodeEmitter>::emitMiscArithInstruction(const MachineInstr &MI) {
Evan Cheng8b59db32008-11-07 01:41:35 +00001092 const TargetInstrDesc &TID = MI.getDesc();
1093
1094 // Part of binary is determined by TableGn.
1095 unsigned Binary = getBinaryCodeForInstr(MI);
1096
1097 // Set the conditional execution predicate
1098 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
1099
1100 unsigned OpIdx = 0;
1101
1102 // Encode Rd
1103 Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift;
1104
1105 const MachineOperand &MO = MI.getOperand(OpIdx++);
1106 if (OpIdx == TID.getNumOperands() ||
1107 TID.OpInfo[OpIdx].isPredicate() ||
1108 TID.OpInfo[OpIdx].isOptionalDef()) {
1109 // Encode Rm and it's done.
1110 Binary |= getMachineOpValue(MI, MO);
1111 emitWordLE(Binary);
1112 return;
1113 }
1114
1115 // Encode Rn.
1116 Binary |= getMachineOpValue(MI, MO) << ARMII::RegRnShift;
1117
1118 // Encode Rm.
1119 Binary |= getMachineOpValue(MI, OpIdx++);
1120
1121 // Encode shift_imm.
1122 unsigned ShiftAmt = MI.getOperand(OpIdx).getImm();
1123 assert(ShiftAmt < 32 && "shift_imm range is 0 to 31!");
1124 Binary |= ShiftAmt << ARMII::ShiftShift;
Jim Grosbach764ab522009-08-11 15:33:49 +00001125
Evan Cheng8b59db32008-11-07 01:41:35 +00001126 emitWordLE(Binary);
1127}
1128
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001129template<class CodeEmitter>
1130void Emitter<CodeEmitter>::emitBranchInstruction(const MachineInstr &MI) {
Evan Chengedda31c2008-11-05 18:35:52 +00001131 const TargetInstrDesc &TID = MI.getDesc();
1132
Torok Edwindac237e2009-07-08 20:53:28 +00001133 if (TID.Opcode == ARM::TPsoft) {
Torok Edwinc23197a2009-07-14 16:55:14 +00001134 llvm_unreachable("ARM::TPsoft FIXME"); // FIXME
Torok Edwindac237e2009-07-08 20:53:28 +00001135 }
Evan Cheng12c3a532008-11-06 17:48:05 +00001136
Evan Cheng7602e112008-09-02 06:52:38 +00001137 // Part of binary is determined by TableGn.
1138 unsigned Binary = getBinaryCodeForInstr(MI);
1139
Evan Chengedda31c2008-11-05 18:35:52 +00001140 // Set the conditional execution predicate
Evan Cheng97f48c32008-11-06 22:15:19 +00001141 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
Evan Chengedda31c2008-11-05 18:35:52 +00001142
1143 // Set signed_immed_24 field
1144 Binary |= getMachineOpValue(MI, 0);
1145
Evan Cheng83b5cf02008-11-05 23:22:34 +00001146 emitWordLE(Binary);
Evan Chengedda31c2008-11-05 18:35:52 +00001147}
1148
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001149template<class CodeEmitter>
1150void Emitter<CodeEmitter>::emitInlineJumpTable(unsigned JTIndex) {
Evan Cheng4df60f52008-11-07 09:06:08 +00001151 // Remember the base address of the inline jump table.
Evan Cheng5788d1a2008-12-10 02:32:19 +00001152 uintptr_t JTBase = MCE.getCurrentPCValue();
Evan Cheng437c1732008-11-07 22:30:53 +00001153 JTI->addJumpTableBaseAddr(JTIndex, JTBase);
Chris Lattner893e1c92009-08-23 06:49:22 +00001154 DEBUG(errs() << " ** Jump Table #" << JTIndex << " @ " << (void*)JTBase
1155 << '\n');
Evan Cheng4df60f52008-11-07 09:06:08 +00001156
1157 // Now emit the jump table entries.
1158 const std::vector<MachineBasicBlock*> &MBBs = (*MJTEs)[JTIndex].MBBs;
1159 for (unsigned i = 0, e = MBBs.size(); i != e; ++i) {
1160 if (IsPIC)
1161 // DestBB address - JT base.
Evan Cheng437c1732008-11-07 22:30:53 +00001162 emitMachineBasicBlock(MBBs[i], ARM::reloc_arm_pic_jt, JTBase);
Evan Cheng4df60f52008-11-07 09:06:08 +00001163 else
1164 // Absolute DestBB address.
1165 emitMachineBasicBlock(MBBs[i], ARM::reloc_arm_absolute);
1166 emitWordLE(0);
1167 }
1168}
1169
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001170template<class CodeEmitter>
1171void Emitter<CodeEmitter>::emitMiscBranchInstruction(const MachineInstr &MI) {
Evan Chengedda31c2008-11-05 18:35:52 +00001172 const TargetInstrDesc &TID = MI.getDesc();
Evan Chengedda31c2008-11-05 18:35:52 +00001173
Evan Cheng437c1732008-11-07 22:30:53 +00001174 // Handle jump tables.
Evan Cheng90daf4d2009-07-25 00:13:11 +00001175 if (TID.Opcode == ARM::BR_JTr || TID.Opcode == ARM::BR_JTadd) {
Evan Cheng437c1732008-11-07 22:30:53 +00001176 // First emit a ldr pc, [] instruction.
1177 emitDataProcessingInstruction(MI, ARM::PC);
1178
1179 // Then emit the inline jump table.
Evan Chengc9a41532009-07-08 00:05:05 +00001180 unsigned JTIndex =
Evan Cheng90daf4d2009-07-25 00:13:11 +00001181 (TID.Opcode == ARM::BR_JTr)
Evan Cheng437c1732008-11-07 22:30:53 +00001182 ? MI.getOperand(1).getIndex() : MI.getOperand(2).getIndex();
1183 emitInlineJumpTable(JTIndex);
1184 return;
Evan Cheng90daf4d2009-07-25 00:13:11 +00001185 } else if (TID.Opcode == ARM::BR_JTm) {
Evan Cheng4df60f52008-11-07 09:06:08 +00001186 // First emit a ldr pc, [] instruction.
1187 emitLoadStoreInstruction(MI, ARM::PC);
1188
1189 // Then emit the inline jump table.
Evan Cheng437c1732008-11-07 22:30:53 +00001190 emitInlineJumpTable(MI.getOperand(3).getIndex());
Evan Cheng4df60f52008-11-07 09:06:08 +00001191 return;
1192 }
1193
Evan Chengedda31c2008-11-05 18:35:52 +00001194 // Part of binary is determined by TableGn.
1195 unsigned Binary = getBinaryCodeForInstr(MI);
1196
1197 // Set the conditional execution predicate
Evan Cheng97f48c32008-11-06 22:15:19 +00001198 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
Evan Chengedda31c2008-11-05 18:35:52 +00001199
1200 if (TID.Opcode == ARM::BX_RET)
1201 // The return register is LR.
1202 Binary |= ARMRegisterInfo::getRegisterNumbering(ARM::LR);
Jim Grosbach764ab522009-08-11 15:33:49 +00001203 else
Evan Chengedda31c2008-11-05 18:35:52 +00001204 // otherwise, set the return register
1205 Binary |= getMachineOpValue(MI, 0);
1206
Evan Cheng83b5cf02008-11-05 23:22:34 +00001207 emitWordLE(Binary);
Evan Cheng148b6a42007-07-05 21:15:40 +00001208}
Evan Cheng7602e112008-09-02 06:52:38 +00001209
Evan Cheng80a11982008-11-12 06:41:41 +00001210static unsigned encodeVFPRd(const MachineInstr &MI, unsigned OpIdx) {
Evan Chengd06d48d2008-11-12 02:19:38 +00001211 unsigned RegD = MI.getOperand(OpIdx).getReg();
Evan Cheng80a11982008-11-12 06:41:41 +00001212 unsigned Binary = 0;
Evan Chengd06d48d2008-11-12 02:19:38 +00001213 bool isSPVFP = false;
Evan Cheng8295d992009-07-22 05:55:18 +00001214 RegD = ARMRegisterInfo::getRegisterNumbering(RegD, &isSPVFP);
Evan Chengd06d48d2008-11-12 02:19:38 +00001215 if (!isSPVFP)
1216 Binary |= RegD << ARMII::RegRdShift;
1217 else {
1218 Binary |= ((RegD & 0x1E) >> 1) << ARMII::RegRdShift;
1219 Binary |= (RegD & 0x01) << ARMII::D_BitShift;
1220 }
Evan Cheng80a11982008-11-12 06:41:41 +00001221 return Binary;
1222}
Evan Cheng78be83d2008-11-11 19:40:26 +00001223
Evan Cheng80a11982008-11-12 06:41:41 +00001224static unsigned encodeVFPRn(const MachineInstr &MI, unsigned OpIdx) {
Evan Chengd06d48d2008-11-12 02:19:38 +00001225 unsigned RegN = MI.getOperand(OpIdx).getReg();
Evan Cheng80a11982008-11-12 06:41:41 +00001226 unsigned Binary = 0;
1227 bool isSPVFP = false;
Evan Cheng8295d992009-07-22 05:55:18 +00001228 RegN = ARMRegisterInfo::getRegisterNumbering(RegN, &isSPVFP);
Evan Chengd06d48d2008-11-12 02:19:38 +00001229 if (!isSPVFP)
1230 Binary |= RegN << ARMII::RegRnShift;
1231 else {
1232 Binary |= ((RegN & 0x1E) >> 1) << ARMII::RegRnShift;
1233 Binary |= (RegN & 0x01) << ARMII::N_BitShift;
1234 }
Evan Cheng80a11982008-11-12 06:41:41 +00001235 return Binary;
1236}
Evan Chengd06d48d2008-11-12 02:19:38 +00001237
Evan Cheng80a11982008-11-12 06:41:41 +00001238static unsigned encodeVFPRm(const MachineInstr &MI, unsigned OpIdx) {
1239 unsigned RegM = MI.getOperand(OpIdx).getReg();
1240 unsigned Binary = 0;
1241 bool isSPVFP = false;
Evan Cheng8295d992009-07-22 05:55:18 +00001242 RegM = ARMRegisterInfo::getRegisterNumbering(RegM, &isSPVFP);
Evan Cheng80a11982008-11-12 06:41:41 +00001243 if (!isSPVFP)
1244 Binary |= RegM;
1245 else {
1246 Binary |= ((RegM & 0x1E) >> 1);
1247 Binary |= (RegM & 0x01) << ARMII::M_BitShift;
Evan Cheng78be83d2008-11-11 19:40:26 +00001248 }
Evan Cheng80a11982008-11-12 06:41:41 +00001249 return Binary;
1250}
1251
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001252template<class CodeEmitter>
1253void Emitter<CodeEmitter>::emitVFPArithInstruction(const MachineInstr &MI) {
Evan Cheng3c4a4ff2008-11-12 07:18:38 +00001254 const TargetInstrDesc &TID = MI.getDesc();
1255
1256 // Part of binary is determined by TableGn.
1257 unsigned Binary = getBinaryCodeForInstr(MI);
1258
1259 // Set the conditional execution predicate
1260 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
1261
1262 unsigned OpIdx = 0;
1263 assert((Binary & ARMII::D_BitShift) == 0 &&
1264 (Binary & ARMII::N_BitShift) == 0 &&
1265 (Binary & ARMII::M_BitShift) == 0 && "VFP encoding bug!");
1266
1267 // Encode Dd / Sd.
1268 Binary |= encodeVFPRd(MI, OpIdx++);
1269
1270 // If this is a two-address operand, skip it, e.g. FMACD.
1271 if (TID.getOperandConstraint(OpIdx, TOI::TIED_TO) != -1)
1272 ++OpIdx;
1273
1274 // Encode Dn / Sn.
1275 if ((TID.TSFlags & ARMII::FormMask) == ARMII::VFPBinaryFrm)
Evan Cheng3f4924e2008-11-12 08:14:21 +00001276 Binary |= encodeVFPRn(MI, OpIdx++);
Evan Cheng3c4a4ff2008-11-12 07:18:38 +00001277
1278 if (OpIdx == TID.getNumOperands() ||
1279 TID.OpInfo[OpIdx].isPredicate() ||
1280 TID.OpInfo[OpIdx].isOptionalDef()) {
1281 // FCMPEZD etc. has only one operand.
1282 emitWordLE(Binary);
1283 return;
1284 }
1285
1286 // Encode Dm / Sm.
1287 Binary |= encodeVFPRm(MI, OpIdx);
Jim Grosbach764ab522009-08-11 15:33:49 +00001288
Evan Cheng3c4a4ff2008-11-12 07:18:38 +00001289 emitWordLE(Binary);
1290}
1291
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001292template<class CodeEmitter>
1293void Emitter<CodeEmitter>::emitVFPConversionInstruction(
1294 const MachineInstr &MI) {
Evan Cheng80a11982008-11-12 06:41:41 +00001295 const TargetInstrDesc &TID = MI.getDesc();
1296 unsigned Form = TID.TSFlags & ARMII::FormMask;
1297
1298 // Part of binary is determined by TableGn.
1299 unsigned Binary = getBinaryCodeForInstr(MI);
1300
1301 // Set the conditional execution predicate
1302 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
1303
1304 switch (Form) {
1305 default: break;
1306 case ARMII::VFPConv1Frm:
1307 case ARMII::VFPConv2Frm:
1308 case ARMII::VFPConv3Frm:
1309 // Encode Dd / Sd.
1310 Binary |= encodeVFPRd(MI, 0);
1311 break;
1312 case ARMII::VFPConv4Frm:
1313 // Encode Dn / Sn.
1314 Binary |= encodeVFPRn(MI, 0);
1315 break;
1316 case ARMII::VFPConv5Frm:
1317 // Encode Dm / Sm.
1318 Binary |= encodeVFPRm(MI, 0);
1319 break;
1320 }
1321
1322 switch (Form) {
1323 default: break;
1324 case ARMII::VFPConv1Frm:
1325 // Encode Dm / Sm.
1326 Binary |= encodeVFPRm(MI, 1);
Evan Cheng67fd91f2008-11-13 07:46:59 +00001327 break;
Evan Cheng80a11982008-11-12 06:41:41 +00001328 case ARMII::VFPConv2Frm:
1329 case ARMII::VFPConv3Frm:
1330 // Encode Dn / Sn.
1331 Binary |= encodeVFPRn(MI, 1);
1332 break;
1333 case ARMII::VFPConv4Frm:
1334 case ARMII::VFPConv5Frm:
1335 // Encode Dd / Sd.
1336 Binary |= encodeVFPRd(MI, 1);
1337 break;
1338 }
1339
1340 if (Form == ARMII::VFPConv5Frm)
1341 // Encode Dn / Sn.
1342 Binary |= encodeVFPRn(MI, 2);
1343 else if (Form == ARMII::VFPConv3Frm)
1344 // Encode Dm / Sm.
1345 Binary |= encodeVFPRm(MI, 2);
Evan Cheng78be83d2008-11-11 19:40:26 +00001346
1347 emitWordLE(Binary);
1348}
1349
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001350template<class CodeEmitter>
1351void Emitter<CodeEmitter>::emitVFPLoadStoreInstruction(const MachineInstr &MI) {
Evan Chengcd8e66a2008-11-11 21:48:44 +00001352 // Part of binary is determined by TableGn.
1353 unsigned Binary = getBinaryCodeForInstr(MI);
1354
1355 // Set the conditional execution predicate
1356 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
1357
1358 unsigned OpIdx = 0;
1359
1360 // Encode Dd / Sd.
Evan Cheng3c4a4ff2008-11-12 07:18:38 +00001361 Binary |= encodeVFPRd(MI, OpIdx++);
Evan Chengcd8e66a2008-11-11 21:48:44 +00001362
1363 // Encode address base.
1364 const MachineOperand &Base = MI.getOperand(OpIdx++);
1365 Binary |= getMachineOpValue(MI, Base) << ARMII::RegRnShift;
1366
1367 // If there is a non-zero immediate offset, encode it.
1368 if (Base.isReg()) {
1369 const MachineOperand &Offset = MI.getOperand(OpIdx);
1370 if (unsigned ImmOffs = ARM_AM::getAM5Offset(Offset.getImm())) {
1371 if (ARM_AM::getAM5Op(Offset.getImm()) == ARM_AM::add)
1372 Binary |= 1 << ARMII::U_BitShift;
Evan Cheng607f1b42008-11-12 08:21:12 +00001373 Binary |= ImmOffs;
Evan Chengcd8e66a2008-11-11 21:48:44 +00001374 emitWordLE(Binary);
1375 return;
1376 }
1377 }
1378
1379 // If immediate offset is omitted, default to +0.
1380 Binary |= 1 << ARMII::U_BitShift;
1381
1382 emitWordLE(Binary);
1383}
1384
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001385template<class CodeEmitter>
1386void Emitter<CodeEmitter>::emitVFPLoadStoreMultipleInstruction(
1387 const MachineInstr &MI) {
Evan Chengcd8e66a2008-11-11 21:48:44 +00001388 // Part of binary is determined by TableGn.
1389 unsigned Binary = getBinaryCodeForInstr(MI);
1390
1391 // Set the conditional execution predicate
1392 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
1393
1394 // Set base address operand
1395 Binary |= getMachineOpValue(MI, 0) << ARMII::RegRnShift;
1396
1397 // Set addressing mode by modifying bits U(23) and P(24)
1398 const MachineOperand &MO = MI.getOperand(1);
1399 Binary |= getAddrModeUPBits(ARM_AM::getAM5SubMode(MO.getImm()));
1400
1401 // Set bit W(21)
1402 if (ARM_AM::getAM5WBFlag(MO.getImm()))
1403 Binary |= 0x1 << ARMII::W_BitShift;
1404
1405 // First register is encoded in Dd.
Evan Cheng7c043d72009-10-01 01:39:21 +00001406 Binary |= encodeVFPRd(MI, 5);
Evan Chengcd8e66a2008-11-11 21:48:44 +00001407
1408 // Number of registers are encoded in offset field.
1409 unsigned NumRegs = 1;
Evan Cheng7c043d72009-10-01 01:39:21 +00001410 for (unsigned i = 6, e = MI.getNumOperands(); i != e; ++i) {
Evan Chengcd8e66a2008-11-11 21:48:44 +00001411 const MachineOperand &MO = MI.getOperand(i);
1412 if (!MO.isReg() || MO.isImplicit())
1413 break;
1414 ++NumRegs;
1415 }
1416 Binary |= NumRegs * 2;
1417
1418 emitWordLE(Binary);
1419}
1420
Bruno Cardoso Lopes434dd4f2009-06-01 19:57:37 +00001421template<class CodeEmitter>
1422void Emitter<CodeEmitter>::emitMiscInstruction(const MachineInstr &MI) {
Evan Chengcd8e66a2008-11-11 21:48:44 +00001423 // Part of binary is determined by TableGn.
1424 unsigned Binary = getBinaryCodeForInstr(MI);
1425
1426 // Set the conditional execution predicate
1427 Binary |= II->getPredicate(&MI) << ARMII::CondShift;
1428
1429 emitWordLE(Binary);
1430}
1431
Evan Cheng7602e112008-09-02 06:52:38 +00001432#include "ARMGenCodeEmitter.inc"