LLVM  14.0.0git
MIRYamlMapping.cpp
Go to the documentation of this file.
1 //===- MIRYamlMapping.cpp - Describe mapping between MIR and YAML ---------===//
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 mapping between various MIR data structures and
10 // their corresponding YAML representation.
11 //
12 //===----------------------------------------------------------------------===//
13 
16 #include "llvm/Support/Error.h"
18 
19 using namespace llvm;
20 using namespace llvm::yaml;
21 
24  if (IsFixed)
25  FI -= MFI.getObjectIndexBegin();
26  this->FI = FI;
27 }
28 
29 // Returns the value and if the frame index is fixed or not.
31  int FI = this->FI;
32  if (IsFixed) {
33  if (unsigned(FI) >= MFI.getNumFixedObjects())
34  return make_error<StringError>(
35  formatv("invalid fixed frame index {0}", FI).str(),
37  FI += MFI.getObjectIndexBegin();
38  }
39  if (unsigned(FI + MFI.getNumFixedObjects()) >= MFI.getNumObjects())
40  return make_error<StringError>(formatv("invalid frame index {0}", FI).str(),
42  return FI;
43 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MachineFrameInfo::getNumFixedObjects
unsigned getNumFixedObjects() const
Return the number of fixed objects.
Definition: MachineFrameInfo.h:396
Error.h
llvm::yaml::FrameIndex::IsFixed
bool IsFixed
Definition: MIRYamlMapping.h:392
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::formatv
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Definition: FormatVariadic.h:250
MIRYamlMapping.h
llvm::MachineFrameInfo::isFixedObjectIndex
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
Definition: MachineFrameInfo.h:656
llvm::MachineFrameInfo::getObjectIndexBegin
int getObjectIndexBegin() const
Return the minimum frame object index.
Definition: MachineFrameInfo.h:390
FormatVariadic.h
llvm::yaml::FrameIndex::FrameIndex
FrameIndex()
Definition: MIRYamlMapping.h:395
llvm::yaml::FrameIndex::FI
int FI
Definition: MIRYamlMapping.h:391
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77
MachineFrameInfo.h
llvm::yaml
Definition: MIRYamlMapping.h:30
llvm::MachineFrameInfo::getNumObjects
unsigned getNumObjects() const
Return the number of objects.
Definition: MachineFrameInfo.h:399
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:107
llvm::yaml::FrameIndex::getFI
Expected< int > getFI(const llvm::MachineFrameInfo &MFI) const
Definition: MIRYamlMapping.cpp:30