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  if (YamlMF.FailsVerification)
458  MF.getProperties().set(
460 
461  PerFunctionMIParsingState PFS(MF, SM, IRSlots, *Target);
462  if (parseRegisterInfo(PFS, YamlMF))
463  return true;
464  if (!YamlMF.Constants.empty()) {
465  auto *ConstantPool = MF.getConstantPool();
466  assert(ConstantPool && "Constant pool must be created");
467  if (initializeConstantPool(PFS, *ConstantPool, YamlMF))
468  return true;
469  }
470  if (!YamlMF.MachineMetadataNodes.empty() &&
471  parseMachineMetadataNodes(PFS, MF, YamlMF))
472  return true;
473 
474  StringRef BlockStr = YamlMF.Body.Value.Value;
476  SourceMgr BlockSM;
477  BlockSM.AddNewSourceBuffer(
478  MemoryBuffer::getMemBuffer(BlockStr, "",/*RequiresNullTerminator=*/false),
479  SMLoc());
480  PFS.SM = &BlockSM;
481  if (parseMachineBasicBlockDefinitions(PFS, BlockStr, Error)) {
483  diagFromBlockStringDiag(Error, YamlMF.Body.Value.SourceRange));
484  return true;
485  }
486  // Check Basic Block Section Flags.
489  } else if (MF.hasBBSections()) {
491  }
492  PFS.SM = &SM;
493 
494  // Initialize the frame information after creating all the MBBs so that the
495  // MBB references in the frame information can be resolved.
496  if (initializeFrameInfo(PFS, YamlMF))
497  return true;
498  // Initialize the jump table after creating all the MBBs so that the MBB
499  // references can be resolved.
500  if (!YamlMF.JumpTableInfo.Entries.empty() &&
502  return true;
503  // Parse the machine instructions after creating all of the MBBs so that the
504  // parser can resolve the MBB references.
505  StringRef InsnStr = YamlMF.Body.Value.Value;
506  SourceMgr InsnSM;
507  InsnSM.AddNewSourceBuffer(
508  MemoryBuffer::getMemBuffer(InsnStr, "", /*RequiresNullTerminator=*/false),
509  SMLoc());
510  PFS.SM = &InsnSM;
511  if (parseMachineInstructions(PFS, InsnStr, Error)) {
513  diagFromBlockStringDiag(Error, YamlMF.Body.Value.SourceRange));
514  return true;
515  }
516  PFS.SM = &SM;
517 
518  if (setupRegisterInfo(PFS, YamlMF))
519  return true;
520 
521  if (YamlMF.MachineFuncInfo) {
522  const LLVMTargetMachine &TM = MF.getTarget();
523  // Note this is called after the initial constructor of the
524  // MachineFunctionInfo based on the MachineFunction, which may depend on the
525  // IR.
526 
527  SMRange SrcRange;
528  if (TM.parseMachineFunctionInfo(*YamlMF.MachineFuncInfo, PFS, Error,
529  SrcRange)) {
530  return error(Error, SrcRange);
531  }
532  }
533 
534  // Set the reserved registers after parsing MachineFuncInfo. The target may
535  // have been recording information used to select the reserved registers
536  // there.
537  // FIXME: This is a temporary workaround until the reserved registers can be
538  // serialized.
541 
542  computeFunctionProperties(MF);
543 
544  if (initializeCallSiteInfo(PFS, YamlMF))
545  return false;
546 
547  setupDebugValueTracking(MF, PFS, YamlMF);
548 
549  MF.getSubtarget().mirFileLoaded(MF);
550 
551  MF.verify();
552  return false;
553 }
554 
556  const yaml::MachineFunction &YamlMF) {
557  MachineFunction &MF = PFS.MF;
558  MachineRegisterInfo &RegInfo = MF.getRegInfo();
559  assert(RegInfo.tracksLiveness());
560  if (!YamlMF.TracksRegLiveness)
561  RegInfo.invalidateLiveness();
562 
564  // Parse the virtual register information.
565  for (const auto &VReg : YamlMF.VirtualRegisters) {
566  VRegInfo &Info = PFS.getVRegInfo(VReg.ID.Value);
567  if (Info.Explicit)
568  return error(VReg.ID.SourceRange.Start,
569  Twine("redefinition of virtual register '%") +
570  Twine(VReg.ID.Value) + "'");
571  Info.Explicit = true;
572 
573  if (StringRef(VReg.Class.Value).equals("_")) {
574  Info.Kind = VRegInfo::GENERIC;
575  Info.D.RegBank = nullptr;
576  } else {
577  const auto *RC = Target->getRegClass(VReg.Class.Value);
578  if (RC) {
579  Info.Kind = VRegInfo::NORMAL;
580  Info.D.RC = RC;
581  } else {
582  const RegisterBank *RegBank = Target->getRegBank(VReg.Class.Value);
583  if (!RegBank)
584  return error(
585  VReg.Class.SourceRange.Start,
586  Twine("use of undefined register class or register bank '") +
587  VReg.Class.Value + "'");
588  Info.Kind = VRegInfo::REGBANK;
589  Info.D.RegBank = RegBank;
590  }
591  }
592 
593  if (!VReg.PreferredRegister.Value.empty()) {
594  if (Info.Kind != VRegInfo::NORMAL)
595  return error(VReg.Class.SourceRange.Start,
596  Twine("preferred register can only be set for normal vregs"));
597 
598  if (parseRegisterReference(PFS, Info.PreferredReg,
599  VReg.PreferredRegister.Value, Error))
600  return error(Error, VReg.PreferredRegister.SourceRange);
601  }
602  }
603 
604  // Parse the liveins.
605  for (const auto &LiveIn : YamlMF.LiveIns) {
606  Register Reg;
607  if (parseNamedRegisterReference(PFS, Reg, LiveIn.Register.Value, Error))
608  return error(Error, LiveIn.Register.SourceRange);
609  Register VReg;
610  if (!LiveIn.VirtualRegister.Value.empty()) {
611  VRegInfo *Info;
612  if (parseVirtualRegisterReference(PFS, Info, LiveIn.VirtualRegister.Value,
613  Error))
614  return error(Error, LiveIn.VirtualRegister.SourceRange);
615  VReg = Info->VReg;
616  }
617  RegInfo.addLiveIn(Reg, VReg);
618  }
619 
620  // Parse the callee saved registers (Registers that will
621  // be saved for the caller).
622  if (YamlMF.CalleeSavedRegisters) {
623  SmallVector<MCPhysReg, 16> CalleeSavedRegisters;
624  for (const auto &RegSource : YamlMF.CalleeSavedRegisters.getValue()) {
625  Register Reg;
626  if (parseNamedRegisterReference(PFS, Reg, RegSource.Value, Error))
627  return error(Error, RegSource.SourceRange);
628  CalleeSavedRegisters.push_back(Reg);
629  }
630  RegInfo.setCalleeSavedRegs(CalleeSavedRegisters);
631  }
632 
633  return false;
634 }
635 
637  const yaml::MachineFunction &YamlMF) {
638  MachineFunction &MF = PFS.MF;
640  bool Error = false;
641  // Create VRegs
642  auto populateVRegInfo = [&] (const VRegInfo &Info, Twine Name) {
643  Register Reg = Info.VReg;
644  switch (Info.Kind) {
645  case VRegInfo::UNKNOWN:
646  error(Twine("Cannot determine class/bank of virtual register ") +
647  Name + " in function '" + MF.getName() + "'");
648  Error = true;
649  break;
650  case VRegInfo::NORMAL:
651  MRI.setRegClass(Reg, Info.D.RC);
652  if (Info.PreferredReg != 0)
653  MRI.setSimpleHint(Reg, Info.PreferredReg);
654  break;
655  case VRegInfo::GENERIC:
656  break;
657  case VRegInfo::REGBANK:
658  MRI.setRegBank(Reg, *Info.D.RegBank);
659  break;
660  }
661  };
662 
663  for (const auto &P : PFS.VRegInfosNamed) {
664  const VRegInfo &Info = *P.second;
665  populateVRegInfo(Info, Twine(P.first()));
666  }
667 
668  for (auto P : PFS.VRegInfos) {
669  const VRegInfo &Info = *P.second;
670  populateVRegInfo(Info, Twine(P.first));
671  }
672 
673  // Compute MachineRegisterInfo::UsedPhysRegMask
674  for (const MachineBasicBlock &MBB : MF) {
675  // Make sure MRI knows about registers clobbered by unwinder.
676  const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
677  if (MBB.isEHPad())
678  if (auto *RegMask = TRI->getCustomEHPadPreservedMask(MF))
680 
681  for (const MachineInstr &MI : MBB) {
682  for (const MachineOperand &MO : MI.operands()) {
683  if (!MO.isRegMask())
684  continue;
685  MRI.addPhysRegsUsedFromRegMask(MO.getRegMask());
686  }
687  }
688  }
689 
690  return Error;
691 }
692 
694  const yaml::MachineFunction &YamlMF) {
695  MachineFunction &MF = PFS.MF;
696  MachineFrameInfo &MFI = MF.getFrameInfo();
698  const Function &F = MF.getFunction();
699  const yaml::MachineFrameInfo &YamlMFI = YamlMF.FrameInfo;
702  MFI.setHasStackMap(YamlMFI.HasStackMap);
703  MFI.setHasPatchPoint(YamlMFI.HasPatchPoint);
704  MFI.setStackSize(YamlMFI.StackSize);
706  if (YamlMFI.MaxAlignment)
707  MFI.ensureMaxAlignment(Align(YamlMFI.MaxAlignment));
708  MFI.setAdjustsStack(YamlMFI.AdjustsStack);
709  MFI.setHasCalls(YamlMFI.HasCalls);
710  if (YamlMFI.MaxCallFrameSize != ~0u)
714  MFI.setHasVAStart(YamlMFI.HasVAStart);
716  MFI.setHasTailCall(YamlMFI.HasTailCall);
717  MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
718  if (!YamlMFI.SavePoint.Value.empty()) {
719  MachineBasicBlock *MBB = nullptr;
720  if (parseMBBReference(PFS, MBB, YamlMFI.SavePoint))
721  return true;
722  MFI.setSavePoint(MBB);
723  }
724  if (!YamlMFI.RestorePoint.Value.empty()) {
725  MachineBasicBlock *MBB = nullptr;
726  if (parseMBBReference(PFS, MBB, YamlMFI.RestorePoint))
727  return true;
728  MFI.setRestorePoint(MBB);
729  }
730 
731  std::vector<CalleeSavedInfo> CSIInfo;
732  // Initialize the fixed frame objects.
733  for (const auto &Object : YamlMF.FixedStackObjects) {
734  int ObjectIdx;
736  ObjectIdx = MFI.CreateFixedObject(Object.Size, Object.Offset,
737  Object.IsImmutable, Object.IsAliased);
738  else
739  ObjectIdx = MFI.CreateFixedSpillStackObject(Object.Size, Object.Offset);
740 
741  if (!TFI->isSupportedStackID(Object.StackID))
742  return error(Object.ID.SourceRange.Start,
743  Twine("StackID is not supported by target"));
744  MFI.setStackID(ObjectIdx, Object.StackID);
745  MFI.setObjectAlignment(ObjectIdx, Object.Alignment.valueOrOne());
746  if (!PFS.FixedStackObjectSlots.insert(std::make_pair(Object.ID.Value,
747  ObjectIdx))
748  .second)
749  return error(Object.ID.SourceRange.Start,
750  Twine("redefinition of fixed stack object '%fixed-stack.") +
751  Twine(Object.ID.Value) + "'");
752  if (parseCalleeSavedRegister(PFS, CSIInfo, Object.CalleeSavedRegister,
753  Object.CalleeSavedRestored, ObjectIdx))
754  return true;
755  if (parseStackObjectsDebugInfo(PFS, Object, ObjectIdx))
756  return true;
757  }
758 
759  // Initialize the ordinary frame objects.
760  for (const auto &Object : YamlMF.StackObjects) {
761  int ObjectIdx;
762  const AllocaInst *Alloca = nullptr;
763  const yaml::StringValue &Name = Object.Name;
764  if (!Name.Value.empty()) {
765  Alloca = dyn_cast_or_null<AllocaInst>(
766  F.getValueSymbolTable()->lookup(Name.Value));
767  if (!Alloca)
768  return error(Name.SourceRange.Start,
769  "alloca instruction named '" + Name.Value +
770  "' isn't defined in the function '" + F.getName() +
771  "'");
772  }
773  if (!TFI->isSupportedStackID(Object.StackID))
774  return error(Object.ID.SourceRange.Start,
775  Twine("StackID is not supported by target"));
777  ObjectIdx =
778  MFI.CreateVariableSizedObject(Object.Alignment.valueOrOne(), Alloca);
779  else
780  ObjectIdx = MFI.CreateStackObject(
781  Object.Size, Object.Alignment.valueOrOne(),
783  Object.StackID);
784  MFI.setObjectOffset(ObjectIdx, Object.Offset);
785 
786  if (!PFS.StackObjectSlots.insert(std::make_pair(Object.ID.Value, ObjectIdx))
787  .second)
788  return error(Object.ID.SourceRange.Start,
789  Twine("redefinition of stack object '%stack.") +
790  Twine(Object.ID.Value) + "'");
791  if (parseCalleeSavedRegister(PFS, CSIInfo, Object.CalleeSavedRegister,
792  Object.CalleeSavedRestored, ObjectIdx))
793  return true;
794  if (Object.LocalOffset)
795  MFI.mapLocalFrameObject(ObjectIdx, Object.LocalOffset.getValue());
796  if (parseStackObjectsDebugInfo(PFS, Object, ObjectIdx))
797  return true;
798  }
799  MFI.setCalleeSavedInfo(CSIInfo);
800  if (!CSIInfo.empty())
801  MFI.setCalleeSavedInfoValid(true);
802 
803  // Initialize the various stack object references after initializing the
804  // stack objects.
805  if (!YamlMFI.StackProtector.Value.empty()) {
807  int FI;
808  if (parseStackObjectReference(PFS, FI, YamlMFI.StackProtector.Value, Error))
809  return error(Error, YamlMFI.StackProtector.SourceRange);
810  MFI.setStackProtectorIndex(FI);
811  }
812  return false;
813 }
814 
816  std::vector<CalleeSavedInfo> &CSIInfo,
817  const yaml::StringValue &RegisterSource, bool IsRestored, int FrameIdx) {
818  if (RegisterSource.Value.empty())
819  return false;
820  Register Reg;
822  if (parseNamedRegisterReference(PFS, Reg, RegisterSource.Value, Error))
823  return error(Error, RegisterSource.SourceRange);
824  CalleeSavedInfo CSI(Reg, FrameIdx);
825  CSI.setRestored(IsRestored);
826  CSIInfo.push_back(CSI);
827  return false;
828 }
829 
830 /// Verify that given node is of a certain type. Return true on error.
831 template <typename T>
832 static bool typecheckMDNode(T *&Result, MDNode *Node,
833  const yaml::StringValue &Source,
834  StringRef TypeString, MIRParserImpl &Parser) {
835  if (!Node)
836  return false;
837  Result = dyn_cast<T>(Node);
838  if (!Result)
839  return Parser.error(Source.SourceRange.Start,
840  "expected a reference to a '" + TypeString +
841  "' metadata node");
842  return false;
843 }
844 
845 template <typename T>
847  const T &Object, int FrameIdx) {
848  // Debug information can only be attached to stack objects; Fixed stack
849  // objects aren't supported.
850  MDNode *Var = nullptr, *Expr = nullptr, *Loc = nullptr;
851  if (parseMDNode(PFS, Var, Object.DebugVar) ||
852  parseMDNode(PFS, Expr, Object.DebugExpr) ||
853  parseMDNode(PFS, Loc, Object.DebugLoc))
854  return true;
855  if (!Var && !Expr && !Loc)
856  return false;
857  DILocalVariable *DIVar = nullptr;
858  DIExpression *DIExpr = nullptr;
859  DILocation *DILoc = nullptr;
860  if (typecheckMDNode(DIVar, Var, Object.DebugVar, "DILocalVariable", *this) ||
861  typecheckMDNode(DIExpr, Expr, Object.DebugExpr, "DIExpression", *this) ||
862  typecheckMDNode(DILoc, Loc, Object.DebugLoc, "DILocation", *this))
863  return true;
864  PFS.MF.setVariableDbgInfo(DIVar, DIExpr, FrameIdx, DILoc);
865  return false;
866 }
867 
868 bool MIRParserImpl::parseMDNode(PerFunctionMIParsingState &PFS,
869  MDNode *&Node, const yaml::StringValue &Source) {
870  if (Source.Value.empty())
871  return false;
873  if (llvm::parseMDNode(PFS, Node, Source.Value, Error))
874  return error(Error, Source.SourceRange);
875  return false;
876 }
877 
880  DenseMap<unsigned, unsigned> &ConstantPoolSlots = PFS.ConstantPoolSlots;
881  const MachineFunction &MF = PFS.MF;
882  const auto &M = *MF.getFunction().getParent();
884  for (const auto &YamlConstant : YamlMF.Constants) {
885  if (YamlConstant.IsTargetSpecific)
886  // FIXME: Support target-specific constant pools
887  return error(YamlConstant.Value.SourceRange.Start,
888  "Can't parse target-specific constant pool entries yet");
889  const Constant *Value = dyn_cast_or_null<Constant>(
890  parseConstantValue(YamlConstant.Value.Value, Error, M));
891  if (!Value)
892  return error(Error, YamlConstant.Value.SourceRange);
893  const Align PrefTypeAlign =
894  M.getDataLayout().getPrefTypeAlign(Value->getType());
895  const Align Alignment = YamlConstant.Alignment.getValueOr(PrefTypeAlign);
896  unsigned Index = ConstantPool.getConstantPoolIndex(Value, Alignment);
897  if (!ConstantPoolSlots.insert(std::make_pair(YamlConstant.ID.Value, Index))
898  .second)
899  return error(YamlConstant.ID.SourceRange.Start,
900  Twine("redefinition of constant pool item '%const.") +
901  Twine(YamlConstant.ID.Value) + "'");
902  }
903  return false;
904 }
905 
907  const yaml::MachineJumpTable &YamlJTI) {
909  for (const auto &Entry : YamlJTI.Entries) {
910  std::vector<MachineBasicBlock *> Blocks;
911  for (const auto &MBBSource : Entry.Blocks) {
912  MachineBasicBlock *MBB = nullptr;
913  if (parseMBBReference(PFS, MBB, MBBSource.Value))
914  return true;
915  Blocks.push_back(MBB);
916  }
917  unsigned Index = JTI->createJumpTableIndex(Blocks);
918  if (!PFS.JumpTableSlots.insert(std::make_pair(Entry.ID.Value, Index))
919  .second)
920  return error(Entry.ID.SourceRange.Start,
921  Twine("redefinition of jump table entry '%jump-table.") +
922  Twine(Entry.ID.Value) + "'");
923  }
924  return false;
925 }
926 
927 bool MIRParserImpl::parseMBBReference(PerFunctionMIParsingState &PFS,
929  const yaml::StringValue &Source) {
931  if (llvm::parseMBBReference(PFS, MBB, Source.Value, Error))
932  return error(Error, Source.SourceRange);
933  return false;
934 }
935 
936 bool MIRParserImpl::parseMachineMetadata(PerFunctionMIParsingState &PFS,
937  const yaml::StringValue &Source) {
939  if (llvm::parseMachineMetadata(PFS, Source.Value, Source.SourceRange, Error))
940  return error(Error, Source.SourceRange);
941  return false;
942 }
943 
946  const yaml::MachineFunction &YMF) {
947  for (auto &MDS : YMF.MachineMetadataNodes) {
948  if (parseMachineMetadata(PFS, MDS))
949  return true;
950  }
951  // Report missing definitions from forward referenced nodes.
952  if (!PFS.MachineForwardRefMDNodes.empty())
953  return error(PFS.MachineForwardRefMDNodes.begin()->second.second,
954  "use of undefined metadata '!" +
955  Twine(PFS.MachineForwardRefMDNodes.begin()->first) + "'");
956  return false;
957 }
958 
959 SMDiagnostic MIRParserImpl::diagFromMIStringDiag(const SMDiagnostic &Error,
960  SMRange SourceRange) {
961  assert(SourceRange.isValid() && "Invalid source range");
962  SMLoc Loc = SourceRange.Start;
963  bool HasQuote = Loc.getPointer() < SourceRange.End.getPointer() &&
964  *Loc.getPointer() == '\'';
965  // Translate the location of the error from the location in the MI string to
966  // the corresponding location in the MIR file.
967  Loc = Loc.getFromPointer(Loc.getPointer() + Error.getColumnNo() +
968  (HasQuote ? 1 : 0));
969 
970  // TODO: Translate any source ranges as well.
971  return SM.GetMessage(Loc, Error.getKind(), Error.getMessage(), None,
972  Error.getFixIts());
973 }
974 
975 SMDiagnostic MIRParserImpl::diagFromBlockStringDiag(const SMDiagnostic &Error,
976  SMRange SourceRange) {
977  assert(SourceRange.isValid());
978 
979  // Translate the location of the error from the location in the llvm IR string
980  // to the corresponding location in the MIR file.
981  auto LineAndColumn = SM.getLineAndColumn(SourceRange.Start);
982  unsigned Line = LineAndColumn.first + Error.getLineNo() - 1;
983  unsigned Column = Error.getColumnNo();
984  StringRef LineStr = Error.getLineContents();
985  SMLoc Loc = Error.getLoc();
986 
987  // Get the full line and adjust the column number by taking the indentation of
988  // LLVM IR into account.
989  for (line_iterator L(*SM.getMemoryBuffer(SM.getMainFileID()), false), E;
990  L != E; ++L) {
991  if (L.line_number() == Line) {
992  LineStr = *L;
993  Loc = SMLoc::getFromPointer(LineStr.data());
994  auto Indent = LineStr.find(Error.getLineContents());
995  if (Indent != StringRef::npos)
996  Column += Indent;
997  break;
998  }
999  }
1000 
1001  return SMDiagnostic(SM, Loc, Filename, Line, Column, Error.getKind(),
1002  Error.getMessage(), LineStr, Error.getRanges(),
1003  Error.getFixIts());
1004 }
1005 
1006 MIRParser::MIRParser(std::unique_ptr<MIRParserImpl> Impl)
1007  : Impl(std::move(Impl)) {}
1008 
1010 
1011 std::unique_ptr<Module>
1013  return Impl->parseIRModule(DataLayoutCallback);
1014 }
1015 
1017  return Impl->parseMachineFunctions(M, MMI);
1018 }
1019 
1020 std::unique_ptr<MIRParser> llvm::createMIRParserFromFile(
1022  std::function<void(Function &)> ProcessIRFunction) {
1023  auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
1024  if (std::error_code EC = FileOrErr.getError()) {
1026  "Could not open input file: " + EC.message());
1027  return nullptr;
1028  }
1029  return createMIRParser(std::move(FileOrErr.get()), Context,
1030  ProcessIRFunction);
1031 }
1032 
1033 std::unique_ptr<MIRParser>
1034 llvm::createMIRParser(std::unique_ptr<MemoryBuffer> Contents,
1036  std::function<void(Function &)> ProcessIRFunction) {
1037  auto Filename = Contents->getBufferIdentifier();
1040  DS_Error,
1041  SMDiagnostic(
1042  Filename, SourceMgr::DK_Error,
1043  "Can't read MIR with a Context that discards named Values")));
1044  return nullptr;
1045  }
1046  return std::make_unique<MIRParser>(std::make_unique<MIRParserImpl>(
1047  std::move(Contents), Filename, Context, ProcessIRFunction));
1048 }
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:957
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:105
llvm::PerFunctionMIParsingState::SM
SourceMgr * SM
Definition: MIParser.h:165
llvm
This file implements support for optimizing divisions by a constant.
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:1288
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:1012
llvm::MachineFrameInfo::setReturnAddressIsTaken
void setReturnAddressIsTaken(bool s)
Definition: MachineFrameInfo.h:375
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
T
Parser.h
llvm::Function
Definition: Function.h:62
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:710
llvm::MachineFunction::assignBeginEndSections
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
Definition: MachineFunction.cpp:335
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::MachineFrameInfo::setCVBytesOfCalleeSavedRegisters
void setCVBytesOfCalleeSavedRegisters(unsigned S)
Definition: MachineFrameInfo.h:639
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:705
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:363
llvm::MachineFunction::getOrCreateJumpTableInfo
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist,...
Definition: MachineFunction.cpp:268
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:233
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1580
DenseMap.h
Module.h
llvm::parseMachineInstructions
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
Definition: MIParser.cpp:3411
llvm::MachineFrameInfo::setStackSize
void setStackSize(uint64_t Size)
Set the size of the stack.
Definition: MachineFrameInfo.h:556
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:815
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:632
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:846
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:578
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:2586
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:906
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:555
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:474
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:3405
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:698
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::MachineFrameInfo::setHasStackMap
void setHasStackMap(bool s=true)
Definition: MachineFrameInfo.h:381
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:640
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:3440
llvm::parseMDNode
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3446
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:878
llvm::DILocalVariable
Local variable.
Definition: DebugInfoMetadata.h:3097
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:681
llvm::DS_Warning
@ DS_Warning
Definition: DiagnosticInfo.h:47
llvm::MachineFrameInfo::setCalleeSavedInfoValid
void setCalleeSavedInfoValid(bool v)
Definition: MachineFrameInfo.h:770
llvm::yaml::MachineFunction::MachineFuncInfo
std::unique_ptr< MachineFunctionInfo > MachineFuncInfo
Constant pool.
Definition: MIRYamlMapping.h:707
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:721
llvm::MachineFunction::size
unsigned size() const
Definition: MachineFunction.h:822
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::MachineFrameInfo::setHasOpaqueSPAdjustment
void setHasOpaqueSPAdjustment(bool B)
Definition: MachineFrameInfo.h:586
llvm::MachineFunctionProperties::set
MachineFunctionProperties & set(Property P)
Definition: MachineFunction.h:173
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:45
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:700
llvm::yaml::MachineFrameInfo::HasVAStart
bool HasVAStart
Definition: MIRYamlMapping.h:612
llvm::MachineFunction::begin
iterator begin()
Definition: MachineFunction.h:812
llvm::MachineFunction::setHasWinCFI
void setHasWinCFI(bool v)
Definition: MachineFunction.h:715
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:703
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:333
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::MachineFunctionProperties::Property::FailsVerification
@ FailsVerification
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:630
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:763
llvm::MachineFrameInfo::setHasMustTailInVarArgFunc
void setHasMustTailInVarArgFunc(bool B)
Definition: MachineFrameInfo.h:603
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:3451
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:1184
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:578
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:1034
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:1009
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
llvm::yaml::MachineFunction::FailsVerification
bool FailsVerification
Definition: MIRYamlMapping.h:697
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:528
MachineConstantPool.h
llvm::MachineFunctionProperties::Property::RegBankSelected
@ RegBankSelected
llvm::MachineFrameInfo::setRestorePoint
void setRestorePoint(MachineBasicBlock *NewRestore)
Definition: MachineFrameInfo.h:775
llvm::MachineFrameInfo::mapLocalFrameObject
void mapLocalFrameObject(int ObjectIndex, int64_t Offset)
Map a frame index into the local object block.
Definition: MachineFrameInfo.h:402
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:542
llvm::yaml::MachineFunction::FixedStackObjects
std::vector< FixedMachineStackObject > FixedStackObjects
Definition: MIRYamlMapping.h:704
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:1020
llvm::MachineFrameInfo::setHasTailCall
void setHasTailCall(bool V=true)
Definition: MachineFrameInfo.h:607
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:139
llvm::MachineFunction::getConstantPool
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
Definition: MachineFunction.h:662
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:1609
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:646
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:832
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:693
MachineModuleInfo.h
llvm::MIRParserImpl::parseMachineMetadataNodes
bool parseMachineMetadataNodes(PerFunctionMIParsingState &PFS, MachineFunction &MF, const yaml::MachineFunction &YMF)
Definition: MIRParser.cpp:944
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:906
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:773
llvm::yaml::MachineStackObject::SpillSlot
@ SpillSlot
Definition: MIRYamlMapping.h:241
llvm::MachineFunction
Definition: MachineFunction.h:234
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:100
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:704
llvm::MachineFrameInfo::setHasCalls
void setHasCalls(bool V)
Definition: MachineFrameInfo.h:582
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:134
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
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:1006
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:608
llvm::yaml::MachineFrameInfo::HasStackMap
bool HasStackMap
Definition: MIRYamlMapping.h:600
llvm::MachineFunctionProperties::reset
MachineFunctionProperties & reset(Property P)
Definition: MachineFunction.h:178
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:709
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::PerFunctionMIParsingState
Definition: MIParser.h:162
llvm::yaml::MachineFunction::VirtualRegisters
std::vector< VirtualRegisterDefinition > VirtualRegisters
Definition: MIRYamlMapping.h:698
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:3428
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:596
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:626
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:496
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:879
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:393
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:357
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:3434
llvm::VRegInfo
Definition: MIParser.h:37
llvm::yaml::MachineFunction::LiveIns
std::vector< MachineFunctionLiveIn > LiveIns
Definition: MIRYamlMapping.h:699
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:224
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:712
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:387
llvm::yaml::MachineFunction::MachineMetadataNodes
std::vector< StringValue > MachineMetadataNodes
Definition: MIRYamlMapping.h:711
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:565
llvm::parseRegisterReference
bool parseRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3422
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:4713
LLVMContext.h
llvm::MachineFrameInfo::setFrameAddressIsTaken
void setFrameAddressIsTaken(bool T)
Definition: MachineFrameInfo.h:369
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:708
MachineFunction.h
llvm::parseMBBReference
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3416
llvm::VRegInfo::GENERIC
@ GENERIC
Definition: MIParser.h:39
llvm::MachineFunction::setBBSectionsType
void setBBSectionsType(BasicBlockSection V)
Definition: MachineFunction.h:619
llvm::MachineFrameInfo::setLocalFrameSize
void setLocalFrameSize(int64_t sz)
Set the size of the local object blob.
Definition: MachineFrameInfo.h:418
llvm::DiagnosticInfoMIRParser
Diagnostic information for machine IR parser.
Definition: DiagnosticInfo.h:932
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MachineFrameInfo::setHasVAStart
void setHasVAStart(bool B)
Definition: MachineFrameInfo.h:599
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:1016
llvm::DS_Error
@ DS_Error
Definition: DiagnosticInfo.h:46
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:1173
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:706
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:297
llvm::MIRParserImpl::setupRegisterInfo
bool setupRegisterInfo(const PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:636
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:51