llvm.org GIT mirror llvm / 14fc45e
[CodeGen] Take a MachineMemOperand::Flags in MachineFunction::getMachineMemOperand. Summary: Previously we took an unsigned. Hooray for type-safety. Reviewers: chandlerc Subscribers: dsanders, llvm-commits Differential Revision: http://reviews.llvm.org/D22282 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275591 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Lebar 4 years ago
19 changed file(s) with 45 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
2020 #include "llvm/ADT/BitVector.h"
2121 #include "llvm/ADT/ilist.h"
2222 #include "llvm/CodeGen/MachineBasicBlock.h"
23 #include "llvm/CodeGen/MachineMemOperand.h"
2324 #include "llvm/IR/DebugLoc.h"
2425 #include "llvm/IR/Metadata.h"
2526 #include "llvm/Support/Allocator.h"
529530 /// MachineMemOperands are owned by the MachineFunction and need not be
530531 /// explicitly deallocated.
531532 MachineMemOperand *getMachineMemOperand(MachinePointerInfo PtrInfo,
532 unsigned f, uint64_t s,
533 unsigned base_alignment,
533 MachineMemOperand::Flags f,
534 uint64_t s, unsigned base_alignment,
534535 const AAMDNodes &AAInfo = AAMDNodes(),
535536 const MDNode *Ranges = nullptr);
536537
164164 bool parseAlignment(unsigned &Alignment);
165165 bool parseOperandsOffset(MachineOperand &Op);
166166 bool parseIRValue(const Value *&V);
167 bool parseMemoryOperandFlag(unsigned &Flags);
167 bool parseMemoryOperandFlag(MachineMemOperand::Flags &Flags);
168168 bool parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV);
169169 bool parseMachinePointerInfo(MachinePointerInfo &Dest);
170170 bool parseMachineMemoryOperand(MachineMemOperand *&Dest);
16511651 return false;
16521652 }
16531653
1654 bool MIParser::parseMemoryOperandFlag(unsigned &Flags) {
1655 const unsigned OldFlags = Flags;
1654 bool MIParser::parseMemoryOperandFlag(MachineMemOperand::Flags &Flags) {
1655 const auto OldFlags = Flags;
16561656 switch (Token.kind()) {
16571657 case MIToken::kw_volatile:
16581658 Flags |= MachineMemOperand::MOVolatile;
17681768 bool MIParser::parseMachineMemoryOperand(MachineMemOperand *&Dest) {
17691769 if (expectAndConsume(MIToken::lparen))
17701770 return true;
1771 unsigned Flags = 0;
1771 MachineMemOperand::Flags Flags = MachineMemOperand::MONone;
17721772 while (Token.isMemoryOperandFlag()) {
17731773 if (parseMemoryOperandFlag(Flags))
17741774 return true;
293293 BasicBlockRecycler.Deallocate(Allocator, MBB);
294294 }
295295
296 MachineMemOperand *
297 MachineFunction::getMachineMemOperand(MachinePointerInfo PtrInfo, unsigned f,
298 uint64_t s, unsigned base_alignment,
299 const AAMDNodes &AAInfo,
300 const MDNode *Ranges) {
301 // FIXME: Get rid of this static_cast and make getMachineOperand take a
302 // MachineMemOperand::Flags param.
296 MachineMemOperand *MachineFunction::getMachineMemOperand(
297 MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s,
298 unsigned base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges) {
303299 return new (Allocator)
304 MachineMemOperand(PtrInfo, static_cast(f), s,
305 base_alignment, AAInfo, Ranges);
300 MachineMemOperand(PtrInfo, f, s, base_alignment, AAInfo, Ranges);
306301 }
307302
308303 MachineMemOperand *
21602160 const Value *Ptr;
21612161 Type *ValTy;
21622162 unsigned Alignment;
2163 unsigned Flags;
2163 MachineMemOperand::Flags Flags;
21642164 bool IsVolatile;
21652165
21662166 if (const auto *LI = dyn_cast(I)) {
48444844
48454845 // FIXME: Volatile isn't really correct; we should keep track of atomic
48464846 // orderings in the memoperand.
4847 unsigned Flags = MachineMemOperand::MOVolatile;
4848 Flags |= MachineMemOperand::MOLoad;
4849 Flags |= MachineMemOperand::MOStore;
4850
4847 auto Flags = MachineMemOperand::MOVolatile | MachineMemOperand::MOLoad |
4848 MachineMemOperand::MOStore;
48514849 MachineMemOperand *MMO =
48524850 MF.getMachineMemOperand(PtrInfo, Flags, MemVT.getStoreSize(), Alignment);
48534851
48864884 // chained as such.
48874885 // FIXME: Volatile isn't really correct; we should keep track of atomic
48884886 // orderings in the memoperand.
4889 unsigned Flags = MachineMemOperand::MOVolatile;
4887 auto Flags = MachineMemOperand::MOVolatile;
48904888 if (Opcode != ISD::ATOMIC_STORE)
48914889 Flags |= MachineMemOperand::MOLoad;
48924890 if (Opcode != ISD::ATOMIC_LOAD)
49574955 Align = getEVTAlignment(MemVT);
49584956
49594957 MachineFunction &MF = getMachineFunction();
4960 unsigned Flags = 0;
4958 auto Flags = MachineMemOperand::MONone;
49614959 if (WriteMem)
49624960 Flags |= MachineMemOperand::MOStore;
49634961 if (ReadMem)
50605058 if (Alignment == 0) // Ensure that codegen never sees alignment 0
50615059 Alignment = getEVTAlignment(VT);
50625060
5063 unsigned Flags = MachineMemOperand::MOLoad;
5061 auto Flags = MachineMemOperand::MOLoad;
50645062 if (isVolatile)
50655063 Flags |= MachineMemOperand::MOVolatile;
50665064 if (isNonTemporal)
51855183 if (Alignment == 0) // Ensure that codegen never sees alignment 0
51865184 Alignment = getEVTAlignment(Val.getValueType());
51875185
5188 unsigned Flags = MachineMemOperand::MOStore;
5186 auto Flags = MachineMemOperand::MOStore;
51895187 if (isVolatile)
51905188 Flags |= MachineMemOperand::MOVolatile;
51915189 if (isNonTemporal)
52415239 if (Alignment == 0) // Ensure that codegen never sees alignment 0
52425240 Alignment = getEVTAlignment(SVT);
52435241
5244 unsigned Flags = MachineMemOperand::MOStore;
5242 auto Flags = MachineMemOperand::MOStore;
52455243 if (isVolatile)
52465244 Flags |= MachineMemOperand::MOVolatile;
52475245 if (isNonTemporal)
20122012 if (Global) {
20132013 MachinePointerInfo MPInfo(Global);
20142014 MachineInstr::mmo_iterator MemRefs = MF.allocateMemRefsArray(1);
2015 unsigned Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
2015 auto Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
20162016 *MemRefs = MF.getMachineMemOperand(MPInfo, Flags, PtrTy.getSizeInBits() / 8,
20172017 DAG.getEVTAlignment(PtrTy));
20182018 Node->setMemRefs(MemRefs, MemRefs + 1);
496496 MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
497497 ArrayRef Ops, int FI,
498498 LiveIntervals *LIS) const {
499 unsigned Flags = 0;
499 auto Flags = MachineMemOperand::MONone;
500500 for (unsigned i = 0, e = Ops.size(); i != e; ++i)
501501 if (MI.getOperand(Ops[i]).isDef())
502502 Flags |= MachineMemOperand::MOStore;
12331233 // Add a new memory operand for this FI.
12341234 assert(MFI.getObjectOffset(FI) != -1);
12351235
1236 unsigned Flags = MachineMemOperand::MOLoad;
1236 auto Flags = MachineMemOperand::MOLoad;
12371237 if (MI->getOpcode() == TargetOpcode::STATEPOINT) {
12381238 Flags |= MachineMemOperand::MOStore;
12391239 Flags |= MachineMemOperand::MOVolatile;
142142 bool computeCallAddress(const Value *V, Address &Addr);
143143 bool simplifyAddress(Address &Addr, MVT VT);
144144 void addLoadStoreOperands(Address &Addr, const MachineInstrBuilder &MIB,
145 unsigned Flags, unsigned ScaleFactor,
146 MachineMemOperand *MMO);
145 MachineMemOperand::Flags Flags,
146 unsigned ScaleFactor, MachineMemOperand *MMO);
147147 bool isMemCpySmall(uint64_t Len, unsigned Alignment);
148148 bool tryEmitSmallMemCpy(Address Dest, Address Src, uint64_t Len,
149149 unsigned Alignment);
10391039
10401040 void AArch64FastISel::addLoadStoreOperands(Address &Addr,
10411041 const MachineInstrBuilder &MIB,
1042 unsigned Flags,
1042 MachineMemOperand::Flags Flags,
10431043 unsigned ScaleFactor,
10441044 MachineMemOperand *MMO) {
10451045 int64_t Offset = Addr.getOffset() / ScaleFactor;
41314131 if (Subtarget.isGVIndirectSymbol(GV)) {
41324132 MIB = BuildMI(MBB, MI, DL, get(LoadOpc), Reg);
41334133 MIB.addReg(Reg, RegState::Kill).addImm(0);
4134 unsigned Flag = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
4134 auto Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
41354135 MachineMemOperand *MMO = MBB.getParent()->getMachineMemOperand(
4136 MachinePointerInfo::getGOT(*MBB.getParent()), Flag, 4, 4);
4136 MachinePointerInfo::getGOT(*MBB.getParent()), Flags, 4, 4);
41374137 MIB.addMemOperand(MMO);
41384138 AddDefaultPred(MIB);
41394139 }
208208 const MachineInstrBuilder &AddOptionalDefs(const MachineInstrBuilder &MIB);
209209 void AddLoadStoreOperands(MVT VT, Address &Addr,
210210 const MachineInstrBuilder &MIB,
211 unsigned Flags, bool useAM3);
211 MachineMemOperand::Flags Flags, bool useAM3);
212212 };
213213
214214 } // end anonymous namespace
872872
873873 void ARMFastISel::AddLoadStoreOperands(MVT VT, Address &Addr,
874874 const MachineInstrBuilder &MIB,
875 unsigned Flags, bool useAM3) {
875 MachineMemOperand::Flags Flags,
876 bool useAM3) {
876877 // addrmode5 output depends on the selection dag addressing dividing the
877878 // offset by 4 that it then later multiplies. Do this here as well.
878879 if (VT.SimpleTy == MVT::f32 || VT.SimpleTy == MVT::f64)
122122
123123 MIB = BuildMI(MBB, MI, DL, get(ARM::MOV_ga_pcrel_ldr), Reg)
124124 .addGlobalAddress(GV, 0, ARMII::MO_NONLAZY);
125 unsigned Flag = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
125 auto Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
126126 MachineMemOperand *MMO = MBB.getParent()->getMachineMemOperand(
127 MachinePointerInfo::getGOT(*MBB.getParent()), Flag, 4, 4);
127 MachinePointerInfo::getGOT(*MBB.getParent()), Flags, 4, 4);
128128 MIB.addMemOperand(MMO);
129129 MIB = BuildMI(MBB, MI, DL, get(ARM::LDRi12), Reg);
130130 MIB.addReg(Reg, RegState::Kill).addImm(0);
641641 MachineFunction &MF = *B.getParent();
642642 for (auto &MO : MI->memoperands()) {
643643 const MachinePointerInfo &Ptr = MO->getPointerInfo();
644 unsigned F = MO->getFlags();
644 MachineMemOperand::Flags F = MO->getFlags();
645645 int A = MO->getAlignment();
646646
647647 auto *Tmp1 = MF.getMachineMemOperand(Ptr, F, 4/*size*/, A);
5353 BuildMI(MBB, MI, DL, get(Mips::NOP));
5454 }
5555
56 MachineMemOperand *MipsInstrInfo::GetMemOperand(MachineBasicBlock &MBB, int FI,
57 unsigned Flag) const {
56 MachineMemOperand *
57 MipsInstrInfo::GetMemOperand(MachineBasicBlock &MBB, int FI,
58 MachineMemOperand::Flags Flags) const {
5859 MachineFunction &MF = *MBB.getParent();
5960 MachineFrameInfo &MFI = *MF.getFrameInfo();
6061 unsigned Align = MFI.getObjectAlignment(FI);
6162
6263 return MF.getMachineMemOperand(MachinePointerInfo::getFixedStack(MF, FI),
63 Flag, MFI.getObjectSize(FI), Align);
64 Flags, MFI.getObjectSize(FI), Align);
6465 }
6566
6667 //===----------------------------------------------------------------------===//
136136 bool isZeroImm(const MachineOperand &op) const;
137137
138138 MachineMemOperand *GetMemOperand(MachineBasicBlock &MBB, int FI,
139 unsigned Flag) const;
139 MachineMemOperand::Flags Flags) const;
140140
141141 private:
142142 virtual unsigned getAnalyzableBrOpc(unsigned Opc) const = 0;
2828 MachineFunction &MF = *MI->getParent()->getParent();
2929 MachineFrameInfo *MFFrame = MF.getFrameInfo();
3030 const MCInstrDesc &MCID = MI->getDesc();
31 unsigned Flags = 0;
31 auto Flags = MachineMemOperand::MONone;
3232 if (MCID.mayLoad())
3333 Flags |= MachineMemOperand::MOLoad;
3434 if (MCID.mayStore())
178178 MachineFunction &MF = *MI->getParent()->getParent();
179179 MachineFrameInfo &MFI = *MF.getFrameInfo();
180180 const MCInstrDesc &MCID = MI->getDesc();
181 unsigned Flags = 0;
181 auto Flags = MachineMemOperand::MONone;
182182 if (MCID.mayLoad())
183183 Flags |= MachineMemOperand::MOLoad;
184184 if (MCID.mayStore())
54975497 unsigned Reg = MIB->getOperand(0).getReg();
54985498 const GlobalValue *GV =
54995499 cast((*MIB->memoperands_begin())->getValue());
5500 unsigned Flag = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
5500 auto Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
55015501 MachineMemOperand *MMO = MBB.getParent()->getMachineMemOperand(
5502 MachinePointerInfo::getGOT(*MBB.getParent()), Flag, 8, 8);
5502 MachinePointerInfo::getGOT(*MBB.getParent()), Flags, 8, 8);
55035503 MachineBasicBlock::iterator I = MIB.getInstr();
55045504
55055505 BuildMI(MBB, I, DL, TII.get(X86::MOV64rm), Reg).addReg(X86::RIP).addImm(1)
171171 std::sort(SpillList.begin(), SpillList.end(), CompareSSIOffset);
172172 }
173173
174 static MachineMemOperand *
175 getFrameIndexMMO(MachineBasicBlock &MBB, int FrameIndex, unsigned flags) {
174 static MachineMemOperand *getFrameIndexMMO(MachineBasicBlock &MBB,
175 int FrameIndex,
176 MachineMemOperand::Flags flags) {
176177 MachineFunction *MF = MBB.getParent();
177178 const MachineFrameInfo &MFI = *MF->getFrameInfo();
178179 MachineMemOperand *MMO = MF->getMachineMemOperand(