LLVM  13.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 
146 private:
147  bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node,
148  const yaml::StringValue &Source);
149 
150  bool parseMBBReference(PerFunctionMIParsingState &PFS,
152  const yaml::StringValue &Source);
153 
154  /// Return a MIR diagnostic converted from an MI string diagnostic.
155  SMDiagnostic diagFromMIStringDiag(const SMDiagnostic &Error,
156  SMRange SourceRange);
157 
158  /// Return a MIR diagnostic converted from a diagnostic located in a YAML
159  /// block scalar string.
160  SMDiagnostic diagFromBlockStringDiag(const SMDiagnostic &Error,
161  SMRange SourceRange);
162 
163  void computeFunctionProperties(MachineFunction &MF);
164 
165  void setupDebugValueTracking(MachineFunction &MF,
167 };
168 
169 } // end namespace llvm
170 
171 static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context) {
172  reinterpret_cast<MIRParserImpl *>(Context)->reportDiagnostic(Diag);
173 }
174 
175 MIRParserImpl::MIRParserImpl(std::unique_ptr<MemoryBuffer> Contents,
176  StringRef Filename, LLVMContext &Context,
177  std::function<void(Function &)> Callback)
178  : SM(),
179  Context(Context),
180  In(SM.getMemoryBuffer(SM.AddNewSourceBuffer(std::move(Contents), SMLoc()))
181  ->getBuffer(),
182  nullptr, handleYAMLDiag, this),
183  Filename(Filename), ProcessIRFunction(Callback) {
184  In.setContext(&In);
185 }
186 
187 bool MIRParserImpl::error(const Twine &Message) {
189  DS_Error, SMDiagnostic(Filename, SourceMgr::DK_Error, Message.str())));
190  return true;
191 }
192 
193 bool MIRParserImpl::error(SMLoc Loc, const Twine &Message) {
195  DS_Error, SM.GetMessage(Loc, SourceMgr::DK_Error, Message)));
196  return true;
197 }
198 
199 bool MIRParserImpl::error(const SMDiagnostic &Error, SMRange SourceRange) {
200  assert(Error.getKind() == SourceMgr::DK_Error && "Expected an error");
201  reportDiagnostic(diagFromMIStringDiag(Error, SourceRange));
202  return true;
203 }
204 
207  switch (Diag.getKind()) {
208  case SourceMgr::DK_Error:
209  Kind = DS_Error;
210  break;
212  Kind = DS_Warning;
213  break;
214  case SourceMgr::DK_Note:
215  Kind = DS_Note;
216  break;
218  llvm_unreachable("remark unexpected");
219  break;
220  }
222 }
223 
224 std::unique_ptr<Module>
226  if (!In.setCurrentDocument()) {
227  if (In.error())
228  return nullptr;
229  // Create an empty module when the MIR file is empty.
230  NoMIRDocuments = true;
231  auto M = std::make_unique<Module>(Filename, Context);
232  if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple()))
233  M->setDataLayout(*LayoutOverride);
234  return M;
235  }
236 
237  std::unique_ptr<Module> M;
238  // Parse the block scalar manually so that we can return unique pointer
239  // without having to go trough YAML traits.
240  if (const auto *BSN =
241  dyn_cast_or_null<yaml::BlockScalarNode>(In.getCurrentNode())) {
243  M = parseAssembly(MemoryBufferRef(BSN->getValue(), Filename), Error,
244  Context, &IRSlots, DataLayoutCallback);
245  if (!M) {
246  reportDiagnostic(diagFromBlockStringDiag(Error, BSN->getSourceRange()));
247  return nullptr;
248  }
249  In.nextDocument();
250  if (!In.setCurrentDocument())
251  NoMIRDocuments = true;
252  } else {
253  // Create an new, empty module.
254  M = std::make_unique<Module>(Filename, Context);
255  if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple()))
256  M->setDataLayout(*LayoutOverride);
257  NoLLVMIR = true;
258  }
259  return M;
260 }
261 
263  if (NoMIRDocuments)
264  return false;
265 
266  // Parse the machine functions.
267  do {
268  if (parseMachineFunction(M, MMI))
269  return true;
270  In.nextDocument();
271  } while (In.setCurrentDocument());
272 
273  return false;
274 }
275 
277  auto &Context = M.getContext();
278  Function *F =
281  BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
282  new UnreachableInst(Context, BB);
283 
284  if (ProcessIRFunction)
285  ProcessIRFunction(*F);
286 
287  return F;
288 }
289 
291  // Parse the yaml.
292  yaml::MachineFunction YamlMF;
293  yaml::EmptyContext Ctx;
294 
295  const LLVMTargetMachine &TM = MMI.getTarget();
296  YamlMF.MachineFuncInfo = std::unique_ptr<yaml::MachineFunctionInfo>(
297  TM.createDefaultFuncInfoYAML());
298 
299  yaml::yamlize(In, YamlMF, false, Ctx);
300  if (In.error())
301  return true;
302 
303  // Search for the corresponding IR function.
304  StringRef FunctionName = YamlMF.Name;
305  Function *F = M.getFunction(FunctionName);
306  if (!F) {
307  if (NoLLVMIR) {
308  F = createDummyFunction(FunctionName, M);
309  } else {
310  return error(Twine("function '") + FunctionName +
311  "' isn't defined in the provided LLVM IR");
312  }
313  }
314  if (MMI.getMachineFunction(*F) != nullptr)
315  return error(Twine("redefinition of machine function '") + FunctionName +
316  "'");
317 
318  // Create the MachineFunction.
320  if (initializeMachineFunction(YamlMF, MF))
321  return true;
322 
323  return false;
324 }
325 
326 static bool isSSA(const MachineFunction &MF) {
327  const MachineRegisterInfo &MRI = MF.getRegInfo();
328  for (unsigned I = 0, E = MRI.getNumVirtRegs(); I != E; ++I) {
330  if (!MRI.hasOneDef(Reg) && !MRI.def_empty(Reg))
331  return false;
332 
333  // Subregister defs are invalid in SSA.
334  const MachineOperand *RegDef = MRI.getOneDef(Reg);
335  if (RegDef && RegDef->getSubReg() != 0)
336  return false;
337  }
338  return true;
339 }
340 
341 void MIRParserImpl::computeFunctionProperties(MachineFunction &MF) {
342  MachineFunctionProperties &Properties = MF.getProperties();
343 
344  bool HasPHI = false;
345  bool HasInlineAsm = false;
346  for (const MachineBasicBlock &MBB : MF) {
347  for (const MachineInstr &MI : MBB) {
348  if (MI.isPHI())
349  HasPHI = true;
350  if (MI.isInlineAsm())
351  HasInlineAsm = true;
352  }
353  }
354  if (!HasPHI)
356  MF.setHasInlineAsm(HasInlineAsm);
357 
358  if (isSSA(MF))
360  else
362 
363  const MachineRegisterInfo &MRI = MF.getRegInfo();
364  if (MRI.getNumVirtRegs() == 0)
366 }
367 
369  PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF) {
370  MachineFunction &MF = PFS.MF;
372  const LLVMTargetMachine &TM = MF.getTarget();
373  for (auto YamlCSInfo : YamlMF.CallSitesInfo) {
374  yaml::CallSiteInfo::MachineInstrLoc MILoc = YamlCSInfo.CallLocation;
375  if (MILoc.BlockNum >= MF.size())
376  return error(Twine(MF.getName()) +
377  Twine(" call instruction block out of range.") +
378  " Unable to reference bb:" + Twine(MILoc.BlockNum));
379  auto CallB = std::next(MF.begin(), MILoc.BlockNum);
380  if (MILoc.Offset >= CallB->size())
381  return error(Twine(MF.getName()) +
382  Twine(" call instruction offset out of range.") +
383  " Unable to reference instruction at bb: " +
384  Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset));
385  auto CallI = std::next(CallB->instr_begin(), MILoc.Offset);
386  if (!CallI->isCall(MachineInstr::IgnoreBundle))
387  return error(Twine(MF.getName()) +
388  Twine(" call site info should reference call "
389  "instruction. Instruction at bb:") +
390  Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset) +
391  " is not a call instruction");
393  for (auto ArgRegPair : YamlCSInfo.ArgForwardingRegs) {
394  Register Reg;
395  if (parseNamedRegisterReference(PFS, Reg, ArgRegPair.Reg.Value, Error))
396  return error(Error, ArgRegPair.Reg.SourceRange);
397  CSInfo.emplace_back(Reg, ArgRegPair.ArgNo);
398  }
399 
400  if (TM.Options.EmitCallSiteInfo)
401  MF.addCallArgsForwardingRegs(&*CallI, std::move(CSInfo));
402  }
403 
404  if (YamlMF.CallSitesInfo.size() && !TM.Options.EmitCallSiteInfo)
405  return error(Twine("Call site info provided but not used"));
406  return false;
407 }
408 
409 void MIRParserImpl::setupDebugValueTracking(
411  const yaml::MachineFunction &YamlMF) {
412  // Compute the value of the "next instruction number" field.
413  unsigned MaxInstrNum = 0;
414  for (auto &MBB : MF)
415  for (auto &MI : MBB)
416  MaxInstrNum = std::max((unsigned)MI.peekDebugInstrNum(), MaxInstrNum);
417  MF.setDebugInstrNumberingCount(MaxInstrNum);
418 
419  // Load any substitutions.
420  for (auto &Sub : YamlMF.DebugValueSubstitutions) {
421  MF.makeDebugValueSubstitution(std::make_pair(Sub.SrcInst, Sub.SrcOp),
422  std::make_pair(Sub.DstInst, Sub.DstOp));
423  }
424 }
425 
426 bool
428  MachineFunction &MF) {
429  // TODO: Recreate the machine function.
430  if (Target) {
431  // Avoid clearing state if we're using the same subtarget again.
432  Target->setTarget(MF.getSubtarget());
433  } else {
435  }
436 
437  MF.setAlignment(YamlMF.Alignment.valueOrOne());
439  MF.setHasWinCFI(YamlMF.HasWinCFI);
440 
441  if (YamlMF.Legalized)
443  if (YamlMF.RegBankSelected)
444  MF.getProperties().set(
446  if (YamlMF.Selected)
448  if (YamlMF.FailedISel)
450 
451  PerFunctionMIParsingState PFS(MF, SM, IRSlots, *Target);
452  if (parseRegisterInfo(PFS, YamlMF))
453  return true;
454  if (!YamlMF.Constants.empty()) {
455  auto *ConstantPool = MF.getConstantPool();
456  assert(ConstantPool && "Constant pool must be created");
457  if (initializeConstantPool(PFS, *ConstantPool, YamlMF))
458  return true;
459  }
460 
461  StringRef BlockStr = YamlMF.Body.Value.Value;
463  SourceMgr BlockSM;
464  BlockSM.AddNewSourceBuffer(
465  MemoryBuffer::getMemBuffer(BlockStr, "",/*RequiresNullTerminator=*/false),
466  SMLoc());
467  PFS.SM = &BlockSM;
468  if (parseMachineBasicBlockDefinitions(PFS, BlockStr, Error)) {
470  diagFromBlockStringDiag(Error, YamlMF.Body.Value.SourceRange));
471  return true;
472  }
473  // Check Basic Block Section Flags.
476  } else if (MF.hasBBSections()) {
478  }
479  PFS.SM = &SM;
480 
481  // Initialize the frame information after creating all the MBBs so that the
482  // MBB references in the frame information can be resolved.
483  if (initializeFrameInfo(PFS, YamlMF))
484  return true;
485  // Initialize the jump table after creating all the MBBs so that the MBB
486  // references can be resolved.
487  if (!YamlMF.JumpTableInfo.Entries.empty() &&
489  return true;
490  // Parse the machine instructions after creating all of the MBBs so that the
491  // parser can resolve the MBB references.
492  StringRef InsnStr = YamlMF.Body.Value.Value;
493  SourceMgr InsnSM;
494  InsnSM.AddNewSourceBuffer(
495  MemoryBuffer::getMemBuffer(InsnStr, "", /*RequiresNullTerminator=*/false),
496  SMLoc());
497  PFS.SM = &InsnSM;
498  if (parseMachineInstructions(PFS, InsnStr, Error)) {
500  diagFromBlockStringDiag(Error, YamlMF.Body.Value.SourceRange));
501  return true;
502  }
503  PFS.SM = &SM;
504 
505  if (setupRegisterInfo(PFS, YamlMF))
506  return true;
507 
508  if (YamlMF.MachineFuncInfo) {
509  const LLVMTargetMachine &TM = MF.getTarget();
510  // Note this is called after the initial constructor of the
511  // MachineFunctionInfo based on the MachineFunction, which may depend on the
512  // IR.
513 
514  SMRange SrcRange;
515  if (TM.parseMachineFunctionInfo(*YamlMF.MachineFuncInfo, PFS, Error,
516  SrcRange)) {
517  return error(Error, SrcRange);
518  }
519  }
520 
521  // Set the reserved registers after parsing MachineFuncInfo. The target may
522  // have been recording information used to select the reserved registers
523  // there.
524  // FIXME: This is a temporary workaround until the reserved registers can be
525  // serialized.
528 
529  computeFunctionProperties(MF);
530 
531  if (initializeCallSiteInfo(PFS, YamlMF))
532  return false;
533 
534  setupDebugValueTracking(MF, PFS, YamlMF);
535 
536  MF.getSubtarget().mirFileLoaded(MF);
537 
538  MF.verify();
539  return false;
540 }
541 
543  const yaml::MachineFunction &YamlMF) {
544  MachineFunction &MF = PFS.MF;
545  MachineRegisterInfo &RegInfo = MF.getRegInfo();
546  assert(RegInfo.tracksLiveness());
547  if (!YamlMF.TracksRegLiveness)
548  RegInfo.invalidateLiveness();
549 
551  // Parse the virtual register information.
552  for (const auto &VReg : YamlMF.VirtualRegisters) {
553  VRegInfo &Info = PFS.getVRegInfo(VReg.ID.Value);
554  if (Info.Explicit)
555  return error(VReg.ID.SourceRange.Start,
556  Twine("redefinition of virtual register '%") +
557  Twine(VReg.ID.Value) + "'");
558  Info.Explicit = true;
559 
560  if (StringRef(VReg.Class.Value).equals("_")) {
561  Info.Kind = VRegInfo::GENERIC;
562  Info.D.RegBank = nullptr;
563  } else {
564  const auto *RC = Target->getRegClass(VReg.Class.Value);
565  if (RC) {
566  Info.Kind = VRegInfo::NORMAL;
567  Info.D.RC = RC;
568  } else {
569  const RegisterBank *RegBank = Target->getRegBank(VReg.Class.Value);
570  if (!RegBank)
571  return error(
572  VReg.Class.SourceRange.Start,
573  Twine("use of undefined register class or register bank '") +
574  VReg.Class.Value + "'");
575  Info.Kind = VRegInfo::REGBANK;
576  Info.D.RegBank = RegBank;
577  }
578  }
579 
580  if (!VReg.PreferredRegister.Value.empty()) {
581  if (Info.Kind != VRegInfo::NORMAL)
582  return error(VReg.Class.SourceRange.Start,
583  Twine("preferred register can only be set for normal vregs"));
584 
585  if (parseRegisterReference(PFS, Info.PreferredReg,
586  VReg.PreferredRegister.Value, Error))
587  return error(Error, VReg.PreferredRegister.SourceRange);
588  }
589  }
590 
591  // Parse the liveins.
592  for (const auto &LiveIn : YamlMF.LiveIns) {
593  Register Reg;
594  if (parseNamedRegisterReference(PFS, Reg, LiveIn.Register.Value, Error))
595  return error(Error, LiveIn.Register.SourceRange);
596  Register VReg;
597  if (!LiveIn.VirtualRegister.Value.empty()) {
598  VRegInfo *Info;
599  if (parseVirtualRegisterReference(PFS, Info, LiveIn.VirtualRegister.Value,
600  Error))
601  return error(Error, LiveIn.VirtualRegister.SourceRange);
602  VReg = Info->VReg;
603  }
604  RegInfo.addLiveIn(Reg, VReg);
605  }
606 
607  // Parse the callee saved registers (Registers that will
608  // be saved for the caller).
609  if (YamlMF.CalleeSavedRegisters) {
610  SmallVector<MCPhysReg, 16> CalleeSavedRegisters;
611  for (const auto &RegSource : YamlMF.CalleeSavedRegisters.getValue()) {
612  Register Reg;
613  if (parseNamedRegisterReference(PFS, Reg, RegSource.Value, Error))
614  return error(Error, RegSource.SourceRange);
615  CalleeSavedRegisters.push_back(Reg);
616  }
617  RegInfo.setCalleeSavedRegs(CalleeSavedRegisters);
618  }
619 
620  return false;
621 }
622 
624  const yaml::MachineFunction &YamlMF) {
625  MachineFunction &MF = PFS.MF;
627  bool Error = false;
628  // Create VRegs
629  auto populateVRegInfo = [&] (const VRegInfo &Info, Twine Name) {
630  Register Reg = Info.VReg;
631  switch (Info.Kind) {
632  case VRegInfo::UNKNOWN:
633  error(Twine("Cannot determine class/bank of virtual register ") +
634  Name + " in function '" + MF.getName() + "'");
635  Error = true;
636  break;
637  case VRegInfo::NORMAL:
638  MRI.setRegClass(Reg, Info.D.RC);
639  if (Info.PreferredReg != 0)
640  MRI.setSimpleHint(Reg, Info.PreferredReg);
641  break;
642  case VRegInfo::GENERIC:
643  break;
644  case VRegInfo::REGBANK:
645  MRI.setRegBank(Reg, *Info.D.RegBank);
646  break;
647  }
648  };
649 
650  for (const auto &P : PFS.VRegInfosNamed) {
651  const VRegInfo &Info = *P.second;
652  populateVRegInfo(Info, Twine(P.first()));
653  }
654 
655  for (auto P : PFS.VRegInfos) {
656  const VRegInfo &Info = *P.second;
657  populateVRegInfo(Info, Twine(P.first));
658  }
659 
660  // Compute MachineRegisterInfo::UsedPhysRegMask
661  for (const MachineBasicBlock &MBB : MF) {
662  // Make sure MRI knows about registers clobbered by unwinder.
663  const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
664  if (MBB.isEHPad())
665  if (auto *RegMask = TRI->getCustomEHPadPreservedMask(MF))
667 
668  for (const MachineInstr &MI : MBB) {
669  for (const MachineOperand &MO : MI.operands()) {
670  if (!MO.isRegMask())
671  continue;
672  MRI.addPhysRegsUsedFromRegMask(MO.getRegMask());
673  }
674  }
675  }
676 
677  return Error;
678 }
679 
681  const yaml::MachineFunction &YamlMF) {
682  MachineFunction &MF = PFS.MF;
683  MachineFrameInfo &MFI = MF.getFrameInfo();
685  const Function &F = MF.getFunction();
686  const yaml::MachineFrameInfo &YamlMFI = YamlMF.FrameInfo;
689  MFI.setHasStackMap(YamlMFI.HasStackMap);
690  MFI.setHasPatchPoint(YamlMFI.HasPatchPoint);
691  MFI.setStackSize(YamlMFI.StackSize);
693  if (YamlMFI.MaxAlignment)
694  MFI.ensureMaxAlignment(Align(YamlMFI.MaxAlignment));
695  MFI.setAdjustsStack(YamlMFI.AdjustsStack);
696  MFI.setHasCalls(YamlMFI.HasCalls);
697  if (YamlMFI.MaxCallFrameSize != ~0u)
701  MFI.setHasVAStart(YamlMFI.HasVAStart);
703  MFI.setHasTailCall(YamlMFI.HasTailCall);
704  MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
705  if (!YamlMFI.SavePoint.Value.empty()) {
706  MachineBasicBlock *MBB = nullptr;
707  if (parseMBBReference(PFS, MBB, YamlMFI.SavePoint))
708  return true;
709  MFI.setSavePoint(MBB);
710  }
711  if (!YamlMFI.RestorePoint.Value.empty()) {
712  MachineBasicBlock *MBB = nullptr;
713  if (parseMBBReference(PFS, MBB, YamlMFI.RestorePoint))
714  return true;
715  MFI.setRestorePoint(MBB);
716  }
717 
718  std::vector<CalleeSavedInfo> CSIInfo;
719  // Initialize the fixed frame objects.
720  for (const auto &Object : YamlMF.FixedStackObjects) {
721  int ObjectIdx;
723  ObjectIdx = MFI.CreateFixedObject(Object.Size, Object.Offset,
724  Object.IsImmutable, Object.IsAliased);
725  else
726  ObjectIdx = MFI.CreateFixedSpillStackObject(Object.Size, Object.Offset);
727 
728  if (!TFI->isSupportedStackID(Object.StackID))
729  return error(Object.ID.SourceRange.Start,
730  Twine("StackID is not supported by target"));
731  MFI.setStackID(ObjectIdx, Object.StackID);
732  MFI.setObjectAlignment(ObjectIdx, Object.Alignment.valueOrOne());
733  if (!PFS.FixedStackObjectSlots.insert(std::make_pair(Object.ID.Value,
734  ObjectIdx))
735  .second)
736  return error(Object.ID.SourceRange.Start,
737  Twine("redefinition of fixed stack object '%fixed-stack.") +
738  Twine(Object.ID.Value) + "'");
739  if (parseCalleeSavedRegister(PFS, CSIInfo, Object.CalleeSavedRegister,
740  Object.CalleeSavedRestored, ObjectIdx))
741  return true;
742  if (parseStackObjectsDebugInfo(PFS, Object, ObjectIdx))
743  return true;
744  }
745 
746  // Initialize the ordinary frame objects.
747  for (const auto &Object : YamlMF.StackObjects) {
748  int ObjectIdx;
749  const AllocaInst *Alloca = nullptr;
750  const yaml::StringValue &Name = Object.Name;
751  if (!Name.Value.empty()) {
752  Alloca = dyn_cast_or_null<AllocaInst>(
753  F.getValueSymbolTable()->lookup(Name.Value));
754  if (!Alloca)
755  return error(Name.SourceRange.Start,
756  "alloca instruction named '" + Name.Value +
757  "' isn't defined in the function '" + F.getName() +
758  "'");
759  }
760  if (!TFI->isSupportedStackID(Object.StackID))
761  return error(Object.ID.SourceRange.Start,
762  Twine("StackID is not supported by target"));
764  ObjectIdx =
765  MFI.CreateVariableSizedObject(Object.Alignment.valueOrOne(), Alloca);
766  else
767  ObjectIdx = MFI.CreateStackObject(
768  Object.Size, Object.Alignment.valueOrOne(),
770  Object.StackID);
771  MFI.setObjectOffset(ObjectIdx, Object.Offset);
772 
773  if (!PFS.StackObjectSlots.insert(std::make_pair(Object.ID.Value, ObjectIdx))
774  .second)
775  return error(Object.ID.SourceRange.Start,
776  Twine("redefinition of stack object '%stack.") +
777  Twine(Object.ID.Value) + "'");
778  if (parseCalleeSavedRegister(PFS, CSIInfo, Object.CalleeSavedRegister,
779  Object.CalleeSavedRestored, ObjectIdx))
780  return true;
781  if (Object.LocalOffset)
782  MFI.mapLocalFrameObject(ObjectIdx, Object.LocalOffset.getValue());
783  if (parseStackObjectsDebugInfo(PFS, Object, ObjectIdx))
784  return true;
785  }
786  MFI.setCalleeSavedInfo(CSIInfo);
787  if (!CSIInfo.empty())
788  MFI.setCalleeSavedInfoValid(true);
789 
790  // Initialize the various stack object references after initializing the
791  // stack objects.
792  if (!YamlMFI.StackProtector.Value.empty()) {
794  int FI;
795  if (parseStackObjectReference(PFS, FI, YamlMFI.StackProtector.Value, Error))
796  return error(Error, YamlMFI.StackProtector.SourceRange);
797  MFI.setStackProtectorIndex(FI);
798  }
799  return false;
800 }
801 
803  std::vector<CalleeSavedInfo> &CSIInfo,
804  const yaml::StringValue &RegisterSource, bool IsRestored, int FrameIdx) {
805  if (RegisterSource.Value.empty())
806  return false;
807  Register Reg;
809  if (parseNamedRegisterReference(PFS, Reg, RegisterSource.Value, Error))
810  return error(Error, RegisterSource.SourceRange);
811  CalleeSavedInfo CSI(Reg, FrameIdx);
812  CSI.setRestored(IsRestored);
813  CSIInfo.push_back(CSI);
814  return false;
815 }
816 
817 /// Verify that given node is of a certain type. Return true on error.
818 template <typename T>
819 static bool typecheckMDNode(T *&Result, MDNode *Node,
820  const yaml::StringValue &Source,
821  StringRef TypeString, MIRParserImpl &Parser) {
822  if (!Node)
823  return false;
824  Result = dyn_cast<T>(Node);
825  if (!Result)
826  return Parser.error(Source.SourceRange.Start,
827  "expected a reference to a '" + TypeString +
828  "' metadata node");
829  return false;
830 }
831 
832 template <typename T>
834  const T &Object, int FrameIdx) {
835  // Debug information can only be attached to stack objects; Fixed stack
836  // objects aren't supported.
837  MDNode *Var = nullptr, *Expr = nullptr, *Loc = nullptr;
838  if (parseMDNode(PFS, Var, Object.DebugVar) ||
839  parseMDNode(PFS, Expr, Object.DebugExpr) ||
840  parseMDNode(PFS, Loc, Object.DebugLoc))
841  return true;
842  if (!Var && !Expr && !Loc)
843  return false;
844  DILocalVariable *DIVar = nullptr;
845  DIExpression *DIExpr = nullptr;
846  DILocation *DILoc = nullptr;
847  if (typecheckMDNode(DIVar, Var, Object.DebugVar, "DILocalVariable", *this) ||
848  typecheckMDNode(DIExpr, Expr, Object.DebugExpr, "DIExpression", *this) ||
849  typecheckMDNode(DILoc, Loc, Object.DebugLoc, "DILocation", *this))
850  return true;
851  PFS.MF.setVariableDbgInfo(DIVar, DIExpr, FrameIdx, DILoc);
852  return false;
853 }
854 
855 bool MIRParserImpl::parseMDNode(PerFunctionMIParsingState &PFS,
856  MDNode *&Node, const yaml::StringValue &Source) {
857  if (Source.Value.empty())
858  return false;
860  if (llvm::parseMDNode(PFS, Node, Source.Value, Error))
861  return error(Error, Source.SourceRange);
862  return false;
863 }
864 
867  DenseMap<unsigned, unsigned> &ConstantPoolSlots = PFS.ConstantPoolSlots;
868  const MachineFunction &MF = PFS.MF;
869  const auto &M = *MF.getFunction().getParent();
871  for (const auto &YamlConstant : YamlMF.Constants) {
872  if (YamlConstant.IsTargetSpecific)
873  // FIXME: Support target-specific constant pools
874  return error(YamlConstant.Value.SourceRange.Start,
875  "Can't parse target-specific constant pool entries yet");
876  const Constant *Value = dyn_cast_or_null<Constant>(
877  parseConstantValue(YamlConstant.Value.Value, Error, M));
878  if (!Value)
879  return error(Error, YamlConstant.Value.SourceRange);
880  const Align PrefTypeAlign =
881  M.getDataLayout().getPrefTypeAlign(Value->getType());
882  const Align Alignment = YamlConstant.Alignment.getValueOr(PrefTypeAlign);
883  unsigned Index = ConstantPool.getConstantPoolIndex(Value, Alignment);
884  if (!ConstantPoolSlots.insert(std::make_pair(YamlConstant.ID.Value, Index))
885  .second)
886  return error(YamlConstant.ID.SourceRange.Start,
887  Twine("redefinition of constant pool item '%const.") +
888  Twine(YamlConstant.ID.Value) + "'");
889  }
890  return false;
891 }
892 
894  const yaml::MachineJumpTable &YamlJTI) {
896  for (const auto &Entry : YamlJTI.Entries) {
897  std::vector<MachineBasicBlock *> Blocks;
898  for (const auto &MBBSource : Entry.Blocks) {
899  MachineBasicBlock *MBB = nullptr;
900  if (parseMBBReference(PFS, MBB, MBBSource.Value))
901  return true;
902  Blocks.push_back(MBB);
903  }
904  unsigned Index = JTI->createJumpTableIndex(Blocks);
905  if (!PFS.JumpTableSlots.insert(std::make_pair(Entry.ID.Value, Index))
906  .second)
907  return error(Entry.ID.SourceRange.Start,
908  Twine("redefinition of jump table entry '%jump-table.") +
909  Twine(Entry.ID.Value) + "'");
910  }
911  return false;
912 }
913 
914 bool MIRParserImpl::parseMBBReference(PerFunctionMIParsingState &PFS,
916  const yaml::StringValue &Source) {
918  if (llvm::parseMBBReference(PFS, MBB, Source.Value, Error))
919  return error(Error, Source.SourceRange);
920  return false;
921 }
922 
923 SMDiagnostic MIRParserImpl::diagFromMIStringDiag(const SMDiagnostic &Error,
924  SMRange SourceRange) {
925  assert(SourceRange.isValid() && "Invalid source range");
926  SMLoc Loc = SourceRange.Start;
927  bool HasQuote = Loc.getPointer() < SourceRange.End.getPointer() &&
928  *Loc.getPointer() == '\'';
929  // Translate the location of the error from the location in the MI string to
930  // the corresponding location in the MIR file.
931  Loc = Loc.getFromPointer(Loc.getPointer() + Error.getColumnNo() +
932  (HasQuote ? 1 : 0));
933 
934  // TODO: Translate any source ranges as well.
935  return SM.GetMessage(Loc, Error.getKind(), Error.getMessage(), None,
936  Error.getFixIts());
937 }
938 
939 SMDiagnostic MIRParserImpl::diagFromBlockStringDiag(const SMDiagnostic &Error,
940  SMRange SourceRange) {
941  assert(SourceRange.isValid());
942 
943  // Translate the location of the error from the location in the llvm IR string
944  // to the corresponding location in the MIR file.
945  auto LineAndColumn = SM.getLineAndColumn(SourceRange.Start);
946  unsigned Line = LineAndColumn.first + Error.getLineNo() - 1;
947  unsigned Column = Error.getColumnNo();
948  StringRef LineStr = Error.getLineContents();
949  SMLoc Loc = Error.getLoc();
950 
951  // Get the full line and adjust the column number by taking the indentation of
952  // LLVM IR into account.
953  for (line_iterator L(*SM.getMemoryBuffer(SM.getMainFileID()), false), E;
954  L != E; ++L) {
955  if (L.line_number() == Line) {
956  LineStr = *L;
957  Loc = SMLoc::getFromPointer(LineStr.data());
958  auto Indent = LineStr.find(Error.getLineContents());
959  if (Indent != StringRef::npos)
960  Column += Indent;
961  break;
962  }
963  }
964 
965  return SMDiagnostic(SM, Loc, Filename, Line, Column, Error.getKind(),
966  Error.getMessage(), LineStr, Error.getRanges(),
967  Error.getFixIts());
968 }
969 
970 MIRParser::MIRParser(std::unique_ptr<MIRParserImpl> Impl)
971  : Impl(std::move(Impl)) {}
972 
974 
975 std::unique_ptr<Module>
977  return Impl->parseIRModule(DataLayoutCallback);
978 }
979 
981  return Impl->parseMachineFunctions(M, MMI);
982 }
983 
984 std::unique_ptr<MIRParser> llvm::createMIRParserFromFile(
986  std::function<void(Function &)> ProcessIRFunction) {
987  auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
988  if (std::error_code EC = FileOrErr.getError()) {
990  "Could not open input file: " + EC.message());
991  return nullptr;
992  }
993  return createMIRParser(std::move(FileOrErr.get()), Context,
994  ProcessIRFunction);
995 }
996 
997 std::unique_ptr<MIRParser>
998 llvm::createMIRParser(std::unique_ptr<MemoryBuffer> Contents,
1000  std::function<void(Function &)> ProcessIRFunction) {
1001  auto Filename = Contents->getBufferIdentifier();
1004  DS_Error,
1005  SMDiagnostic(
1006  Filename, SourceMgr::DK_Error,
1007  "Can't read MIR with a Context that discards named Values")));
1008  return nullptr;
1009  }
1010  return std::make_unique<MIRParser>(std::make_unique<MIRParserImpl>(
1011  std::move(Contents), Filename, Context, ProcessIRFunction));
1012 }
llvm::MIRParserImpl::reportDiagnostic
void reportDiagnostic(const SMDiagnostic &Diag)
Definition: MIRParser.cpp:205
llvm::MachineRegisterInfo::addLiveIn
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
Definition: MachineRegisterInfo.h:929
llvm::EngineKind::Kind
Kind
Definition: ExecutionEngine.h:524
MemoryBuffer.h
llvm::yaml::MachineFunction::RegBankSelected
bool RegBankSelected
Definition: MIRYamlMapping.h:644
llvm::SMRange::Start
SMLoc Start
Definition: SMLoc.h:50
llvm::yaml::MachineFrameInfo::OffsetAdjustment
int OffsetAdjustment
Definition: MIRYamlMapping.h:556
llvm::CalleeSavedInfo::setRestored
void setRestored(bool R)
Definition: MachineFrameInfo.h:74
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:100
llvm::PerFunctionMIParsingState::SM
SourceMgr * SM
Definition: MIParser.h:163
llvm
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
llvm::SystemZISD::TM
@ TM
Definition: SystemZISelLowering.h:65
TargetFrameLowering.h
llvm::MachineJumpTableInfo::createJumpTableIndex
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
Definition: MachineFunction.cpp:1034
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:42
handleYAMLDiag
static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context)
Definition: MIRParser.cpp:171
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:976
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:555
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:662
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:124
llvm::MachineFrameInfo::setCVBytesOfCalleeSavedRegisters
void setCVBytesOfCalleeSavedRegisters(unsigned S)
Definition: MachineFrameInfo.h:660
llvm::yaml::StringValue::SourceRange
SMRange SourceRange
Definition: MIRYamlMapping.h:36
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:59
llvm::MIRParserImpl::error
bool error(const Twine &Message)
Report an error with the given message at unknown location.
Definition: MIRParser.cpp:187
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:318
llvm::yaml::MachineFrameInfo::RestorePoint
StringValue RestorePoint
Definition: MIRYamlMapping.h:570
llvm::PerTargetMIParsingState
Definition: MIParser.h:51
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:657
llvm::PerFunctionMIParsingState::StackObjectSlots
DenseMap< unsigned, int > StackObjectSlots
Definition: MIParser.h:171
MIRParser.h
llvm::yaml::MachineFunction::TracksRegLiveness
bool TracksRegLiveness
Definition: MIRYamlMapping.h:648
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:328
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:170
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:1558
DenseMap.h
Module.h
llvm::parseMachineInstructions
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
Definition: MIParser.cpp:3221
llvm::MachineFrameInfo::setStackSize
void setStackSize(uint64_t Size)
Set the size of the stack.
Definition: MachineFrameInfo.h:566
llvm::yaml::CallSiteInfo::MachineInstrLoc::Offset
unsigned Offset
Definition: MIRYamlMapping.h:401
llvm::MaybeAlign::valueOrOne
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
Definition: Alignment.h:144
llvm::yaml::MachineFunction::Alignment
MaybeAlign Alignment
Definition: MIRYamlMapping.h:640
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:37
llvm::MIRParserImpl::parseCalleeSavedRegister
bool parseCalleeSavedRegister(PerFunctionMIParsingState &PFS, std::vector< CalleeSavedInfo > &CSIInfo, const yaml::StringValue &RegisterSource, bool IsRestored, int FrameIdx)
Definition: MIRParser.cpp:802
llvm::MachineFunctionProperties::Property::IsSSA
@ IsSSA
llvm::PerFunctionMIParsingState::VRegInfosNamed
StringMap< VRegInfo * > VRegInfosNamed
Definition: MIParser.h:169
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:653
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:833
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:599
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:2559
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:893
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
llvm::yaml::MachineFrameInfo::CVBytesOfCalleeSavedRegisters
unsigned CVBytesOfCalleeSavedRegisters
Definition: MIRYamlMapping.h:563
llvm::yaml::MachineFunction::Name
StringRef Name
Definition: MIRYamlMapping.h:639
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::MIRParserImpl::parseRegisterInfo
bool parseRegisterInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:542
llvm::yaml::MachineJumpTable
Definition: MIRYamlMapping.h:496
llvm::MachineFrameInfo::setObjectAlignment
void setObjectAlignment(int ObjectIdx, Align Alignment)
setObjectAlignment - Change the alignment of the specified stack object.
Definition: MachineFrameInfo.h:478
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:3215
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:623
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:752
llvm::yaml::MachineFrameInfo::AdjustsStack
bool AdjustsStack
Definition: MIRYamlMapping.h:558
llvm::PerFunctionMIParsingState::JumpTableSlots
DenseMap< unsigned, unsigned > JumpTableSlots
Definition: MIParser.h:173
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:565
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:112
llvm::parseStackObjectReference
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3250
llvm::parseMDNode
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3256
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:865
llvm::DILocalVariable
Local variable.
Definition: DebugInfoMetadata.h:3041
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:606
llvm::DS_Warning
@ DS_Warning
Definition: DiagnosticInfo.h:46
llvm::MachineFrameInfo::setCalleeSavedInfoValid
void setCalleeSavedInfoValid(bool v)
Definition: MachineFrameInfo.h:811
llvm::yaml::MachineFunction::MachineFuncInfo
std::unique_ptr< MachineFunctionInfo > MachineFuncInfo
Constant pool.
Definition: MIRYamlMapping.h:659
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:646
llvm::MachineFunction::size
unsigned size() const
Definition: MachineFunction.h:747
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::MachineFrameInfo::setHasOpaqueSPAdjustment
void setHasOpaqueSPAdjustment(bool B)
Definition: MachineFrameInfo.h:607
llvm::MachineFunctionProperties::set
MachineFunctionProperties & set(Property P)
Definition: MachineFunction.h:166
llvm::MachineRegisterInfo::setCalleeSavedRegs
void setCalleeSavedRegs(ArrayRef< MCPhysReg > CSRs)
Sets the updated Callee Saved Registers list.
Definition: MachineRegisterInfo.cpp:627
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:652
llvm::yaml::MachineFrameInfo::HasVAStart
bool HasVAStart
Definition: MIRYamlMapping.h:565
llvm::MachineFunction::begin
iterator begin()
Definition: MachineFunction.h:737
llvm::MachineFunction::setHasWinCFI
void setHasWinCFI(bool v)
Definition: MachineFunction.h:640
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:175
llvm::yaml::MachineFunction::FrameInfo
MachineFrameInfo FrameInfo
Definition: MIRYamlMapping.h:655
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:26
llvm::yaml::MachineFrameInfo::HasCalls
bool HasCalls
Definition: MIRYamlMapping.h:559
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
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:190
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:176
llvm::yaml::MachineFrameInfo::StackProtector
StringValue StackProtector
Definition: MIRYamlMapping.h:560
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:555
llvm::tgtok::In
@ In
Definition: TGLexer.h:51
llvm::PerFunctionMIParsingState::VRegInfos
DenseMap< Register, VRegInfo * > VRegInfos
Definition: MIParser.h:168
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:804
llvm::MachineFrameInfo::setHasMustTailInVarArgFunc
void setHasMustTailInVarArgFunc(bool B)
Definition: MachineFrameInfo.h:624
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:645
llvm::TargetFrameLowering::isSupportedStackID
virtual bool isSupportedStackID(TargetStackID::Value ID) const
Definition: TargetFrameLowering.h:422
llvm::MachineFunction::addCallArgsForwardingRegs
void addCallArgsForwardingRegs(const MachineInstr *CallI, CallSiteInfoImpl &&CallInfo)
Start tracking the arguments passed to the call CallI.
Definition: MachineFunction.h:1095
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:568
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:37
llvm::SourceMgr::DK_Warning
@ DK_Warning
Definition: SourceMgr.h:35
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:998
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:973
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:143
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:538
MachineConstantPool.h
llvm::MachineFunctionProperties::Property::RegBankSelected
@ RegBankSelected
llvm::MachineFrameInfo::setRestorePoint
void setRestorePoint(MachineBasicBlock *NewRestore)
Definition: MachineFrameInfo.h:816
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:638
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:522
llvm::yaml::MachineFunction::FixedStackObjects
std::vector< FixedMachineStackObject > FixedStackObjects
Definition: MIRYamlMapping.h:656
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:984
llvm::MachineFrameInfo::setHasTailCall
void setHasTailCall(bool V=true)
Definition: MachineFrameInfo.h:628
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:587
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:1563
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:571
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:819
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:427
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::MIRParserImpl::initializeFrameInfo
bool initializeFrameInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:680
MachineModuleInfo.h
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:814
llvm::yaml::MachineStackObject::SpillSlot
@ SpillSlot
Definition: MIRYamlMapping.h:241
llvm::MachineFunction
Definition: MachineFunction.h:227
llvm::yaml::MachineFrameInfo::HasOpaqueSPAdjustment
bool HasOpaqueSPAdjustment
Definition: MIRYamlMapping.h:564
YAMLTraits.h
llvm::yaml::MachineJumpTable::Entries
std::vector< Entry > Entries
Definition: MIRYamlMapping.h:507
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:98
llvm::yaml::MachineFrameInfo::MaxCallFrameSize
unsigned MaxCallFrameSize
~0u means: not computed yet.
Definition: MIRYamlMapping.h:562
llvm::yaml::MachineFunction::Legalized
bool Legalized
Definition: MIRYamlMapping.h:643
llvm::MachineFrameInfo::setStackID
void setStackID(int ObjectIdx, uint8_t ID)
Definition: MachineFrameInfo.h:725
llvm::MachineFrameInfo::setHasCalls
void setHasCalls(bool V)
Definition: MachineFrameInfo.h:603
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:435
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::yaml::MachineJumpTable::Kind
MachineJumpTableInfo::JTEntryKind Kind
Definition: MIRYamlMapping.h:506
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:646
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:970
llvm::MachineModuleInfo::getOrCreateMachineFunction
MachineFunction & getOrCreateMachineFunction(Function &F)
Returns the MachineFunction constructed for the IR function F.
Definition: MachineModuleInfo.cpp:284
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:533
llvm::yaml::MachineFrameInfo::HasStackMap
bool HasStackMap
Definition: MIRYamlMapping.h:553
llvm::MachineFunctionProperties::reset
MachineFunctionProperties & reset(Property P)
Definition: MachineFunction.h:171
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:362
llvm::yaml::MachineFrameInfo
Serializable representation of MachineFrameInfo.
Definition: MIRYamlMapping.h:550
llvm::yaml::MachineFrameInfo::IsFrameAddressTaken
bool IsFrameAddressTaken
Definition: MIRYamlMapping.h:551
llvm::yaml::MachineFunction::DebugValueSubstitutions
std::vector< DebugValueSubstitution > DebugValueSubstitutions
Definition: MIRYamlMapping.h:661
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::PerFunctionMIParsingState
Definition: MIParser.h:160
llvm::yaml::MachineFunction::VirtualRegisters
std::vector< VirtualRegisterDefinition > VirtualRegisters
Definition: MIRYamlMapping.h:650
llvm::yaml::MachineFunction::ExposesReturnsTwice
bool ExposesReturnsTwice
Definition: MIRYamlMapping.h:641
llvm::MachineFunctionProperties::Property::FailedISel
@ FailedISel
llvm::parseNamedRegisterReference
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3238
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:80
llvm::MIRParserImpl::initializeCallSiteInfo
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:368
llvm::yaml::MachineFrameInfo::IsReturnAddressTaken
bool IsReturnAddressTaken
Definition: MIRYamlMapping.h:552
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:521
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:551
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:279
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:480
DiagnosticInfo.h
llvm::PerFunctionMIParsingState::ConstantPoolSlots
DenseMap< unsigned, unsigned > ConstantPoolSlots
Definition: MIParser.h:172
llvm::MachineRegisterInfo::addPhysRegsUsedFromRegMask
void addPhysRegsUsedFromRegMask(const uint32_t *RegMask)
addPhysRegsUsedFromRegMask - Mark any registers not in RegMask as used.
Definition: MachineRegisterInfo.h:851
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:225
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:386
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:276
SlotMapping.h
llvm::PerFunctionMIParsingState::MF
MachineFunction & MF
Definition: MIParser.h:162
llvm::MachineFrameInfo::setStackProtectorIndex
void setStackProtectorIndex(int I)
Definition: MachineFrameInfo.h:355
llvm::MIRParserImpl::parseMachineFunctions
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI)
Definition: MIRParser.cpp:262
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:3244
llvm::VRegInfo
Definition: MIParser.h:35
llvm::yaml::MachineFunction::LiveIns
std::vector< MachineFunctionLiveIn > LiveIns
Definition: MIRYamlMapping.h:651
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
llvm::yaml::MachineFrameInfo::SavePoint
StringValue SavePoint
Definition: MIRYamlMapping.h:569
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:755
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:187
llvm::yaml::MachineFunction::HasWinCFI
bool HasWinCFI
Definition: MIRYamlMapping.h:649
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:400
Instructions.h
llvm::yaml::MachineFrameInfo::HasTailCall
bool HasTailCall
Definition: MIRYamlMapping.h:567
llvm::yaml::MachineFunction::Body
BlockStringValue Body
Definition: MIRYamlMapping.h:663
llvm::yaml::MachineFrameInfo::MaxAlignment
unsigned MaxAlignment
Definition: MIRYamlMapping.h:557
llvm::yaml::MachineFrameInfo::HasMustTailInVarArgFunc
bool HasMustTailInVarArgFunc
Definition: MIRYamlMapping.h:566
llvm::VRegInfo::UNKNOWN
@ UNKNOWN
Definition: MIParser.h:37
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:350
llvm::MachineFrameInfo::setHasPatchPoint
void setHasPatchPoint(bool s=true)
Definition: MachineFrameInfo.h:385
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:152
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:575
llvm::parseRegisterReference
bool parseRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3232
llvm::yaml::MachineFrameInfo::HasPatchPoint
bool HasPatchPoint
Definition: MIRYamlMapping.h:554
llvm::yaml::CallSiteInfo::MachineInstrLoc
Identifies call instruction location in machine function.
Definition: MIRYamlMapping.h:399
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:4650
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:61
llvm::MIRParserImpl::parseMachineFunction
bool parseMachineFunction(Module &M, MachineModuleInfo &MMI)
Parse the machine function in the current YAML document.
Definition: MIRParser.cpp:290
llvm::MachineJumpTableInfo
Definition: MachineJumpTableInfo.h:42
llvm::yaml::MachineFunction::CallSitesInfo
std::vector< CallSiteInfo > CallSitesInfo
Definition: MIRYamlMapping.h:660
MachineFunction.h
llvm::parseMBBReference
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3226
llvm::VRegInfo::GENERIC
@ GENERIC
Definition: MIParser.h:37
llvm::MachineFunction::setBBSectionsType
void setBBSectionsType(BasicBlockSection V)
Definition: MachineFunction.h:544
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:921
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::MachineFrameInfo::setHasVAStart
void setHasVAStart(bool B)
Definition: MachineFrameInfo.h:620
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:980
llvm::DS_Error
@ DS_Error
Definition: DiagnosticInfo.h:45
isSSA
static bool isSSA(const MachineFunction &MF)
Definition: MIRParser.cpp:326
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:1084
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:658
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:623
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