14#ifndef LLVM_CODEGEN_MIRYAMLMAPPING_H
15#define LLVM_CODEGEN_MIRYAMLMAPPING_H
53 S.
Value = Scalar.str();
54 if (
const auto *
Node =
55 reinterpret_cast<yaml::Input *
>(Ctx)->getCurrentNode())
70 return ScalarTraits<StringValue>::output(S,
nullptr,
OS);
74 return ScalarTraits<StringValue>::input(Scalar, Ctx, S);
90 return ScalarTraits<StringValue>::output(S.
Value, Ctx,
OS);
94 return ScalarTraits<StringValue>::input(Scalar, Ctx, S.
Value);
114 return ScalarTraits<unsigned>::output(
Value.
Value, Ctx,
OS);
118 if (
const auto *
Node =
119 reinterpret_cast<yaml::Input *
>(Ctx)->getCurrentNode())
121 return ScalarTraits<unsigned>::input(Scalar, Ctx,
Value.
Value);
125 return ScalarTraits<unsigned>::mustQuote(Scalar);
132 IO.enumCase(EntryKind,
"block-address",
133 MachineJumpTableInfo::EK_BlockAddress);
134 IO.enumCase(EntryKind,
"gp-rel64-block-address",
135 MachineJumpTableInfo::EK_GPRel64BlockAddress);
136 IO.enumCase(EntryKind,
"gp-rel32-block-address",
137 MachineJumpTableInfo::EK_GPRel32BlockAddress);
138 IO.enumCase(EntryKind,
"label-difference32",
139 MachineJumpTableInfo::EK_LabelDifference32);
140 IO.enumCase(EntryKind,
"label-difference64",
141 MachineJumpTableInfo::EK_LabelDifference64);
142 IO.enumCase(EntryKind,
"inline", MachineJumpTableInfo::EK_Inline);
143 IO.enumCase(EntryKind,
"custom32", MachineJumpTableInfo::EK_Custom32);
150 out <<
uint64_t(Alignment ? Alignment->value() : 0U);
153 unsigned long long n;
155 return "invalid number";
157 return "must be 0 or a power of two";
164template <>
struct ScalarTraits<
Align> {
169 unsigned long long N;
171 return "invalid number";
173 return "must be a power of two";
208 YamlIO.mapOptional(
"preferred-register",
Reg.PreferredRegister,
210 YamlIO.mapOptional(
"flags",
Reg.RegisterFlags,
211 std::vector<FlowStringValue>());
214 static const bool flow =
true;
235 static const bool flow =
true;
276 IO.enumCase(
Type,
"default", MachineStackObject::DefaultType);
277 IO.enumCase(
Type,
"spill-slot", MachineStackObject::SpillSlot);
278 IO.enumCase(
Type,
"variable-sized", MachineStackObject::VariableSized);
284 YamlIO.mapRequired(
"id", Object.ID);
285 YamlIO.mapOptional(
"name", Object.Name,
290 YamlIO.mapOptional(
"offset", Object.Offset, (int64_t)0);
292 YamlIO.mapRequired(
"size", Object.Size);
293 YamlIO.mapOptional(
"alignment", Object.Alignment, std::nullopt);
295 YamlIO.mapOptional(
"callee-saved-register", Object.CalleeSavedRegister,
297 YamlIO.mapOptional(
"callee-saved-restored", Object.CalleeSavedRestored,
299 YamlIO.mapOptional(
"local-offset", Object.LocalOffset,
300 std::optional<int64_t>());
301 YamlIO.mapOptional(
"debug-info-variable", Object.DebugVar,
303 YamlIO.mapOptional(
"debug-info-expression", Object.DebugExpr,
305 YamlIO.mapOptional(
"debug-info-location", Object.DebugLoc,
309 static const bool flow =
true;
328 YamlIO.mapRequired(
"entry-value-register", Object.EntryValueRegister);
329 YamlIO.mapRequired(
"debug-info-variable", Object.DebugVar);
330 YamlIO.mapRequired(
"debug-info-expression", Object.DebugExpr);
331 YamlIO.mapRequired(
"debug-info-location", Object.DebugLoc);
333 static const bool flow =
true;
370 IO.enumCase(
Type,
"default", FixedMachineStackObject::DefaultType);
371 IO.enumCase(
Type,
"spill-slot", FixedMachineStackObject::SpillSlot);
376struct ScalarEnumerationTraits<TargetStackID::
Value> {
378 IO.enumCase(
ID,
"default", TargetStackID::Default);
379 IO.enumCase(
ID,
"sgpr-spill", TargetStackID::SGPRSpill);
380 IO.enumCase(
ID,
"scalable-vector", TargetStackID::ScalableVector);
381 IO.enumCase(
ID,
"wasm-local", TargetStackID::WasmLocal);
382 IO.enumCase(
ID,
"noalloc", TargetStackID::NoAlloc);
388 YamlIO.mapRequired(
"id", Object.ID);
392 YamlIO.mapOptional(
"offset", Object.Offset, (int64_t)0);
394 YamlIO.mapOptional(
"alignment", Object.Alignment, std::nullopt);
397 YamlIO.mapOptional(
"isImmutable", Object.IsImmutable,
false);
398 YamlIO.mapOptional(
"isAliased", Object.IsAliased,
false);
400 YamlIO.mapOptional(
"callee-saved-register", Object.CalleeSavedRegister,
402 YamlIO.mapOptional(
"callee-saved-restored", Object.CalleeSavedRestored,
404 YamlIO.mapOptional(
"debug-info-variable", Object.DebugVar,
406 YamlIO.mapOptional(
"debug-info-expression", Object.DebugExpr,
408 YamlIO.mapOptional(
"debug-info-location", Object.DebugLoc,
412 static const bool flow =
true;
433 MachineOperand::printStackObjectReference(
OS, FI.
FI, FI.
IsFixed,
"");
439 if (Scalar.starts_with(
"%stack.")) {
440 Num = Scalar.substr(7);
441 }
else if (Scalar.starts_with(
"%fixed-stack.")) {
442 Num = Scalar.substr(13);
445 return "Invalid frame index, needs to start with %stack. or "
449 return "Invalid frame index, not a valid number";
451 if (
const auto *
Node =
452 reinterpret_cast<yaml::Input *
>(Ctx)->getCurrentNode())
498 static const bool flow =
true;
513 std::vector<CallSiteInfo::ArgRegPair>());
516 static const bool flow =
true;
542 static const bool flow =
true;
568 YamlIO.mapOptional(
"alignment",
Constant.Alignment, std::nullopt);
569 YamlIO.mapOptional(
"isTargetSpecific",
Constant.IsTargetSpecific,
false);
593 YamlIO.mapRequired(
"id", Entry.ID);
594 YamlIO.mapOptional(
"blocks", Entry.Blocks, std::vector<FlowStringValue>());
615 YamlIO.mapRequired(
"kind", JT.Kind);
616 YamlIO.mapOptional(
"entries", JT.Entries,
617 std::vector<MachineJumpTable::Entry>());
664 Other.CVBytesOfCalleeSavedRegisters &&
691 YamlIO.mapOptional(
"cvBytesOfCalleeSavedRegisters",
717 static void mapping(IO &
YamlIO, std::unique_ptr<MachineFunctionInfo> &MFI) {
784 YamlIO.mapOptional(
"noPhis", MF.
NoPHIs, std::optional<bool>());
785 YamlIO.mapOptional(
"isSSA", MF.
IsSSA, std::optional<bool>());
786 YamlIO.mapOptional(
"noVRegs", MF.
NoVRegs, std::optional<bool>());
801 std::vector<VirtualRegisterDefinition>());
803 std::vector<MachineFunctionLiveIn>());
805 std::optional<std::vector<FlowStringValue>>());
808 std::vector<FixedMachineStackObject>());
810 std::vector<MachineStackObject>());
812 std::vector<EntryValueObject>());
814 std::vector<CallSiteInfo>());
816 std::vector<DebugValueSubstitution>());
818 std::vector<MachineConstantPoolValue>());
824 std::vector<StringValue>());
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type)
This is an important base class in LLVM.
Tagged union holding either a T or a Error.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
JTEntryKind
JTEntryKind - This enum indicates how each entry of the jump table is represented and emitted.
@ EK_Custom32
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
Wrapper class representing virtual and physical registers.
Represents a range in source code.
StringRef - Represent a constant reference to a string, i.e.
bool consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
Value(Type *Ty, unsigned scid)
This class implements an extremely fast bulk output stream that can only output to a stream.
Abstract base class for all Nodes.
SMRange getSourceRange() const
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
static void output(const BlockStringValue &S, void *Ctx, raw_ostream &OS)
static StringRef input(StringRef Scalar, void *Ctx, BlockStringValue &S)
bool operator==(const BlockStringValue &Other) const
bool operator==(const ArgRegPair &Other) const
Identifies call instruction location in machine function.
bool operator==(const MachineInstrLoc &Other) const
Serializable representation of CallSiteInfo.
std::vector< ArgRegPair > ArgForwardingRegs
MachineInstrLoc CallLocation
bool operator==(const CallSiteInfo &Other) const
Serializable representation of debug value substitutions.
bool operator==(const DebugValueSubstitution &Other) const
Serializable representation of the MCRegister variant of MachineFunction::VariableDbgInfo.
bool operator==(const EntryValueObject &Other) const
StringValue EntryValueRegister
Serializable representation of the fixed stack object from the MachineFrameInfo class.
bool operator==(const FixedMachineStackObject &Other) const
StringValue CalleeSavedRegister
TargetStackID::Value StackID
FlowStringValue(std::string Value)
FlowStringValue()=default
A serializaable representation of a reference to a stack object or fixed stack object.
Expected< int > getFI(const llvm::MachineFrameInfo &MFI) const
bool operator==(const MachineConstantPoolValue &Other) const
Serializable representation of MachineFrameInfo.
bool operator==(const MachineFrameInfo &Other) const
bool IsCalleeSavedInfoValid
unsigned MaxCallFrameSize
~0u means: not computed yet.
StringValue StackProtector
bool HasMustTailInVarArgFunc
unsigned CVBytesOfCalleeSavedRegisters
bool HasOpaqueSPAdjustment
bool IsReturnAddressTaken
StringValue FunctionContext
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
virtual void mappingImpl(IO &YamlIO)
virtual ~MachineFunctionInfo()=default
bool operator==(const MachineFunctionLiveIn &Other) const
StringValue VirtualRegister
std::vector< MachineStackObject > StackObjects
std::vector< StringValue > MachineMetadataNodes
std::optional< std::vector< FlowStringValue > > CalleeSavedRegisters
std::optional< bool > HasFakeUses
std::vector< EntryValueObject > EntryValueObjects
std::optional< bool > NoPHIs
bool TracksDebugUserValues
std::vector< MachineConstantPoolValue > Constants
std::optional< bool > NoVRegs
std::vector< CallSiteInfo > CallSitesInfo
std::vector< MachineFunctionLiveIn > LiveIns
std::vector< VirtualRegisterDefinition > VirtualRegisters
std::vector< FixedMachineStackObject > FixedStackObjects
std::optional< bool > IsSSA
std::vector< DebugValueSubstitution > DebugValueSubstitutions
std::unique_ptr< MachineFunctionInfo > MachineFuncInfo
Constant pool.
MachineJumpTable JumpTableInfo
MachineFrameInfo FrameInfo
bool operator==(const Entry &Other) const
std::vector< FlowStringValue > Blocks
bool operator==(const MachineJumpTable &Other) const
std::vector< Entry > Entries
MachineJumpTableInfo::JTEntryKind Kind
Serializable representation of stack object from the MachineFrameInfo class.
StringValue CalleeSavedRegister
bool operator==(const MachineStackObject &Other) const
TargetStackID::Value StackID
std::optional< int64_t > LocalOffset
static void mapping(IO &YamlIO, CallSiteInfo &CSInfo)
static void mapping(IO &YamlIO, CallSiteInfo::ArgRegPair &ArgReg)
static void mapping(IO &YamlIO, DebugValueSubstitution &Sub)
static void mapping(yaml::IO &YamlIO, EntryValueObject &Object)
static void mapping(yaml::IO &YamlIO, FixedMachineStackObject &Object)
static void mapping(IO &YamlIO, MachineConstantPoolValue &Constant)
static void mapping(IO &YamlIO, MachineFrameInfo &MFI)
static void mapping(IO &YamlIO, MachineFunctionLiveIn &LiveIn)
static void mapping(IO &YamlIO, MachineFunction &MF)
static void mapping(IO &YamlIO, MachineJumpTable &JT)
static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry)
static void mapping(yaml::IO &YamlIO, MachineStackObject &Object)
static void mapping(IO &YamlIO, VirtualRegisterDefinition &Reg)
static void mapping(IO &YamlIO, std::unique_ptr< MachineFunctionInfo > &MFI)
static void enumeration(yaml::IO &IO, FixedMachineStackObject::ObjectType &Type)
static void enumeration(yaml::IO &IO, MachineJumpTableInfo::JTEntryKind &EntryKind)
static void enumeration(yaml::IO &IO, MachineStackObject::ObjectType &Type)
static void enumeration(yaml::IO &IO, TargetStackID::Value &ID)
static StringRef input(StringRef Scalar, void *, Align &Alignment)
static QuotingType mustQuote(StringRef)
static void output(const Align &Alignment, void *, llvm::raw_ostream &OS)
static QuotingType mustQuote(StringRef S)
static void output(const FlowStringValue &S, void *, raw_ostream &OS)
static StringRef input(StringRef Scalar, void *Ctx, FlowStringValue &S)
static void output(const FrameIndex &FI, void *, raw_ostream &OS)
static StringRef input(StringRef Scalar, void *Ctx, FrameIndex &FI)
static QuotingType mustQuote(StringRef S)
static StringRef input(StringRef Scalar, void *, MaybeAlign &Alignment)
static void output(const MaybeAlign &Alignment, void *, llvm::raw_ostream &out)
static QuotingType mustQuote(StringRef)
static StringRef input(StringRef Scalar, void *Ctx, StringValue &S)
static QuotingType mustQuote(StringRef S)
static void output(const StringValue &S, void *, raw_ostream &OS)
static StringRef input(StringRef Scalar, void *Ctx, UnsignedValue &Value)
static QuotingType mustQuote(StringRef Scalar)
static void output(const UnsignedValue &Value, void *Ctx, raw_ostream &OS)
A wrapper around std::string which contains a source range that's being set during parsing.
StringValue(const char Val[])
StringValue(std::string Value)
bool operator==(const StringValue &Other) const
A wrapper around unsigned which contains a source range that's being set during parsing.
bool operator==(const UnsignedValue &Other) const
UnsignedValue(unsigned Value)
bool operator==(const VirtualRegisterDefinition &Other) const
std::vector< FlowStringValue > RegisterFlags
StringValue PreferredRegister