15 #include "llvm/ADT/APFloat.h" 
   16 #include "llvm/ADT/SmallVector.h" 
   17 #include "llvm/ADT/TypeSwitch.h" 
   18 #include <type_traits> 
   27 static void write(DIExpressionElemAttr attribute,
 
   29 static LogicalResult writeAttribute(
Attribute attribute,
 
   39 template <
class EntryTy>
 
   42   if (storage.empty()) {
 
   48   writer.
writeList(storage, [&](EntryTy val) {
 
   49     if constexpr (std::is_base_of_v<Attribute, EntryTy>) {
 
   51     } 
else if constexpr (std::is_integral_v<EntryTy>) {
 
   54       static_assert(
true, 
"EntryTy not supported");
 
   59 template <
class EntryTy>
 
   62   bool isPresent = 
false;
 
   69   auto readEntry = [&]() -> FailureOr<EntryTy> {
 
   71     if constexpr (std::is_base_of_v<Attribute, EntryTy>) {
 
   74     } 
else if constexpr (std::is_integral_v<EntryTy>) {
 
   78       static_assert(
true, 
"EntryTy not supported");
 
   83   return reader.
readList(storage, readEntry);
 
   90 template <
class EntryTy>
 
   92                              std::optional<EntryTy> storage) {
 
   93   static_assert(std::is_integral_v<EntryTy>,
 
   94                 "EntryTy must be an integral type");
 
   95   EntryTy val = storage.value_or(0);
 
   99 template <
class EntryTy>
 
  101                                      std::optional<EntryTy> &storage) {
 
  102   static_assert(std::is_integral_v<EntryTy>,
 
  103                 "EntryTy must be an integral type");
 
  109     storage = 
static_cast<EntryTy
>(result);
 
  111     storage = std::nullopt;
 
  119 #include "mlir/Dialect/LLVMIR/LLVMDialectBytecode.cpp.inc" 
  127   LLVMDialectBytecodeInterface(
Dialect *dialect)
 
  135   LogicalResult writeAttribute(
Attribute attr,
 
  137     return ::writeAttribute(attr, writer);
 
  145   LogicalResult writeType(
Type type,
 
  147     return ::writeType(type, writer);
 
  153   dialect->addInterfaces<LLVMDialectBytecodeInterface>();
 
static MLIRContext * getContext(OpFoldResult val)
Attributes are known-constant values of operations.
This class defines a virtual interface for reading a bytecode stream, providing hooks into the byteco...
virtual LogicalResult readBool(bool &result)=0
Read a bool from the bytecode.
virtual LogicalResult readVarInt(uint64_t &result)=0
Read a variable width integer.
LogicalResult readVarIntWithFlag(uint64_t &result, bool &flag)
Parse a variable length encoded integer whose low bit is used to encode an unrelated flag,...
virtual LogicalResult readOptionalAttribute(Attribute &attr)=0
Read an optional reference to the given attribute.
LogicalResult readList(SmallVectorImpl< T > &result, CallbackFn &&callback)
Read out a list of elements, invoking the provided callback for each element.
This class defines a virtual interface for writing to a bytecode stream, providing hooks into the byt...
virtual void writeOptionalAttribute(Attribute attr)=0
virtual void writeVarInt(uint64_t value)=0
Write a variable width integer to the output stream.
void writeVarIntWithFlag(uint64_t value, bool flag)
Write a VarInt and a flag packed together.
void writeList(RangeT &&range, CallbackFn &&callback)
Write out a list of elements, invoking the provided callback for each element.
virtual void writeOwnedBool(bool value)=0
Write a bool to the output stream.
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
void addBytecodeInterface(LLVMDialect *dialect)
Add the interfaces necessary for encoding the LLVM dialect components in bytecode.
Include the generated interface declarations.