@@ -76,10 +76,6 @@ using namespace llvm;
7676#define GET_INSTRINFO_CTOR_DTOR
7777#include " ARMGenInstrInfo.inc"
7878
79- static cl::opt<bool >
80- EnableARM3Addr (" enable-arm-3-addr-conv" , cl::Hidden,
81- cl::desc (" Enable ARM 2-addr to 3-addr conv" ));
82-
8379// / ARM_MLxEntry - Record information about MLA / MLS instructions.
8480struct ARM_MLxEntry {
8581 uint16_t MLxOpc; // MLA / MLS opcode
@@ -175,175 +171,6 @@ CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II,
175171 return MHR;
176172}
177173
178- MachineInstr *
179- ARMBaseInstrInfo::convertToThreeAddress (MachineInstr &MI, LiveVariables *LV,
180- LiveIntervals *LIS) const {
181- // FIXME: Thumb2 support.
182-
183- if (!EnableARM3Addr)
184- return nullptr ;
185-
186- MachineFunction &MF = *MI.getParent ()->getParent ();
187- uint64_t TSFlags = MI.getDesc ().TSFlags ;
188- bool isPre = false ;
189- switch ((TSFlags & ARMII::IndexModeMask) >> ARMII::IndexModeShift) {
190- default : return nullptr ;
191- case ARMII::IndexModePre:
192- isPre = true ;
193- break ;
194- case ARMII::IndexModePost:
195- break ;
196- }
197-
198- // Try splitting an indexed load/store to an un-indexed one plus an add/sub
199- // operation.
200- unsigned MemOpc = getUnindexedOpcode (MI.getOpcode ());
201- if (MemOpc == 0 )
202- return nullptr ;
203-
204- MachineInstr *UpdateMI = nullptr ;
205- MachineInstr *MemMI = nullptr ;
206- unsigned AddrMode = (TSFlags & ARMII::AddrModeMask);
207- const MCInstrDesc &MCID = MI.getDesc ();
208- unsigned NumOps = MCID.getNumOperands ();
209- bool isLoad = !MI.mayStore ();
210- const MachineOperand &WB = isLoad ? MI.getOperand (1 ) : MI.getOperand (0 );
211- const MachineOperand &Base = MI.getOperand (2 );
212- const MachineOperand &Offset = MI.getOperand (NumOps - 3 );
213- Register WBReg = WB.getReg ();
214- Register BaseReg = Base.getReg ();
215- Register OffReg = Offset.getReg ();
216- unsigned OffImm = MI.getOperand (NumOps - 2 ).getImm ();
217- ARMCC::CondCodes Pred = (ARMCC::CondCodes)MI.getOperand (NumOps - 1 ).getImm ();
218- switch (AddrMode) {
219- default : llvm_unreachable (" Unknown indexed op!" );
220- case ARMII::AddrMode2: {
221- bool isSub = ARM_AM::getAM2Op (OffImm) == ARM_AM::sub;
222- unsigned Amt = ARM_AM::getAM2Offset (OffImm);
223- if (OffReg == 0 ) {
224- if (ARM_AM::getSOImmVal (Amt) == -1 )
225- // Can't encode it in a so_imm operand. This transformation will
226- // add more than 1 instruction. Abandon!
227- return nullptr ;
228- UpdateMI = BuildMI (MF, MI.getDebugLoc (),
229- get (isSub ? ARM::SUBri : ARM::ADDri), WBReg)
230- .addReg (BaseReg)
231- .addImm (Amt)
232- .add (predOps (Pred))
233- .add (condCodeOp ());
234- } else if (Amt != 0 ) {
235- ARM_AM::ShiftOpc ShOpc = ARM_AM::getAM2ShiftOpc (OffImm);
236- unsigned SOOpc = ARM_AM::getSORegOpc (ShOpc, Amt);
237- UpdateMI = BuildMI (MF, MI.getDebugLoc (),
238- get (isSub ? ARM::SUBrsi : ARM::ADDrsi), WBReg)
239- .addReg (BaseReg)
240- .addReg (OffReg)
241- .addReg (0 )
242- .addImm (SOOpc)
243- .add (predOps (Pred))
244- .add (condCodeOp ());
245- } else
246- UpdateMI = BuildMI (MF, MI.getDebugLoc (),
247- get (isSub ? ARM::SUBrr : ARM::ADDrr), WBReg)
248- .addReg (BaseReg)
249- .addReg (OffReg)
250- .add (predOps (Pred))
251- .add (condCodeOp ());
252- break ;
253- }
254- case ARMII::AddrMode3 : {
255- bool isSub = ARM_AM::getAM3Op (OffImm) == ARM_AM::sub;
256- unsigned Amt = ARM_AM::getAM3Offset (OffImm);
257- if (OffReg == 0 )
258- // Immediate is 8-bits. It's guaranteed to fit in a so_imm operand.
259- UpdateMI = BuildMI (MF, MI.getDebugLoc (),
260- get (isSub ? ARM::SUBri : ARM::ADDri), WBReg)
261- .addReg (BaseReg)
262- .addImm (Amt)
263- .add (predOps (Pred))
264- .add (condCodeOp ());
265- else
266- UpdateMI = BuildMI (MF, MI.getDebugLoc (),
267- get (isSub ? ARM::SUBrr : ARM::ADDrr), WBReg)
268- .addReg (BaseReg)
269- .addReg (OffReg)
270- .add (predOps (Pred))
271- .add (condCodeOp ());
272- break ;
273- }
274- }
275-
276- std::vector<MachineInstr*> NewMIs;
277- if (isPre) {
278- if (isLoad)
279- MemMI =
280- BuildMI (MF, MI.getDebugLoc (), get (MemOpc), MI.getOperand (0 ).getReg ())
281- .addReg (WBReg)
282- .addImm (0 )
283- .addImm (Pred);
284- else
285- MemMI = BuildMI (MF, MI.getDebugLoc (), get (MemOpc))
286- .addReg (MI.getOperand (1 ).getReg ())
287- .addReg (WBReg)
288- .addReg (0 )
289- .addImm (0 )
290- .addImm (Pred);
291- NewMIs.push_back (MemMI);
292- NewMIs.push_back (UpdateMI);
293- } else {
294- if (isLoad)
295- MemMI =
296- BuildMI (MF, MI.getDebugLoc (), get (MemOpc), MI.getOperand (0 ).getReg ())
297- .addReg (BaseReg)
298- .addImm (0 )
299- .addImm (Pred);
300- else
301- MemMI = BuildMI (MF, MI.getDebugLoc (), get (MemOpc))
302- .addReg (MI.getOperand (1 ).getReg ())
303- .addReg (BaseReg)
304- .addReg (0 )
305- .addImm (0 )
306- .addImm (Pred);
307- if (WB.isDead ())
308- UpdateMI->getOperand (0 ).setIsDead ();
309- NewMIs.push_back (UpdateMI);
310- NewMIs.push_back (MemMI);
311- }
312-
313- // Transfer LiveVariables states, kill / dead info.
314- if (LV) {
315- for (const MachineOperand &MO : MI.operands ()) {
316- if (MO.isReg () && MO.getReg ().isVirtual ()) {
317- Register Reg = MO.getReg ();
318-
319- LiveVariables::VarInfo &VI = LV->getVarInfo (Reg);
320- if (MO.isDef ()) {
321- MachineInstr *NewMI = (Reg == WBReg) ? UpdateMI : MemMI;
322- if (MO.isDead ())
323- LV->addVirtualRegisterDead (Reg, *NewMI);
324- }
325- if (MO.isUse () && MO.isKill ()) {
326- for (unsigned j = 0 ; j < 2 ; ++j) {
327- // Look at the two new MI's in reverse order.
328- MachineInstr *NewMI = NewMIs[j];
329- if (!NewMI->readsRegister (Reg, /* TRI=*/ nullptr ))
330- continue ;
331- LV->addVirtualRegisterKilled (Reg, *NewMI);
332- if (VI.removeKill (MI))
333- VI.Kills .push_back (NewMI);
334- break ;
335- }
336- }
337- }
338- }
339- }
340-
341- MachineBasicBlock &MBB = *MI.getParent ();
342- MBB.insert (MI, NewMIs[1 ]);
343- MBB.insert (MI, NewMIs[0 ]);
344- return NewMIs[0 ];
345- }
346-
347174// Branch analysis.
348175// Cond vector output format:
349176// 0 elements indicates an unconditional branch
0 commit comments