mirror of https://github.com/llvm/circt.git
Update LLVM to latest (7d246cb) (#342)
* Updating LLVM submodule * Start of LLVM update to 7d246cb19db9fce65946fb4bac6e570787dbe78a * Fixed a few more * Fixed breakage in LLHD due to TypeConverter change. * Fixing some tests with Chris' fix * FIRRTL module parsing change * All tests pass locally * Clang-format Co-authored-by: mikeurbach <mikeurbach@gmail.com>
This commit is contained in:
parent
aef375e78f
commit
abb748f377
|
@ -13,8 +13,8 @@
|
|||
#ifndef CIRCT_DIALECT_ESI_ESIDIALECT_H
|
||||
#define CIRCT_DIALECT_ESI_ESIDIALECT_H
|
||||
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
|
||||
namespace circt {
|
||||
namespace esi {
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef CIRCT_DIALECT_FIRRTL_DIALECT_H
|
||||
#define CIRCT_DIALECT_FIRRTL_DIALECT_H
|
||||
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
|
||||
namespace circt {
|
||||
|
|
|
@ -133,7 +133,7 @@ class BinaryPrimOp<string mnemonic, string resultTypeFunction,
|
|||
`(` type($lhs) `,` type($rhs) `)` `->` type($result)
|
||||
}];
|
||||
|
||||
let extraClassDeclaration = !cast<code>(!strconcat(!cast<string>([{
|
||||
let extraClassDeclaration = !cast<string>(!strconcat(!cast<string>([{
|
||||
/// Return the result for inputs with the specified type, returning a null
|
||||
/// type if the input types are invalid.
|
||||
static FIRRTLType getResultType(FIRRTLType lhs, FIRRTLType rhs,
|
||||
|
@ -199,7 +199,7 @@ class UnaryPrimOp<string mnemonic, string resultTypeFunction,
|
|||
$input attr-dict `:` functional-type($input, $result)
|
||||
}];
|
||||
|
||||
let extraClassDeclaration = !cast<code>(!strconcat(!cast<string>([{
|
||||
let extraClassDeclaration = !cast<string>(!strconcat(!cast<string>([{
|
||||
/// Return the result for inputs with the specified type, returning a null
|
||||
/// type if the input types are invalid.
|
||||
static FIRRTLType getResultType(FIRRTLType input, Location loc) {
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
|
||||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/Function.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "mlir/IR/Operation.h"
|
||||
#include "mlir/IR/RegionKindInterface.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/TypeSupport.h"
|
||||
#include "mlir/IR/Types.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
|
|
@ -66,7 +66,7 @@ def FuncOp : Op<Handshake_Dialect, "func", [
|
|||
let builders =
|
||||
[OpBuilderDAG<(ins "StringRef":$name, "FunctionType":$type,
|
||||
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs,
|
||||
CArg<"ArrayRef<MutableDictionaryAttr>", "{}">:$argAttrs),
|
||||
CArg<"ArrayRef<NamedAttrList>", "{}">:$argAttrs),
|
||||
[{
|
||||
$_state.addAttribute(SymbolTable::getSymbolAttrName(),
|
||||
$_builder.getStringAttr(name));
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#ifndef CIRCT_DIALECT_LLHD_IR_LLHDDIALECT_H
|
||||
#define CIRCT_DIALECT_LLHD_IR_LLHDDIALECT_H
|
||||
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/Function.h"
|
||||
|
||||
namespace circt {
|
||||
namespace llhd {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "circt/Dialect/LLHD/IR/LLHDDialect.h"
|
||||
#include "circt/Dialect/LLHD/IR/LLHDEnums.h.inc"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/Interfaces/ControlFlowInterfaces.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "circt/Dialect/LLHD/IR/LLHDOps.h"
|
||||
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
|
||||
namespace mlir {
|
||||
class ExecutionEngine;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#define CIRCT_DIALECT_RTL_OPS_H
|
||||
|
||||
#include "circt/Dialect/RTL/Dialect.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/FunctionSupport.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "mlir/IR/RegionKindInterface.h"
|
||||
#include "mlir/IR/SymbolTable.h"
|
||||
|
|
|
@ -22,7 +22,7 @@ def ArrayType : RTLType<"Array"> {
|
|||
let genVerifyInvariantsDecl = 1;
|
||||
}
|
||||
|
||||
def InOutType : RTLType<"InOut">, Type<CPred<"$_self.isa<InOutType>()">, "InOutType"> {
|
||||
def InOutType : RTLType<"InOut"> {
|
||||
let summary = "bidirectional type for ports and wires";
|
||||
/*let description = [{
|
||||
InOut type is used for model operations and values that have "connection"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define CIRCT_DIALECT_SV_TYPES_H
|
||||
|
||||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/Types.h"
|
||||
|
||||
#define GET_TYPEDEF_CLASSES
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
|
||||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/Function.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "mlir/IR/Operation.h"
|
||||
#include "mlir/IR/RegionKindInterface.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/TypeSupport.h"
|
||||
#include "mlir/IR/Types.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "circt/Dialect/RTL/Types.h"
|
||||
#include "circt/Dialect/SV/Ops.h"
|
||||
#include "circt/Support/ImplicitLocOpBuilder.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
|
||||
using namespace circt;
|
||||
|
@ -35,7 +35,7 @@ static Type lowerType(Type type) {
|
|||
|
||||
auto width = firType.getBitWidthOrSentinel();
|
||||
if (width >= 0) // IntType, analog with known width, clock, etc.
|
||||
return IntegerType::get(width, type.getContext());
|
||||
return IntegerType::get(type.getContext(), width);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ static unsigned getStdOrLLVMIntegerWidth(Type type) {
|
|||
|
||||
/// Get an existing global string.
|
||||
static Value getGlobalString(Location loc, OpBuilder &builder,
|
||||
LLVMTypeConverter &typeConverter,
|
||||
TypeConverter *typeConverter,
|
||||
LLVM::GlobalOp &str) {
|
||||
auto i8PtrTy = LLVM::LLVMType::getInt8PtrTy(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i8PtrTy = LLVM::LLVMType::getInt8PtrTy(builder.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(builder.getContext());
|
||||
|
||||
auto addr = builder.create<LLVM::AddressOfOp>(
|
||||
loc, str.getType().getPointerTo(), str.getName());
|
||||
|
@ -189,13 +189,13 @@ static LLVM::LLVMType unwrapLLVMPtr(Type ty) {
|
|||
/// defined in. An LLVMType structure containing those types, in order of
|
||||
/// appearance, is returned.
|
||||
static LLVM::LLVMType getProcPersistenceTy(LLVM::LLVMDialect *dialect,
|
||||
LLVMTypeConverter &converter,
|
||||
TypeConverter *converter,
|
||||
ProcOp &proc) {
|
||||
SmallVector<LLVM::LLVMType, 3> types = SmallVector<LLVM::LLVMType, 3>();
|
||||
proc.walk([&](Operation *op) -> void {
|
||||
if (op->isUsedOutsideOfBlock(op->getBlock()) || isWaitDestArg(op)) {
|
||||
auto ty = op->getResult(0).getType();
|
||||
auto convertedTy = converter.convertType(ty);
|
||||
auto convertedTy = converter->convertType(ty);
|
||||
if (ty.isa<PtrType, SigType>()) {
|
||||
// Persist the unwrapped value.
|
||||
types.push_back(unwrapLLVMPtr(convertedTy));
|
||||
|
@ -215,7 +215,7 @@ static LLVM::LLVMType getProcPersistenceTy(LLVM::LLVMDialect *dialect,
|
|||
for (auto arg : block.getArguments()) {
|
||||
if (arg.isUsedOutsideOfBlock(&block)) {
|
||||
types.push_back(
|
||||
converter.convertType(arg.getType()).cast<LLVM::LLVMType>());
|
||||
converter->convertType(arg.getType()).cast<LLVM::LLVMType>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ static Value gepPersistenceState(LLVM::LLVMDialect *dialect, Location loc,
|
|||
/// substituting the uses that escape the block the operation is defined in with
|
||||
/// a load from the persistence table.
|
||||
static void persistValue(LLVM::LLVMDialect *dialect, Location loc,
|
||||
LLVMTypeConverter &converter,
|
||||
TypeConverter *converter,
|
||||
ConversionPatternRewriter &rewriter,
|
||||
LLVM::LLVMType stateTy, int &i, Value state,
|
||||
Value persist) {
|
||||
|
@ -290,7 +290,7 @@ static void persistValue(LLVM::LLVMDialect *dialect, Location loc,
|
|||
Value toStore;
|
||||
if (auto ptr = persist.getType().dyn_cast<PtrType>()) {
|
||||
// Unwrap the pointer and store it's value.
|
||||
auto elemTy = converter.convertType(ptr.getUnderlyingType());
|
||||
auto elemTy = converter->convertType(ptr.getUnderlyingType());
|
||||
toStore = rewriter.create<LLVM::LoadOp>(loc, elemTy, persist);
|
||||
} else if (persist.getType().isa<SigType>()) {
|
||||
// Unwrap and store the signal struct.
|
||||
|
@ -342,7 +342,7 @@ static void persistValue(LLVM::LLVMDialect *dialect, Location loc,
|
|||
|
||||
/// Insert the blocks and operations needed to persist values across suspension,
|
||||
/// as well as ones needed to resume execution at the right spot.
|
||||
static void insertPersistence(LLVMTypeConverter &converter,
|
||||
static void insertPersistence(TypeConverter *converter,
|
||||
ConversionPatternRewriter &rewriter,
|
||||
LLVM::LLVMDialect *dialect, Location loc,
|
||||
ProcOp &proc, LLVM::LLVMType &stateTy,
|
||||
|
@ -747,7 +747,7 @@ struct EntityOpConversion : public ConvertToLLVMPattern {
|
|||
// Collect used llvm types.
|
||||
auto voidTy = getVoidType();
|
||||
auto i8PtrTy = getVoidPtrType();
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
auto sigTy = getLLVMSigType(&getDialect());
|
||||
auto entityStatePtrTy = getRegStateTy(&getDialect(), op).getPointerTo();
|
||||
|
||||
|
@ -851,8 +851,8 @@ struct ProcOpConversion : public ConvertToLLVMPattern {
|
|||
// Collect used llvm types.
|
||||
auto voidTy = getVoidType();
|
||||
auto i8PtrTy = getVoidPtrType();
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(rewriter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
auto senseTableTy =
|
||||
LLVM::LLVMType::getArrayTy(i1Ty, procOp.getNumArguments())
|
||||
.getPointerTo();
|
||||
|
@ -916,7 +916,7 @@ struct ProcOpConversion : public ConvertToLLVMPattern {
|
|||
|
||||
// Convert the block argument types after inserting the persistence, as this
|
||||
// would otherwise interfere with the persistence generation.
|
||||
if (failed(rewriter.convertRegionTypes(&llvmFunc.getBody(), typeConverter,
|
||||
if (failed(rewriter.convertRegionTypes(&llvmFunc.getBody(), *typeConverter,
|
||||
&final))) {
|
||||
return failure();
|
||||
}
|
||||
|
@ -939,8 +939,8 @@ struct HaltOpConversion : public ConvertToLLVMPattern {
|
|||
LogicalResult
|
||||
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(rewriter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
|
||||
auto llvmFunc = op->getParentOfType<LLVM::LLVMFuncOp>();
|
||||
auto procState = llvmFunc.getArgument(1);
|
||||
|
@ -996,9 +996,9 @@ struct WaitOpConversion : public ConvertToLLVMPattern {
|
|||
|
||||
auto voidTy = getVoidType();
|
||||
auto i8PtrTy = getVoidPtrType();
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i64Ty = LLVM::LLVMType::getInt64Ty(&typeConverter.getContext());
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(rewriter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
auto i64Ty = LLVM::LLVMType::getInt64Ty(rewriter.getContext());
|
||||
|
||||
// Get the llhdSuspend runtime function.
|
||||
auto llhdSuspendTy = LLVM::LLVMType::getFunctionTy(
|
||||
|
@ -1098,9 +1098,9 @@ struct InstOpConversion : public ConvertToLLVMPattern {
|
|||
|
||||
auto voidTy = getVoidType();
|
||||
auto i8PtrTy = getVoidPtrType();
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i64Ty = LLVM::LLVMType::getInt64Ty(&typeConverter.getContext());
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(rewriter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
auto i64Ty = LLVM::LLVMType::getInt64Ty(rewriter.getContext());
|
||||
|
||||
// Init function signature: (i8* %state) -> void.
|
||||
auto initFuncTy =
|
||||
|
@ -1228,7 +1228,7 @@ struct InstOpConversion : public ConvertToLLVMPattern {
|
|||
// Walk over the entity and generate mallocs for each one of its signals.
|
||||
child.walk([&](SigOp op) -> void {
|
||||
// if (auto sigOp = dyn_cast<SigOp>(op)) {
|
||||
auto underlyingTy = typeConverter.convertType(op.init().getType())
|
||||
auto underlyingTy = typeConverter->convertType(op.init().getType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
// Get index constant of the signal in the entity's signal table.
|
||||
auto indexConst = initBuilder.create<LLVM::ConstantOp>(
|
||||
|
@ -1389,7 +1389,6 @@ struct InstOpConversion : public ConvertToLLVMPattern {
|
|||
auto procStateBC = initBuilder.create<LLVM::BitcastOp>(
|
||||
op->getLoc(), procStatePtrTy, procStateMall);
|
||||
|
||||
|
||||
// Store the initial resume index.
|
||||
auto resumeGep = initBuilder.create<LLVM::GEPOp>(
|
||||
op->getLoc(), i32Ty.getPointerTo(), procStateBC,
|
||||
|
@ -1468,7 +1467,7 @@ struct SigOpConversion : public ConvertToLLVMPattern {
|
|||
SigOpAdaptor transformed(operands);
|
||||
|
||||
// Collect the used llvm types.
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
auto sigTy = getLLVMSigType(&getDialect());
|
||||
|
||||
// Get the signal table pointer from the arguments.
|
||||
|
@ -1511,7 +1510,7 @@ struct PrbOpConversion : public ConvertToLLVMPattern {
|
|||
|
||||
// Collect the used llvm types.
|
||||
auto resTy = prbOp.getType();
|
||||
auto finalTy = typeConverter.convertType(resTy).cast<LLVM::LLVMType>();
|
||||
auto finalTy = typeConverter->convertType(resTy).cast<LLVM::LLVMType>();
|
||||
|
||||
// Get the signal details from the signal struct.
|
||||
auto sigDetail = getSignalDetail(rewriter, &getDialect(), op->getLoc(),
|
||||
|
@ -1522,8 +1521,7 @@ struct PrbOpConversion : public ConvertToLLVMPattern {
|
|||
// cover the case where a subsignal spans halfway in the last byte.
|
||||
int resWidth = getStdOrLLVMIntegerWidth(resTy);
|
||||
int loadWidth = (llvm::divideCeil(resWidth, 8) + 1) * 8;
|
||||
auto loadTy =
|
||||
LLVM::LLVMType::getIntNTy(&typeConverter.getContext(), loadWidth);
|
||||
auto loadTy = LLVM::LLVMType::getIntNTy(rewriter.getContext(), loadWidth);
|
||||
|
||||
auto bitcast = rewriter.create<LLVM::BitcastOp>(
|
||||
op->getLoc(), loadTy.getPointerTo(), sigDetail[0]);
|
||||
|
@ -1576,9 +1574,9 @@ struct DrvOpConversion : public ConvertToLLVMPattern {
|
|||
// Collect used llvm types.
|
||||
auto voidTy = getVoidType();
|
||||
auto i8PtrTy = getVoidPtrType();
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i64Ty = LLVM::LLVMType::getInt64Ty(&typeConverter.getContext());
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(rewriter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
auto i64Ty = LLVM::LLVMType::getInt64Ty(rewriter.getContext());
|
||||
auto sigTy = getLLVMSigType(&getDialect());
|
||||
|
||||
// Get or insert the drive library call.
|
||||
|
@ -1596,7 +1594,7 @@ struct DrvOpConversion : public ConvertToLLVMPattern {
|
|||
Value sigWidth;
|
||||
auto underlyingTy = drvOp.value().getType();
|
||||
if (isArrayOrTuple(underlyingTy)) {
|
||||
auto llvmPtrTy = typeConverter.convertType(underlyingTy)
|
||||
auto llvmPtrTy = typeConverter->convertType(underlyingTy)
|
||||
.cast<LLVM::LLVMType>()
|
||||
.getPointerTo();
|
||||
auto oneC = rewriter.create<LLVM::ConstantOp>(
|
||||
|
@ -1681,8 +1679,8 @@ struct RegOpConversion : public ConvertToLLVMPattern {
|
|||
auto regOp = cast<RegOp>(op);
|
||||
RegOpAdaptor transformed(operands, op->getAttrDictionary());
|
||||
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i1Ty = LLVM::LLVMType::getInt1Ty(rewriter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
|
||||
auto func = op->getParentOfType<LLVM::LLVMFuncOp>();
|
||||
|
||||
|
@ -1827,7 +1825,7 @@ struct NotOpConversion : public ConvertToLLVMPattern {
|
|||
// Get integer width.
|
||||
unsigned width = getStdOrLLVMIntegerWidth(notOp.getType());
|
||||
// Get the used llvm types.
|
||||
auto iTy = LLVM::LLVMType::getIntNTy(&typeConverter.getContext(), width);
|
||||
auto iTy = LLVM::LLVMType::getIntNTy(rewriter.getContext(), width);
|
||||
|
||||
// Get the all-ones mask operand
|
||||
APInt mask(width, 0);
|
||||
|
@ -1836,7 +1834,7 @@ struct NotOpConversion : public ConvertToLLVMPattern {
|
|||
auto rhsConst = rewriter.create<LLVM::ConstantOp>(op->getLoc(), iTy, rhs);
|
||||
|
||||
rewriter.replaceOpWithNewOp<LLVM::XOrOp>(
|
||||
op, typeConverter.convertType(notOp.getType()), transformed.value(),
|
||||
op, typeConverter->convertType(notOp.getType()), transformed.value(),
|
||||
rhsConst);
|
||||
|
||||
return success();
|
||||
|
@ -1867,7 +1865,7 @@ struct ShrOpConversion : public ConvertToLLVMPattern {
|
|||
auto hdnWidth = getStdOrLLVMIntegerWidth(shrOp.hidden().getType());
|
||||
auto full = baseWidth + hdnWidth;
|
||||
|
||||
auto tmpTy = LLVM::LLVMType::getIntNTy(&typeConverter.getContext(), full);
|
||||
auto tmpTy = LLVM::LLVMType::getIntNTy(rewriter.getContext(), full);
|
||||
|
||||
// Extend all operands the combined width.
|
||||
auto baseZext =
|
||||
|
@ -1907,16 +1905,16 @@ struct ShrOpConversion : public ConvertToLLVMPattern {
|
|||
return success();
|
||||
}
|
||||
if (auto arrTy = shrOp.result().getType().dyn_cast<ArrayType>()) {
|
||||
auto baseTy = typeConverter.convertType(shrOp.base().getType())
|
||||
auto baseTy = typeConverter->convertType(shrOp.base().getType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
auto hiddenTy = typeConverter.convertType(shrOp.hidden().getType())
|
||||
auto hiddenTy = typeConverter->convertType(shrOp.hidden().getType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
auto combinedTy = llhd::ArrayType::get(baseTy.getArrayNumElements() +
|
||||
hiddenTy.getArrayNumElements(),
|
||||
arrTy.getElementType());
|
||||
|
||||
auto combinedArrayInit = rewriter.create<LLVM::UndefOp>(
|
||||
op->getLoc(), typeConverter.convertType(combinedTy));
|
||||
op->getLoc(), typeConverter->convertType(combinedTy));
|
||||
auto insertBase = rewriter.create<InsertSliceOp>(
|
||||
op->getLoc(), combinedTy, combinedArrayInit, shrOp.base(),
|
||||
rewriter.getIndexAttr(0));
|
||||
|
@ -1957,7 +1955,7 @@ struct ShlOpConversion : public ConvertToLLVMPattern {
|
|||
auto hdnWidth = getStdOrLLVMIntegerWidth(shlOp.hidden().getType());
|
||||
auto full = baseWidth + hdnWidth;
|
||||
|
||||
auto tmpTy = LLVM::LLVMType::getIntNTy(&typeConverter.getContext(), full);
|
||||
auto tmpTy = LLVM::LLVMType::getIntNTy(rewriter.getContext(), full);
|
||||
|
||||
// Extend all operands to the combined width.
|
||||
auto baseZext =
|
||||
|
@ -2097,7 +2095,7 @@ struct ConstOpConversion : public ConvertToLLVMPattern {
|
|||
// Handle the time const special case: create a new array containing the
|
||||
// three time values.
|
||||
if (auto timeAttr = attr.dyn_cast<TimeAttr>()) {
|
||||
auto timeTy = typeConverter.convertType(constOp.getResult().getType());
|
||||
auto timeTy = typeConverter->convertType(constOp.getResult().getType());
|
||||
|
||||
// Convert real-time element to ps.
|
||||
llvm::StringMap<uint64_t> map = {
|
||||
|
@ -2117,7 +2115,7 @@ struct ConstOpConversion : public ConvertToLLVMPattern {
|
|||
}
|
||||
|
||||
// Get the converted llvm type.
|
||||
auto intType = typeConverter.convertType(attr.getType());
|
||||
auto intType = typeConverter->convertType(attr.getType());
|
||||
// Replace the operation with an llvm constant op.
|
||||
rewriter.replaceOpWithNewOp<LLVM::ConstantOp>(op, intType,
|
||||
constOp.valueAttr());
|
||||
|
@ -2139,7 +2137,7 @@ struct ArrayOpConversion : public ConvertToLLVMPattern {
|
|||
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
ArrayOpAdaptor transformed(operands);
|
||||
auto arrayTy = typeConverter.convertType(op->getResult(0).getType());
|
||||
auto arrayTy = typeConverter->convertType(op->getResult(0).getType());
|
||||
|
||||
Value arr = rewriter.create<LLVM::UndefOp>(op->getLoc(), arrayTy);
|
||||
for (size_t i = 0, e = transformed.values().size(); i < e; ++i) {
|
||||
|
@ -2168,7 +2166,7 @@ struct ArrayUniformOpConversion : public ConvertToLLVMPattern {
|
|||
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
ArrayUniformOpAdaptor transformed(operands);
|
||||
auto arrayTy = typeConverter.convertType(op->getResult(0).getType())
|
||||
auto arrayTy = typeConverter->convertType(op->getResult(0).getType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
|
||||
Value arr = rewriter.create<LLVM::UndefOp>(op->getLoc(), arrayTy);
|
||||
|
@ -2196,7 +2194,7 @@ struct TupleOpConversion : public ConvertToLLVMPattern {
|
|||
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
TupleOpAdaptor transformed(operands);
|
||||
auto resTy = typeConverter.convertType(op->getResult(0).getType())
|
||||
auto resTy = typeConverter->convertType(op->getResult(0).getType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
|
||||
Value tup = rewriter.create<LLVM::UndefOp>(op->getLoc(), resTy);
|
||||
|
@ -2235,14 +2233,14 @@ struct ExtractSliceOpConversion : public ConvertToLLVMPattern {
|
|||
|
||||
ExtractSliceOpAdaptor transformed(operands);
|
||||
|
||||
auto indexTy = typeConverter.convertType(extsOp.startAttr().getType());
|
||||
auto indexTy = typeConverter->convertType(extsOp.startAttr().getType());
|
||||
|
||||
// Get the attributes as constants.
|
||||
auto startConst = rewriter.create<LLVM::ConstantOp>(op->getLoc(), indexTy,
|
||||
extsOp.startAttr());
|
||||
|
||||
if (auto retTy = extsOp.result().getType().dyn_cast<IntegerType>()) {
|
||||
auto resTy = typeConverter.convertType(extsOp.result().getType())
|
||||
auto resTy = typeConverter->convertType(extsOp.result().getType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
rewriter.replaceOp(op, extractInt(op->getLoc(), rewriter, resTy,
|
||||
transformed.target(), startConst));
|
||||
|
@ -2269,7 +2267,7 @@ struct ExtractSliceOpConversion : public ConvertToLLVMPattern {
|
|||
adjusted.first, adjusted.second));
|
||||
} else if (auto arrTy = resTy.getUnderlyingType().dyn_cast<ArrayType>()) {
|
||||
auto llvmArrTy =
|
||||
typeConverter.convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
typeConverter->convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
auto adjustedPtr = shiftArraySigPointer(
|
||||
op->getLoc(), rewriter, llvmArrTy, sigDetail[0], startConst);
|
||||
rewriter.replaceOp(op,
|
||||
|
@ -2279,12 +2277,12 @@ struct ExtractSliceOpConversion : public ConvertToLLVMPattern {
|
|||
return success();
|
||||
}
|
||||
if (auto arrTy = extsOp.result().getType().dyn_cast<ArrayType>()) {
|
||||
auto elemTy = typeConverter.convertType(arrTy.getElementType());
|
||||
auto llvmArrTy = typeConverter.convertType(arrTy);
|
||||
auto elemTy = typeConverter->convertType(arrTy.getElementType());
|
||||
auto llvmArrTy = typeConverter->convertType(arrTy);
|
||||
size_t startIndex = extsOp.startAttr().getInt();
|
||||
|
||||
Value slice = rewriter.create<LLVM::UndefOp>(
|
||||
op->getLoc(), typeConverter.convertType(arrTy));
|
||||
op->getLoc(), typeConverter->convertType(arrTy));
|
||||
|
||||
// Insert all affected elements into the new slice.
|
||||
for (size_t i = 0, e = arrTy.getLength(); i < e; ++i) {
|
||||
|
@ -2319,10 +2317,10 @@ struct DynExtractSliceOpConversion : public ConvertToLLVMPattern {
|
|||
|
||||
DynExtractSliceOpAdaptor transformed(operands);
|
||||
|
||||
auto i64Ty = LLVM::LLVMType::getInt64Ty(&typeConverter.getContext());
|
||||
auto i64Ty = LLVM::LLVMType::getInt64Ty(rewriter.getContext());
|
||||
|
||||
if (auto retTy = extsOp.result().getType().dyn_cast<IntegerType>()) {
|
||||
auto resTy = typeConverter.convertType(extsOp.result().getType())
|
||||
auto resTy = typeConverter->convertType(extsOp.result().getType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
rewriter.replaceOp(op,
|
||||
extractInt(op->getLoc(), rewriter, resTy,
|
||||
|
@ -2352,7 +2350,7 @@ struct DynExtractSliceOpConversion : public ConvertToLLVMPattern {
|
|||
adjusted.first, adjusted.second));
|
||||
} else if (auto arrTy = resTy.getUnderlyingType().dyn_cast<ArrayType>()) {
|
||||
auto llvmArrTy =
|
||||
typeConverter.convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
typeConverter->convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
|
||||
auto adjustedPtr =
|
||||
shiftArraySigPointer(op->getLoc(), rewriter, llvmArrTy,
|
||||
|
@ -2365,9 +2363,9 @@ struct DynExtractSliceOpConversion : public ConvertToLLVMPattern {
|
|||
}
|
||||
|
||||
if (auto arrTy = extsOp.result().getType().dyn_cast<ArrayType>()) {
|
||||
auto elemTy = typeConverter.convertType(arrTy.getElementType())
|
||||
auto elemTy = typeConverter->convertType(arrTy.getElementType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
auto llvmArrTy = typeConverter.convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
auto llvmArrTy = typeConverter->convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
auto targetTy = transformed.target().getType().cast<LLVM::LLVMType>();
|
||||
|
||||
auto zeroC = rewriter.create<LLVM::ConstantOp>(
|
||||
|
@ -2423,14 +2421,14 @@ struct ExtractElementOpConversion : public ConvertToLLVMPattern {
|
|||
|
||||
if (isArrayOrTuple(extOp.target().getType())) {
|
||||
rewriter.replaceOpWithNewOp<LLVM::ExtractValueOp>(
|
||||
op, typeConverter.convertType(extOp.result().getType()),
|
||||
op, typeConverter->convertType(extOp.result().getType()),
|
||||
transformed.target(), rewriter.getArrayAttr(extOp.indexAttr()));
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
if (auto sigTy = extOp.target().getType().dyn_cast<SigType>()) {
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
|
||||
auto sigDetail =
|
||||
getSignalDetail(rewriter, &getDialect(), op->getLoc(),
|
||||
|
@ -2442,12 +2440,13 @@ struct ExtractElementOpConversion : public ConvertToLLVMPattern {
|
|||
Value adjusted;
|
||||
if (auto arrTy = sigTy.getUnderlyingType().dyn_cast<ArrayType>()) {
|
||||
auto llvmArrTy =
|
||||
typeConverter.convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
typeConverter->convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
adjusted = shiftArraySigPointer(op->getLoc(), rewriter, llvmArrTy,
|
||||
sigDetail[0], indexC);
|
||||
} else {
|
||||
auto llvmStructTy = typeConverter.convertType(sigTy.getUnderlyingType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
auto llvmStructTy =
|
||||
typeConverter->convertType(sigTy.getUnderlyingType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
auto index = extOp.indexAttr().getInt();
|
||||
auto elemPtrTy =
|
||||
llvmStructTy.getStructElementType(index).getPointerTo();
|
||||
|
@ -2482,14 +2481,14 @@ struct DynExtractElementOpConversion : public ConvertToLLVMPattern {
|
|||
DynExtractElementOpAdaptor transformed(operands);
|
||||
|
||||
if (extOp.target().getType().isa<ArrayType, TupleType>()) {
|
||||
auto elemTy = typeConverter.convertType(extOp.getResult().getType())
|
||||
auto elemTy = typeConverter->convertType(extOp.getResult().getType())
|
||||
.cast<LLVM::LLVMType>();
|
||||
|
||||
auto zeroC = rewriter.create<LLVM::ConstantOp>(
|
||||
op->getLoc(), LLVM::LLVMType::getInt32Ty(&typeConverter.getContext()),
|
||||
op->getLoc(), LLVM::LLVMType::getInt32Ty(rewriter.getContext()),
|
||||
rewriter.getI32IntegerAttr(0));
|
||||
auto oneC = rewriter.create<LLVM::ConstantOp>(
|
||||
op->getLoc(), LLVM::LLVMType::getInt32Ty(&typeConverter.getContext()),
|
||||
op->getLoc(), LLVM::LLVMType::getInt32Ty(rewriter.getContext()),
|
||||
rewriter.getI32IntegerAttr(1));
|
||||
auto arrPtr = rewriter.create<LLVM::AllocaOp>(
|
||||
op->getLoc(),
|
||||
|
@ -2508,7 +2507,7 @@ struct DynExtractElementOpConversion : public ConvertToLLVMPattern {
|
|||
if (auto sigTy = extOp.target().getType().dyn_cast<SigType>()) {
|
||||
if (auto arrTy = sigTy.getUnderlyingType().dyn_cast<ArrayType>()) {
|
||||
auto llvmArrTy =
|
||||
typeConverter.convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
typeConverter->convertType(arrTy).cast<LLVM::LLVMType>();
|
||||
|
||||
auto sigDetail =
|
||||
getSignalDetail(rewriter, &getDialect(), op->getLoc(),
|
||||
|
@ -2549,7 +2548,7 @@ struct InsertSliceOpConversion : public ConvertToLLVMPattern {
|
|||
|
||||
InsertSliceOpAdaptor transformed(operands);
|
||||
|
||||
auto indexTy = typeConverter.convertType(inssOp.startAttr().getType());
|
||||
auto indexTy = typeConverter->convertType(inssOp.startAttr().getType());
|
||||
|
||||
if (inssOp.result().getType().isa<IntegerType>()) {
|
||||
auto startConst = rewriter.create<LLVM::ConstantOp>(op->getLoc(), indexTy,
|
||||
|
@ -2567,7 +2566,7 @@ struct InsertSliceOpConversion : public ConvertToLLVMPattern {
|
|||
auto maskConst = rewriter.create<LLVM::ConstantOp>(
|
||||
op->getLoc(), transformed.target().getType(),
|
||||
rewriter.getIntegerAttr(
|
||||
IntegerType::get(width, rewriter.getContext()), mask));
|
||||
IntegerType::get(rewriter.getContext(), width), mask));
|
||||
|
||||
// Generate a mask for the slice, to avoid resetting bits outside of the
|
||||
// slice.
|
||||
|
@ -2575,7 +2574,7 @@ struct InsertSliceOpConversion : public ConvertToLLVMPattern {
|
|||
auto sliceMaskConst = rewriter.create<LLVM::ConstantOp>(
|
||||
op->getLoc(), transformed.target().getType(),
|
||||
rewriter.getIntegerAttr(
|
||||
IntegerType::get(width, rewriter.getContext()), mask));
|
||||
IntegerType::get(rewriter.getContext(), width), mask));
|
||||
|
||||
// Adjust the slice to the start index.
|
||||
auto sliceZext =
|
||||
|
@ -2595,8 +2594,8 @@ struct InsertSliceOpConversion : public ConvertToLLVMPattern {
|
|||
return success();
|
||||
}
|
||||
if (auto arrTy = inssOp.result().getType().dyn_cast<ArrayType>()) {
|
||||
auto elemTy = typeConverter.convertType(arrTy.getElementType());
|
||||
auto llvmArrTy = typeConverter.convertType(arrTy);
|
||||
auto elemTy = typeConverter->convertType(arrTy.getElementType());
|
||||
auto llvmArrTy = typeConverter->convertType(arrTy);
|
||||
auto llvmSliceTy = transformed.slice().getType().cast<LLVM::LLVMType>();
|
||||
size_t startIndex = inssOp.startAttr().getInt();
|
||||
|
||||
|
@ -2657,7 +2656,7 @@ struct VarOpConversion : ConvertToLLVMPattern {
|
|||
ConversionPatternRewriter &rewriter) const override {
|
||||
VarOpAdaptor transformed(operands);
|
||||
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(&typeConverter.getContext());
|
||||
auto i32Ty = LLVM::LLVMType::getInt32Ty(rewriter.getContext());
|
||||
|
||||
auto oneC = rewriter.create<LLVM::ConstantOp>(
|
||||
op->getLoc(), i32Ty, rewriter.getI32IntegerAttr(1));
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/Function.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
#include "mlir/IR/Types.h"
|
||||
|
|
|
@ -29,27 +29,6 @@ ESIDialect::ESIDialect(MLIRContext *context)
|
|||
#include "circt/Dialect/ESI/ESI.cpp.inc"
|
||||
>();
|
||||
}
|
||||
|
||||
/// Parses a type registered to this dialect
|
||||
Type ESIDialect::parseType(DialectAsmParser &parser) const {
|
||||
llvm::StringRef mnemonic;
|
||||
if (parser.parseKeyword(&mnemonic))
|
||||
return Type();
|
||||
auto genType = generatedTypeParser(getContext(), parser, mnemonic);
|
||||
if (genType != Type())
|
||||
return genType;
|
||||
parser.emitError(parser.getCurrentLocation(),
|
||||
llvm::formatv("Could not parse esi.{0}!\n", mnemonic));
|
||||
return Type();
|
||||
}
|
||||
|
||||
/// Print a type registered to this dialect
|
||||
void ESIDialect::printType(Type type, DialectAsmPrinter &printer) const {
|
||||
if (succeeded(generatedTypePrinter(type, printer)))
|
||||
return;
|
||||
llvm_unreachable("unexpected 'esi' type kind");
|
||||
}
|
||||
|
||||
} // namespace esi
|
||||
} // namespace circt
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "circt/Dialect/SV/Types.h"
|
||||
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/SymbolTable.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
@ -42,7 +42,7 @@ static ParseResult parseChannelBuffer(OpAsmParser &parser,
|
|||
ChannelPort::get(parser.getBuilder().getContext(), innerOutputType);
|
||||
result.addTypes({outputType});
|
||||
|
||||
auto i1 = IntegerType::get(1, result.getContext());
|
||||
auto i1 = IntegerType::get(result.getContext(), 1);
|
||||
if (parser.resolveOperands(operands, {i1, i1, outputType}, inputOperandsLoc,
|
||||
result.operands))
|
||||
return failure();
|
||||
|
@ -75,7 +75,7 @@ static ParseResult parsePipelineStage(OpAsmParser &parser,
|
|||
ChannelPort::get(parser.getBuilder().getContext(), innerOutputType);
|
||||
result.addTypes({type});
|
||||
|
||||
auto i1 = IntegerType::get(1, result.getContext());
|
||||
auto i1 = IntegerType::get(result.getContext(), 1);
|
||||
if (parser.resolveOperands(operands, {i1, i1, type}, inputOperandsLoc,
|
||||
result.operands))
|
||||
return failure();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "circt/Dialect/RTL/Types.h"
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
|
@ -208,7 +208,7 @@ LogicalResult PipelineStageLowering::matchAndRewrite(
|
|||
return failure();
|
||||
auto stageModule = builder.declareStage();
|
||||
|
||||
MutableDictionaryAttr stageAttrs = stage.getAttrs();
|
||||
NamedAttrList stageAttrs = stage.getAttrs();
|
||||
size_t width = getNumBits(chPort.getInner());
|
||||
stageAttrs.set(builder.width, rewriter.getUI32IntegerAttr(width));
|
||||
|
||||
|
|
|
@ -30,3 +30,23 @@ void ChannelPort::print(mlir::DialectAsmPrinter &p) const {
|
|||
|
||||
#define GET_TYPEDEF_CLASSES
|
||||
#include "circt/Dialect/ESI/ESITypes.cpp.inc"
|
||||
|
||||
/// Parses a type registered to this dialect
|
||||
Type ESIDialect::parseType(DialectAsmParser &parser) const {
|
||||
llvm::StringRef mnemonic;
|
||||
if (parser.parseKeyword(&mnemonic))
|
||||
return Type();
|
||||
auto genType = generatedTypeParser(getContext(), parser, mnemonic);
|
||||
if (genType != Type())
|
||||
return genType;
|
||||
parser.emitError(parser.getCurrentLocation(), "Could not parse esi.")
|
||||
<< mnemonic << "!\n";
|
||||
return Type();
|
||||
}
|
||||
|
||||
/// Print a type registered to this dialect
|
||||
void ESIDialect::printType(Type type, DialectAsmPrinter &printer) const {
|
||||
if (succeeded(generatedTypePrinter(type, printer)))
|
||||
return;
|
||||
llvm_unreachable("unexpected 'esi' type kind");
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ using namespace circt;
|
|||
using namespace firrtl;
|
||||
|
||||
static Attribute getIntAttr(const APInt &value, MLIRContext *context) {
|
||||
return IntegerAttr::get(IntegerType::get(value.getBitWidth(), context),
|
||||
return IntegerAttr::get(IntegerType::get(context, value.getBitWidth()),
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ OpFoldResult XorPrimOp::fold(ArrayRef<Attribute> operands) {
|
|||
auto width = getType().cast<IntType>().getWidthOrSentinel();
|
||||
if (width == -1)
|
||||
width = 1;
|
||||
auto type = IntegerType::get(width, getContext());
|
||||
auto type = IntegerType::get(getContext(), width);
|
||||
return Builder(getContext()).getZeroAttr(type);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
#include "circt/Dialect/FIRRTL/Types.h"
|
||||
#include "circt/Dialect/FIRRTL/Visitors.h"
|
||||
#include "circt/Dialect/RTL/Types.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/IR/DialectImplementation.h"
|
||||
#include "mlir/IR/FunctionImplementation.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
|
||||
using namespace circt;
|
||||
|
@ -433,12 +433,13 @@ static ParseResult parseFModuleOp(OpAsmParser &parser, OperationState &result,
|
|||
|
||||
// Parse the optional function body.
|
||||
auto *body = result.addRegion();
|
||||
if (parser.parseOptionalRegion(
|
||||
*body, entryArgs, entryArgs.empty() ? ArrayRef<Type>() : argTypes))
|
||||
return failure();
|
||||
if (!isExtModule) {
|
||||
if (parser.parseRegion(*body, entryArgs,
|
||||
entryArgs.empty() ? ArrayRef<Type>() : argTypes))
|
||||
return failure();
|
||||
|
||||
if (!isExtModule)
|
||||
FModuleOp::ensureTerminator(*body, parser.getBuilder(), result.location);
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
|
@ -800,7 +801,7 @@ void ConstantOp::build(OpBuilder &builder, OperationState &result, IntType type,
|
|||
auto signedness =
|
||||
type.isSigned() ? IntegerType::Signed : IntegerType::Unsigned;
|
||||
Type attrType =
|
||||
IntegerType::get(value.getBitWidth(), signedness, type.getContext());
|
||||
IntegerType::get(type.getContext(), value.getBitWidth(), signedness);
|
||||
auto attr = builder.getIntegerAttr(attrType, value);
|
||||
return build(builder, result, type, attr);
|
||||
}
|
||||
|
|
|
@ -11,13 +11,12 @@
|
|||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/Function.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/FunctionImplementation.h"
|
||||
#include "mlir/IR/Matchers.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/Value.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
#include "circt/Dialect/LLHD/IR/LLHDDialect.h"
|
||||
#include "mlir/Dialect/CommonFolders.h"
|
||||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Matchers.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
#include "mlir/IR/Region.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/Types.h"
|
||||
#include "mlir/IR/Value.h"
|
||||
#include "mlir/Support/LogicalResult.h"
|
||||
|
@ -945,7 +945,7 @@ static LogicalResult verify(llhd::InstOp op) {
|
|||
|
||||
FunctionType llhd::InstOp::getCalleeType() {
|
||||
SmallVector<Type, 8> argTypes(getOperandTypes());
|
||||
return FunctionType::get(argTypes, ArrayRef<Type>(), getContext());
|
||||
return FunctionType::get(getContext(), argTypes, ArrayRef<Type>());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include "circt/Dialect/RTL/Ops.h"
|
||||
#include "circt/Dialect/RTL/Types.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/DialectImplementation.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
|
||||
using namespace circt;
|
||||
using namespace rtl;
|
||||
|
@ -87,20 +87,3 @@ Operation *RTLDialect::materializeConstant(OpBuilder &builder, Attribute value,
|
|||
|
||||
// Provide implementations for the enums we use.
|
||||
#include "circt/Dialect/RTL/RTLEnums.cpp.inc"
|
||||
|
||||
/// Parses a type registered to this dialect. Parse out the mnemonic then invoke
|
||||
/// the tblgen'd type parser dispatcher.
|
||||
Type RTLDialect::parseType(DialectAsmParser &parser) const {
|
||||
llvm::StringRef mnemonic;
|
||||
if (parser.parseKeyword(&mnemonic))
|
||||
return Type();
|
||||
return generatedTypeParser(getContext(), parser, mnemonic);
|
||||
}
|
||||
|
||||
/// Print a type registered to this dialect. Try the tblgen'd type printer
|
||||
/// dispatcher then fail since all RTL types are defined via ODS.
|
||||
void RTLDialect::printType(Type type, DialectAsmPrinter &printer) const {
|
||||
if (succeeded(generatedTypePrinter(type, printer)))
|
||||
return;
|
||||
llvm_unreachable("unexpected 'rtl' type");
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
#include "circt/Dialect/RTL/Visitors.h"
|
||||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/DialectImplementation.h"
|
||||
#include "mlir/IR/FunctionImplementation.h"
|
||||
#include "mlir/IR/FunctionSupport.h"
|
||||
#include "mlir/IR/Matchers.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
|
||||
using namespace circt;
|
||||
using namespace rtl;
|
||||
|
@ -273,12 +273,13 @@ static ParseResult parseRTLModuleOp(OpAsmParser &parser, OperationState &result,
|
|||
|
||||
// Parse the optional function body.
|
||||
auto *body = result.addRegion();
|
||||
if (parser.parseOptionalRegion(
|
||||
*body, entryArgs, entryArgs.empty() ? ArrayRef<Type>() : argTypes))
|
||||
return failure();
|
||||
if (!isExtModule) {
|
||||
if (parser.parseRegion(*body, entryArgs,
|
||||
entryArgs.empty() ? ArrayRef<Type>() : argTypes))
|
||||
return failure();
|
||||
|
||||
if (!isExtModule)
|
||||
RTLModuleOp::ensureTerminator(*body, parser.getBuilder(), result.location);
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
|
@ -539,7 +540,7 @@ bool rtl::isCombinatorial(Operation *op) {
|
|||
}
|
||||
|
||||
static Attribute getIntAttr(const APInt &value, MLIRContext *context) {
|
||||
return IntegerAttr::get(IntegerType::get(value.getBitWidth(), context),
|
||||
return IntegerAttr::get(IntegerType::get(context, value.getBitWidth()),
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -652,8 +653,8 @@ OpFoldResult ConstantOp::fold(ArrayRef<Attribute> operands) {
|
|||
void ConstantOp::build(OpBuilder &builder, OperationState &result,
|
||||
const APInt &value) {
|
||||
|
||||
auto type = IntegerType::get(value.getBitWidth(), IntegerType::Signless,
|
||||
builder.getContext());
|
||||
auto type = IntegerType::get(builder.getContext(), value.getBitWidth(),
|
||||
IntegerType::Signless);
|
||||
auto attr = builder.getIntegerAttr(type, value);
|
||||
return build(builder, result, type, attr);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "circt/Dialect/RTL/Types.h"
|
||||
#include "circt/Dialect/RTL/Dialect.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/DialectImplementation.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
@ -92,3 +93,20 @@ LogicalResult InOutType::verifyConstructionInvariants(Location loc,
|
|||
|
||||
#define GET_TYPEDEF_CLASSES
|
||||
#include "circt/Dialect/RTL/RTLTypes.cpp.inc"
|
||||
|
||||
/// Parses a type registered to this dialect. Parse out the mnemonic then invoke
|
||||
/// the tblgen'd type parser dispatcher.
|
||||
Type RTLDialect::parseType(DialectAsmParser &parser) const {
|
||||
llvm::StringRef mnemonic;
|
||||
if (parser.parseKeyword(&mnemonic))
|
||||
return Type();
|
||||
return generatedTypeParser(getContext(), parser, mnemonic);
|
||||
}
|
||||
|
||||
/// Print a type registered to this dialect. Try the tblgen'd type printer
|
||||
/// dispatcher then fail since all RTL types are defined via ODS.
|
||||
void RTLDialect::printType(Type type, DialectAsmPrinter &printer) const {
|
||||
if (succeeded(generatedTypePrinter(type, printer)))
|
||||
return;
|
||||
llvm_unreachable("unexpected 'rtl' type");
|
||||
}
|
||||
|
|
|
@ -33,22 +33,3 @@ SVDialect::SVDialect(MLIRContext *context)
|
|||
}
|
||||
|
||||
SVDialect::~SVDialect() {}
|
||||
|
||||
/// Parses a type registered to this dialect
|
||||
Type SVDialect::parseType(DialectAsmParser &parser) const {
|
||||
llvm::StringRef mnemonic;
|
||||
auto loc = parser.getCurrentLocation();
|
||||
if (parser.parseKeyword(&mnemonic))
|
||||
return Type();
|
||||
if (auto type = generatedTypeParser(getContext(), parser, mnemonic))
|
||||
return type;
|
||||
parser.emitError(loc, "Failed to parse type sv.") << mnemonic << "\n";
|
||||
return Type();
|
||||
}
|
||||
|
||||
/// Print a type registered to this dialect
|
||||
void SVDialect::printType(Type type, DialectAsmPrinter &printer) const {
|
||||
if (succeeded(generatedTypePrinter(type, printer)))
|
||||
return;
|
||||
llvm_unreachable("unexpected 'rtl' type kind");
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "circt/Dialect/SV/Ops.h"
|
||||
#include "circt/Dialect/RTL/Types.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
|
||||
using namespace circt;
|
||||
using namespace sv;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "circt/Dialect/SV/Types.h"
|
||||
#include "circt/Dialect/SV/Dialect.h"
|
||||
|
||||
#include "mlir/IR/DialectImplementation.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
|
@ -43,3 +44,22 @@ void ModportType::print(DialectAsmPrinter &p) const {
|
|||
// Provide the autogenerated implementation guts for the Op classes.
|
||||
#define GET_TYPEDEF_CLASSES
|
||||
#include "circt/Dialect/SV/SVTypes.cpp.inc"
|
||||
|
||||
/// Parses a type registered to this dialect
|
||||
Type SVDialect::parseType(DialectAsmParser &parser) const {
|
||||
llvm::StringRef mnemonic;
|
||||
auto loc = parser.getCurrentLocation();
|
||||
if (parser.parseKeyword(&mnemonic))
|
||||
return Type();
|
||||
if (auto type = generatedTypeParser(getContext(), parser, mnemonic))
|
||||
return type;
|
||||
parser.emitError(loc, "Failed to parse type sv.") << mnemonic << "\n";
|
||||
return Type();
|
||||
}
|
||||
|
||||
/// Print a type registered to this dialect
|
||||
void SVDialect::printType(Type type, DialectAsmPrinter &printer) const {
|
||||
if (succeeded(generatedTypePrinter(type, printer)))
|
||||
return;
|
||||
llvm_unreachable("unexpected 'rtl' type kind");
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#include "circt/Dialect/SV/Ops.h"
|
||||
#include "circt/Dialect/SV/Visitors.h"
|
||||
#include "circt/Support/LLVM.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/Translation.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#include "circt/FIRParser.h"
|
||||
#include "FIRLexer.h"
|
||||
#include "circt/Dialect/FIRRTL/Ops.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/Verifier.h"
|
||||
#include "mlir/Translation.h"
|
||||
#include "llvm/ADT/ScopedHashTable.h"
|
||||
|
@ -1138,7 +1138,7 @@ ParseResult FIRStmtParser::parseIntegerLiteralExp(Value &result,
|
|||
}
|
||||
|
||||
Type attrType =
|
||||
IntegerType::get(value.getBitWidth(), signedness, type.getContext());
|
||||
IntegerType::get(type.getContext(), value.getBitWidth(), signedness);
|
||||
auto attr = builder.getIntegerAttr(attrType, value);
|
||||
|
||||
// Check to see if we've already created this constant. If so, reuse it.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "circt/Dialect/LLHD/IR/LLHDOps.h"
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/Visitors.h"
|
||||
#include "mlir/Support/LogicalResult.h"
|
||||
#include "mlir/Translation.h"
|
||||
|
|
2
llvm
2
llvm
|
@ -1 +1 @@
|
|||
Subproject commit 5f0c1e380661f5a28fb8e87d70a68fa31e923436
|
||||
Subproject commit 7d246cb19db9fce65946fb4bac6e570787dbe78a
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: circt-opt %s -inline="disable-simplify" -llhd-function-elimination | FileCheck %s
|
||||
// RUN: circt-opt %s -inline="default-pipeline=''" -llhd-function-elimination | FileCheck %s
|
||||
|
||||
// This test checks the presence of inlining into entities and processes
|
||||
// and their general structure after inlining. It also checks that the functions
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// RUN: circt-translate -emit-verilog -verify-diagnostics --split-input-file -mlir-print-op-on-diagnostic=false %s
|
||||
|
||||
func private @foo() { // expected-error {{unknown operation}}
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
|
|
@ -205,7 +205,7 @@ firrtl.circuit "Foo" {
|
|||
|
||||
firrtl.circuit "Foo" {
|
||||
|
||||
firrtl.module @Foo()
|
||||
firrtl.extmodule @Foo()
|
||||
// expected-error @+1 {{'firrtl.instance' op should be embedded in a 'firrtl.module'}}
|
||||
%a = firrtl.instance @Foo : !firrtl.bundle<>
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
|
||||
// expected-error @+1 {{unexpected operation 'func' in a firrtl.circuit}}
|
||||
func private @UnknownFunction() {
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: rtl.module @OutputFirst(%in1: i1, %in4: i4) -> (%out4: i4) {
|
||||
|
|
|
@ -37,7 +37,9 @@ func private @test_and() {
|
|||
|
||||
// -----
|
||||
|
||||
func private @notModule () {}
|
||||
func private @notModule () {
|
||||
return
|
||||
}
|
||||
|
||||
rtl.module @A(%arg0: i1) {
|
||||
// expected-error @+1 {{Symbol resolved to 'func' which is not a RTL[Ext]ModuleOp}}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "circt/EmitVerilog.h"
|
||||
#include "circt/FIRParser.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/Parser.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Pass/PassManager.h"
|
||||
|
|
|
@ -29,9 +29,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/Function.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/Parser.h"
|
||||
#include "llvm/ADT/APFloat.h"
|
||||
#include "llvm/ADT/APInt.h"
|
||||
|
|
Loading…
Reference in New Issue