blob: 22b0c1e3b4715ec525dd638804e37855f38a8459 [file] [log] [blame]
Tim Northover3b0846e2014-05-24 12:50:23 +00001//===-- AArch64AdvSIMDScalar.cpp - Replace dead defs w/ zero reg --===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9// When profitable, replace GPR targeting i64 instructions with their
10// AdvSIMD scalar equivalents. Generally speaking, "profitable" is defined
11// as minimizing the number of cross-class register copies.
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// TODO: Graph based predicate heuristics.
16// Walking the instruction list linearly will get many, perhaps most, of
17// the cases, but to do a truly thorough job of this, we need a more
18// wholistic approach.
19//
20// This optimization is very similar in spirit to the register allocator's
21// spill placement, only here we're determining where to place cross-class
22// register copies rather than spills. As such, a similar approach is
23// called for.
24//
25// We want to build up a set of graphs of all instructions which are candidates
26// for transformation along with instructions which generate their inputs and
27// consume their outputs. For each edge in the graph, we assign a weight
28// based on whether there is a copy required there (weight zero if not) and
29// the block frequency of the block containing the defining or using
30// instruction, whichever is less. Our optimization is then a graph problem
31// to minimize the total weight of all the graphs, then transform instructions
32// and add or remove copy instructions as called for to implement the
33// solution.
34//===----------------------------------------------------------------------===//
35
36#include "AArch64.h"
37#include "AArch64InstrInfo.h"
38#include "AArch64RegisterInfo.h"
39#include "llvm/ADT/Statistic.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000040#include "llvm/CodeGen/MachineFunction.h"
Benjamin Kramer1f8930e2014-07-25 11:42:14 +000041#include "llvm/CodeGen/MachineFunctionPass.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000042#include "llvm/CodeGen/MachineInstr.h"
43#include "llvm/CodeGen/MachineInstrBuilder.h"
44#include "llvm/CodeGen/MachineRegisterInfo.h"
45#include "llvm/Support/CommandLine.h"
46#include "llvm/Support/Debug.h"
47#include "llvm/Support/raw_ostream.h"
48using namespace llvm;
49
50#define DEBUG_TYPE "aarch64-simd-scalar"
51
52// Allow forcing all i64 operations with equivalent SIMD instructions to use
53// them. For stress-testing the transformation function.
54static cl::opt<bool>
55TransformAll("aarch64-simd-scalar-force-all",
56 cl::desc("Force use of AdvSIMD scalar instructions everywhere"),
57 cl::init(false), cl::Hidden);
58
59STATISTIC(NumScalarInsnsUsed, "Number of scalar instructions used");
60STATISTIC(NumCopiesDeleted, "Number of cross-class copies deleted");
61STATISTIC(NumCopiesInserted, "Number of cross-class copies inserted");
62
Chad Rosier794b9b22015-08-05 15:18:58 +000063#define AARCH64_ADVSIMD_NAME "AdvSIMD Scalar Operation Optimization"
64
Tim Northover3b0846e2014-05-24 12:50:23 +000065namespace {
66class AArch64AdvSIMDScalar : public MachineFunctionPass {
67 MachineRegisterInfo *MRI;
Eric Christopherf761d902015-01-30 01:10:18 +000068 const TargetInstrInfo *TII;
Tim Northover3b0846e2014-05-24 12:50:23 +000069
70private:
71 // isProfitableToTransform - Predicate function to determine whether an
72 // instruction should be transformed to its equivalent AdvSIMD scalar
73 // instruction. "add Xd, Xn, Xm" ==> "add Dd, Da, Db", for example.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +000074 bool isProfitableToTransform(const MachineInstr &MI) const;
Tim Northover3b0846e2014-05-24 12:50:23 +000075
76 // transformInstruction - Perform the transformation of an instruction
77 // to its equivalant AdvSIMD scalar instruction. Update inputs and outputs
78 // to be the correct register class, minimizing cross-class copies.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +000079 void transformInstruction(MachineInstr &MI);
Tim Northover3b0846e2014-05-24 12:50:23 +000080
81 // processMachineBasicBlock - Main optimzation loop.
82 bool processMachineBasicBlock(MachineBasicBlock *MBB);
83
84public:
85 static char ID; // Pass identification, replacement for typeid.
Chad Rosier794b9b22015-08-05 15:18:58 +000086 explicit AArch64AdvSIMDScalar() : MachineFunctionPass(ID) {
87 initializeAArch64AdvSIMDScalarPass(*PassRegistry::getPassRegistry());
88 }
Tim Northover3b0846e2014-05-24 12:50:23 +000089
90 bool runOnMachineFunction(MachineFunction &F) override;
91
Mehdi Amini117296c2016-10-01 02:56:57 +000092 StringRef getPassName() const override { return AARCH64_ADVSIMD_NAME; }
Tim Northover3b0846e2014-05-24 12:50:23 +000093
94 void getAnalysisUsage(AnalysisUsage &AU) const override {
95 AU.setPreservesCFG();
96 MachineFunctionPass::getAnalysisUsage(AU);
97 }
98};
99char AArch64AdvSIMDScalar::ID = 0;
100} // end anonymous namespace
101
Chad Rosier794b9b22015-08-05 15:18:58 +0000102INITIALIZE_PASS(AArch64AdvSIMDScalar, "aarch64-simd-scalar",
103 AARCH64_ADVSIMD_NAME, false, false)
104
Tim Northover3b0846e2014-05-24 12:50:23 +0000105static bool isGPR64(unsigned Reg, unsigned SubReg,
106 const MachineRegisterInfo *MRI) {
107 if (SubReg)
108 return false;
109 if (TargetRegisterInfo::isVirtualRegister(Reg))
110 return MRI->getRegClass(Reg)->hasSuperClassEq(&AArch64::GPR64RegClass);
111 return AArch64::GPR64RegClass.contains(Reg);
112}
113
114static bool isFPR64(unsigned Reg, unsigned SubReg,
115 const MachineRegisterInfo *MRI) {
116 if (TargetRegisterInfo::isVirtualRegister(Reg))
117 return (MRI->getRegClass(Reg)->hasSuperClassEq(&AArch64::FPR64RegClass) &&
118 SubReg == 0) ||
119 (MRI->getRegClass(Reg)->hasSuperClassEq(&AArch64::FPR128RegClass) &&
120 SubReg == AArch64::dsub);
121 // Physical register references just check the register class directly.
122 return (AArch64::FPR64RegClass.contains(Reg) && SubReg == 0) ||
123 (AArch64::FPR128RegClass.contains(Reg) && SubReg == AArch64::dsub);
124}
125
126// getSrcFromCopy - Get the original source register for a GPR64 <--> FPR64
127// copy instruction. Return zero_reg if the instruction is not a copy.
Quentin Colombet9598f102016-04-22 18:09:14 +0000128static MachineOperand *getSrcFromCopy(MachineInstr *MI,
129 const MachineRegisterInfo *MRI,
130 unsigned &SubReg) {
Tim Northover3b0846e2014-05-24 12:50:23 +0000131 SubReg = 0;
132 // The "FMOV Xd, Dn" instruction is the typical form.
133 if (MI->getOpcode() == AArch64::FMOVDXr ||
134 MI->getOpcode() == AArch64::FMOVXDr)
Quentin Colombet9598f102016-04-22 18:09:14 +0000135 return &MI->getOperand(1);
Tim Northover3b0846e2014-05-24 12:50:23 +0000136 // A lane zero extract "UMOV.d Xd, Vn[0]" is equivalent. We shouldn't see
137 // these at this stage, but it's easy to check for.
138 if (MI->getOpcode() == AArch64::UMOVvi64 && MI->getOperand(2).getImm() == 0) {
139 SubReg = AArch64::dsub;
Quentin Colombet9598f102016-04-22 18:09:14 +0000140 return &MI->getOperand(1);
Tim Northover3b0846e2014-05-24 12:50:23 +0000141 }
142 // Or just a plain COPY instruction. This can be directly to/from FPR64,
143 // or it can be a dsub subreg reference to an FPR128.
144 if (MI->getOpcode() == AArch64::COPY) {
145 if (isFPR64(MI->getOperand(0).getReg(), MI->getOperand(0).getSubReg(),
146 MRI) &&
147 isGPR64(MI->getOperand(1).getReg(), MI->getOperand(1).getSubReg(), MRI))
Quentin Colombet9598f102016-04-22 18:09:14 +0000148 return &MI->getOperand(1);
Tim Northover3b0846e2014-05-24 12:50:23 +0000149 if (isGPR64(MI->getOperand(0).getReg(), MI->getOperand(0).getSubReg(),
150 MRI) &&
151 isFPR64(MI->getOperand(1).getReg(), MI->getOperand(1).getSubReg(),
152 MRI)) {
153 SubReg = MI->getOperand(1).getSubReg();
Quentin Colombet9598f102016-04-22 18:09:14 +0000154 return &MI->getOperand(1);
Tim Northover3b0846e2014-05-24 12:50:23 +0000155 }
156 }
157
158 // Otherwise, this is some other kind of instruction.
Quentin Colombet9598f102016-04-22 18:09:14 +0000159 return nullptr;
Tim Northover3b0846e2014-05-24 12:50:23 +0000160}
161
162// getTransformOpcode - For any opcode for which there is an AdvSIMD equivalent
163// that we're considering transforming to, return that AdvSIMD opcode. For all
164// others, return the original opcode.
Matthias Braunfa3872e2015-05-18 20:27:55 +0000165static unsigned getTransformOpcode(unsigned Opc) {
Tim Northover3b0846e2014-05-24 12:50:23 +0000166 switch (Opc) {
167 default:
168 break;
169 // FIXME: Lots more possibilities.
170 case AArch64::ADDXrr:
171 return AArch64::ADDv1i64;
172 case AArch64::SUBXrr:
173 return AArch64::SUBv1i64;
Chad Rosier5908ab42014-08-04 21:20:25 +0000174 case AArch64::ANDXrr:
175 return AArch64::ANDv8i8;
176 case AArch64::EORXrr:
177 return AArch64::EORv8i8;
178 case AArch64::ORRXrr:
179 return AArch64::ORRv8i8;
Tim Northover3b0846e2014-05-24 12:50:23 +0000180 }
181 // No AdvSIMD equivalent, so just return the original opcode.
182 return Opc;
183}
184
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000185static bool isTransformable(const MachineInstr &MI) {
186 unsigned Opc = MI.getOpcode();
Tim Northover3b0846e2014-05-24 12:50:23 +0000187 return Opc != getTransformOpcode(Opc);
188}
189
190// isProfitableToTransform - Predicate function to determine whether an
191// instruction should be transformed to its equivalent AdvSIMD scalar
192// instruction. "add Xd, Xn, Xm" ==> "add Dd, Da, Db", for example.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000193bool AArch64AdvSIMDScalar::isProfitableToTransform(
194 const MachineInstr &MI) const {
Tim Northover3b0846e2014-05-24 12:50:23 +0000195 // If this instruction isn't eligible to be transformed (no SIMD equivalent),
196 // early exit since that's the common case.
197 if (!isTransformable(MI))
198 return false;
199
200 // Count the number of copies we'll need to add and approximate the number
201 // of copies that a transform will enable us to remove.
202 unsigned NumNewCopies = 3;
203 unsigned NumRemovableCopies = 0;
204
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000205 unsigned OrigSrc0 = MI.getOperand(1).getReg();
206 unsigned OrigSrc1 = MI.getOperand(2).getReg();
Quentin Colombet9598f102016-04-22 18:09:14 +0000207 unsigned SubReg0;
208 unsigned SubReg1;
Tim Northover3b0846e2014-05-24 12:50:23 +0000209 if (!MRI->def_empty(OrigSrc0)) {
210 MachineRegisterInfo::def_instr_iterator Def =
211 MRI->def_instr_begin(OrigSrc0);
212 assert(std::next(Def) == MRI->def_instr_end() && "Multiple def in SSA!");
Quentin Colombet9598f102016-04-22 18:09:14 +0000213 MachineOperand *MOSrc0 = getSrcFromCopy(&*Def, MRI, SubReg0);
Tim Northover3b0846e2014-05-24 12:50:23 +0000214 // If the source was from a copy, we don't need to insert a new copy.
Quentin Colombet9598f102016-04-22 18:09:14 +0000215 if (MOSrc0)
Tim Northover3b0846e2014-05-24 12:50:23 +0000216 --NumNewCopies;
217 // If there are no other users of the original source, we can delete
218 // that instruction.
Quentin Colombet9598f102016-04-22 18:09:14 +0000219 if (MOSrc0 && MRI->hasOneNonDBGUse(OrigSrc0))
Tim Northover3b0846e2014-05-24 12:50:23 +0000220 ++NumRemovableCopies;
221 }
222 if (!MRI->def_empty(OrigSrc1)) {
223 MachineRegisterInfo::def_instr_iterator Def =
224 MRI->def_instr_begin(OrigSrc1);
225 assert(std::next(Def) == MRI->def_instr_end() && "Multiple def in SSA!");
Quentin Colombet9598f102016-04-22 18:09:14 +0000226 MachineOperand *MOSrc1 = getSrcFromCopy(&*Def, MRI, SubReg1);
227 if (MOSrc1)
Tim Northover3b0846e2014-05-24 12:50:23 +0000228 --NumNewCopies;
229 // If there are no other users of the original source, we can delete
230 // that instruction.
Quentin Colombet9598f102016-04-22 18:09:14 +0000231 if (MOSrc1 && MRI->hasOneNonDBGUse(OrigSrc1))
Tim Northover3b0846e2014-05-24 12:50:23 +0000232 ++NumRemovableCopies;
233 }
234
235 // If any of the uses of the original instructions is a cross class copy,
236 // that's a copy that will be removable if we transform. Likewise, if
237 // any of the uses is a transformable instruction, it's likely the tranforms
238 // will chain, enabling us to save a copy there, too. This is an aggressive
239 // heuristic that approximates the graph based cost analysis described above.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000240 unsigned Dst = MI.getOperand(0).getReg();
Tim Northover3b0846e2014-05-24 12:50:23 +0000241 bool AllUsesAreCopies = true;
242 for (MachineRegisterInfo::use_instr_nodbg_iterator
243 Use = MRI->use_instr_nodbg_begin(Dst),
244 E = MRI->use_instr_nodbg_end();
245 Use != E; ++Use) {
246 unsigned SubReg;
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000247 if (getSrcFromCopy(&*Use, MRI, SubReg) || isTransformable(*Use))
Tim Northover3b0846e2014-05-24 12:50:23 +0000248 ++NumRemovableCopies;
249 // If the use is an INSERT_SUBREG, that's still something that can
250 // directly use the FPR64, so we don't invalidate AllUsesAreCopies. It's
251 // preferable to have it use the FPR64 in most cases, as if the source
252 // vector is an IMPLICIT_DEF, the INSERT_SUBREG just goes away entirely.
253 // Ditto for a lane insert.
254 else if (Use->getOpcode() == AArch64::INSERT_SUBREG ||
255 Use->getOpcode() == AArch64::INSvi64gpr)
256 ;
257 else
258 AllUsesAreCopies = false;
259 }
260 // If all of the uses of the original destination register are copies to
261 // FPR64, then we won't end up having a new copy back to GPR64 either.
262 if (AllUsesAreCopies)
263 --NumNewCopies;
264
265 // If a transform will not increase the number of cross-class copies required,
266 // return true.
267 if (NumNewCopies <= NumRemovableCopies)
268 return true;
269
270 // Finally, even if we otherwise wouldn't transform, check if we're forcing
271 // transformation of everything.
272 return TransformAll;
273}
274
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000275static MachineInstr *insertCopy(const TargetInstrInfo *TII, MachineInstr &MI,
Tim Northover3b0846e2014-05-24 12:50:23 +0000276 unsigned Dst, unsigned Src, bool IsKill) {
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000277 MachineInstrBuilder MIB = BuildMI(*MI.getParent(), MI, MI.getDebugLoc(),
278 TII->get(AArch64::COPY), Dst)
279 .addReg(Src, getKillRegState(IsKill));
Nicola Zaghend34e60c2018-05-14 12:53:11 +0000280 LLVM_DEBUG(dbgs() << " adding copy: " << *MIB);
Tim Northover3b0846e2014-05-24 12:50:23 +0000281 ++NumCopiesInserted;
282 return MIB;
283}
284
285// transformInstruction - Perform the transformation of an instruction
286// to its equivalant AdvSIMD scalar instruction. Update inputs and outputs
287// to be the correct register class, minimizing cross-class copies.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000288void AArch64AdvSIMDScalar::transformInstruction(MachineInstr &MI) {
Nicola Zaghend34e60c2018-05-14 12:53:11 +0000289 LLVM_DEBUG(dbgs() << "Scalar transform: " << MI);
Tim Northover3b0846e2014-05-24 12:50:23 +0000290
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000291 MachineBasicBlock *MBB = MI.getParent();
292 unsigned OldOpc = MI.getOpcode();
Matthias Braunfa3872e2015-05-18 20:27:55 +0000293 unsigned NewOpc = getTransformOpcode(OldOpc);
Tim Northover3b0846e2014-05-24 12:50:23 +0000294 assert(OldOpc != NewOpc && "transform an instruction to itself?!");
295
296 // Check if we need a copy for the source registers.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000297 unsigned OrigSrc0 = MI.getOperand(1).getReg();
298 unsigned OrigSrc1 = MI.getOperand(2).getReg();
Tim Northover3b0846e2014-05-24 12:50:23 +0000299 unsigned Src0 = 0, SubReg0;
300 unsigned Src1 = 0, SubReg1;
Quentin Colombet9598f102016-04-22 18:09:14 +0000301 bool KillSrc0 = false, KillSrc1 = false;
Tim Northover3b0846e2014-05-24 12:50:23 +0000302 if (!MRI->def_empty(OrigSrc0)) {
303 MachineRegisterInfo::def_instr_iterator Def =
304 MRI->def_instr_begin(OrigSrc0);
305 assert(std::next(Def) == MRI->def_instr_end() && "Multiple def in SSA!");
Quentin Colombet9598f102016-04-22 18:09:14 +0000306 MachineOperand *MOSrc0 = getSrcFromCopy(&*Def, MRI, SubReg0);
Tim Northover3b0846e2014-05-24 12:50:23 +0000307 // If there are no other users of the original source, we can delete
308 // that instruction.
Quentin Colombet9598f102016-04-22 18:09:14 +0000309 if (MOSrc0) {
310 Src0 = MOSrc0->getReg();
311 KillSrc0 = MOSrc0->isKill();
312 // Src0 is going to be reused, thus, it cannot be killed anymore.
313 MOSrc0->setIsKill(false);
314 if (MRI->hasOneNonDBGUse(OrigSrc0)) {
315 assert(MOSrc0 && "Can't delete copy w/o a valid original source!");
316 Def->eraseFromParent();
317 ++NumCopiesDeleted;
318 }
Tim Northover3b0846e2014-05-24 12:50:23 +0000319 }
320 }
321 if (!MRI->def_empty(OrigSrc1)) {
322 MachineRegisterInfo::def_instr_iterator Def =
323 MRI->def_instr_begin(OrigSrc1);
324 assert(std::next(Def) == MRI->def_instr_end() && "Multiple def in SSA!");
Quentin Colombet9598f102016-04-22 18:09:14 +0000325 MachineOperand *MOSrc1 = getSrcFromCopy(&*Def, MRI, SubReg1);
Tim Northover3b0846e2014-05-24 12:50:23 +0000326 // If there are no other users of the original source, we can delete
327 // that instruction.
Quentin Colombet9598f102016-04-22 18:09:14 +0000328 if (MOSrc1) {
329 Src1 = MOSrc1->getReg();
330 KillSrc1 = MOSrc1->isKill();
331 // Src0 is going to be reused, thus, it cannot be killed anymore.
332 MOSrc1->setIsKill(false);
333 if (MRI->hasOneNonDBGUse(OrigSrc1)) {
334 assert(MOSrc1 && "Can't delete copy w/o a valid original source!");
335 Def->eraseFromParent();
336 ++NumCopiesDeleted;
337 }
Tim Northover3b0846e2014-05-24 12:50:23 +0000338 }
339 }
340 // If we weren't able to reference the original source directly, create a
341 // copy.
342 if (!Src0) {
343 SubReg0 = 0;
344 Src0 = MRI->createVirtualRegister(&AArch64::FPR64RegClass);
Quentin Colombet9598f102016-04-22 18:09:14 +0000345 insertCopy(TII, MI, Src0, OrigSrc0, KillSrc0);
346 KillSrc0 = true;
Tim Northover3b0846e2014-05-24 12:50:23 +0000347 }
348 if (!Src1) {
349 SubReg1 = 0;
350 Src1 = MRI->createVirtualRegister(&AArch64::FPR64RegClass);
Quentin Colombet9598f102016-04-22 18:09:14 +0000351 insertCopy(TII, MI, Src1, OrigSrc1, KillSrc1);
352 KillSrc1 = true;
Tim Northover3b0846e2014-05-24 12:50:23 +0000353 }
354
355 // Create a vreg for the destination.
356 // FIXME: No need to do this if the ultimate user expects an FPR64.
357 // Check for that and avoid the copy if possible.
358 unsigned Dst = MRI->createVirtualRegister(&AArch64::FPR64RegClass);
359
360 // For now, all of the new instructions have the same simple three-register
361 // form, so no need to special case based on what instruction we're
362 // building.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000363 BuildMI(*MBB, MI, MI.getDebugLoc(), TII->get(NewOpc), Dst)
Quentin Colombet9598f102016-04-22 18:09:14 +0000364 .addReg(Src0, getKillRegState(KillSrc0), SubReg0)
365 .addReg(Src1, getKillRegState(KillSrc1), SubReg1);
Tim Northover3b0846e2014-05-24 12:50:23 +0000366
367 // Now copy the result back out to a GPR.
368 // FIXME: Try to avoid this if all uses could actually just use the FPR64
369 // directly.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000370 insertCopy(TII, MI, MI.getOperand(0).getReg(), Dst, true);
Tim Northover3b0846e2014-05-24 12:50:23 +0000371
372 // Erase the old instruction.
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000373 MI.eraseFromParent();
Tim Northover3b0846e2014-05-24 12:50:23 +0000374
375 ++NumScalarInsnsUsed;
376}
377
378// processMachineBasicBlock - Main optimzation loop.
379bool AArch64AdvSIMDScalar::processMachineBasicBlock(MachineBasicBlock *MBB) {
380 bool Changed = false;
381 for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E;) {
Duncan P. N. Exon Smithab53fd92016-07-08 20:29:42 +0000382 MachineInstr &MI = *I++;
Tim Northover3b0846e2014-05-24 12:50:23 +0000383 if (isProfitableToTransform(MI)) {
384 transformInstruction(MI);
385 Changed = true;
386 }
387 }
388 return Changed;
389}
390
391// runOnMachineFunction - Pass entry point from PassManager.
392bool AArch64AdvSIMDScalar::runOnMachineFunction(MachineFunction &mf) {
393 bool Changed = false;
Nicola Zaghend34e60c2018-05-14 12:53:11 +0000394 LLVM_DEBUG(dbgs() << "***** AArch64AdvSIMDScalar *****\n");
Tim Northover3b0846e2014-05-24 12:50:23 +0000395
Matthias Braunf1caa282017-12-15 22:22:58 +0000396 if (skipFunction(mf.getFunction()))
Andrew Kaylor1ac98bb2016-04-25 21:58:52 +0000397 return false;
398
Tim Northover3b0846e2014-05-24 12:50:23 +0000399 MRI = &mf.getRegInfo();
Eric Christopherf761d902015-01-30 01:10:18 +0000400 TII = mf.getSubtarget().getInstrInfo();
Tim Northover3b0846e2014-05-24 12:50:23 +0000401
402 // Just check things on a one-block-at-a-time basis.
403 for (MachineFunction::iterator I = mf.begin(), E = mf.end(); I != E; ++I)
Duncan P. N. Exon Smithd3b9df02015-10-13 20:02:15 +0000404 if (processMachineBasicBlock(&*I))
Tim Northover3b0846e2014-05-24 12:50:23 +0000405 Changed = true;
406 return Changed;
407}
408
409// createAArch64AdvSIMDScalar - Factory function used by AArch64TargetMachine
410// to add the pass to the PassManager.
411FunctionPass *llvm::createAArch64AdvSIMDScalar() {
412 return new AArch64AdvSIMDScalar();
413}