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,
"inline", MachineJumpTableInfo::EK_Inline);
141 IO.enumCase(EntryKind,
"custom32", MachineJumpTableInfo::EK_Custom32);
148 out <<
uint64_t(Alignment ? Alignment->value() : 0U);
151 unsigned long long n;
153 return "invalid number";
155 return "must be 0 or a power of two";
162template <>
struct ScalarTraits<
Align> {
164 OS << Alignment.
value();
167 unsigned long long N;
169 return "invalid number";
171 return "must be a power of two";
205 YamlIO.mapOptional(
"preferred-register",
Reg.PreferredRegister,
209 static const bool flow =
true;
230 static const bool flow =
true;
271 IO.enumCase(
Type,
"default", MachineStackObject::DefaultType);
272 IO.enumCase(
Type,
"spill-slot", MachineStackObject::SpillSlot);
273 IO.enumCase(
Type,
"variable-sized", MachineStackObject::VariableSized);
285 YamlIO.mapOptional(
"offset",
Object.Offset, (int64_t)0);
288 YamlIO.mapOptional(
"alignment",
Object.Alignment, std::nullopt);
290 YamlIO.mapOptional(
"callee-saved-register",
Object.CalleeSavedRegister,
292 YamlIO.mapOptional(
"callee-saved-restored",
Object.CalleeSavedRestored,
295 std::optional<int64_t>());
296 YamlIO.mapOptional(
"debug-info-variable",
Object.DebugVar,
298 YamlIO.mapOptional(
"debug-info-expression",
Object.DebugExpr,
300 YamlIO.mapOptional(
"debug-info-location",
Object.DebugLoc,
304 static const bool flow =
true;
341 IO.enumCase(
Type,
"default", FixedMachineStackObject::DefaultType);
342 IO.enumCase(
Type,
"spill-slot", FixedMachineStackObject::SpillSlot);
347struct ScalarEnumerationTraits<TargetStackID::
Value> {
349 IO.enumCase(
ID,
"default", TargetStackID::Default);
350 IO.enumCase(
ID,
"sgpr-spill", TargetStackID::SGPRSpill);
351 IO.enumCase(
ID,
"scalable-vector", TargetStackID::ScalableVector);
352 IO.enumCase(
ID,
"wasm-local", TargetStackID::WasmLocal);
353 IO.enumCase(
ID,
"noalloc", TargetStackID::NoAlloc);
363 YamlIO.mapOptional(
"offset",
Object.Offset, (int64_t)0);
365 YamlIO.mapOptional(
"alignment",
Object.Alignment, std::nullopt);
368 YamlIO.mapOptional(
"isImmutable",
Object.IsImmutable,
false);
369 YamlIO.mapOptional(
"isAliased",
Object.IsAliased,
false);
371 YamlIO.mapOptional(
"callee-saved-register",
Object.CalleeSavedRegister,
373 YamlIO.mapOptional(
"callee-saved-restored",
Object.CalleeSavedRestored,
375 YamlIO.mapOptional(
"debug-info-variable",
Object.DebugVar,
377 YamlIO.mapOptional(
"debug-info-expression",
Object.DebugExpr,
379 YamlIO.mapOptional(
"debug-info-location",
Object.DebugLoc,
383 static const bool flow =
true;
404 MachineOperand::printStackObjectReference(OS, FI.
FI, FI.
IsFixed,
"");
410 if (Scalar.startswith(
"%stack.")) {
411 Num = Scalar.substr(7);
412 }
else if (Scalar.startswith(
"%fixed-stack.")) {
413 Num = Scalar.substr(13);
416 return "Invalid frame index, needs to start with %stack. or "
420 return "Invalid frame index, not a valid number";
422 if (
const auto *
Node =
423 reinterpret_cast<yaml::Input *
>(Ctx)->getCurrentNode())
469 static const bool flow =
true;
484 std::vector<CallSiteInfo::ArgRegPair>());
487 static const bool flow =
true;
513 static const bool flow =
true;
539 YamlIO.mapOptional(
"alignment",
Constant.Alignment, std::nullopt);
540 YamlIO.mapOptional(
"isTargetSpecific",
Constant.IsTargetSpecific,
false);
564 YamlIO.mapRequired(
"id", Entry.ID);
565 YamlIO.mapOptional(
"blocks", Entry.Blocks, std::vector<FlowStringValue>());
585 YamlIO.mapRequired(
"kind", JT.Kind);
586 YamlIO.mapOptional(
"entries", JT.Entries,
587 std::vector<MachineJumpTable::Entry>());
633 Other.CVBytesOfCalleeSavedRegisters &&
659 YamlIO.mapOptional(
"cvBytesOfCalleeSavedRegisters",
683 static void mapping(IO &
YamlIO, std::unique_ptr<MachineFunctionInfo> &MFI) {
751 std::vector<VirtualRegisterDefinition>());
753 std::vector<MachineFunctionLiveIn>());
755 std::optional<std::vector<FlowStringValue>>());
758 std::vector<FixedMachineStackObject>());
760 std::vector<MachineStackObject>());
762 std::vector<CallSiteInfo>());
764 std::vector<DebugValueSubstitution>());
766 std::vector<MachineConstantPoolValue>());
772 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.
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 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
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
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, 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