LLVM  16.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/StringMap.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/AsmParser/Parser.h"
28 #include "llvm/IR/BasicBlock.h"
30 #include "llvm/IR/DiagnosticInfo.h"
31 #include "llvm/IR/Instructions.h"
32 #include "llvm/IR/LLVMContext.h"
33 #include "llvm/IR/Module.h"
37 #include "llvm/Support/SMLoc.h"
38 #include "llvm/Support/SourceMgr.h"
41 #include <memory>
42 
43 using namespace llvm;
44 
45 namespace llvm {
46 class MDNode;
47 class RegisterBank;
48 
49 /// This class implements the parsing of LLVM IR that's embedded inside a MIR
50 /// file.
52  SourceMgr SM;
53  LLVMContext &Context;
54  yaml::Input In;
55  StringRef Filename;
56  SlotMapping IRSlots;
57  std::unique_ptr<PerTargetMIParsingState> Target;
58 
59  /// True when the MIR file doesn't have LLVM IR. Dummy IR functions are
60  /// created and inserted into the given module when this is true.
61  bool NoLLVMIR = false;
62  /// True when a well formed MIR file does not contain any MIR/machine function
63  /// parts.
64  bool NoMIRDocuments = false;
65 
66  std::function<void(Function &)> ProcessIRFunction;
67 
68 public:
69  MIRParserImpl(std::unique_ptr<MemoryBuffer> Contents, StringRef Filename,
71  std::function<void(Function &)> ProcessIRFunction);
72 
73  void reportDiagnostic(const SMDiagnostic &Diag);
74 
75  /// Report an error with the given message at unknown location.
76  ///
77  /// Always returns true.
78  bool error(const Twine &Message);
79 
80  /// Report an error with the given message at the given location.
81  ///
82  /// Always returns true.
83  bool error(SMLoc Loc, const Twine &Message);
84 
85  /// Report a given error with the location translated from the location in an
86  /// embedded string literal to a location in the MIR file.
87  ///
88  /// Always returns true.
89  bool error(const SMDiagnostic &Error, SMRange SourceRange);
90 
91  /// Try to parse the optional LLVM module and the machine functions in the MIR
92  /// file.
93  ///
94  /// Return null if an error occurred.
95  std::unique_ptr<Module>
96  parseIRModule(DataLayoutCallbackTy DataLayoutCallback);
97 
98  /// Create an empty function with the given name.
100 
102 
103  /// Parse the machine function in the current YAML document.
104  ///
105  ///
106  /// Return true if an error occurred.
108 
109  /// Initialize the machine function to the state that's described in the MIR
110  /// file.
111  ///
112  /// Return true if error occurred.
114  MachineFunction &MF);
115 
117  const yaml::MachineFunction &YamlMF);
118 
120  const yaml::MachineFunction &YamlMF);
121 
123  const yaml::MachineFunction &YamlMF);
124 
126  const yaml::MachineFunction &YamlMF);
127 
129  std::vector<CalleeSavedInfo> &CSIInfo,
130  const yaml::StringValue &RegisterSource,
131  bool IsRestored, int FrameIdx);
132 
133  template <typename T>
135  const T &Object,
136  int FrameIdx);
137 
140  const yaml::MachineFunction &YamlMF);
141 
143  const yaml::MachineJumpTable &YamlJTI);
144 
146  MachineFunction &MF,
147  const yaml::MachineFunction &YMF);
148 
149 private:
150  bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node,
151  const yaml::StringValue &Source);
152 
153  bool parseMBBReference(PerFunctionMIParsingState &PFS,
155  const yaml::StringValue &Source);
156 
157  bool parseMachineMetadata(PerFunctionMIParsingState &PFS,
158  const yaml::StringValue &Source);
159 
160  /// Return a MIR diagnostic converted from an MI string diagnostic.
161  SMDiagnostic diagFromMIStringDiag(const SMDiagnostic &Error,
162  SMRange SourceRange);
163 
164  /// Return a MIR diagnostic converted from a diagnostic located in a YAML
165  /// block scalar string.
166  SMDiagnostic diagFromBlockStringDiag(const SMDiagnostic &Error,
167  SMRange SourceRange);
168 
169  void computeFunctionProperties(MachineFunction &MF);
170 
171  void setupDebugValueTracking(MachineFunction &MF,
173 };
174 
175 } // end namespace llvm
176 
177 static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context) {
178  reinterpret_cast<MIRParserImpl *>(Context)->reportDiagnostic(Diag);
179 }
180 
181 MIRParserImpl::MIRParserImpl(std::unique_ptr<MemoryBuffer> Contents,
182  StringRef Filename, LLVMContext &Context,
183  std::function<void(Function &)> Callback)
184  : Context(Context),
185  In(SM.getMemoryBuffer(SM.AddNewSourceBuffer(std::move(Contents), SMLoc()))
186  ->getBuffer(),
187  nullptr, handleYAMLDiag, this),
188  Filename(Filename), ProcessIRFunction(Callback) {
189  In.setContext(&In);
190 }
191 
192 bool MIRParserImpl::error(const Twine &Message) {
194  DS_Error, SMDiagnostic(Filename, SourceMgr::DK_Error, Message.str())));
195  return true;
196 }
197 
198 bool MIRParserImpl::error(SMLoc Loc, const Twine &Message) {
200  DS_Error, SM.GetMessage(Loc, SourceMgr::DK_Error, Message)));
201  return true;
202 }
203 
204 bool MIRParserImpl::error(const SMDiagnostic &Error, SMRange SourceRange) {
205  assert(Error.getKind() == SourceMgr::DK_Error && "Expected an error");
206  reportDiagnostic(diagFromMIStringDiag(Error, SourceRange));
207  return true;
208 }
209 
212  switch (Diag.getKind()) {
213  case SourceMgr::DK_Error:
214  Kind = DS_Error;
215  break;
217  Kind = DS_Warning;
218  break;
219  case SourceMgr::DK_Note:
220  Kind = DS_Note;
221  break;
223  llvm_unreachable("remark unexpected");
224  break;
225  }
227 }
228 
229 std::unique_ptr<Module>
231  if (!In.setCurrentDocument()) {
232  if (In.error())
233  return nullptr;
234  // Create an empty module when the MIR file is empty.
235  NoMIRDocuments = true;
236  auto M = std::make_unique<Module>(Filename, Context);
237  if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple()))
238  M->setDataLayout(*LayoutOverride);
239  return M;
240  }
241 
242  std::unique_ptr<Module> M;
243  // Parse the block scalar manually so that we can return unique pointer
244  // without having to go trough YAML traits.
245  if (const auto *BSN =
246  dyn_cast_or_null<yaml::BlockScalarNode>(In.getCurrentNode())) {
248  M = parseAssembly(MemoryBufferRef(BSN->getValue(), Filename), Error,
249  Context, &IRSlots, DataLayoutCallback);
250  if (!M) {
251  reportDiagnostic(diagFromBlockStringDiag(Error, BSN->getSourceRange()));
252  return nullptr;
253  }
254  In.nextDocument();
255  if (!In.setCurrentDocument())
256  NoMIRDocuments = true;
257  } else {
258  // Create an new, empty module.
259  M = std::make_unique<Module>(Filename, Context);
260  if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple()))
261  M->setDataLayout(*LayoutOverride);
262  NoLLVMIR = true;
263  }
264  return M;
265 }
266 
268  if (NoMIRDocuments)
269  return false;
270 
271  // Parse the machine functions.
272  do {
273  if (parseMachineFunction(M, MMI))
274  return true;
275  In.nextDocument();
276  } while (In.setCurrentDocument());
277 
278  return false;
279 }
280 
282  auto &Context = M.getContext();
283  Function *F =
286  BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
287  new UnreachableInst(Context, BB);
288 
289  if (ProcessIRFunction)
290  ProcessIRFunction(*F);
291 
292  return F;
293 }
294 
296  // Parse the yaml.
297  yaml::MachineFunction YamlMF;
298  yaml::EmptyContext Ctx;
299 
300  const LLVMTargetMachine &TM = MMI.getTarget();
301  YamlMF.MachineFuncInfo = std::unique_ptr<yaml::MachineFunctionInfo>(
302  TM.createDefaultFuncInfoYAML());
303 
304  yaml::yamlize(In, YamlMF, false, Ctx);
305  if (In.error())
306  return true;
307 
308  // Search for the corresponding IR function.
309  StringRef FunctionName = YamlMF.Name;
310  Function *F = M.getFunction(FunctionName);
311  if (!F) {
312  if (NoLLVMIR) {
313  F = createDummyFunction(FunctionName, M);
314  } else {
315  return error(Twine("function '") + FunctionName +
316  "' isn't defined in the provided LLVM IR");
317  }
318  }
319  if (MMI.getMachineFunction(*F) != nullptr)
320  return error(Twine("redefinition of machine function '") + FunctionName +
321  "'");
322 
323  // Create the MachineFunction.
325  if (initializeMachineFunction(YamlMF, MF))
326  return true;
327 
328  return false;
329 }
330 
331 static bool isSSA(const MachineFunction &MF) {
332  const MachineRegisterInfo &MRI = MF.getRegInfo();
333  for (unsigned I = 0, E = MRI.getNumVirtRegs(); I != E; ++I) {
335  if (!MRI.hasOneDef(Reg) && !MRI.def_empty(Reg))
336  return false;
337 
338  // Subregister defs are invalid in SSA.
339  const MachineOperand *RegDef = MRI.getOneDef(Reg);
340  if (RegDef && RegDef->getSubReg() != 0)
341  return false;
342  }
343  return true;
344 }
345 
346 void MIRParserImpl::computeFunctionProperties(MachineFunction &MF) {
347  MachineFunctionProperties &Properties = MF.getProperties();
348 
349  bool HasPHI = false;
350  bool HasInlineAsm = false;
351  bool AllTiedOpsRewritten = true, HasTiedOps = false;
352  for (const MachineBasicBlock &MBB : MF) {
353  for (const MachineInstr &MI : MBB) {
354  if (MI.isPHI())
355  HasPHI = true;
356  if (MI.isInlineAsm())
357  HasInlineAsm = true;
358  for (unsigned I = 0; I < MI.getNumOperands(); ++I) {
359  const MachineOperand &MO = MI.getOperand(I);
360  if (!MO.isReg() || !MO.getReg())
361  continue;
362  unsigned DefIdx;
363  if (MO.isUse() && MI.isRegTiedToDefOperand(I, &DefIdx)) {
364  HasTiedOps = true;
365  if (MO.getReg() != MI.getOperand(DefIdx).getReg())
366  AllTiedOpsRewritten = false;
367  }
368  }
369  }
370  }
371  if (!HasPHI)
373  MF.setHasInlineAsm(HasInlineAsm);
374 
375  if (HasTiedOps && AllTiedOpsRewritten)
377 
378  if (isSSA(MF))
380  else
382 
383  const MachineRegisterInfo &MRI = MF.getRegInfo();
384  if (MRI.getNumVirtRegs() == 0)
386 }
387 
389  PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF) {
390  MachineFunction &MF = PFS.MF;
392  const LLVMTargetMachine &TM = MF.getTarget();
393  for (auto YamlCSInfo : YamlMF.CallSitesInfo) {
394  yaml::CallSiteInfo::MachineInstrLoc MILoc = YamlCSInfo.CallLocation;
395  if (MILoc.BlockNum >= MF.size())
396  return error(Twine(MF.getName()) +
397  Twine(" call instruction block out of range.") +
398  " Unable to reference bb:" + Twine(MILoc.BlockNum));
399  auto CallB = std::next(MF.begin(), MILoc.BlockNum);
400  if (MILoc.Offset >= CallB->size())
401  return error(Twine(MF.getName()) +
402  Twine(" call instruction offset out of range.") +
403  " Unable to reference instruction at bb: " +
404  Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset));
405  auto CallI = std::next(CallB->instr_begin(), MILoc.Offset);
406  if (!CallI->isCall(MachineInstr::IgnoreBundle))
407  return error(Twine(MF.getName()) +
408  Twine(" call site info should reference call "
409  "instruction. Instruction at bb:") +
410  Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset) +
411  " is not a call instruction");
413  for (auto ArgRegPair : YamlCSInfo.ArgForwardingRegs) {
414  Register Reg;
415  if (parseNamedRegisterReference(PFS, Reg, ArgRegPair.Reg.Value, Error))
416  return error(Error, ArgRegPair.Reg.SourceRange);
417  CSInfo.emplace_back(Reg, ArgRegPair.ArgNo);
418  }
419 
420  if (TM.Options.EmitCallSiteInfo)
421  MF.addCallArgsForwardingRegs(&*CallI, std::move(CSInfo));
422  }
423 
424  if (YamlMF.CallSitesInfo.size() && !TM.Options.EmitCallSiteInfo)
425  return error(Twine("Call site info provided but not used"));
426  return false;
427 }
428 
429 void MIRParserImpl::setupDebugValueTracking(
431  const yaml::MachineFunction &YamlMF) {
432  // Compute the value of the "next instruction number" field.
433  unsigned MaxInstrNum = 0;
434  for (auto &MBB : MF)
435  for (auto &MI : MBB)
436  MaxInstrNum = std::max((unsigned)MI.peekDebugInstrNum(), MaxInstrNum);
437  MF.setDebugInstrNumberingCount(MaxInstrNum);
438 
439  // Load any substitutions.
440  for (const auto &Sub : YamlMF.DebugValueSubstitutions) {
441  MF.makeDebugValueSubstitution({Sub.SrcInst, Sub.SrcOp},
442  {Sub.DstInst, Sub.DstOp}, Sub.Subreg);
443  }
444 }
445 
446 bool
448  MachineFunction &MF) {
449  // TODO: Recreate the machine function.
450  if (Target) {
451  // Avoid clearing state if we're using the same subtarget again.
452  Target->setTarget(MF.getSubtarget());
453  } else {
455  }
456 
457  MF.setAlignment(YamlMF.Alignment.valueOrOne());
459  MF.setHasWinCFI(YamlMF.HasWinCFI);
460 
461  MF.setCallsEHReturn(YamlMF.CallsEHReturn);
463  MF.setHasEHCatchret(YamlMF.HasEHCatchret);
464  MF.setHasEHScopes(YamlMF.HasEHScopes);
465  MF.setHasEHFunclets(YamlMF.HasEHFunclets);
466 
467  if (YamlMF.Legalized)
469  if (YamlMF.RegBankSelected)
470  MF.getProperties().set(
472  if (YamlMF.Selected)
474  if (YamlMF.FailedISel)
476  if (YamlMF.FailsVerification)
477  MF.getProperties().set(
479  if (YamlMF.TracksDebugUserValues)
480  MF.getProperties().set(
482 
483  PerFunctionMIParsingState PFS(MF, SM, IRSlots, *Target);
484  if (parseRegisterInfo(PFS, YamlMF))
485  return true;
486  if (!YamlMF.Constants.empty()) {
487  auto *ConstantPool = MF.getConstantPool();
488  assert(ConstantPool && "Constant pool must be created");
489  if (initializeConstantPool(PFS, *ConstantPool, YamlMF))
490  return true;
491  }
492  if (!YamlMF.MachineMetadataNodes.empty() &&
493  parseMachineMetadataNodes(PFS, MF, YamlMF))
494  return true;
495 
496  StringRef BlockStr = YamlMF.Body.Value.Value;
498  SourceMgr BlockSM;
499  BlockSM.AddNewSourceBuffer(
500  MemoryBuffer::getMemBuffer(BlockStr, "",/*RequiresNullTerminator=*/false),
501  SMLoc());
502  PFS.SM = &BlockSM;
503  if (parseMachineBasicBlockDefinitions(PFS, BlockStr, Error)) {
505  diagFromBlockStringDiag(Error, YamlMF.Body.Value.SourceRange));
506  return true;
507  }
508  // Check Basic Block Section Flags.
511  } else if (MF.hasBBSections()) {
513  }
514  PFS.SM = &SM;
515 
516  // Initialize the frame information after creating all the MBBs so that the
517  // MBB references in the frame information can be resolved.
518  if (initializeFrameInfo(PFS, YamlMF))
519  return true;
520  // Initialize the jump table after creating all the MBBs so that the MBB
521  // references can be resolved.
522  if (!YamlMF.JumpTableInfo.Entries.empty() &&
524  return true;
525  // Parse the machine instructions after creating all of the MBBs so that the
526  // parser can resolve the MBB references.
527  StringRef InsnStr = YamlMF.Body.Value.Value;
528  SourceMgr InsnSM;
529  InsnSM.AddNewSourceBuffer(
530  MemoryBuffer::getMemBuffer(InsnStr, "", /*RequiresNullTerminator=*/false),
531  SMLoc());
532  PFS.SM = &InsnSM;
533  if (parseMachineInstructions(PFS, InsnStr, Error)) {
535  diagFromBlockStringDiag(Error, YamlMF.Body.Value.SourceRange));
536  return true;
537  }
538  PFS.SM = &SM;
539 
540  if (setupRegisterInfo(PFS, YamlMF))
541  return true;
542 
543  if (YamlMF.MachineFuncInfo) {
544  const LLVMTargetMachine &TM = MF.getTarget();
545  // Note this is called after the initial constructor of the
546  // MachineFunctionInfo based on the MachineFunction, which may depend on the
547  // IR.
548 
549  SMRange SrcRange;
550  if (TM.parseMachineFunctionInfo(*YamlMF.MachineFuncInfo, PFS, Error,
551  SrcRange)) {
552  return error(Error, SrcRange);
553  }
554  }
555 
556  // Set the reserved registers after parsing MachineFuncInfo. The target may
557  // have been recording information used to select the reserved registers
558  // there.
559  // FIXME: This is a temporary workaround until the reserved registers can be
560  // serialized.
563 
564  computeFunctionProperties(MF);
565 
566  if (initializeCallSiteInfo(PFS, YamlMF))
567  return false;
568 
569  setupDebugValueTracking(MF, PFS, YamlMF);
570 
571  MF.getSubtarget().mirFileLoaded(MF);
572 
573  MF.verify();
574  return false;
575 }
576 
578  const yaml::MachineFunction &YamlMF) {
579  MachineFunction &MF = PFS.MF;
580  MachineRegisterInfo &RegInfo = MF.getRegInfo();
581  assert(RegInfo.tracksLiveness());
582  if (!YamlMF.TracksRegLiveness)
583  RegInfo.invalidateLiveness();
584 
586  // Parse the virtual register information.
587  for (const auto &VReg : YamlMF.VirtualRegisters) {
588  VRegInfo &Info = PFS.getVRegInfo(VReg.ID.Value);
589  if (Info.Explicit)
590  return error(VReg.ID.SourceRange.Start,
591  Twine("redefinition of virtual register '%") +
592  Twine(VReg.ID.Value) + "'");
593  Info.Explicit = true;
594 
595  if (StringRef(VReg.Class.Value).equals("_")) {
596  Info.Kind = VRegInfo::GENERIC;
597  Info.D.RegBank = nullptr;
598  } else {
599  const auto *RC = Target->getRegClass(VReg.Class.Value);
600  if (RC) {
601  Info.Kind = VRegInfo::NORMAL;
602  Info.D.RC = RC;
603  } else {
604  const RegisterBank *RegBank = Target->getRegBank(VReg.Class.Value);
605  if (!RegBank)
606  return error(
607  VReg.Class.SourceRange.Start,
608  Twine("use of undefined register class or register bank '") +
609  VReg.Class.Value + "'");
610  Info.Kind = VRegInfo::REGBANK;
611  Info.D.RegBank = RegBank;
612  }
613  }
614 
615  if (!VReg.PreferredRegister.Value.empty()) {
616  if (Info.Kind != VRegInfo::NORMAL)
617  return error(VReg.Class.SourceRange.Start,
618  Twine("preferred register can only be set for normal vregs"));
619 
620  if (parseRegisterReference(PFS, Info.PreferredReg,
621  VReg.PreferredRegister.Value, Error))
622  return error(Error, VReg.PreferredRegister.SourceRange);
623  }
624  }
625 
626  // Parse the liveins.
627  for (const auto &LiveIn : YamlMF.LiveIns) {
628  Register Reg;
629  if (parseNamedRegisterReference(PFS, Reg, LiveIn.Register.Value, Error))
630  return error(Error, LiveIn.Register.SourceRange);
631  Register VReg;
632  if (!LiveIn.VirtualRegister.Value.empty()) {
633  VRegInfo *Info;
634  if (parseVirtualRegisterReference(PFS, Info, LiveIn.VirtualRegister.Value,
635  Error))
636  return error(Error, LiveIn.VirtualRegister.SourceRange);
637  VReg = Info->VReg;
638  }
639  RegInfo.addLiveIn(Reg, VReg);
640  }
641 
642  // Parse the callee saved registers (Registers that will
643  // be saved for the caller).
644  if (YamlMF.CalleeSavedRegisters) {
645  SmallVector<MCPhysReg, 16> CalleeSavedRegisters;
646  for (const auto &RegSource : *YamlMF.CalleeSavedRegisters) {
647  Register Reg;
648  if (parseNamedRegisterReference(PFS, Reg, RegSource.Value, Error))
649  return error(Error, RegSource.SourceRange);
650  CalleeSavedRegisters.push_back(Reg);
651  }
652  RegInfo.setCalleeSavedRegs(CalleeSavedRegisters);
653  }
654 
655  return false;
656 }
657 
659  const yaml::MachineFunction &YamlMF) {
660  MachineFunction &MF = PFS.MF;
662  bool Error = false;
663  // Create VRegs
664  auto populateVRegInfo = [&] (const VRegInfo &Info, Twine Name) {
665  Register Reg = Info.VReg;
666  switch (Info.Kind) {
667  case VRegInfo::UNKNOWN:
668  error(Twine("Cannot determine class/bank of virtual register ") +
669  Name + " in function '" + MF.getName() + "'");
670  Error = true;
671  break;
672  case VRegInfo::NORMAL:
673  MRI.setRegClass(Reg, Info.D.RC);
674  if (Info.PreferredReg != 0)
675  MRI.setSimpleHint(Reg, Info.PreferredReg);
676  break;
677  case VRegInfo::GENERIC:
678  break;
679  case VRegInfo::REGBANK:
680  MRI.setRegBank(Reg, *Info.D.RegBank);
681  break;
682  }
683  };
684 
685  for (const auto &P : PFS.VRegInfosNamed) {
686  const VRegInfo &Info = *P.second;
687  populateVRegInfo(Info, Twine(P.first()));
688  }
689 
690  for (auto P : PFS.VRegInfos) {
691  const VRegInfo &Info = *P.second;
692  populateVRegInfo(Info, Twine(P.first));
693  }
694 
695  // Compute MachineRegisterInfo::UsedPhysRegMask
696  for (const MachineBasicBlock &MBB : MF) {
697  // Make sure MRI knows about registers clobbered by unwinder.
698  const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
699  if (MBB.isEHPad())
700  if (auto *RegMask = TRI->getCustomEHPadPreservedMask(MF))
702 
703  for (const MachineInstr &MI : MBB) {
704  for (const MachineOperand &MO : MI.operands()) {
705  if (!MO.isRegMask())
706  continue;
708  }
709  }
710  }
711 
712  return Error;
713 }
714 
716  const yaml::MachineFunction &YamlMF) {
717  MachineFunction &MF = PFS.MF;
718  MachineFrameInfo &MFI = MF.getFrameInfo();
720  const Function &F = MF.getFunction();
721  const yaml::MachineFrameInfo &YamlMFI = YamlMF.FrameInfo;
724  MFI.setHasStackMap(YamlMFI.HasStackMap);
725  MFI.setHasPatchPoint(YamlMFI.HasPatchPoint);
726  MFI.setStackSize(YamlMFI.StackSize);
728  if (YamlMFI.MaxAlignment)
729  MFI.ensureMaxAlignment(Align(YamlMFI.MaxAlignment));
730  MFI.setAdjustsStack(YamlMFI.AdjustsStack);
731  MFI.setHasCalls(YamlMFI.HasCalls);
732  if (YamlMFI.MaxCallFrameSize != ~0u)
736  MFI.setHasVAStart(YamlMFI.HasVAStart);
738  MFI.setHasTailCall(YamlMFI.HasTailCall);
739  MFI.setLocalFrameSize(YamlMFI.LocalFrameSize);
740  if (!YamlMFI.SavePoint.Value.empty()) {
741  MachineBasicBlock *MBB = nullptr;
742  if (parseMBBReference(PFS, MBB, YamlMFI.SavePoint))
743  return true;
744  MFI.setSavePoint(MBB);
745  }
746  if (!YamlMFI.RestorePoint.Value.empty()) {
747  MachineBasicBlock *MBB = nullptr;
748  if (parseMBBReference(PFS, MBB, YamlMFI.RestorePoint))
749  return true;
750  MFI.setRestorePoint(MBB);
751  }
752 
753  std::vector<CalleeSavedInfo> CSIInfo;
754  // Initialize the fixed frame objects.
755  for (const auto &Object : YamlMF.FixedStackObjects) {
756  int ObjectIdx;
758  ObjectIdx = MFI.CreateFixedObject(Object.Size, Object.Offset,
759  Object.IsImmutable, Object.IsAliased);
760  else
761  ObjectIdx = MFI.CreateFixedSpillStackObject(Object.Size, Object.Offset);
762 
763  if (!TFI->isSupportedStackID(Object.StackID))
764  return error(Object.ID.SourceRange.Start,
765  Twine("StackID is not supported by target"));
766  MFI.setStackID(ObjectIdx, Object.StackID);
767  MFI.setObjectAlignment(ObjectIdx, Object.Alignment.valueOrOne());
768  if (!PFS.FixedStackObjectSlots.insert(std::make_pair(Object.ID.Value,
769  ObjectIdx))
770  .second)
771  return error(Object.ID.SourceRange.Start,
772  Twine("redefinition of fixed stack object '%fixed-stack.") +
773  Twine(Object.ID.Value) + "'");
774  if (parseCalleeSavedRegister(PFS, CSIInfo, Object.CalleeSavedRegister,
775  Object.CalleeSavedRestored, ObjectIdx))
776  return true;
777  if (parseStackObjectsDebugInfo(PFS, Object, ObjectIdx))
778  return true;
779  }
780 
781  // Initialize the ordinary frame objects.
782  for (const auto &Object : YamlMF.StackObjects) {
783  int ObjectIdx;
784  const AllocaInst *Alloca = nullptr;
785  const yaml::StringValue &Name = Object.Name;
786  if (!Name.Value.empty()) {
787  Alloca = dyn_cast_or_null<AllocaInst>(
788  F.getValueSymbolTable()->lookup(Name.Value));
789  if (!Alloca)
790  return error(Name.SourceRange.Start,
791  "alloca instruction named '" + Name.Value +
792  "' isn't defined in the function '" + F.getName() +
793  "'");
794  }
795  if (!TFI->isSupportedStackID(Object.StackID))
796  return error(Object.ID.SourceRange.Start,
797  Twine("StackID is not supported by target"));
799  ObjectIdx =
800  MFI.CreateVariableSizedObject(Object.Alignment.valueOrOne(), Alloca);
801  else
802  ObjectIdx = MFI.CreateStackObject(
803  Object.Size, Object.Alignment.valueOrOne(),
805  Object.StackID);
806  MFI.setObjectOffset(ObjectIdx, Object.Offset);
807 
808  if (!PFS.StackObjectSlots.insert(std::make_pair(Object.ID.Value, ObjectIdx))
809  .second)
810  return error(Object.ID.SourceRange.Start,
811  Twine("redefinition of stack object '%stack.") +
812  Twine(Object.ID.Value) + "'");
813  if (parseCalleeSavedRegister(PFS, CSIInfo, Object.CalleeSavedRegister,
814  Object.CalleeSavedRestored, ObjectIdx))
815  return true;
816  if (Object.LocalOffset)
817  MFI.mapLocalFrameObject(ObjectIdx, *Object.LocalOffset);
818  if (parseStackObjectsDebugInfo(PFS, Object, ObjectIdx))
819  return true;
820  }
821  MFI.setCalleeSavedInfo(CSIInfo);
822  if (!CSIInfo.empty())
823  MFI.setCalleeSavedInfoValid(true);
824 
825  // Initialize the various stack object references after initializing the
826  // stack objects.
827  if (!YamlMFI.StackProtector.Value.empty()) {
829  int FI;
830  if (parseStackObjectReference(PFS, FI, YamlMFI.StackProtector.Value, Error))
831  return error(Error, YamlMFI.StackProtector.SourceRange);
832  MFI.setStackProtectorIndex(FI);
833  }
834 
835  if (!YamlMFI.FunctionContext.Value.empty()) {
837  int FI;
838  if (parseStackObjectReference(PFS, FI, YamlMFI.FunctionContext.Value, Error))
839  return error(Error, YamlMFI.FunctionContext.SourceRange);
840  MFI.setFunctionContextIndex(FI);
841  }
842 
843  return false;
844 }
845 
847  std::vector<CalleeSavedInfo> &CSIInfo,
848  const yaml::StringValue &RegisterSource, bool IsRestored, int FrameIdx) {
849  if (RegisterSource.Value.empty())
850  return false;
851  Register Reg;
853  if (parseNamedRegisterReference(PFS, Reg, RegisterSource.Value, Error))
854  return error(Error, RegisterSource.SourceRange);
855  CalleeSavedInfo CSI(Reg, FrameIdx);
856  CSI.setRestored(IsRestored);
857  CSIInfo.push_back(CSI);
858  return false;
859 }
860 
861 /// Verify that given node is of a certain type. Return true on error.
862 template <typename T>
863 static bool typecheckMDNode(T *&Result, MDNode *Node,
864  const yaml::StringValue &Source,
865  StringRef TypeString, MIRParserImpl &Parser) {
866  if (!Node)
867  return false;
868  Result = dyn_cast<T>(Node);
869  if (!Result)
870  return Parser.error(Source.SourceRange.Start,
871  "expected a reference to a '" + TypeString +
872  "' metadata node");
873  return false;
874 }
875 
876 template <typename T>
878  const T &Object, int FrameIdx) {
879  // Debug information can only be attached to stack objects; Fixed stack
880  // objects aren't supported.
881  MDNode *Var = nullptr, *Expr = nullptr, *Loc = nullptr;
882  if (parseMDNode(PFS, Var, Object.DebugVar) ||
883  parseMDNode(PFS, Expr, Object.DebugExpr) ||
884  parseMDNode(PFS, Loc, Object.DebugLoc))
885  return true;
886  if (!Var && !Expr && !Loc)
887  return false;
888  DILocalVariable *DIVar = nullptr;
889  DIExpression *DIExpr = nullptr;
890  DILocation *DILoc = nullptr;
891  if (typecheckMDNode(DIVar, Var, Object.DebugVar, "DILocalVariable", *this) ||
892  typecheckMDNode(DIExpr, Expr, Object.DebugExpr, "DIExpression", *this) ||
893  typecheckMDNode(DILoc, Loc, Object.DebugLoc, "DILocation", *this))
894  return true;
895  PFS.MF.setVariableDbgInfo(DIVar, DIExpr, FrameIdx, DILoc);
896  return false;
897 }
898 
899 bool MIRParserImpl::parseMDNode(PerFunctionMIParsingState &PFS,
900  MDNode *&Node, const yaml::StringValue &Source) {
901  if (Source.Value.empty())
902  return false;
904  if (llvm::parseMDNode(PFS, Node, Source.Value, Error))
905  return error(Error, Source.SourceRange);
906  return false;
907 }
908 
911  DenseMap<unsigned, unsigned> &ConstantPoolSlots = PFS.ConstantPoolSlots;
912  const MachineFunction &MF = PFS.MF;
913  const auto &M = *MF.getFunction().getParent();
915  for (const auto &YamlConstant : YamlMF.Constants) {
916  if (YamlConstant.IsTargetSpecific)
917  // FIXME: Support target-specific constant pools
918  return error(YamlConstant.Value.SourceRange.Start,
919  "Can't parse target-specific constant pool entries yet");
920  const Constant *Value = dyn_cast_or_null<Constant>(
921  parseConstantValue(YamlConstant.Value.Value, Error, M));
922  if (!Value)
923  return error(Error, YamlConstant.Value.SourceRange);
924  const Align PrefTypeAlign =
925  M.getDataLayout().getPrefTypeAlign(Value->getType());
926  const Align Alignment = YamlConstant.Alignment.value_or(PrefTypeAlign);
927  unsigned Index = ConstantPool.getConstantPoolIndex(Value, Alignment);
928  if (!ConstantPoolSlots.insert(std::make_pair(YamlConstant.ID.Value, Index))
929  .second)
930  return error(YamlConstant.ID.SourceRange.Start,
931  Twine("redefinition of constant pool item '%const.") +
932  Twine(YamlConstant.ID.Value) + "'");
933  }
934  return false;
935 }
936 
938  const yaml::MachineJumpTable &YamlJTI) {
940  for (const auto &Entry : YamlJTI.Entries) {
941  std::vector<MachineBasicBlock *> Blocks;
942  for (const auto &MBBSource : Entry.Blocks) {
943  MachineBasicBlock *MBB = nullptr;
944  if (parseMBBReference(PFS, MBB, MBBSource.Value))
945  return true;
946  Blocks.push_back(MBB);
947  }
948  unsigned Index = JTI->createJumpTableIndex(Blocks);
949  if (!PFS.JumpTableSlots.insert(std::make_pair(Entry.ID.Value, Index))
950  .second)
951  return error(Entry.ID.SourceRange.Start,
952  Twine("redefinition of jump table entry '%jump-table.") +
953  Twine(Entry.ID.Value) + "'");
954  }
955  return false;
956 }
957 
958 bool MIRParserImpl::parseMBBReference(PerFunctionMIParsingState &PFS,
960  const yaml::StringValue &Source) {
962  if (llvm::parseMBBReference(PFS, MBB, Source.Value, Error))
963  return error(Error, Source.SourceRange);
964  return false;
965 }
966 
967 bool MIRParserImpl::parseMachineMetadata(PerFunctionMIParsingState &PFS,
968  const yaml::StringValue &Source) {
970  if (llvm::parseMachineMetadata(PFS, Source.Value, Source.SourceRange, Error))
971  return error(Error, Source.SourceRange);
972  return false;
973 }
974 
977  const yaml::MachineFunction &YMF) {
978  for (const auto &MDS : YMF.MachineMetadataNodes) {
979  if (parseMachineMetadata(PFS, MDS))
980  return true;
981  }
982  // Report missing definitions from forward referenced nodes.
983  if (!PFS.MachineForwardRefMDNodes.empty())
984  return error(PFS.MachineForwardRefMDNodes.begin()->second.second,
985  "use of undefined metadata '!" +
986  Twine(PFS.MachineForwardRefMDNodes.begin()->first) + "'");
987  return false;
988 }
989 
990 SMDiagnostic MIRParserImpl::diagFromMIStringDiag(const SMDiagnostic &Error,
991  SMRange SourceRange) {
992  assert(SourceRange.isValid() && "Invalid source range");
993  SMLoc Loc = SourceRange.Start;
994  bool HasQuote = Loc.getPointer() < SourceRange.End.getPointer() &&
995  *Loc.getPointer() == '\'';
996  // Translate the location of the error from the location in the MI string to
997  // the corresponding location in the MIR file.
998  Loc = Loc.getFromPointer(Loc.getPointer() + Error.getColumnNo() +
999  (HasQuote ? 1 : 0));
1000 
1001  // TODO: Translate any source ranges as well.
1002  return SM.GetMessage(Loc, Error.getKind(), Error.getMessage(), None,
1003  Error.getFixIts());
1004 }
1005 
1006 SMDiagnostic MIRParserImpl::diagFromBlockStringDiag(const SMDiagnostic &Error,
1007  SMRange SourceRange) {
1008  assert(SourceRange.isValid());
1009 
1010  // Translate the location of the error from the location in the llvm IR string
1011  // to the corresponding location in the MIR file.
1012  auto LineAndColumn = SM.getLineAndColumn(SourceRange.Start);
1013  unsigned Line = LineAndColumn.first + Error.getLineNo() - 1;
1014  unsigned Column = Error.getColumnNo();
1015  StringRef LineStr = Error.getLineContents();
1016  SMLoc Loc = Error.getLoc();
1017 
1018  // Get the full line and adjust the column number by taking the indentation of
1019  // LLVM IR into account.
1020  for (line_iterator L(*SM.getMemoryBuffer(SM.getMainFileID()), false), E;
1021  L != E; ++L) {
1022  if (L.line_number() == Line) {
1023  LineStr = *L;
1024  Loc = SMLoc::getFromPointer(LineStr.data());
1025  auto Indent = LineStr.find(Error.getLineContents());
1026  if (Indent != StringRef::npos)
1027  Column += Indent;
1028  break;
1029  }
1030  }
1031 
1032  return SMDiagnostic(SM, Loc, Filename, Line, Column, Error.getKind(),
1033  Error.getMessage(), LineStr, Error.getRanges(),
1034  Error.getFixIts());
1035 }
1036 
1037 MIRParser::MIRParser(std::unique_ptr<MIRParserImpl> Impl)
1038  : Impl(std::move(Impl)) {}
1039 
1040 MIRParser::~MIRParser() = default;
1041 
1042 std::unique_ptr<Module>
1044  return Impl->parseIRModule(DataLayoutCallback);
1045 }
1046 
1048  return Impl->parseMachineFunctions(M, MMI);
1049 }
1050 
1051 std::unique_ptr<MIRParser> llvm::createMIRParserFromFile(
1053  std::function<void(Function &)> ProcessIRFunction) {
1054  auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
1055  if (std::error_code EC = FileOrErr.getError()) {
1057  "Could not open input file: " + EC.message());
1058  return nullptr;
1059  }
1060  return createMIRParser(std::move(FileOrErr.get()), Context,
1061  ProcessIRFunction);
1062 }
1063 
1064 std::unique_ptr<MIRParser>
1065 llvm::createMIRParser(std::unique_ptr<MemoryBuffer> Contents,
1067  std::function<void(Function &)> ProcessIRFunction) {
1068  auto Filename = Contents->getBufferIdentifier();
1071  DS_Error,
1072  SMDiagnostic(
1073  Filename, SourceMgr::DK_Error,
1074  "Can't read MIR with a Context that discards named Values")));
1075  return nullptr;
1076  }
1077  return std::make_unique<MIRParser>(std::make_unique<MIRParserImpl>(
1078  std::move(Contents), Filename, Context, ProcessIRFunction));
1079 }
llvm::MIRParserImpl::reportDiagnostic
void reportDiagnostic(const SMDiagnostic &Diag)
Definition: MIRParser.cpp:210
llvm::MachineRegisterInfo::addLiveIn
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
Definition: MachineRegisterInfo.h:959
MemoryBuffer.h
llvm::yaml::MachineFunction::RegBankSelected
bool RegBankSelected
Definition: MIRYamlMapping.h:694
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:72
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:108
llvm::PerFunctionMIParsingState::SM
SourceMgr * SM
Definition: MIParser.h:165
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::yaml::MachineFunction::HasEHFunclets
bool HasEHFunclets
Definition: MIRYamlMapping.h:705
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:1310
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:177
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:1043
llvm::MachineFrameInfo::setReturnAddressIsTaken
void setReturnAddressIsTaken(bool s)
Definition: MachineFrameInfo.h:377
llvm::line_iterator
A forward iterator which reads text lines from a buffer.
Definition: LineIterator.h:33
DebugInfoMetadata.h
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:50
T
llvm::Function
Definition: Function.h:60
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:721
llvm::MachineFunction::assignBeginEndSections
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
Definition: MachineFunction.cpp:359
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:145
llvm::MachineFrameInfo::setCVBytesOfCalleeSavedRegisters
void setCVBytesOfCalleeSavedRegisters(unsigned S)
Definition: MachineFrameInfo.h:663
llvm::yaml::StringValue::SourceRange
SMRange SourceRange
Definition: MIRYamlMapping.h:36
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:52
llvm::MIRParserImpl::error
bool error(const Twine &Message)
Report an error with the given message at unknown location.
Definition: MIRParser.cpp:192
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:1181
llvm::yaml::MachineFunction::StackObjects
std::vector< MachineStackObject > StackObjects
Definition: MIRYamlMapping.h:716
llvm::PerFunctionMIParsingState::StackObjectSlots
DenseMap< unsigned, int > StackObjectSlots
Definition: MIParser.h:176
MIRParser.h
llvm::yaml::MachineFunction::TracksRegLiveness
bool TracksRegLiveness
Definition: MIRYamlMapping.h:698
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
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:361
llvm::MachineFunction::getOrCreateJumpTableInfo
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist,...
Definition: MachineFunction.cpp:292
llvm::MachineFunction::setCallsUnwindInit
void setCallsUnwindInit(bool b)
Definition: MachineFunction.h:1091
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:237
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1557
DenseMap.h
Module.h
llvm::parseMachineInstructions
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
Definition: MIParser.cpp:3502
llvm::MachineFrameInfo::setStackSize
void setStackSize(uint64_t Size)
Set the size of the stack.
Definition: MachineFrameInfo.h:580
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:142
llvm::yaml::MachineFunction::Alignment
MaybeAlign Alignment
Definition: MIRYamlMapping.h:690
llvm::TargetSubtargetInfo::mirFileLoaded
virtual void mirFileLoaded(MachineFunction &MF) const
This is called after a .mir file was loaded.
Definition: TargetSubtargetInfo.cpp:60
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:846
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:127
llvm::MachineFrameInfo::setMaxCallFrameSize
void setMaxCallFrameSize(unsigned S)
Definition: MachineFrameInfo.h:656
llvm::MachineRegisterInfo::getNumVirtRegs
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
Definition: MachineRegisterInfo.h:770
llvm::MIRParserImpl::parseStackObjectsDebugInfo
bool parseStackObjectsDebugInfo(PerFunctionMIParsingState &PFS, const T &Object, int FrameIdx)
Definition: MIRParser.cpp:877
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:46
llvm::MachineFrameInfo::setAdjustsStack
void setAdjustsStack(bool V)
Definition: MachineFrameInfo.h:602
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
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
llvm::DIExpression
DWARF expression.
Definition: DebugInfoMetadata.h:2558
llvm::MachineFunction::setHasEHFunclets
void setHasEHFunclets(bool V)
Definition: MachineFunction.h:1100
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:937
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1628
llvm::yaml::MachineFrameInfo::CVBytesOfCalleeSavedRegisters
unsigned CVBytesOfCalleeSavedRegisters
Definition: MIRYamlMapping.h:610
llvm::yaml::MachineFunction::Name
StringRef Name
Definition: MIRYamlMapping.h:689
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::MIRParserImpl::parseRegisterInfo
bool parseRegisterInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:577
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:490
F
#define F(x, y, z)
Definition: MD5.cpp:55
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:3496
llvm::SourceMgr::DK_Remark
@ DK_Remark
Definition: SourceMgr.h:36
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::MachineRegisterInfo::tracksLiveness
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
Definition: MachineRegisterInfo.h:195
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:724
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::MachineFrameInfo::setHasStackMap
void setHasStackMap(bool s=true)
Definition: MachineFrameInfo.h:383
llvm::MachineBasicBlock::push_back
void push_back(MachineInstr *MI)
Definition: MachineBasicBlock.h:902
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:666
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:115
llvm::parseStackObjectReference
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3531
llvm::parseMDNode
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3537
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:909
llvm::DILocalVariable
Local variable.
Definition: DebugInfoMetadata.h:3058
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:707
llvm::DS_Warning
@ DS_Warning
Definition: DiagnosticInfo.h:51
llvm::MachineOperand::isUse
bool isUse() const
Definition: MachineOperand.h:369
llvm::MachineFrameInfo::setCalleeSavedInfoValid
void setCalleeSavedInfoValid(bool v)
Definition: MachineFrameInfo.h:794
llvm::yaml::MachineFunction::CallsUnwindInit
bool CallsUnwindInit
Definition: MIRYamlMapping.h:702
llvm::yaml::MachineFunction::MachineFuncInfo
std::unique_ptr< MachineFunctionInfo > MachineFuncInfo
Constant pool.
Definition: MIRYamlMapping.h:718
llvm::MachineOperand::getRegMask
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
Definition: MachineOperand.h:639
llvm::MachineModuleInfo::getTarget
const LLVMTargetMachine & getTarget() const
Definition: MachineModuleInfo.h:141
llvm::SMDiagnostic
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:281
llvm::MachineFunction::getProperties
const MachineFunctionProperties & getProperties() const
Get the function properties.
Definition: MachineFunction.h:747
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::MachineFunction::size
unsigned size() const
Definition: MachineFunction.h:863
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:48
llvm::MachineFrameInfo::setHasOpaqueSPAdjustment
void setHasOpaqueSPAdjustment(bool B)
Definition: MachineFrameInfo.h:610
llvm::MachineFunctionProperties::set
MachineFunctionProperties & set(Property P)
Definition: MachineFunction.h:196
llvm::MachineRegisterInfo::setCalleeSavedRegs
void setCalleeSavedRegs(ArrayRef< MCPhysReg > CSRs)
Sets the updated Callee Saved Registers list.
Definition: MachineRegisterInfo.cpp:630
llvm::BasicBlockSection::Labels
@ Labels
llvm::MachineModuleInfo
This class contains meta information specific to a module.
Definition: MachineModuleInfo.h:74
llvm::DiagnosticSeverity
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
Definition: DiagnosticInfo.h:49
SMLoc.h
LineIterator.h
llvm::SourceMgr::getMainFileID
unsigned getMainFileID() const
Definition: SourceMgr.h:132
llvm::yaml::MachineFunction::CalleeSavedRegisters
Optional< std::vector< FlowStringValue > > CalleeSavedRegisters
Definition: MIRYamlMapping.h:711
llvm::yaml::MachineFrameInfo::HasVAStart
bool HasVAStart
Definition: MIRYamlMapping.h:612
llvm::MachineFunction::begin
iterator begin()
Definition: MachineFunction.h:853
llvm::StringRef::data
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:131
llvm::MachineFunction::setHasWinCFI
void setHasWinCFI(bool v)
Definition: MachineFunction.h:741
llvm::MachineRegisterInfo::freezeReservedRegs
void freezeReservedRegs(const MachineFunction &)
freezeReservedRegs - Called by the register allocator to freeze the set of reserved registers before ...
Definition: MachineRegisterInfo.cpp:509
llvm::MIRParserImpl::MIRParserImpl
MIRParserImpl(std::unique_ptr< MemoryBuffer > Contents, StringRef Filename, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction)
Definition: MIRParser.cpp:181
llvm::yaml::MachineFunction::FrameInfo
MachineFrameInfo FrameInfo
Definition: MIRYamlMapping.h:714
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::yaml::MachineFrameInfo::HasCalls
bool HasCalls
Definition: MIRYamlMapping.h:606
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:340
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
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:24
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
SourceMgr.h
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
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:434
llvm::SourceMgr::getMemoryBuffer
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Definition: SourceMgr.h:125
llvm::StringRef::equals
bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:164
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: STLFunctionalExtras.h:36
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:656
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:787
llvm::MachineFrameInfo::setHasMustTailInVarArgFunc
void setHasMustTailInVarArgFunc(bool B)
Definition: MachineFrameInfo.h:627
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:695
llvm::parseMachineMetadata
bool parseMachineMetadata(PerFunctionMIParsingState &PFS, StringRef Src, SMRange SourceRange, SMDiagnostic &Error)
Definition: MIParser.cpp:3542
llvm::TargetFrameLowering::isSupportedStackID
virtual bool isSupportedStackID(TargetStackID::Value ID) const
Definition: TargetFrameLowering.h:436
llvm::MachineFunction::addCallArgsForwardingRegs
void addCallArgsForwardingRegs(const MachineInstr *CallI, CallSiteInfoImpl &&CallInfo)
Start tracking the arguments passed to the call CallI.
Definition: MachineFunction.h:1236
llvm::MachineOperand::isReg
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Definition: MachineOperand.h:320
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:66
llvm::PerFunctionMIParsingState::getVRegInfo
VRegInfo & getVRegInfo(Register Num)
Definition: MIParser.cpp:321
llvm::MachineFunction::setHasEHCatchret
void setHasEHCatchret(bool V)
Definition: MachineFunction.h:1094
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:61
llvm::LLVMContext::shouldDiscardValueNames
bool shouldDiscardValueNames() const
Return true if the Context runtime configuration is set to discard all value names.
Definition: LLVMContext.cpp:336
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:650
llvm::yaml::MachineFrameInfo::FunctionContext
StringValue FunctionContext
Definition: MIRYamlMapping.h:608
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:1065
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:67
llvm::MIRParser::~MIRParser
~MIRParser()
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
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:146
llvm::yaml::MachineFunction::FailsVerification
bool FailsVerification
Definition: MIRYamlMapping.h:707
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::MachineFunctionProperties::Property::TracksDebugUserValues
@ TracksDebugUserValues
llvm::MachineFrameInfo::setObjectOffset
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
Definition: MachineFrameInfo.h:552
MachineConstantPool.h
llvm::MachineFunctionProperties::Property::RegBankSelected
@ RegBankSelected
llvm::MachineFrameInfo::setRestorePoint
void setRestorePoint(MachineBasicBlock *NewRestore)
Definition: MachineFrameInfo.h:799
llvm::MachineFrameInfo::setFunctionContextIndex
void setFunctionContextIndex(int I)
Definition: MachineFrameInfo.h:364
llvm::MachineFrameInfo::mapLocalFrameObject
void mapLocalFrameObject(int ObjectIndex, int64_t Offset)
Map a frame index into the local object block.
Definition: MachineFrameInfo.h:418
llvm::yaml::MachineFunction
Definition: MIRYamlMapping.h:688
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:794
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition: MachineFunction.cpp:567
llvm::yaml::MachineFunction::FixedStackObjects
std::vector< FixedMachineStackObject > FixedStackObjects
Definition: MIRYamlMapping.h:715
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:1051
llvm::MachineFrameInfo::setHasTailCall
void setHasTailCall(bool V=true)
Definition: MachineFrameInfo.h:631
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:458
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:688
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:1666
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:672
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:863
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:447
llvm::MachineOperand::isRegMask
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
Definition: MachineOperand.h:344
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
llvm::MIRParserImpl::initializeFrameInfo
bool initializeFrameInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:715
MachineModuleInfo.h
llvm::MIRParserImpl::parseMachineMetadataNodes
bool parseMachineMetadataNodes(PerFunctionMIParsingState &PFS, MachineFunction &MF, const yaml::MachineFunction &YMF)
Definition: MIRParser.cpp:975
llvm::MachineOperand::getReg
Register getReg() const
getReg - Returns the register number.
Definition: MachineOperand.h:359
llvm::MachineRegisterInfo::hasOneDef
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
Definition: MachineRegisterInfo.h:452
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MDNode
Metadata node.
Definition: Metadata.h:944
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:797
llvm::yaml::MachineStackObject::SpillSlot
@ SpillSlot
Definition: MIRYamlMapping.h:241
llvm::MachineFunction
Definition: MachineFunction.h:257
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:98
llvm::yaml::MachineFrameInfo::MaxCallFrameSize
unsigned MaxCallFrameSize
~0u means: not computed yet.
Definition: MIRYamlMapping.h:609
llvm::yaml::MachineFunction::Legalized
bool Legalized
Definition: MIRYamlMapping.h:693
llvm::MachineFrameInfo::setStackID
void setStackID(int ObjectIdx, uint8_t ID)
Definition: MachineFrameInfo.h:728
llvm::MachineFrameInfo::setHasCalls
void setHasCalls(bool V)
Definition: MachineFrameInfo.h:606
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:576
llvm::MachineFunction::setHasEHScopes
void setHasEHScopes(bool V)
Definition: MachineFunction.h:1097
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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:143
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:696
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:97
llvm::MachineRegisterInfo::invalidateLiveness
void invalidateLiveness()
invalidateLiveness - Indicates that register liveness is no longer being tracked accurately.
Definition: MachineRegisterInfo.h:205
llvm::MIRParser::MIRParser
MIRParser(std::unique_ptr< MIRParserImpl > Impl)
Definition: MIRParser.cpp:1037
llvm::MachineModuleInfo::getOrCreateMachineFunction
MachineFunction & getOrCreateMachineFunction(Function &F)
Returns the MachineFunction constructed for the IR function F.
Definition: MachineModuleInfo.cpp:108
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:634
llvm::MachineFunctionProperties::Property::TiedOpsRewritten
@ TiedOpsRewritten
llvm::yaml::MachineFrameInfo::HasStackMap
bool HasStackMap
Definition: MIRYamlMapping.h:600
llvm::MachineFunctionProperties::reset
MachineFunctionProperties & reset(Property P)
Definition: MachineFunction.h:201
llvm::yaml::MachineFunction::HasEHScopes
bool HasEHScopes
Definition: MIRYamlMapping.h:704
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:310
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MachineOperand::getSubReg
unsigned getSubReg() const
Definition: MachineOperand.h:364
Parser.h
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:720
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::PerFunctionMIParsingState
Definition: MIParser.h:162
llvm::yaml::MachineFunction::VirtualRegisters
std::vector< VirtualRegisterDefinition > VirtualRegisters
Definition: MIRYamlMapping.h:709
llvm::yaml::MachineFunction::ExposesReturnsTwice
bool ExposesReturnsTwice
Definition: MIRYamlMapping.h:691
llvm::MachineFunctionProperties::Property::FailedISel
@ FailedISel
llvm::parseNamedRegisterReference
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3519
llvm::LLVMContext::diagnose
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Definition: LLVMContext.cpp:248
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::MIRParserImpl::initializeCallSiteInfo
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:388
llvm::yaml::MachineFrameInfo::IsReturnAddressTaken
bool IsReturnAddressTaken
Definition: MIRYamlMapping.h:599
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:622
llvm::TargetSubtargetInfo::getFrameLowering
virtual const TargetFrameLowering * getFrameLowering() const
Definition: TargetSubtargetInfo.h:94
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:33
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:652
llvm::MIRParserImpl
This class implements the parsing of LLVM IR that's embedded inside a MIR file.
Definition: MIRParser.cpp:51
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:103
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:155
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:492
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:881
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:230
llvm::yaml::MachineFunction::TracksDebugUserValues
bool TracksDebugUserValues
Definition: MIRYamlMapping.h:708
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:414
llvm::SourceMgr::AddNewSourceBuffer
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
Definition: SourceMgr.h:144
llvm::MIRParserImpl::createDummyFunction
Function * createDummyFunction(StringRef Name, Module &M)
Create an empty function with the given name.
Definition: MIRParser.cpp:281
SlotMapping.h
llvm::PerFunctionMIParsingState::MF
MachineFunction & MF
Definition: MIParser.h:164
llvm::MachineFrameInfo::setStackProtectorIndex
void setStackProtectorIndex(int I)
Definition: MachineFrameInfo.h:358
llvm::MIRParserImpl::parseMachineFunctions
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI)
Definition: MIRParser.cpp:267
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:270
llvm::parseVirtualRegisterReference
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3525
llvm::VRegInfo
Definition: MIParser.h:37
llvm::yaml::MachineFunction::LiveIns
std::vector< MachineFunctionLiveIn > LiveIns
Definition: MIRYamlMapping.h:710
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:180
llvm::MachineInstr::IgnoreBundle
@ IgnoreBundle
Definition: MachineInstr.h:809
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:222
llvm::yaml::MachineFunction::HasWinCFI
bool HasWinCFI
Definition: MIRYamlMapping.h:699
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:105
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:723
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
llvm::SMRange
Represents a range in source code.
Definition: SMLoc.h:48
llvm::MachineFrameInfo::setHasPatchPoint
void setHasPatchPoint(bool s=true)
Definition: MachineFrameInfo.h:389
llvm::yaml::MachineFunction::MachineMetadataNodes
std::vector< StringValue > MachineMetadataNodes
Definition: MIRYamlMapping.h:722
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:589
llvm::parseRegisterReference
bool parseRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3513
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::StringRef::find
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:281
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:188
llvm::UnreachableInst
This function has undefined behavior.
Definition: Instructions.h:4771
StringMap.h
LLVMContext.h
llvm::MachineFrameInfo::setFrameAddressIsTaken
void setFrameAddressIsTaken(bool T)
Definition: MachineFrameInfo.h:371
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:59
llvm::MIRParserImpl::parseMachineFunction
bool parseMachineFunction(Module &M, MachineModuleInfo &MMI)
Parse the machine function in the current YAML document.
Definition: MIRParser.cpp:295
llvm::MachineJumpTableInfo
Definition: MachineJumpTableInfo.h:42
llvm::yaml::MachineFunction::CallSitesInfo
std::vector< CallSiteInfo > CallSitesInfo
Definition: MIRYamlMapping.h:719
MachineFunction.h
llvm::parseMBBReference
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
Definition: MIParser.cpp:3507
llvm::VRegInfo::GENERIC
@ GENERIC
Definition: MIParser.h:39
llvm::MachineFunction::setBBSectionsType
void setBBSectionsType(BasicBlockSection V)
Definition: MachineFunction.h:645
llvm::yaml::MachineFunction::CallsEHReturn
bool CallsEHReturn
Definition: MIRYamlMapping.h:701
llvm::MachineFrameInfo::setLocalFrameSize
void setLocalFrameSize(int64_t sz)
Set the size of the local object blob.
Definition: MachineFrameInfo.h:434
llvm::DiagnosticInfoMIRParser
Diagnostic information for machine IR parser.
Definition: DiagnosticInfo.h:937
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MachineFrameInfo::setHasVAStart
void setHasVAStart(bool B)
Definition: MachineFrameInfo.h:623
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:1047
llvm::DS_Error
@ DS_Error
Definition: DiagnosticInfo.h:50
isSSA
static bool isSSA(const MachineFunction &MF)
Definition: MIRParser.cpp:331
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:1225
llvm::MachineFunction::setCallsEHReturn
void setCallsEHReturn(bool b)
Definition: MachineFunction.h:1088
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:56
llvm::yaml::MachineFunction::HasEHCatchret
bool HasEHCatchret
Definition: MIRYamlMapping.h:703
llvm::yaml::MachineFunction::Constants
std::vector< MachineConstantPoolValue > Constants
Definition: MIRYamlMapping.h:717
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:300
llvm::MIRParserImpl::setupRegisterInfo
bool setupRegisterInfo(const PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
Definition: MIRParser.cpp:658
MIParser.h
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:923
llvm::MachineFunctionProperties::Property::Legalized
@ Legalized
llvm::DS_Note
@ DS_Note
Definition: DiagnosticInfo.h:55