CIRCT  18.0.0git
Classes | Namespaces | Functions
Schema.cpp File Reference
#include "ESICapnp.h"
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/ESI/ESITypes.h"
#include "circt/Dialect/HW/HWDialect.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/HWTypes.h"
#include "circt/Dialect/SV/SVOps.h"
#include "circt/Dialect/Seq/SeqOps.h"
#include "mlir/Support/IndentedOstream.h"
#include "capnp/schema-parser.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "llvm/ADT/IntervalMap.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Format.h"
#include <initializer_list>
#include <string>
Include dependency graph for Schema.cpp:

Go to the source code of this file.

Classes

struct  circt::esi::capnp::detail::CapnpTypeSchemaImpl
 Actual implementation of CapnpTypeSchema to keep all the details out of the header. More...
 

Namespaces

 circt
 This file defines an intermediate representation for circuits acting as an abstraction for constraints defined over an SMT's solver context.
 
 circt::esi
 
 circt::esi::capnp
 
 circt::esi::capnp::detail
 

Functions

static size_t bitsEncoding (::capnp::schema::Type::Reader type)
 Return the encoding value for the size of this type (from the encoding spec): 0 = 0 bits, 1 = 1 bit, 2 = 1 byte, 3 = 2 bytes, 4 = 4 bytes, 5 = 8 bytes (non-pointer), 6 = 8 bytes (pointer). More...
 
static size_t bits (::capnp::schema::Type::Reader type)
 Return the number of bits used by a Capnp type. More...
 
static bool isPointerType (::capnp::schema::Type::Reader type)
 Return true if 'type' is capnp pointer. More...
 
static int64_t size (hw::ArrayType mType, capnp::schema::Field::Reader cField)
 Returns the expected size of an array (capnp list) in 64-bit words. More...
 
static int64_t size (capnp::schema::Node::Struct::Reader cStruct, ArrayRef< hw::StructType::FieldInfo > mFields)
 Compute the size of a capnp struct, in 64-bit words. More...
 
static void emitCapnpType (Type type, llvm::raw_ostream &os)
 Write a valid Capnp type. More...
 
static GasketComponent decodeList (hw::ArrayType type, capnp::schema::Field::Reader field, Slice ptrSection, AssertBuilder &asserts)
 Construct the proper operations to decode a capnp list. More...
 
static GasketComponent decodeField (Type type, capnp::schema::Field::Reader field, Slice dataSection, Slice ptrSection, AssertBuilder &asserts)
 Construct the proper operations to convert a capnp field to 'type'. More...
 

Function Documentation

◆ bits()

static size_t bits ( ::capnp::schema::Type::Reader  type)
static

Return the number of bits used by a Capnp type.

Definition at line 121 of file Schema.cpp.

References bitsEncoding().

Referenced by circt::sv::CaseBitPattern::CaseBitPattern(), decodeField(), decodeList(), getCommonOperand(), circt::hw::isOffset(), and size().

◆ bitsEncoding()

static size_t bitsEncoding ( ::capnp::schema::Type::Reader  type)
static

Return the encoding value for the size of this type (from the encoding spec): 0 = 0 bits, 1 = 1 bit, 2 = 1 byte, 3 = 2 bytes, 4 = 4 bytes, 5 = 8 bytes (non-pointer), 6 = 8 bytes (pointer).

Definition at line 89 of file Schema.cpp.

Referenced by bits().

◆ decodeField()

static GasketComponent decodeField ( Type  type,
capnp::schema::Field::Reader  field,
Slice  dataSection,
Slice  ptrSection,
AssertBuilder &  asserts 
)
static

Construct the proper operations to convert a capnp field to 'type'.

Definition at line 953 of file Schema.cpp.

References bits(), and decodeList().

Referenced by circt::esi::capnp::detail::CapnpTypeSchemaImpl::buildDecoder().

◆ decodeList()

static GasketComponent decodeList ( hw::ArrayType  type,
capnp::schema::Field::Reader  field,
Slice  ptrSection,
AssertBuilder &  asserts 
)
static

Construct the proper operations to decode a capnp list.

This only works for arrays of ints or bools. Will need to be updated for structs and lists of lists.

Definition at line 860 of file Schema.cpp.

References assert(), and bits().

Referenced by decodeField().

◆ emitCapnpType()

static void emitCapnpType ( Type  type,
llvm::raw_ostream &  os 
)
static

Write a valid Capnp type.

Definition at line 235 of file Schema.cpp.

References assert().

Referenced by circt::esi::capnp::detail::CapnpTypeSchemaImpl::write().

◆ isPointerType()

static bool isPointerType ( ::capnp::schema::Type::Reader  type)
static

Return true if 'type' is capnp pointer.

Definition at line 131 of file Schema.cpp.

◆ size() [1/2]

static int64_t size ( capnp::schema::Node::Struct::Reader  cStruct,
ArrayRef< hw::StructType::FieldInfo >  mFields 
)
static

Compute the size of a capnp struct, in 64-bit words.

Definition at line 203 of file Schema.cpp.

References assert(), and size().

◆ size() [2/2]

static int64_t size ( hw::ArrayType  mType,
capnp::schema::Field::Reader  cField 
)
static

Returns the expected size of an array (capnp list) in 64-bit words.

Definition at line 193 of file Schema.cpp.

References assert(), and bits().

Referenced by circt::calyx::ComponentLoweringStateInterface::addBlockArgReg(), addSigArrayElements(), circt::llhd::sim::State::addSignalData(), circt::llhd::sim::State::addSignalElement(), addSigStructElement(), circt::pretty::PrettyPrinter::advanceLeft(), allocSignal(), customTypeParser(), dotPrintNode(), circt::pretty::detail::emitNBSP(), circt::scheduling::detail::DependenceIterator::findNextDependence(), foldCreateToSlice(), circt::moore::UnpackedArrayDim::get(), circt::moore::UnpackedType::getBitSize(), circt::moore::PackedType::getBitSize(), getBitWidthFromVectorSize(), getCommonOperand(), circt::moore::IntType::getKindFromDomainAndSize(), ModuleSizeCache::getModuleSize(), circt::llhd::sim::UpdateQueue::getOrCreateSlot(), getRegStateTy(), PipelineLowering::getStageEgressNames(), hwArrayTypeGet(), circt::llhd::sim::Slot::insertChange(), lowerCirctIsX(), lowerCirctSizeof(), circt::msft::makeSequentialRange(), mergeConcatSlices(), EmittedExpressionState::mergeState(), moorePackedRangeDimTypeGet(), mooreSimpleBitVectorTypeGet(), mooreUnpackedArrayDimTypeGet(), mooreUnpackedRangeDimTypeGet(), circt::moore::detail::SizedDimStorage::operator==(), circt::firrtl::direction::packAttribute(), parseForkOp(), parseSostOperation(), printParameterList(), StructuralHasher::record(), LowerXMRPass::setPortToRemove(), circt::esi::capnp::detail::CapnpTypeSchemaImpl::size(), size(), sizedPort(), circt::llhd::sim::Signal::toHexString(), circt::llhd::sim::UpdateQueue::top(), tryFlatteningOperands(), and circt::firrtl::direction::unpackAttribute().