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";
207 YamlIO.mapOptional(
"preferred-register",
Reg.PreferredRegister,
211 static const bool flow =
true;
232 static const bool flow =
true;
273 IO.enumCase(
Type,
"default", MachineStackObject::DefaultType);
274 IO.enumCase(
Type,
"spill-slot", MachineStackObject::SpillSlot);
275 IO.enumCase(
Type,
"variable-sized", MachineStackObject::VariableSized);
281 YamlIO.mapRequired(
"id", Object.ID);
282 YamlIO.mapOptional(
"name", Object.Name,
287 YamlIO.mapOptional(
"offset", Object.Offset, (int64_t)0);
289 YamlIO.mapRequired(
"size", Object.Size);
290 YamlIO.mapOptional(
"alignment", Object.Alignment, std::nullopt);
292 YamlIO.mapOptional(
"callee-saved-register", Object.CalleeSavedRegister,
294 YamlIO.mapOptional(
"callee-saved-restored", Object.CalleeSavedRestored,
296 YamlIO.mapOptional(
"local-offset", Object.LocalOffset,
297 std::optional<int64_t>());
298 YamlIO.mapOptional(
"debug-info-variable", Object.DebugVar,
300 YamlIO.mapOptional(
"debug-info-expression", Object.DebugExpr,
302 YamlIO.mapOptional(
"debug-info-location", Object.DebugLoc,
306 static const bool flow =
true;
325 YamlIO.mapRequired(
"entry-value-register", Object.EntryValueRegister);
326 YamlIO.mapRequired(
"debug-info-variable", Object.DebugVar);
327 YamlIO.mapRequired(
"debug-info-expression", Object.DebugExpr);
328 YamlIO.mapRequired(
"debug-info-location", Object.DebugLoc);
330 static const bool flow =
true;
367 IO.enumCase(
Type,
"default", FixedMachineStackObject::DefaultType);
368 IO.enumCase(
Type,
"spill-slot", FixedMachineStackObject::SpillSlot);
373struct ScalarEnumerationTraits<TargetStackID::
Value> {
375 IO.enumCase(
ID,
"default", TargetStackID::Default);
376 IO.enumCase(
ID,
"sgpr-spill", TargetStackID::SGPRSpill);
377 IO.enumCase(
ID,
"scalable-vector", TargetStackID::ScalableVector);
378 IO.enumCase(
ID,
"wasm-local", TargetStackID::WasmLocal);
379 IO.enumCase(
ID,
"noalloc", TargetStackID::NoAlloc);
385 YamlIO.mapRequired(
"id", Object.ID);
389 YamlIO.mapOptional(
"offset", Object.Offset, (int64_t)0);
391 YamlIO.mapOptional(
"alignment", Object.Alignment, std::nullopt);
394 YamlIO.mapOptional(
"isImmutable", Object.IsImmutable,
false);
395 YamlIO.mapOptional(
"isAliased", Object.IsAliased,
false);
397 YamlIO.mapOptional(
"callee-saved-register", Object.CalleeSavedRegister,
399 YamlIO.mapOptional(
"callee-saved-restored", Object.CalleeSavedRestored,
401 YamlIO.mapOptional(
"debug-info-variable", Object.DebugVar,
403 YamlIO.mapOptional(
"debug-info-expression", Object.DebugExpr,
405 YamlIO.mapOptional(
"debug-info-location", Object.DebugLoc,
409 static const bool flow =
true;
430 MachineOperand::printStackObjectReference(
OS, FI.
FI, FI.
IsFixed,
"");
436 if (Scalar.starts_with(
"%stack.")) {
437 Num = Scalar.substr(7);
438 }
else if (Scalar.starts_with(
"%fixed-stack.")) {
439 Num = Scalar.substr(13);
442 return "Invalid frame index, needs to start with %stack. or "
446 return "Invalid frame index, not a valid number";
448 if (
const auto *
Node =
449 reinterpret_cast<yaml::Input *
>(Ctx)->getCurrentNode())
495 static const bool flow =
true;
510 std::vector<CallSiteInfo::ArgRegPair>());
513 static const bool flow =
true;
539 static const bool flow =
true;
565 YamlIO.mapOptional(
"alignment",
Constant.Alignment, std::nullopt);
566 YamlIO.mapOptional(
"isTargetSpecific",
Constant.IsTargetSpecific,
false);
590 YamlIO.mapRequired(
"id", Entry.ID);
591 YamlIO.mapOptional(
"blocks", Entry.Blocks, std::vector<FlowStringValue>());
612 YamlIO.mapRequired(
"kind", JT.Kind);
613 YamlIO.mapOptional(
"entries", JT.Entries,
614 std::vector<MachineJumpTable::Entry>());
661 Other.CVBytesOfCalleeSavedRegisters &&
688 YamlIO.mapOptional(
"cvBytesOfCalleeSavedRegisters",
714 static void mapping(IO &
YamlIO, std::unique_ptr<MachineFunctionInfo> &MFI) {
785 std::vector<VirtualRegisterDefinition>());
787 std::vector<MachineFunctionLiveIn>());
789 std::optional<std::vector<FlowStringValue>>());
792 std::vector<FixedMachineStackObject>());
794 std::vector<MachineStackObject>());
796 std::vector<EntryValueObject>());
798 std::vector<CallSiteInfo>());
800 std::vector<DebugValueSubstitution>());
802 std::vector<MachineConstantPoolValue>());
808 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::vector< EntryValueObject > EntryValueObjects
bool TracksDebugUserValues
std::vector< MachineConstantPoolValue > Constants
std::vector< CallSiteInfo > CallSitesInfo
std::vector< MachineFunctionLiveIn > LiveIns
std::vector< VirtualRegisterDefinition > VirtualRegisters
std::vector< FixedMachineStackObject > FixedStackObjects
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
StringValue PreferredRegister