LLVM  14.0.0git
MIRParser.cpp
Go to the documentation of this file.
1 //===- MIRParser.cpp - MIR serialization format parser implementation -----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the class that parses the optional LLVM IR and machine
10 // functions that are stored in MIR files.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/AsmParser/Parser.h"
31 #include "llvm/IR/BasicBlock.h"
32 #include "llvm/IR/DebugInfo.h"
33 #include "llvm/IR/DiagnosticInfo.h"
34 #include "llvm/IR/Instructions.h"
35 #include "llvm/IR/LLVMContext.h"
36 #include "llvm/IR/Module.h"
40 #include "llvm/Support/SMLoc.h"
41 #include "llvm/Support/SourceMgr.h"
44 #include <memory>
45 
46 using namespace llvm;
47 
48 namespace llvm {
49 
50 /// This class implements the parsing of LLVM IR that's embedded inside a MIR
51 /// file.
53  SourceMgr SM;
54  LLVMContext &Context;
55  yaml::Input In;
56  StringRef Filename;
57  SlotMapping IRSlots;
58  std::unique_ptr<PerTargetMIParsingState> Target;
59 
60  /// True when the MIR file doesn't have LLVM IR. Dummy IR functions are
61  /// created and inserted into the given module when this is true.
62  bool NoLLVMIR = false;
63  /// True when a well formed MIR file does not contain any MIR/machine function
64  /// parts.
65  bool NoMIRDocuments = false;
66 
67  std::function<void(Function &)> ProcessIRFunction;
68 
69 public:
70  MIRParserImpl(std::unique_ptr<MemoryBuffer> Contents, StringRef Filename,
72  std::function<void(Function &)> ProcessIRFunction);
73 
74  void reportDiagnostic(const SMDiagnostic &Diag);
75 
76  /// Report an error with the given message at unknown location.
77  ///
78  /// Always returns true.
79  bool error(const Twine &Message);
80 
81  /// Report an error with the given message at the given location.
82  ///
83  /// Always returns true.
84  bool error(SMLoc Loc, const Twine &Message);
85 
86  /// Report a given error with the location translated from the location in an
87  /// embedded string literal to a location in the MIR file.
88  ///
89  /// Always returns true.
90  bool error(const SMDiagnostic &Error, SMRange SourceRange);
91 
92  /// Try to parse the optional LLVM module and the machine functions in the MIR
93  /// file.
94  ///
95  /// Return null if an error occurred.
96  std::unique_ptr<Module>
97  parseIRModule(DataLayoutCallbackTy DataLayoutCallback);
98 
99  /// Create an empty function with the given name.
101 
103 
104  /// Parse the machine function in the current YAML document.
105  ///
106  ///
107  /// Return true if an error occurred.
109 
110  /// Initialize the machine function to the state that's described in the MIR
111  /// file.
112  ///
113  /// Return true if error occurred.
115  MachineFunction &MF);
116 
118  const yaml::MachineFunction &YamlMF);
119 
121  const yaml::MachineFunction &YamlMF);
122 
124  const yaml::MachineFunction &YamlMF);
125 
127  const yaml::MachineFunction &YamlMF);
128 
130  std::vector<CalleeSavedInfo> &CSIInfo,
131  const yaml::StringValue &RegisterSource,
132  bool IsRestored, int FrameIdx);
133 
134  template <typename T>
136  const T &Object,
137  int FrameIdx);
138 
141  const yaml::MachineFunction &YamlMF);
142 
144  const yaml::MachineJumpTable &YamlJTI);
145 
147  MachineFunction &MF,
148  const yaml::MachineFunction &YMF);
149 
150 private:
151  bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node,
152  const yaml::StringValue &Source);
153 
154  bool parseMBBReference(PerFunctionMIParsingState &PFS,
156  const yaml::StringValue &Source);
157 
158  bool parseMachineMetadata(PerFunctionMIParsingState &PFS,
159  const yaml::StringValue &Source);
160 
161  /// Return a MIR diagnostic converted from an MI string diagnostic.
162  SMDiagnostic diagFromMIStringDiag(const SMDiagnostic &Error,
163  SMRange SourceRange);
164 
165  /// Return a MIR diagnostic converted from a diagnostic located in a YAML
166  /// block scalar string.
167  SMDiagnostic diagFromBlockStringDiag(const SMDiagnostic &Error,
168  SMRange SourceRange);
169 
170  void computeFunctionProperties(MachineFunction &MF);
171 
172  void setupDebugValueTracking(MachineFunction &MF,
174 };
175 
176 } // end namespace llvm
177 
178 static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context) {
179  reinterpret_cast<MIRParserImpl *>(Context)->reportDiagnostic(Diag);
180 }
181 
182 MIRParserImpl::MIRParserImpl(std::unique_ptr<MemoryBuffer> Contents,
183  StringRef Filename, LLVMContext &Context,
184  std::function<void(Function &)> Callback)
185  : SM(),
186  Context(Context),
187  In(SM.getMemoryBuffer(SM.AddNewSourceBuffer(std::move(Contents), SMLoc()))
188  ->getBuffer(),
189  nullptr, handleYAMLDiag, this),
190  Filename(Filename), ProcessIRFunction(Callback) {
191  In.setContext(&In);
192 }
193 
194 bool MIRParserImpl::error(const Twine &Message) {
196  DS_Error, SMDiagnostic(Filename, SourceMgr::DK_Error, Message.str())));
197  return true;
198 }
199 
200 bool MIRParserImpl::error(SMLoc Loc, const Twine &Message) {
202  DS_Error, SM.GetMessage(Loc, SourceMgr::DK_Error, Message)));
203  return true;
204 }
205 
206 bool MIRParserImpl::error(const SMDiagnostic &Error, SMRange SourceRange) {
207  assert(Error.getKind() == SourceMgr::DK_Error && "Expected an error");
208  reportDiagnostic(diagFromMIStringDiag(Error, SourceRange));
209  return true;
210 }
211 
214  switch (Diag.getKind()) {
215  case SourceMgr::DK_Error:
216  Kind = DS_Error;
217  break;
219  Kind = DS_Warning;
220  break;
221  case SourceMgr::DK_Note:
222  Kind = DS_Note;
223  break;
225  llvm_unreachable("remark unexpected");
226  break;
227  }
229 }
230 
231 std::unique_ptr<Module>
233  if (!In.setCurrentDocument()) {
234  if (In.error())
235  return nullptr;
236  // Create an empty module when the MIR file is empty.
237  NoMIRDocuments = true;
238  auto M = std::make_unique<Module>(Filename, Context);
239  if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple()))
240  M->setDataLayout(*LayoutOverride);
241  return M;
242  }
243 
244  std::unique_ptr<Module> M;
245  // Parse the block scalar manually so that we can return unique pointer
246  // without having to go trough YAML traits.
247  if (const auto *BSN =
248  dyn_cast_or_null<yaml::BlockScalarNode>(In.getCurrentNode())) {
250  M = parseAssembly(MemoryBufferRef(BSN->getValue(), Filename), Error,
251  Context, &IRSlots, DataLayoutCallback);
252  if (!M) {
253  reportDiagnostic(diagFromBlockStringDiag(Error, BSN->getSourceRange()));
254  return nullptr;
255  }
256  In.nextDocument();
257  if (!In.setCurrentDocument())
258  NoMIRDocuments = true;
259  } else {
260  // Create an new, empty module.
261  M = std::make_unique<Module>(Filename, Context);
262  if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple()))
263  M->setDataLayout(*LayoutOverride);
264  NoLLVMIR = true;
265  }
266  return M;
267 }
268 
270  if (NoMIRDocuments)
271  return false;
272 
273  // Parse the machine functions.
274  do {
275  if (parseMachineFunction(M, MMI))
276  return true;
277  In.nextDocument();
278  } while (In.setCurrentDocument());
279 
280  return false;
281 }
282 
284  auto &Context = M.getContext();
285  Function *F =
288  BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
289  new UnreachableInst(Context, BB);
290 
291  if (ProcessIRFunction)
292  ProcessIRFunction(*F);
293 
294  return F;
295 }
296 
298  // Parse the yaml.
299  yaml::MachineFunction YamlMF;
300  yaml::EmptyContext Ctx;
301 
302  const LLVMTargetMachine &TM = MMI.getTarget();
303  YamlMF.MachineFuncInfo = std::unique_ptr<yaml::MachineFunctionInfo>(
304  TM.createDefaultFuncInfoYAML());
305 
306  yaml::yamlize(In, YamlMF, false, Ctx);
307  if (In.error())
308  return true;
309 
310  // Search for the corresponding IR function.
311  StringRef FunctionName = YamlMF.Name;
312  Function *F = M.getFunction(FunctionName);
313  if (!F) {
314  if (NoLLVMIR) {
315  F = createDummyFunction(FunctionName, M);
316  } else {
317  return error(Twine("function '") + FunctionName +
318  "' isn't defined in the provided LLVM IR");
319  }
320  }
321  if (MMI.getMachineFunction(*F) != nullptr)
322  return error(Twine("redefinition of machine function '") + FunctionName +
323  "'");
324 
325  // Create the MachineFunction.
327  if (initializeMachineFunction(YamlMF, MF))
328  return true;
329 
330  return false;
331 }
332 
333 static bool isSSA(const MachineFunction &MF) {
334  const MachineRegisterInfo &MRI = MF.getRegInfo();
335  for (unsigned I = 0, E = MRI.getNumVirtRegs(); I != E; ++I) {
337  if (!MRI.hasOneDef(Reg) && !MRI.def_empty(Reg))
338  return false;
339 
340  // Subregister defs are invalid in SSA.
341  const MachineOperand *RegDef = MRI.getOneDef(Reg);
342  if (RegDef && RegDef->getSubReg() != 0)
343  return false;
344  }
345  return true;
346 }
347 
348 void MIRParserImpl::computeFunctionProperties(MachineFunction &MF) {
349  MachineFunctionProperties &Properties = MF.getProperties();
350 
351  bool HasPHI = false;
352  bool HasInlineAsm = false;
353  for (const MachineBasicBlock &MBB : MF) {
354  for (const MachineInstr &MI : MBB) {
355  if (MI.isPHI())
356  HasPHI = true;
357  if (MI.isInlineAsm())
358  HasInlineAsm = true;
359  }
360  }
361  if (!HasPHI)
363  MF.setHasInlineAsm(HasInlineAsm);
364 
365  if (isSSA(MF))
367  else
369 
370  const MachineRegisterInfo &MRI = MF.getRegInfo();
371  if (MRI.getNumVirtRegs() == 0)
373 }
374 
376  PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF) {
377  MachineFunction &MF = PFS.MF;
379  const LLVMTargetMachine &TM = MF.getTarget();
380  for (auto YamlCSInfo : YamlMF.CallSitesInfo) {
381  yaml::CallSiteInfo::MachineInstrLoc MILoc = YamlCSInfo.CallLocation;
382  if (MILoc.BlockNum >= MF.size())
383  return error(Twine(MF.getName()) +
384  Twine(" call instruction block out of range.") +
385  " Unable to reference bb:" + Twine(MILoc.BlockNum));
386  auto CallB = std::next(MF.begin(), MILoc.BlockNum);
387  if (MILoc.Offset >= CallB->size())
388  return error(Twine(MF.getName()) +
389  Twine(" call instruction offset out of range.") +
390  " Unable to reference instruction at bb: " +
391  Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset));
392  auto CallI = std::next(CallB->instr_begin(), MILoc.Offset);
393  if (!CallI->isCall(MachineInstr::IgnoreBundle))
394  return error(Twine(MF.getName()) +
395  Twine(" call site info should reference call "
396  "instruction. Instruction at bb:") +
397  Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset) +
398  " is not a call instruction");
400  for (auto ArgRegPair : YamlCSInfo.ArgForwardingRegs) {
401  Register Reg;
402  if (parseNamedRegisterReference(PFS, Reg, ArgRegPair.Reg.Value, Error))
403  return error(Error, ArgRegPair.Reg.SourceRange);
404  CSInfo.emplace_back(Reg, ArgRegPair.ArgNo);
405  }
406 
407  if (TM.Options.EmitCallSiteInfo)
408  MF.addCallArgsForwardingRegs(&*CallI, std::move(CSInfo));
409  }
410 
411  if (YamlMF.CallSitesInfo.size() && !TM.Options.EmitCallSiteInfo)
412  return error(Twine("Call site info provided but not used"));
413  return false;
414 }
415 
416 void MIRParserImpl::setupDebugValueTracking(
418  const yaml::MachineFunction &YamlMF) {
419  // Compute the value of the "next instruction number" field.
420  unsigned MaxInstrNum = 0;
421  for (auto &MBB : MF)
422  for (auto &MI : MBB)
423  MaxInstrNum = std::max((unsigned)MI.peekDebugInstrNum(), MaxInstrNum);
424  MF.setDebugInstrNumberingCount(MaxInstrNum);
425 
426  // Load any substitutions.
427  for (auto &Sub : YamlMF.DebugValueSubstitutions) {
428  MF.makeDebugValueSubstitution({Sub.SrcInst, Sub.SrcOp},
429  {Sub.DstInst, Sub.DstOp}, Sub.Subreg);
430  }
431 }
432 
433 bool
435  MachineFunction &MF) {
436  // TODO: Recreate the machine function.
437  if (Target) {
438  // Avoid clearing state if we're using the same subtarget again.
439  Target->setTarget(MF.getSubtarget());
440  } else {
442  }
443 
444  MF.setAlignment(YamlMF.Alignment.valueOrOne());
446  MF.setHasWinCFI(YamlMF.HasWinCFI);
447 
448  if (YamlMF.Legalized)
450  if (YamlMF.RegBankSelected)
451  MF.getProperties().set(
453  if (YamlMF.Selected)
455  if (YamlMF.FailedISel)
457 
458  PerFunctionMIParsingState PFS(MF, SM, IRSlots, *Target);
459  if (parseRegisterInfo(PFS, YamlMF))
460  return true;
461  if (!YamlMF.Constants.empty()) {
462  auto *ConstantPool = MF.getConstantPool();
463  assert(ConstantPool && "Constant pool must be created");
464  if (initializeConstantPool(PFS, *ConstantPool, YamlMF))
465  return true;
466  }
467  if (!YamlMF.MachineMetadataNodes.empty() &&
468  parseMachineMetadataNodes(PFS, MF, YamlMF))
469  return true;
470 
471  StringRef BlockStr = YamlMF.Body.Value.Value;
473  SourceMgr BlockSM;
474  BlockSM.AddNewSourceBuffer(
475  MemoryBuffer::getMemBuffer(BlockStr, "",/*RequiresNullTerminator=*/false),
476  SMLoc());
477  PFS.SM = &BlockSM;
478  if (parseMachineBasicBlockDefinitions(PFS, BlockStr, Error)) {
480  diagFromBlockStringDiag(Error, YamlMF.Body.Value.SourceRange));
481  return true;
482  }
483  // Check Basic Block Section Flags.
486  } else if (MF.hasBBSections()) {
488  }
489  PFS.SM = &SM;
490 
491  // Initialize the frame information after creating all the MBBs so that the
492  // MBB references in the frame information can be resolved.
493  if (initializeFrameInfo(PFS, YamlMF))
494  return true;
495  // Initialize the jump table after creating all the MBBs so that the MBB
496  // references can be resolved.
497  if (!YamlMF.JumpTableInfo.Entries.empty() &&
499  return true;
500  // Parse the machine instructions after creating all of the MBBs so that the
501  // parser can resolve the MBB references.
502  StringRef InsnStr = YamlMF.Body.Value.Value;
503  SourceMgr InsnSM;
504  InsnSM.AddNewSourceBuffer(
505  MemoryBuffer::getMemBuffer(InsnStr, "", /*RequiresNullTerminator=*/false),
506  SMLoc());
507  PFS.SM = &InsnSM;
508  if (parseMachineInstructions(PFS, InsnStr, Error)) {
510  diagFromBlockStringDiag(Error, YamlMF.Body.Value.SourceRange));
511  return true;
512  }
513  PFS.SM = &SM;
514 
515  if (setupRegisterInfo(PFS, YamlMF))
516  return true;
517 
518  if (YamlMF.MachineFuncInfo) {
519  const LLVMTargetMachine &TM = MF.getTarget();
520  // Note this is called after the initial constructor of the
521  // MachineFunctionInfo based on the MachineFunction, which may depend on the
522  // IR.
523 
524  SMRange SrcRange;
525  if (TM.parseMachineFunctionInfo(*YamlMF.MachineFuncInfo, PFS, Error,
526  SrcRange)) {
527  return error(Error, SrcRange);
528  }
529  }
530 
531  // Set the reserved registers after parsing MachineFuncInfo. The target may
532  // have been recording information used to select the reserved registers
533  // there.
534  // FIXME: This is a temporary workaround until the reserved registers can be
535  // serialized.
538 
539  computeFunctionProperties(MF);
540 
541  if (initializeCallSiteInfo(PFS, YamlMF))
542  return false;
543 
544  setupDebugValueTracking(MF, PFS, YamlMF);
545 
546  MF.getSubtarget().mirFileLoaded(MF);
547 
548  MF.verify();
549  return false;
550 }
551 
553  const yaml::MachineFunction &YamlMF) {
554  MachineFunction &MF = PFS.MF;
555  MachineRegisterInfo &RegInfo = MF.getRegInfo();
556  assert(RegInfo.tracksLiveness());
557  if (!YamlMF.TracksRegLiveness)
558  RegInfo.invalidateLiveness();
559 
561  // Parse the virtual register information.
562  for (const auto &VReg : YamlMF.VirtualRegisters) {
563  VRegInfo &Info = PFS.getVRegInfo(VReg.ID.Value);
564  if (Info.Explicit)
565  return error(VReg.ID.SourceRange.Start,
566  Twine("redefinition of virtual register '%") +
567  Twine(VReg.ID.Value) + "'");
568  Info.Explicit = true;
569 
570  if (StringRef(VReg.Class.Value).equals("_")) {
571  Info.Kind = VRegInfo::GENERIC;
572  Info.D.RegBank = nullptr;
573  } else {
574  const auto *RC = Target->getRegClass(VReg.Class.Value);
575  if (RC) {
576  Info.Kind = VRegInfo::NORMAL;
577  Info.D.RC = RC;
578  } else {
579  const RegisterBank *RegBank = Target->getRegBank(VReg.Class.Value);
580  if (!RegBank)
581  return error(
582  VReg.Class.SourceRange.Start,
583  Twine("use of undefined register class or register bank '") +
584  VReg.Class.Value + "'");
585  Info.Kind = VRegInfo::REGBANK;
586  Info.D.RegBank = RegBank;
587  }
588  }
589 
590  if (!VReg.PreferredRegister.Value.empty()) {
591  if (Info.Kind != VRegInfo::NORMAL)
592  return error(VReg.Class.SourceRange.Start,
593  Twine("preferred register can only be set for normal vregs"));
594 
595  if (parseRegisterReference(PFS, Info.PreferredReg,
596  VReg.PreferredRegister.Value, Error))
597  return error(Error, VReg.PreferredRegister.SourceRange);
598  }
599  }
600 
601  // Parse the liveins.
602  for (const auto &LiveIn : YamlMF.LiveIns) {
603  Register Reg;
604  if (parseNamedRegisterReference(PFS, Reg, LiveIn.Register.Value, Error))
605  return error(Error, LiveIn.Register.SourceRange);
606  Register VReg;
607  if (!LiveIn.VirtualRegister.Value.empty()) {
608  VRegInfo *Info;
609  if (parseVirtualRegisterReference(PFS, Info, LiveIn.VirtualRegister.Value,
610  Error))
611  return error(Error, LiveIn.VirtualRegister.SourceRange);
612  VReg = Info->VReg;
613  }
614  RegInfo.addLiveIn(Reg, VReg);
615  }
616 
617  // Parse the callee saved registers (Registers that will
618  // be saved for the caller).
619  if (YamlMF.CalleeSavedRegisters) {
620  SmallVector<MCPhysReg, 16> CalleeSavedRegisters;
621  for (const auto &RegSource : YamlMF.CalleeSavedRegisters.getValue()) {
622  Register Reg;
623  if (parseNamedRegisterReference(PFS, Reg, RegSource.Value, Error))
624  return error(Error, RegSource.SourceRange);
625  CalleeSavedRegisters.push_back(Reg);
626  }
627  RegInfo.setCalleeSavedRegs(CalleeSavedRegisters);
628  }
629 
630  return false;
631 }
632 
634  const yaml::MachineFunction &YamlMF) {
635  MachineFunction &MF = PFS.MF;
637  bool Error = false;
638  // Create VRegs
639  auto populateVRegInfo = [&] (const VRegInfo &Info, Twine Name) {
640  Register Reg = Info.VReg;
641  switch (Info.Kind) {
642  case VRegInfo::UNKNOWN:
643  error(Twine("Cannot determine class/bank of virtual register ") +
644  Name + " in function '" + MF.getName() + "'");
645  Error = true;
646  break;
647  case VRegInfo::NORMAL:
648  MRI.setRegClass(Reg, Info.D.RC);
649  if (Info.PreferredReg != 0)
650  MRI.setSimpleHint(Reg, Info.PreferredReg);
651  break;
652  case VRegInfo::GENERIC:
653  break;
654  case VRegInfo::REGBANK:
655  MRI.setRegBank(Reg, *Info.D.RegBank);
656  break;
657  }
658  };
659 
660  for (const auto &P : PFS.VRegInfosNamed) {
661  const VRegInfo &Info = *P.second;
662  populateVRegInfo(Info, Twine(P.first()));
663  }
664 
665  for (auto P : PFS.VRegInfos) {
666  const VRegInfo &Info = *P.second;
667  populateVRegInfo(Info, Twine(P.first));
668  }
669 
670  // Compute MachineRegisterInfo::UsedPhysRegMask
671  for (const MachineBasicBlock &MBB : MF) {
672  // Make sure MRI knows about registers clobbered by unwinder.
673  const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
674  if (MBB.isEHPad())
675  if (auto *RegMask = TRI->getCustomEHPadPreservedMask(MF))
677 
678  for (const MachineInstr &MI : MBB) {
679  for (const MachineOperand &MO : MI.operands()) {
680  if (!MO.isRegMask())
681  continue;
682  MRI.addPhysRegsUsedFromRegMask(MO.getRegMask());
683  }
684  }
685  }
686 
687  return Error;
688 }
689 
691  const yaml::MachineFunction &YamlMF) {
692  MachineFunction &MF = PFS.MF;
693  MachineFrameInfo &MFI = MF.getFrameInfo();
695  const Function &F = MF.getFunction();
696  const yaml::MachineFrameInfo &YamlMFI = YamlMF.FrameInfo;
699  MFI.setHasStackMap(YamlMFI.HasStackMap);
700  MFI.setHasPatchPoint(YamlMFI.HasPatchPoint);
701  MFI.setStackSize(YamlMFI.StackSize);
703  if (YamlMFI.MaxAlignment)
704  MFI.ensureMaxAlignment(Align(YamlMFI.MaxAlignment));
705  MFI.setAdjustsStack(YamlMFI.AdjustsStack);
706  MFI.setHasCalls(YamlMFI.HasCalls);
707  if (YamlMFI.MaxCallFrameSize != ~0u)
711  MFI.setHasVAStart(YamlMFI.HasVAStart);
713  MFI.setHasTailCall(YamlMFI.HasTailCall);
714  MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
715  if (!YamlMFI.SavePoint.Value.empty()) {
716  MachineBasicBlock *MBB = nullptr;
717  if (parseMBBReference(PFS, MBB, YamlMFI.SavePoint))
718  return true;
719  MFI.setSavePoint(MBB);
720  }
721  if (!YamlMFI.RestorePoint.Value.empty()) {
722  MachineBasicBlock *MBB = nullptr;
723  if (parseMBBReference(PFS, MBB, YamlMFI.RestorePoint))
724  return true;
725  MFI.setRestorePoint(MBB);
726  }
727 
728  std::vector<CalleeSavedInfo> CSIInfo;
729  // Initialize the fixed frame objects.
730  for (const auto &Object : YamlMF.FixedStackObjects) {
731  int ObjectIdx;
733  ObjectIdx = MFI.CreateFixedObject(Object.Size, Object.Offset,
734  Object.IsImmutable, Object.IsAliased);
735  else
736  ObjectIdx = MFI.CreateFixedSpillStackObject(Object.Size, Object.Offset);
737 
738  if (!TFI->isSupportedStackID(Object.StackID))
739  return error(Object.ID.SourceRange.Start,
740  Twine("StackID is not supported by target"));
741  MFI.setStackID(ObjectIdx, Object.StackID);
742  MFI.setObjectAlignment(ObjectIdx, Object.Alignment.valueOrOne());
743  if (!PFS.FixedStackObjectSlots.insert(std::make_pair(Object.ID.Value,
744  ObjectIdx))
745  .second)
746  return error(Object.ID.SourceRange.Start,
747  Twine("redefinition of fixed stack object '%fixed-stack.") +
748  Twine(Object.ID.Value) + "'");
749  if (parseCalleeSavedRegister(PFS, CSIInfo, Object.CalleeSavedRegister,
750  Object.CalleeSavedRestored, ObjectIdx))
751  return true;
752  if (parseStackObjectsDebugInfo(PFS, Object, ObjectIdx))
753  return true;
754  }
755 
756  // Initialize the ordinary frame objects.
757  for (const auto &Object : YamlMF.StackObjects) {
758  int ObjectIdx;
759  const AllocaInst *Alloca = nullptr;
760  const yaml::StringValue &Name = Object.Name;
761  if (!Name.Value.empty()) {
762  Alloca = dyn_cast_or_null<AllocaInst>(
763  F.getValueSymbolTable()->lookup(Name.Value));
764  if (!Alloca)
765  return error(Name.SourceRange.Start,
766  "alloca instruction named '" + Name.Value +
767  "' isn't defined in the function '" + F.getName() +
768  "'");
769  }
770  if (!TFI->isSupportedStackID(Object.StackID))
771  return error(Object.ID.SourceRange.Start,
772  Twine("StackID is not supported by target"));
774  ObjectIdx =
775  MFI.CreateVariableSizedObject(Object.Alignment.valueOrOne(), Alloca);
776  else
777  ObjectIdx = MFI.CreateStackObject(
778  Object.Size, Object.Alignment.valueOrOne(),
780  Object.StackID);
781  MFI.setObjectOffset(ObjectIdx, Object.Offset);
782 
783  if (!PFS.StackObjectSlots.insert(std::make_pair(Object.ID.Value, ObjectIdx))
784  .second)
785  return error(Object.ID.SourceRange.Start,
786  Twine("redefinition of stack object '%stack.") +
787  Twine(Object.ID.Value) + "'");
788  if (parseCalleeSavedRegister(PFS, CSIInfo, Object.CalleeSavedRegister,
789  Object.CalleeSavedRestored, ObjectIdx))
790  return true;
791  if (Object.LocalOffset)
792  MFI.mapLocalFrameObject(ObjectIdx, Object.LocalOffset.getValue());
793  if (parseStackObjectsDebugInfo(PFS, Object, ObjectIdx))
794  return true;
795  }
796  MFI.setCalleeSavedInfo(CSIInfo);
797  if (!CSIInfo.empty())
798  MFI.setCalleeSavedInfoValid(true);
799 
800  // Initialize the various stack object references after initializing the
801  // stack objects.
802  if (!YamlMFI.StackProtector.Value.empty()) {
804  int FI;
805  if (parseStackObjectReference(PFS, FI, YamlMFI.StackProtector.Value, Error))
806  return error(Error, YamlMFI.StackProtector.SourceRange);
807  MFI.setStackProtectorIndex(FI);
808  }
809  return false;
810 }
811 
813  std::vector<CalleeSavedInfo> &CSIInfo,
814  const yaml::StringValue &RegisterSource, bool IsRestored, int FrameIdx) {
815  if (RegisterSource.Value.empty())
816  return false;
817  Register Reg;
819  if (parseNamedRegisterReference(PFS, Reg, RegisterSource.Value, Error))
820  return error(Error, RegisterSource.SourceRange);
821  CalleeSavedInfo CSI(Reg, FrameIdx);
822  CSI.setRestored(IsRestored);
823  CSIInfo.push_back(CSI);
824  return false;
825 }
826 
827 /// Verify that given node is of a certain type. Return true on error.
828 template <typename T>
829 static bool typecheckMDNode(T *&Result, MDNode *Node,
830  const yaml::StringValue &Source,
831  StringRef TypeString, MIRParserImpl &Parser) {
832  if (!Node)
833  return false;
834  Result = dyn_cast<T>(Node);
835  if (!Result)
836  return Parser.error(Source.SourceRange.Start,
837  "expected a reference to a '" + TypeString +
838  "' metadata node");
839  return false;
840 }
841 
842 template <typename T>
844  const T &Object, int FrameIdx) {
845  // Debug information can only be attached to stack objects; Fixed stack
846  // objects aren't supported.
847  MDNode *Var = nullptr, *Expr = nullptr, *Loc = nullptr;
848  if (parseMDNode(PFS, Var, Object.DebugVar) ||
849  parseMDNode(PFS, Expr, Object.DebugExpr) ||
850  parseMDNode(PFS, Loc, Object.DebugLoc))
851  return true;
852  if (!Var && !Expr && !Loc)
853  return false;
854  DILocalVariable *DIVar = nullptr;
855  DIExpression *DIExpr = nullptr;
856  DILocation *DILoc = nullptr;
857  if (typecheckMDNode(DIVar, Var, Object.DebugVar, "DILocalVariable", *this) ||
858  typecheckMDNode(DIExpr, Expr, Object.DebugExpr, "DIExpression", *this) ||
859  typecheckMDNode(DILoc, Loc, Object.DebugLoc, "DILocation", *this))
860  return true;
861  PFS.MF.setVariableDbgInfo(DIVar, DIExpr, FrameIdx, DILoc);
862  return false;
863 }
864 
865 bool MIRParserImpl::parseMDNode(PerFunctionMIParsingState &PFS,
866  MDNode *&Node, const yaml::StringValue &Source) {
867  if (Source.Value.empty())
868  return false;
870  if (llvm::parseMDNode(PFS, Node, Source.Value, Error))
871  return error(Error, Source.SourceRange);
872  return false;
873 }
874 
877  DenseMap<unsigned, unsigned> &ConstantPoolSlots = PFS.ConstantPoolSlots;
878  const MachineFunction &MF = PFS.MF;
879  const auto &M = *MF.getFunction().getParent();
881  for (const auto &YamlConstant : YamlMF.Constants) {
882  if (YamlConstant.IsTargetSpecific)
883  // FIXME: Support target-specific constant pools
884  return error(YamlConstant.Value.SourceRange.Start,
885  "Can't parse target-specific constant pool entries yet");
886  const Constant *Value = dyn_cast_or_null<Constant>(
887  parseConstantValue(YamlConstant.Value.Value, Error, M));
888  if (!Value)
889  return error(Error, YamlConstant.Value.SourceRange);
890  const Align PrefTypeAlign =
891  M.getDataLayout().getPrefTypeAlign(Value->getType());
892  const Align Alignment = YamlConstant.Alignment.getValueOr(PrefTypeAlign);
893  unsigned Index = ConstantPool.getConstantPoolIndex(Value, Alignment);
894  if (!ConstantPoolSlots.insert(std::make_pair(YamlConstant.ID.Value, Index))
895  .second)
896  return error(YamlConstant.ID.SourceRange.Start,
897  Twine("redefinition of constant pool item '%const.") +
898  Twine(YamlConstant.ID.Value) + "'");
899  }
900  return false;
901 }
902 
904  const yaml::MachineJumpTable &YamlJTI) {
906  for (const auto &Entry : YamlJTI.Entries) {
907  std::vector<MachineBasicBlock *> Blocks;
908  for (const auto &MBBSource : Entry.Blocks) {
909  MachineBasicBlock *MBB = nullptr;
910  if (parseMBBReference(PFS, MBB, MBBSource.Value))
911  return true;
912  Blocks.push_back(MBB);
913  }
914  unsigned Index = JTI->createJumpTableIndex(Blocks);
915  if (!PFS.JumpTableSlots.insert(std::make_pair(Entry.ID.Value, Index))
916  .second)
917  return error(Entry.ID.SourceRange.Start,
918  Twine("redefinition of jump table entry '%jump-table.") +
919  Twine(Entry.ID.Value) + "'");
920  }
921  return false;
922 }
923 
924 bool MIRParserImpl::parseMBBReference(PerFunctionMIParsingState &PFS,
926  const yaml::StringValue &Source) {
928  if (llvm::parseMBBReference(PFS, MBB, Source.Value, Error))
929  return error(Error, Source.SourceRange);
930  return false;
931 }
932 
933 bool MIRParserImpl::parseMachineMetadata(PerFunctionMIParsingState &PFS,
934  const yaml::StringValue &Source) {
936  if (llvm::parseMachineMetadata(PFS, Source.Value, Source.SourceRange, Error))
937  return error(Error, Source.SourceRange);
938  return false;
939 }
940 
943  const yaml::MachineFunction &YMF) {
944  for (auto &MDS : YMF.MachineMetadataNodes) {
945  if (parseMachineMetadata(PFS, MDS))
946  return true;
947  }
948  // Report missing definitions from forward referenced nodes.
949  if (!PFS.MachineForwardRefMDNodes.empty())
950  return error(PFS.MachineForwardRefMDNodes.begin()->second.second,
951  "use of undefined metadata '!" +
952  Twine(PFS.MachineForwardRefMDNodes.begin()->first) + "'");
953  return false;
954 }
955 
956 SMDiagnostic MIRParserImpl::diagFromMIStringDiag(const SMDiagnostic &Error,
957  SMRange SourceRange) {
958  assert(SourceRange.isValid() && "Invalid source range");
959  SMLoc Loc = SourceRange.Start;
960  bool HasQuote = Loc.getPointer() < SourceRange.End.getPointer() &&
961  *Loc.getPointer() == '\'';
962  // Translate the location of the error from the location in the MI string to
963  // the corresponding location in the MIR file.
964  Loc = Loc.getFromPointer(Loc.getPointer() + Error.getColumnNo() +
965  (HasQuote ? 1 : 0));
966 
967  // TODO: Translate any source ranges as well.
968  return SM.GetMessage(Loc, Error.getKind(), Error.getMessage(), None,
969  Error.getFixIts());
970 }
971 
972 SMDiagnostic MIRParserImpl::diagFromBlockStringDiag(const SMDiagnostic &Error,
973  SMRange SourceRange) {
974  assert(SourceRange.isValid());
975 
976  // Translate the location of the error from the location in the llvm IR string
977  // to the corresponding location in the MIR file.
978  auto LineAndColumn = SM.getLineAndColumn(SourceRange.Start);
979  unsigned Line = LineAndColumn.first + Error.getLineNo() - 1;
980  unsigned Column = Error.getColumnNo();
981  StringRef LineStr = Error.getLineContents();
982  SMLoc Loc = Error.getLoc();
983 
984  // Get the full line and adjust the column number by taking the indentation of
985  // LLVM IR into account.
986  for (line_iterator L(*SM.getMemoryBuffer(SM.getMainFileID()), false), E;
987  L != E; ++L) {
988  if (L.line_number() == Line) {
989  LineStr = *L;
990  Loc = SMLoc::getFromPointer(LineStr.data());
991  auto Indent = LineStr.find(Error.getLineContents());
992  if (Indent != StringRef::npos)
993  Column += Indent;
994  break;
995  }
996  }
997 
998  return SMDiagnostic(SM, Loc, Filename, Line, Column, Error.getKind(),
999  Error.getMessage(), LineStr, Error.getRanges(),
1000  Error.getFixIts());
1001 }
1002 
1003 MIRParser::MIRParser(std::unique_ptr<MIRParserImpl> Impl)
1004  : Impl(std::move(Impl)) {}
1005 
1007 
1008 std::unique_ptr<Module>
1010  return Impl->parseIRModule(DataLayoutCallback);
1011 }
1012 
1014  return Impl->parseMachineFunctions(M, MMI);
1015 }
1016 
1017 std::unique_ptr<MIRParser> llvm::createMIRParserFromFile(
1019  std::function<void(Function &)> ProcessIRFunction) {
1020  auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
1021  if (std::error_code EC = FileOrErr.getError()) {
1023  "Could not open input file: " + EC.message());
1024  return nullptr;
1025  }
1026  return createMIRParser(std::move(FileOrErr.get()), Context,
1027  ProcessIRFunction);
1028 }
1029 
1030 std::unique_ptr<MIRParser>
1031 llvm::createMIRParser(std::unique_ptr<MemoryBuffer> Contents,
1033  std::function<void(Function &)> ProcessIRFunction) {
1034  auto Filename = Contents->getBufferIdentifier();
1037  DS_Error,
1038  SMDiagnostic(
1039  Filename, SourceMgr::DK_Error,
1040  "Can't read MIR with a Context that discards named Values")));
1041  return nullptr;
1042  }
1043  return std::make_unique<MIRParser>(std::make_unique<MIRParserImpl>(
1044  std::move(Contents), Filename, Context, ProcessIRFunction));
1045 }
llvm::MIRParserImpl::reportDiagnostic
void reportDiagnostic(const SMDiagnostic &Diag)
Definition: MIRParser.cpp:212
llvm::MachineRegisterInfo::addLiveIn
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
Definition: MachineRegisterInfo.h:944
MemoryBuffer.h
llvm::yaml::MachineFunction::RegBankSelected
bool RegBankSelected
Definition: MIRYamlMapping.h:691
llvm::SMRange::Start
SMLoc Start
Definition: SMLoc.h:50
llvm::yaml::MachineFrameInfo::OffsetAdjustment
int OffsetAdjustment
Definition: MIRYamlMapping.h:603
llvm::CalleeSavedInfo::setRestored
void setRestored(bool R)
Definition: MachineFrameInfo.h:74
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:102
llvm::PerFunctionMIParsingState::SM
SourceMgr * SM
Definition: MIParser.h:165
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
TargetFrameLowering.h
llvm::MachineJumpTableInfo::createJumpTableIndex
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
Definition: MachineFunction.cpp:1270
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:43
handleYAMLDiag
static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context)
Definition: MIRParser.cpp:178
llvm::MIRParser::parseIRModule
std::unique_ptr< Module > parseIRModule(DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
Parses the optional LLVM IR module in the MIR file.
Definition: MIRParser.cpp:1009
llvm::MachineFrameInfo::setReturnAddressIsTaken
void setReturnAddressIsTaken(bool s)
Definition: MachineFrameInfo.h:373
llvm::line_iterator
A forward iterator which reads text lines from a buffer.
Definition: LineIterator.h:33
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
Parser.h
llvm::Function
Definition: Function.h:61
llvm::yaml::MachineFrameInfo::StackSize
uint64_t StackSize
Definition: MIRYamlMapping.h:602
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::SMRange::End
SMLoc End
Definition: SMLoc.h:50
llvm::yaml::MachineFunction::JumpTableInfo
MachineJumpTable JumpTableInfo
Definition: MIRYamlMapping.h:709
llvm::MachineFunction::assignBeginEndSections
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
Definition: MachineFunction.cpp:334
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::MachineFrameInfo::setCVBytesOfCalleeSavedRegisters
void setCVBytesOfCalleeSavedRegisters(unsigned S)
Definition: MachineFrameInfo.h:637
llvm::yaml::StringValue::SourceRange
SMRange SourceRange
Definition: MIRYamlMapping.h:36
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:60
llvm::MIRParserImpl::error
bool error(const Twine &Message)
Report an error with the given message at unknown location.
Definition: MIRParser.cpp:194
llvm::StringRef::find
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:315
llvm::yaml::MachineFrameInfo::RestorePoint
StringValue RestorePoint
Definition: MIRYamlMapping.h:617
llvm::PerTargetMIParsingState
Definition: MIParser.h:53
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::yaml::MachineFunction::StackObjects
std::vector< MachineStackObject > StackObjects
Definition: MIRYamlMapping.h:704
llvm::PerFunctionMIParsingState::StackObjectSlots
DenseMap< unsigned, int > StackObjectSlots
Definition: MIParser.h:176
MIRParser.h
llvm::yaml::MachineFunction::TracksRegLiveness
bool TracksRegLiveness
Definition: MIRYamlMapping.h:695
RegisterBankInfo.h
llvm::FunctionType::get
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Definition: Type.cpp:327
llvm::MachineFunction::getOrCreateJumpTableInfo
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist,...
Definition: MachineFunction.cpp:267
llvm::PerFunctionMIParsingState::FixedStackObjectSlots
DenseMap< unsigned, int > FixedStackObjectSlots
Definition: MIParser.h:175
llvm::ConstantPool
Definition: ConstantPools.h:43
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:231
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1562
DenseMap.h
Module.h
llvm::parseMachineInstructions
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
Definition: MIParser.cpp:3409
llvm::MachineFrameInfo::setStackSize
void setStackSize(uint64_t Size)
Set the size of the stack.
Definition: MachineFrameInfo.h:554
llvm::yaml::CallSiteInfo::MachineInstrLoc::Offset
unsigned Offset
Definition: MIRYamlMapping.h:446
llvm::MaybeAlign::valueOrOne
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
Definition: Alignment.h:134
llvm::yaml::MachineFunction::Alignment
MaybeAlign Alignment
Definition: MIRYamlMapping.h:687
llvm::TargetSubtargetInfo::mirFileLoaded
virtual void mirFileLoaded(MachineFunction &MF) const
This is called after a .mir file was loaded.
Definition: TargetSubtargetInfo.cpp:64
llvm::VRegInfo::REGBANK
@ REGBANK
Definition: MIParser.h:39
llvm::MIRParserImpl::parseCalleeSavedRegister
bool parseCalleeSavedRegister(PerFunctionMIParsingState &PFS, std::vector< CalleeSavedInfo > &CSIInfo, const yaml::StringValue &RegisterSource, bool IsRestored, int FrameIdx)
Definition: MIRParser.cpp:812
llvm::MachineFunctionProperties::Property::IsSSA
@ IsSSA
llvm::PerFunctionMIParsingState::VRegInfosNamed
StringMap< VRegInfo * > VRegInfosNamed
Definition: MIParser.h:174
llvm::MachineFunctionProperties
Properties which a MachineFunction may have at a given point in time.
Definition: MachineFunction.h:111
llvm::MachineFrameInfo::setMaxCallFrameSize
void setMaxCallFrameSize(unsigned S)
Definition: MachineFrameInfo.h:630
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::MachineRegisterInfo::getNumVirtRegs
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
Definition: MachineRegisterInfo.h:757
llvm::MIRParserImpl::parseStackObjectsDebugInfo
bool parseStackObjectsDebugInfo(PerFunctionMIParsingState &PFS, const T &Object, int FrameIdx)
Definition: MIRParser.cpp:843
llvm::yaml::FixedMachineStackObject::SpillSlot
@ SpillSlot
Definition: MIRYamlMapping.h:309
llvm::parseAssembly
std::unique_ptr< Module > parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context, SlotMapping *Slots=nullptr, DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
parseAssemblyFile and parseAssemblyString are wrappers around this function.
Definition: Parser.cpp:48
llvm::MachineFrameInfo::setAdjustsStack
void setAdjustsStack(bool V)
Definition: MachineFrameInfo.h:576
llvm::SourceMgr::DK_Note
@ DK_Note
Definition: SourceMgr.h:37
llvm::Register::index2VirtReg
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
Definition: Register.h:84
STLExtras.h
llvm::DIExpression
DWARF expression.
Definition: DebugInfoMetadata.h:2557
llvm::MachineFrameInfo::CreateVariableSizedObject
int CreateVariableSizedObject(Align Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created.
Definition: MachineFrameInfo.cpp:74
llvm::MIRParserImpl::initializeJumpTableInfo
bool initializeJumpTableInfo(PerFunctionMIParsingState &PFS, const yaml::MachineJumpTable &YamlJTI)
Definition: MIRParser.cpp:903
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
llvm::yaml::MachineFrameInfo::CVBytesOfCalleeSavedRegisters
unsigned CVBytesOfCalleeSavedRegisters
Definition: MIRYamlMapping.h:610
llvm::yaml::MachineFunction::Name
StringRef Name
Definition: MIRYamlMapping.h:686
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::MIRParserImpl::parseRegisterInfo
bool parseRegisterInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:552
llvm::yaml::MachineJumpTable
Definition: MIRYamlMapping.h:543
llvm::MachineFrameInfo::setObjectAlignment
void setObjectAlignment(int ObjectIdx, Align Alignment)
setObjectAlignment - Change the alignment of the specified stack object.
Definition: MachineFrameInfo.h:472
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::yaml::MachineStackObject::VariableSized
@ VariableSized
Definition: MIRYamlMapping.h:241
MachineRegisterInfo.h
llvm::parseMachineBasicBlockDefinitions
bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine basic block definitions, and skip the machine instructions.
Definition: MIParser.cpp:3403
llvm::SourceMgr::DK_Remark
@ DK_Remark
Definition: SourceMgr.h:36
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::MachineRegisterInfo::tracksLiveness
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
Definition: MachineRegisterInfo.h:197
llvm::MachineFunction::setExposesReturnsTwice
void setExposesReturnsTwice(bool B)
setCallsSetJmp - Set a flag that indicates if there's a call to a "returns twice" function.
Definition: MachineFunction.h:690
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::MachineFrameInfo::setHasStackMap
void setHasStackMap(bool s=true)
Definition: MachineFrameInfo.h:379
llvm::MachineBasicBlock::push_back
void push_back(MachineInstr *MI)
Definition: MachineBasicBlock.h:843
llvm::yaml::MachineFrameInfo::AdjustsStack
bool AdjustsStack
Definition: MIRYamlMapping.h:605
llvm::PerFunctionMIParsingState::JumpTableSlots
DenseMap< unsigned, unsigned > JumpTableSlots
Definition: MIParser.h:178
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:632
MIRYamlMapping.h
llvm::MemoryBuffer::getMemBuffer
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
Definition: MemoryBuffer.cpp:113
llvm::parseStackObjectReference
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3438
llvm::parseMDNode
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3444
llvm::MachineFunctionProperties::Property::Selected
@ Selected
TargetMachine.h
llvm::RegisterBank
This class implements the register bank concept.
Definition: RegisterBank.h:28
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::MIRParserImpl::initializeConstantPool
bool initializeConstantPool(PerFunctionMIParsingState &PFS, MachineConstantPool &ConstantPool, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:875
llvm::DILocalVariable
Local variable.
Definition: DebugInfoMetadata.h:3053
llvm::MachineFrameInfo::ensureMaxAlignment
void ensureMaxAlignment(Align Alignment)
Make sure the function is at least Align bytes aligned.
Definition: MachineFrameInfo.cpp:31
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::MachineFunction::setAlignment
void setAlignment(Align A)
setAlignment - Set the alignment of the function.
Definition: MachineFunction.h:673
llvm::DS_Warning
@ DS_Warning
Definition: DiagnosticInfo.h:46
llvm::MachineFrameInfo::setCalleeSavedInfoValid
void setCalleeSavedInfoValid(bool v)
Definition: MachineFrameInfo.h:768
llvm::yaml::MachineFunction::MachineFuncInfo
std::unique_ptr< MachineFunctionInfo > MachineFuncInfo
Constant pool.
Definition: MIRYamlMapping.h:706
llvm::MachineModuleInfo::getTarget
const LLVMTargetMachine & getTarget() const
Definition: MachineModuleInfo.h:165
llvm::SMDiagnostic
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:251
llvm::MachineFunction::getProperties
const MachineFunctionProperties & getProperties() const
Get the function properties.
Definition: MachineFunction.h:713
llvm::MachineFunction::size
unsigned size() const
Definition: MachineFunction.h:814
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::MachineFrameInfo::setHasOpaqueSPAdjustment
void setHasOpaqueSPAdjustment(bool B)
Definition: MachineFrameInfo.h:584
llvm::MachineFunctionProperties::set
MachineFunctionProperties & set(Property P)
Definition: MachineFunction.h:169
llvm::MachineRegisterInfo::setCalleeSavedRegs
void setCalleeSavedRegs(ArrayRef< MCPhysReg > CSRs)
Sets the updated Callee Saved Registers list.
Definition: MachineRegisterInfo.cpp:628
llvm::BasicBlockSection::Labels
@ Labels
llvm::MachineModuleInfo
This class contains meta information specific to a module.
Definition: MachineModuleInfo.h:78
llvm::DiagnosticSeverity
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
Definition: DiagnosticInfo.h:44
SMLoc.h
LineIterator.h
llvm::SourceMgr::getMainFileID
unsigned getMainFileID() const
Definition: SourceMgr.h:129
llvm::yaml::MachineFunction::CalleeSavedRegisters
Optional< std::vector< FlowStringValue > > CalleeSavedRegisters
Definition: MIRYamlMapping.h:699
llvm::yaml::MachineFrameInfo::HasVAStart
bool HasVAStart
Definition: MIRYamlMapping.h:612
llvm::MachineFunction::begin
iterator begin()
Definition: MachineFunction.h:804
llvm::MachineFunction::setHasWinCFI
void setHasWinCFI(bool v)
Definition: MachineFunction.h:707
llvm::MachineRegisterInfo::freezeReservedRegs
void freezeReservedRegs(const MachineFunction &)
freezeReservedRegs - Called by the register allocator to freeze the set of reserved registers before ...
Definition: MachineRegisterInfo.cpp:507
llvm::MIRParserImpl::MIRParserImpl
MIRParserImpl(std::unique_ptr< MemoryBuffer > Contents, StringRef Filename, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction)
Definition: MIRParser.cpp:182
llvm::yaml::MachineFunction::FrameInfo
MachineFrameInfo FrameInfo
Definition: MIRYamlMapping.h:702
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::yaml::MachineFrameInfo::HasCalls
bool HasCalls
Definition: MIRYamlMapping.h:606
StringMap.h
llvm::MachineFunction::verify
bool verify(Pass *p=nullptr, const char *Banner=nullptr, bool AbortOnError=true) const
Run the current MachineFunction through the machine code verifier, useful for debugger use.
Definition: MachineVerifier.cpp:321
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::None
const NoneType None
Definition: None.h:23
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
SourceMgr.h
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::StringRef::equals
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:187
llvm::MachineRegisterInfo::def_empty
bool def_empty(Register RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
Definition: MachineRegisterInfo.h:426
llvm::SourceMgr::getMemoryBuffer
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Definition: SourceMgr.h:122
llvm::Twine::str
std::string str() const
Return the twine contents as a std::string.
Definition: Twine.cpp:17
ValueSymbolTable.h
llvm::MachineFunctionProperties::Property::NoVRegs
@ NoVRegs
llvm::OutputFileType::Object
@ Object
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::yaml::MachineFrameInfo::StackProtector
StringValue StackProtector
Definition: MIRYamlMapping.h:607
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:622
llvm::tgtok::In
@ In
Definition: TGLexer.h:51
llvm::PerFunctionMIParsingState::VRegInfos
DenseMap< Register, VRegInfo * > VRegInfos
Definition: MIParser.h:173
BasicBlock.h
llvm::MachineFrameInfo::setCalleeSavedInfo
void setCalleeSavedInfo(std::vector< CalleeSavedInfo > CSI)
Used by prolog/epilog inserter to set the function's callee saved information.
Definition: MachineFrameInfo.h:761
llvm::MachineFrameInfo::setHasMustTailInVarArgFunc
void setHasMustTailInVarArgFunc(bool B)
Definition: MachineFrameInfo.h:601
llvm::SlotMapping
This struct contains the mappings from the slot numbers to unnamed metadata nodes,...
Definition: SlotMapping.h:32
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::MachineFrameInfo::CreateFixedSpillStackObject
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool IsImmutable=false)
Create a spill slot at a fixed location on the stack.
Definition: MachineFrameInfo.cpp:102
llvm::yaml::MachineFunction::Selected
bool Selected
Definition: MIRYamlMapping.h:692
llvm::parseMachineMetadata
bool parseMachineMetadata(PerFunctionMIParsingState &PFS, StringRef Src, SMRange SourceRange, SMDiagnostic &Error)
Definition: MIParser.cpp:3449
llvm::TargetFrameLowering::isSupportedStackID
virtual bool isSupportedStackID(TargetStackID::Value ID) const
Definition: TargetFrameLowering.h:418
llvm::MachineFunction::addCallArgsForwardingRegs
void addCallArgsForwardingRegs(const MachineInstr *CallI, CallSiteInfoImpl &&CallInfo)
Start tracking the arguments passed to the call CallI.
Definition: MachineFunction.h:1176
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::PerFunctionMIParsingState::getVRegInfo
VRegInfo & getVRegInfo(Register Num)
Definition: MIParser.cpp:324
llvm::yaml::MachineFrameInfo::LocalFrameSize
unsigned LocalFrameSize
Definition: MIRYamlMapping.h:615
llvm::MachineRegisterInfo::setRegBank
void setRegBank(Register Reg, const RegisterBank &RegBank)
Set the register bank to RegBank for Reg.
Definition: MachineRegisterInfo.cpp:63
llvm::LLVMContext::shouldDiscardValueNames
bool shouldDiscardValueNames() const
Return true if the Context runtime configuration is set to discard all value names.
Definition: LLVMContext.cpp:316
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:572
llvm::VRegInfo::NORMAL
@ NORMAL
Definition: MIParser.h:39
llvm::SourceMgr::DK_Warning
@ DK_Warning
Definition: SourceMgr.h:35
llvm::PerFunctionMIParsingState::MachineForwardRefMDNodes
std::map< unsigned, std::pair< TempMDTuple, SMLoc > > MachineForwardRefMDNodes
Definition: MIParser.h:170
llvm::createMIRParser
std::unique_ptr< MIRParser > createMIRParser(std::unique_ptr< MemoryBuffer > Contents, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction=nullptr)
This function is another interface to the MIR serialization format parser.
Definition: MIRParser.cpp:1031
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::MIRParser::~MIRParser
~MIRParser()
Definition: MIRParser.cpp:1006
llvm::DenseMap< unsigned, unsigned >
llvm::MachineConstantPool
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
Definition: MachineConstantPool.h:117
DebugInfo.h
llvm::MemoryBuffer::getFileOrSTDIN
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
Definition: MemoryBuffer.cpp:144
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::MachineFrameInfo::setObjectOffset
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
Definition: MachineFrameInfo.h:526
MachineConstantPool.h
llvm::MachineFunctionProperties::Property::RegBankSelected
@ RegBankSelected
llvm::MachineFrameInfo::setRestorePoint
void setRestorePoint(MachineBasicBlock *NewRestore)
Definition: MachineFrameInfo.h:773
llvm::MachineFrameInfo::mapLocalFrameObject
void mapLocalFrameObject(int ObjectIndex, int64_t Offset)
Map a frame index into the local object block.
Definition: MachineFrameInfo.h:400
llvm::yaml::MachineFunction
Definition: MIRYamlMapping.h:685
llvm::MachineRegisterInfo::setSimpleHint
void setSimpleHint(Register VReg, Register PrefReg)
Specify the preferred (target independent) register allocation hint for the specified virtual registe...
Definition: MachineRegisterInfo.h:781
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition: MachineFunction.cpp:541
llvm::yaml::MachineFunction::FixedStackObjects
std::vector< FixedMachineStackObject > FixedStackObjects
Definition: MIRYamlMapping.h:703
llvm::createMIRParserFromFile
std::unique_ptr< MIRParser > createMIRParserFromFile(StringRef Filename, SMDiagnostic &Error, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction=nullptr)
This function is the main interface to the MIR serialization format parser.
Definition: MIRParser.cpp:1017
llvm::MachineFrameInfo::setHasTailCall
void setHasTailCall(bool V=true)
Definition: MachineFrameInfo.h:605
llvm::MachineRegisterInfo::getOneDef
MachineOperand * getOneDef(Register Reg) const
Returns the defining operand if there is exactly one operand defining the specified register,...
Definition: MachineRegisterInfo.h:450
llvm::Function::Create
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:137
llvm::MachineFunction::getConstantPool
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
Definition: MachineFunction.h:654
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MachineFrameInfo::CreateFixedObject
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
Definition: MachineFrameInfo.cpp:83
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1605
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:638
typecheckMDNode
static bool typecheckMDNode(T *&Result, MDNode *Node, const yaml::StringValue &Source, StringRef TypeString, MIRParserImpl &Parser)
Verify that given node is of a certain type. Return true on error.
Definition: MIRParser.cpp:829
llvm::MIRParserImpl::initializeMachineFunction
bool initializeMachineFunction(const yaml::MachineFunction &YamlMF, MachineFunction &MF)
Initialize the machine function to the state that's described in the MIR file.
Definition: MIRParser.cpp:434
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::MIRParserImpl::initializeFrameInfo
bool initializeFrameInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:690
MachineModuleInfo.h
llvm::MIRParserImpl::parseMachineMetadataNodes
bool parseMachineMetadataNodes(PerFunctionMIParsingState &PFS, MachineFunction &MF, const yaml::MachineFunction &YMF)
Definition: MIRParser.cpp:941
llvm::MachineRegisterInfo::hasOneDef
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
Definition: MachineRegisterInfo.h:444
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:897
llvm::yaml::StringValue
A wrapper around std::string which contains a source range that's being set during parsing.
Definition: MIRYamlMapping.h:34
llvm::MachineFrameInfo::setSavePoint
void setSavePoint(MachineBasicBlock *NewSave)
Definition: MachineFrameInfo.h:771
llvm::yaml::MachineStackObject::SpillSlot
@ SpillSlot
Definition: MIRYamlMapping.h:241
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::yaml::MachineFrameInfo::HasOpaqueSPAdjustment
bool HasOpaqueSPAdjustment
Definition: MIRYamlMapping.h:611
YAMLTraits.h
llvm::yaml::MachineJumpTable::Entries
std::vector< Entry > Entries
Definition: MIRYamlMapping.h:554
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:99
llvm::yaml::MachineFrameInfo::MaxCallFrameSize
unsigned MaxCallFrameSize
~0u means: not computed yet.
Definition: MIRYamlMapping.h:609
llvm::yaml::MachineFunction::Legalized
bool Legalized
Definition: MIRYamlMapping.h:690
llvm::MachineFrameInfo::setStackID
void setStackID(int ObjectIdx, uint8_t ID)
Definition: MachineFrameInfo.h:702
llvm::MachineFrameInfo::setHasCalls
void setHasCalls(bool V)
Definition: MachineFrameInfo.h:580
llvm::MachineFrameInfo::CreateStackObject
int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
Definition: MachineFrameInfo.cpp:51
llvm::MachineBasicBlock::isEHPad
bool isEHPad() const
Returns true if the block is a landing pad.
Definition: MachineBasicBlock.h:526
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::yaml::MachineJumpTable::Kind
MachineJumpTableInfo::JTEntryKind Kind
Definition: MIRYamlMapping.h:553
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
llvm::yaml::MachineFunction::FailedISel
bool FailedISel
Definition: MIRYamlMapping.h:693
llvm::SourceMgr
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:31
llvm::BasicBlock::Create
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:100
llvm::MachineRegisterInfo::invalidateLiveness
void invalidateLiveness()
invalidateLiveness - Indicates that register liveness is no longer being tracked accurately.
Definition: MachineRegisterInfo.h:207
llvm::MIRParser::MIRParser
MIRParser(std::unique_ptr< MIRParserImpl > Impl)
Definition: MIRParser.cpp:1003
llvm::MachineModuleInfo::getOrCreateMachineFunction
MachineFunction & getOrCreateMachineFunction(Function &F)
Returns the MachineFunction constructed for the IR function F.
Definition: MachineModuleInfo.cpp:291
llvm::SMRange::isValid
bool isValid() const
Definition: SMLoc.h:59
llvm::MachineFunction::hasBBSections
bool hasBBSections() const
Returns true if this function has basic block sections enabled.
Definition: MachineFunction.h:600
llvm::yaml::MachineFrameInfo::HasStackMap
bool HasStackMap
Definition: MIRYamlMapping.h:600
llvm::MachineFunctionProperties::reset
MachineFunctionProperties & reset(Property P)
Definition: MachineFunction.h:174
llvm::DenseMapBase::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:207
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::SMDiagnostic::getKind
SourceMgr::DiagKind getKind() const
Definition: SourceMgr.h:280
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MachineOperand::getSubReg
unsigned getSubReg() const
Definition: MachineOperand.h:365
llvm::yaml::MachineFrameInfo
Serializable representation of MachineFrameInfo.
Definition: MIRYamlMapping.h:597
llvm::yaml::MachineFrameInfo::IsFrameAddressTaken
bool IsFrameAddressTaken
Definition: MIRYamlMapping.h:598
llvm::yaml::MachineFunction::DebugValueSubstitutions
std::vector< DebugValueSubstitution > DebugValueSubstitutions
Definition: MIRYamlMapping.h:708
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::PerFunctionMIParsingState
Definition: MIParser.h:162
llvm::yaml::MachineFunction::VirtualRegisters
std::vector< VirtualRegisterDefinition > VirtualRegisters
Definition: MIRYamlMapping.h:697
llvm::yaml::MachineFunction::ExposesReturnsTwice
bool ExposesReturnsTwice
Definition: MIRYamlMapping.h:688
llvm::MachineFunctionProperties::Property::FailedISel
@ FailedISel
llvm::parseNamedRegisterReference
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3426
llvm::LLVMContext::diagnose
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Definition: LLVMContext.cpp:228
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::MIRParserImpl::initializeCallSiteInfo
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:375
llvm::yaml::MachineFrameInfo::IsReturnAddressTaken
bool IsReturnAddressTaken
Definition: MIRYamlMapping.h:599
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:588
llvm::TargetSubtargetInfo::getFrameLowering
virtual const TargetFrameLowering * getFrameLowering() const
Definition: TargetSubtargetInfo.h:93
llvm::MachineFunctionProperties::Property::NoPHIs
@ NoPHIs
llvm::CalleeSavedInfo
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
Definition: MachineFrameInfo.h:34
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:618
llvm::MIRParserImpl
This class implements the parsing of LLVM IR that's embedded inside a MIR file.
Definition: MIRParser.cpp:52
llvm::MachineModuleInfo::getMachineFunction
MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr.
Definition: MachineModuleInfo.cpp:286
llvm::SMLoc::getPointer
const char * getPointer() const
Definition: SMLoc.h:34
MachineFrameInfo.h
llvm::yaml::StringValue::Value
std::string Value
Definition: MIRYamlMapping.h:35
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::TargetRegisterInfo::getCustomEHPadPreservedMask
virtual const uint32_t * getCustomEHPadPreservedMask(const MachineFunction &MF) const
Return a register mask for the registers preserved by the unwinder, or nullptr if no custom mask is n...
Definition: TargetRegisterInfo.h:494
DiagnosticInfo.h
llvm::PerFunctionMIParsingState::ConstantPoolSlots
DenseMap< unsigned, unsigned > ConstantPoolSlots
Definition: MIParser.h:177
llvm::MachineRegisterInfo::addPhysRegsUsedFromRegMask
void addPhysRegsUsedFromRegMask(const uint32_t *RegMask)
addPhysRegsUsedFromRegMask - Mark any registers not in RegMask as used.
Definition: MachineRegisterInfo.h:866
llvm::MIRParserImpl::parseIRModule
std::unique_ptr< Module > parseIRModule(DataLayoutCallbackTy DataLayoutCallback)
Try to parse the optional LLVM module and the machine functions in the MIR file.
Definition: MIRParser.cpp:232
llvm::SourceMgr::DK_Error
@ DK_Error
Definition: SourceMgr.h:34
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:385
llvm::SourceMgr::AddNewSourceBuffer
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
Definition: SourceMgr.h:141
llvm::MIRParserImpl::createDummyFunction
Function * createDummyFunction(StringRef Name, Module &M)
Create an empty function with the given name.
Definition: MIRParser.cpp:283
SlotMapping.h
llvm::PerFunctionMIParsingState::MF
MachineFunction & MF
Definition: MIParser.h:164
llvm::MachineFrameInfo::setStackProtectorIndex
void setStackProtectorIndex(int I)
Definition: MachineFrameInfo.h:355
llvm::MIRParserImpl::parseMachineFunctions
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI)
Definition: MIRParser.cpp:269
llvm::SourceMgr::GetMessage
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges={}, ArrayRef< SMFixIt > FixIts={}) const
Return an SMDiagnostic at the specified location with the specified string.
Definition: SourceMgr.cpp:262
llvm::parseVirtualRegisterReference
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3432
llvm::VRegInfo
Definition: MIParser.h:37
llvm::yaml::MachineFunction::LiveIns
std::vector< MachineFunctionLiveIn > LiveIns
Definition: MIRYamlMapping.h:698
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
llvm::yaml::MachineFrameInfo::SavePoint
StringValue SavePoint
Definition: MIRYamlMapping.h:616
llvm::parseConstantValue
Constant * parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M, const SlotMapping *Slots=nullptr)
Parse a type and a constant value in the given string.
Definition: Parser.cpp:182
llvm::MachineInstr::IgnoreBundle
@ IgnoreBundle
Definition: MachineInstr.h:766
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:186
llvm::yaml::MachineFunction::HasWinCFI
bool HasWinCFI
Definition: MIRYamlMapping.h:696
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:107
llvm::yaml::CallSiteInfo::MachineInstrLoc::BlockNum
unsigned BlockNum
Definition: MIRYamlMapping.h:445
Instructions.h
llvm::yaml::MachineFrameInfo::HasTailCall
bool HasTailCall
Definition: MIRYamlMapping.h:614
llvm::yaml::MachineFunction::Body
BlockStringValue Body
Definition: MIRYamlMapping.h:711
llvm::yaml::MachineFrameInfo::MaxAlignment
unsigned MaxAlignment
Definition: MIRYamlMapping.h:604
llvm::yaml::MachineFrameInfo::HasMustTailInVarArgFunc
bool HasMustTailInVarArgFunc
Definition: MIRYamlMapping.h:613
llvm::VRegInfo::UNKNOWN
@ UNKNOWN
Definition: MIParser.h:39
RegisterBank.h
llvm::SMRange
Represents a range in source code.
Definition: SMLoc.h:48
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::MachineFrameInfo::setHasPatchPoint
void setHasPatchPoint(bool s=true)
Definition: MachineFrameInfo.h:385
llvm::yaml::MachineFunction::MachineMetadataNodes
std::vector< StringValue > MachineMetadataNodes
Definition: MIRYamlMapping.h:710
llvm::StringRef::data
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:149
llvm::SMLoc::getFromPointer
static SMLoc getFromPointer(const char *Ptr)
Definition: SMLoc.h:36
llvm::MachineFrameInfo::setOffsetAdjustment
void setOffsetAdjustment(int Adj)
Set the correction for frame offsets.
Definition: MachineFrameInfo.h:563
llvm::parseRegisterReference
bool parseRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3420
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::yaml::MachineFrameInfo::HasPatchPoint
bool HasPatchPoint
Definition: MIRYamlMapping.h:601
llvm::yaml::CallSiteInfo::MachineInstrLoc
Identifies call instruction location in machine function.
Definition: MIRYamlMapping.h:444
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::SourceMgr::getLineAndColumn
std::pair< unsigned, unsigned > getLineAndColumn(SMLoc Loc, unsigned BufferID=0) const
Find the line and column number for the specified location in the specified file.
Definition: SourceMgr.cpp:180
llvm::UnreachableInst
This function has undefined behavior.
Definition: Instructions.h:4709
LLVMContext.h
llvm::MachineFrameInfo::setFrameAddressIsTaken
void setFrameAddressIsTaken(bool T)
Definition: MachineFrameInfo.h:367
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:62
llvm::MIRParserImpl::parseMachineFunction
bool parseMachineFunction(Module &M, MachineModuleInfo &MMI)
Parse the machine function in the current YAML document.
Definition: MIRParser.cpp:297
llvm::MachineJumpTableInfo
Definition: MachineJumpTableInfo.h:42
llvm::yaml::MachineFunction::CallSitesInfo
std::vector< CallSiteInfo > CallSitesInfo
Definition: MIRYamlMapping.h:707
MachineFunction.h
llvm::parseMBBReference
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3414
llvm::VRegInfo::GENERIC
@ GENERIC
Definition: MIParser.h:39
llvm::MachineFunction::setBBSectionsType
void setBBSectionsType(BasicBlockSection V)
Definition: MachineFunction.h:611
llvm::MachineFrameInfo::setLocalFrameSize
void setLocalFrameSize(int64_t sz)
Set the size of the local object blob.
Definition: MachineFrameInfo.h:416
llvm::DiagnosticInfoMIRParser
Diagnostic information for machine IR parser.
Definition: DiagnosticInfo.h:931
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::MachineFrameInfo::setHasVAStart
void setHasVAStart(bool B)
Definition: MachineFrameInfo.h:597
llvm::MIRParser::parseMachineFunctions
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI)
Parses MachineFunctions in the MIR file and add them to the given MachineModuleInfo MMI.
Definition: MIRParser.cpp:1013
llvm::DS_Error
@ DS_Error
Definition: DiagnosticInfo.h:45
isSSA
static bool isSSA(const MachineFunction &MF)
Definition: MIRParser.cpp:333
llvm::MachineFunction::setVariableDbgInfo
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable.
Definition: MachineFunction.h:1165
llvm::yaml::BlockStringValue::Value
StringValue Value
Definition: MIRYamlMapping.h:81
llvm::MachineRegisterInfo::setRegClass
void setRegClass(Register Reg, const TargetRegisterClass *RC)
setRegClass - Set the register class of the specified virtual register.
Definition: MachineRegisterInfo.cpp:58
llvm::yaml::MachineFunction::Constants
std::vector< MachineConstantPoolValue > Constants
Definition: MIRYamlMapping.h:705
llvm::TargetMachine::getBBSectionsType
llvm::BasicBlockSection getBBSectionsType() const
If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.
Definition: TargetMachine.h:292
llvm::MIRParserImpl::setupRegisterInfo
bool setupRegisterInfo(const PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:633
MIParser.h
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:908
llvm::MachineFunctionProperties::Property::Legalized
@ Legalized
llvm::DS_Note
@ DS_Note
Definition: DiagnosticInfo.h:50