LLVM 20.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
19using namespace llvm;
20using 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}
Tagged union holding either a T or a Error.
Definition: Error.h:481
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
unsigned getNumObjects() const
Return the number of objects.
unsigned getNumFixedObjects() const
Return the number of fixed objects.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
int getObjectIndexBegin() const
Return the minimum frame object index.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:98
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Expected< int > getFI(const llvm::MachineFrameInfo &MFI) const