diff --git a/include/circt/Dialect/ESI/ESIDialect.h b/include/circt/Dialect/ESI/ESIDialect.h index 9e267ddab3..be17776943 100644 --- a/include/circt/Dialect/ESI/ESIDialect.h +++ b/include/circt/Dialect/ESI/ESIDialect.h @@ -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 { diff --git a/include/circt/Dialect/FIRRTL/Dialect.h b/include/circt/Dialect/FIRRTL/Dialect.h index 9e4c92aaf5..1af9802130 100644 --- a/include/circt/Dialect/FIRRTL/Dialect.h +++ b/include/circt/Dialect/FIRRTL/Dialect.h @@ -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 { diff --git a/include/circt/Dialect/FIRRTL/OpExpressions.td b/include/circt/Dialect/FIRRTL/OpExpressions.td index 67b4062abf..3c37c40b18 100644 --- a/include/circt/Dialect/FIRRTL/OpExpressions.td +++ b/include/circt/Dialect/FIRRTL/OpExpressions.td @@ -133,7 +133,7 @@ class BinaryPrimOp` type($result) }]; - let extraClassDeclaration = !cast(!strconcat(!cast([{ + let extraClassDeclaration = !cast(!strconcat(!cast([{ /// 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(!strconcat(!cast([{ + let extraClassDeclaration = !cast(!strconcat(!cast([{ /// 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) { diff --git a/include/circt/Dialect/Handshake/HandshakeOps.h b/include/circt/Dialect/Handshake/HandshakeOps.h index 4605ded308..263d9eb050 100644 --- a/include/circt/Dialect/Handshake/HandshakeOps.h +++ b/include/circt/Dialect/Handshake/HandshakeOps.h @@ -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" diff --git a/include/circt/Dialect/Handshake/HandshakeOps.td b/include/circt/Dialect/Handshake/HandshakeOps.td index a873607452..e46b2dc3dc 100644 --- a/include/circt/Dialect/Handshake/HandshakeOps.td +++ b/include/circt/Dialect/Handshake/HandshakeOps.td @@ -66,7 +66,7 @@ def FuncOp : Op", "{}">:$attrs, - CArg<"ArrayRef", "{}">:$argAttrs), + CArg<"ArrayRef", "{}">:$argAttrs), [{ $_state.addAttribute(SymbolTable::getSymbolAttrName(), $_builder.getStringAttr(name)); diff --git a/include/circt/Dialect/LLHD/IR/LLHDDialect.h b/include/circt/Dialect/LLHD/IR/LLHDDialect.h index 1bc7a5b3a5..1d34267277 100644 --- a/include/circt/Dialect/LLHD/IR/LLHDDialect.h +++ b/include/circt/Dialect/LLHD/IR/LLHDDialect.h @@ -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 { diff --git a/include/circt/Dialect/LLHD/IR/LLHDOps.h b/include/circt/Dialect/LLHD/IR/LLHDOps.h index f329f3919a..e860c62fec 100644 --- a/include/circt/Dialect/LLHD/IR/LLHDOps.h +++ b/include/circt/Dialect/LLHD/IR/LLHDOps.h @@ -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" diff --git a/include/circt/Dialect/LLHD/Simulator/Engine.h b/include/circt/Dialect/LLHD/Simulator/Engine.h index d11e1b8531..01f27ca520 100644 --- a/include/circt/Dialect/LLHD/Simulator/Engine.h +++ b/include/circt/Dialect/LLHD/Simulator/Engine.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; diff --git a/include/circt/Dialect/RTL/Ops.h b/include/circt/Dialect/RTL/Ops.h index dae2b411d2..d1b9cef57c 100644 --- a/include/circt/Dialect/RTL/Ops.h +++ b/include/circt/Dialect/RTL/Ops.h @@ -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" diff --git a/include/circt/Dialect/RTL/Types.td b/include/circt/Dialect/RTL/Types.td index 9bb3ed079e..98ba37c00f 100644 --- a/include/circt/Dialect/RTL/Types.td +++ b/include/circt/Dialect/RTL/Types.td @@ -22,7 +22,7 @@ def ArrayType : RTLType<"Array"> { let genVerifyInvariantsDecl = 1; } -def InOutType : RTLType<"InOut">, Type()">, "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" diff --git a/include/circt/Dialect/SV/Types.h b/include/circt/Dialect/SV/Types.h index d0088a907f..1f73093272 100644 --- a/include/circt/Dialect/SV/Types.h +++ b/include/circt/Dialect/SV/Types.h @@ -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 diff --git a/include/circt/Dialect/StaticLogic/StaticLogic.h b/include/circt/Dialect/StaticLogic/StaticLogic.h index 3ec474dfbf..7839b4f365 100644 --- a/include/circt/Dialect/StaticLogic/StaticLogic.h +++ b/include/circt/Dialect/StaticLogic/StaticLogic.h @@ -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" diff --git a/lib/Conversion/FIRRTLToRTL/LowerToRTL.cpp b/lib/Conversion/FIRRTLToRTL/LowerToRTL.cpp index 36b9c9fca6..cbca4d2463 100644 --- a/lib/Conversion/FIRRTLToRTL/LowerToRTL.cpp +++ b/lib/Conversion/FIRRTLToRTL/LowerToRTL.cpp @@ -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 {}; } diff --git a/lib/Conversion/LLHDToLLVM/LLHDToLLVM.cpp b/lib/Conversion/LLHDToLLVM/LLHDToLLVM.cpp index 09dfe2c085..f48121cc46 100644 --- a/lib/Conversion/LLHDToLLVM/LLHDToLLVM.cpp +++ b/lib/Conversion/LLHDToLLVM/LLHDToLLVM.cpp @@ -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( 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 types = SmallVector(); 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()) { // 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()); + converter->convertType(arg.getType()).cast()); } } } @@ -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()) { // Unwrap the pointer and store it's value. - auto elemTy = converter.convertType(ptr.getUnderlyingType()); + auto elemTy = converter->convertType(ptr.getUnderlyingType()); toStore = rewriter.create(loc, elemTy, persist); } else if (persist.getType().isa()) { // 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 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(); 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(op)) { - auto underlyingTy = typeConverter.convertType(op.init().getType()) + auto underlyingTy = typeConverter->convertType(op.init().getType()) .cast(); // Get index constant of the signal in the entity's signal table. auto indexConst = initBuilder.create( @@ -1389,7 +1389,6 @@ struct InstOpConversion : public ConvertToLLVMPattern { auto procStateBC = initBuilder.create( op->getLoc(), procStatePtrTy, procStateMall); - // Store the initial resume index. auto resumeGep = initBuilder.create( 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(); + auto finalTy = typeConverter->convertType(resTy).cast(); // 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( 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() .getPointerTo(); auto oneC = rewriter.create( @@ -1681,8 +1679,8 @@ struct RegOpConversion : public ConvertToLLVMPattern { auto regOp = cast(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(); @@ -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(op->getLoc(), iTy, rhs); rewriter.replaceOpWithNewOp( - 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()) { - auto baseTy = typeConverter.convertType(shrOp.base().getType()) + auto baseTy = typeConverter->convertType(shrOp.base().getType()) .cast(); - auto hiddenTy = typeConverter.convertType(shrOp.hidden().getType()) + auto hiddenTy = typeConverter->convertType(shrOp.hidden().getType()) .cast(); auto combinedTy = llhd::ArrayType::get(baseTy.getArrayNumElements() + hiddenTy.getArrayNumElements(), arrTy.getElementType()); auto combinedArrayInit = rewriter.create( - op->getLoc(), typeConverter.convertType(combinedTy)); + op->getLoc(), typeConverter->convertType(combinedTy)); auto insertBase = rewriter.create( 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()) { - auto timeTy = typeConverter.convertType(constOp.getResult().getType()); + auto timeTy = typeConverter->convertType(constOp.getResult().getType()); // Convert real-time element to ps. llvm::StringMap 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(op, intType, constOp.valueAttr()); @@ -2139,7 +2137,7 @@ struct ArrayOpConversion : public ConvertToLLVMPattern { matchAndRewrite(Operation *op, ArrayRef 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(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 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(); Value arr = rewriter.create(op->getLoc(), arrayTy); @@ -2196,7 +2194,7 @@ struct TupleOpConversion : public ConvertToLLVMPattern { matchAndRewrite(Operation *op, ArrayRef 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(); Value tup = rewriter.create(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(op->getLoc(), indexTy, extsOp.startAttr()); if (auto retTy = extsOp.result().getType().dyn_cast()) { - auto resTy = typeConverter.convertType(extsOp.result().getType()) + auto resTy = typeConverter->convertType(extsOp.result().getType()) .cast(); 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()) { auto llvmArrTy = - typeConverter.convertType(arrTy).cast(); + typeConverter->convertType(arrTy).cast(); 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()) { - 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( - 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()) { - auto resTy = typeConverter.convertType(extsOp.result().getType()) + auto resTy = typeConverter->convertType(extsOp.result().getType()) .cast(); 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()) { auto llvmArrTy = - typeConverter.convertType(arrTy).cast(); + typeConverter->convertType(arrTy).cast(); auto adjustedPtr = shiftArraySigPointer(op->getLoc(), rewriter, llvmArrTy, @@ -2365,9 +2363,9 @@ struct DynExtractSliceOpConversion : public ConvertToLLVMPattern { } if (auto arrTy = extsOp.result().getType().dyn_cast()) { - auto elemTy = typeConverter.convertType(arrTy.getElementType()) + auto elemTy = typeConverter->convertType(arrTy.getElementType()) .cast(); - auto llvmArrTy = typeConverter.convertType(arrTy).cast(); + auto llvmArrTy = typeConverter->convertType(arrTy).cast(); auto targetTy = transformed.target().getType().cast(); auto zeroC = rewriter.create( @@ -2423,14 +2421,14 @@ struct ExtractElementOpConversion : public ConvertToLLVMPattern { if (isArrayOrTuple(extOp.target().getType())) { rewriter.replaceOpWithNewOp( - 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()) { - 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()) { auto llvmArrTy = - typeConverter.convertType(arrTy).cast(); + typeConverter->convertType(arrTy).cast(); adjusted = shiftArraySigPointer(op->getLoc(), rewriter, llvmArrTy, sigDetail[0], indexC); } else { - auto llvmStructTy = typeConverter.convertType(sigTy.getUnderlyingType()) - .cast(); + auto llvmStructTy = + typeConverter->convertType(sigTy.getUnderlyingType()) + .cast(); 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()) { - auto elemTy = typeConverter.convertType(extOp.getResult().getType()) + auto elemTy = typeConverter->convertType(extOp.getResult().getType()) .cast(); auto zeroC = rewriter.create( - op->getLoc(), LLVM::LLVMType::getInt32Ty(&typeConverter.getContext()), + op->getLoc(), LLVM::LLVMType::getInt32Ty(rewriter.getContext()), rewriter.getI32IntegerAttr(0)); auto oneC = rewriter.create( - op->getLoc(), LLVM::LLVMType::getInt32Ty(&typeConverter.getContext()), + op->getLoc(), LLVM::LLVMType::getInt32Ty(rewriter.getContext()), rewriter.getI32IntegerAttr(1)); auto arrPtr = rewriter.create( op->getLoc(), @@ -2508,7 +2507,7 @@ struct DynExtractElementOpConversion : public ConvertToLLVMPattern { if (auto sigTy = extOp.target().getType().dyn_cast()) { if (auto arrTy = sigTy.getUnderlyingType().dyn_cast()) { auto llvmArrTy = - typeConverter.convertType(arrTy).cast(); + typeConverter->convertType(arrTy).cast(); 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()) { auto startConst = rewriter.create(op->getLoc(), indexTy, @@ -2567,7 +2566,7 @@ struct InsertSliceOpConversion : public ConvertToLLVMPattern { auto maskConst = rewriter.create( 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( 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()) { - 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(); 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( op->getLoc(), i32Ty, rewriter.getI32IntegerAttr(1)); diff --git a/lib/Conversion/StandardToHandshake/StandardToHandshake.cpp b/lib/Conversion/StandardToHandshake/StandardToHandshake.cpp index 7b799ea6a2..81e711525c 100644 --- a/lib/Conversion/StandardToHandshake/StandardToHandshake.cpp +++ b/lib/Conversion/StandardToHandshake/StandardToHandshake.cpp @@ -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" diff --git a/lib/Dialect/ESI/ESIDialect.cpp b/lib/Dialect/ESI/ESIDialect.cpp index 6f631dbcf1..f174076c93 100644 --- a/lib/Dialect/ESI/ESIDialect.cpp +++ b/lib/Dialect/ESI/ESIDialect.cpp @@ -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 diff --git a/lib/Dialect/ESI/ESIOps.cpp b/lib/Dialect/ESI/ESIOps.cpp index 373c1abe7c..49c6f4444d 100644 --- a/lib/Dialect/ESI/ESIOps.cpp +++ b/lib/Dialect/ESI/ESIOps.cpp @@ -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(); diff --git a/lib/Dialect/ESI/ESIPasses.cpp b/lib/Dialect/ESI/ESIPasses.cpp index 95c3a485f2..f9afc70787 100644 --- a/lib/Dialect/ESI/ESIPasses.cpp +++ b/lib/Dialect/ESI/ESIPasses.cpp @@ -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)); diff --git a/lib/Dialect/ESI/ESITypes.cpp b/lib/Dialect/ESI/ESITypes.cpp index 495ff193a9..bceade1b29 100644 --- a/lib/Dialect/ESI/ESITypes.cpp +++ b/lib/Dialect/ESI/ESITypes.cpp @@ -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"); +} diff --git a/lib/Dialect/FIRRTL/OpFolds.cpp b/lib/Dialect/FIRRTL/OpFolds.cpp index 05d7658072..01c3bd03a9 100644 --- a/lib/Dialect/FIRRTL/OpFolds.cpp +++ b/lib/Dialect/FIRRTL/OpFolds.cpp @@ -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 operands) { auto width = getType().cast().getWidthOrSentinel(); if (width == -1) width = 1; - auto type = IntegerType::get(width, getContext()); + auto type = IntegerType::get(getContext(), width); return Builder(getContext()).getZeroAttr(type); } diff --git a/lib/Dialect/FIRRTL/Ops.cpp b/lib/Dialect/FIRRTL/Ops.cpp index c0dc03f759..f10d04e30a 100644 --- a/lib/Dialect/FIRRTL/Ops.cpp +++ b/lib/Dialect/FIRRTL/Ops.cpp @@ -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() : argTypes)) - return failure(); + if (!isExtModule) { + if (parser.parseRegion(*body, entryArgs, + entryArgs.empty() ? ArrayRef() : 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); } diff --git a/lib/Dialect/Handshake/HandshakeOps.cpp b/lib/Dialect/Handshake/HandshakeOps.cpp index d2ffc8ff90..e881adccd7 100644 --- a/lib/Dialect/Handshake/HandshakeOps.cpp +++ b/lib/Dialect/Handshake/HandshakeOps.cpp @@ -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; diff --git a/lib/Dialect/LLHD/IR/LLHDOps.cpp b/lib/Dialect/LLHD/IR/LLHDOps.cpp index 620e0c52bf..f22648ee85 100644 --- a/lib/Dialect/LLHD/IR/LLHDOps.cpp +++ b/lib/Dialect/LLHD/IR/LLHDOps.cpp @@ -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 argTypes(getOperandTypes()); - return FunctionType::get(argTypes, ArrayRef(), getContext()); + return FunctionType::get(getContext(), argTypes, ArrayRef()); } //===----------------------------------------------------------------------===// diff --git a/lib/Dialect/RTL/Dialect.cpp b/lib/Dialect/RTL/Dialect.cpp index 1c20f1722c..786e002a0d 100644 --- a/lib/Dialect/RTL/Dialect.cpp +++ b/lib/Dialect/RTL/Dialect.cpp @@ -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"); -} diff --git a/lib/Dialect/RTL/Ops.cpp b/lib/Dialect/RTL/Ops.cpp index f79d92bab1..da2c09fa75 100644 --- a/lib/Dialect/RTL/Ops.cpp +++ b/lib/Dialect/RTL/Ops.cpp @@ -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() : argTypes)) - return failure(); + if (!isExtModule) { + if (parser.parseRegion(*body, entryArgs, + entryArgs.empty() ? ArrayRef() : 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 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); } diff --git a/lib/Dialect/RTL/Types.cpp b/lib/Dialect/RTL/Types.cpp index 248dcfabf1..e74f614d26 100644 --- a/lib/Dialect/RTL/Types.cpp +++ b/lib/Dialect/RTL/Types.cpp @@ -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"); +} diff --git a/lib/Dialect/SV/Dialect.cpp b/lib/Dialect/SV/Dialect.cpp index 860597b4f5..ed7a6798ec 100644 --- a/lib/Dialect/SV/Dialect.cpp +++ b/lib/Dialect/SV/Dialect.cpp @@ -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"); -} diff --git a/lib/Dialect/SV/Ops.cpp b/lib/Dialect/SV/Ops.cpp index 3ebfac871e..fb95c88bcd 100644 --- a/lib/Dialect/SV/Ops.cpp +++ b/lib/Dialect/SV/Ops.cpp @@ -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; diff --git a/lib/Dialect/SV/Types.cpp b/lib/Dialect/SV/Types.cpp index 007581f86e..dfd2570714 100644 --- a/lib/Dialect/SV/Types.cpp +++ b/lib/Dialect/SV/Types.cpp @@ -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"); +} diff --git a/lib/EmitVerilog/EmitVerilog.cpp b/lib/EmitVerilog/EmitVerilog.cpp index a79d683326..177f4ce550 100644 --- a/lib/EmitVerilog/EmitVerilog.cpp +++ b/lib/EmitVerilog/EmitVerilog.cpp @@ -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" diff --git a/lib/FIRParser/FIRParser.cpp b/lib/FIRParser/FIRParser.cpp index 6ba8de9388..175bf7561e 100644 --- a/lib/FIRParser/FIRParser.cpp +++ b/lib/FIRParser/FIRParser.cpp @@ -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. diff --git a/lib/Target/Verilog/TranslateToVerilog.cpp b/lib/Target/Verilog/TranslateToVerilog.cpp index efb90393a6..d63bf4e57d 100644 --- a/lib/Target/Verilog/TranslateToVerilog.cpp +++ b/lib/Target/Verilog/TranslateToVerilog.cpp @@ -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" diff --git a/llvm b/llvm index 5f0c1e3806..7d246cb19d 160000 --- a/llvm +++ b/llvm @@ -1 +1 @@ -Subproject commit 5f0c1e380661f5a28fb8e87d70a68fa31e923436 +Subproject commit 7d246cb19db9fce65946fb4bac6e570787dbe78a diff --git a/test/Dialect/LLHD/Transforms/totalFunctionInlining.mlir b/test/Dialect/LLHD/Transforms/totalFunctionInlining.mlir index d4a62c6484..acedeab1ed 100644 --- a/test/Dialect/LLHD/Transforms/totalFunctionInlining.mlir +++ b/test/Dialect/LLHD/Transforms/totalFunctionInlining.mlir @@ -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 diff --git a/test/EmitVerilog/verilog-errors.mlir b/test/EmitVerilog/verilog-errors.mlir index eeb2efc200..b9db72f5da 100644 --- a/test/EmitVerilog/verilog-errors.mlir +++ b/test/EmitVerilog/verilog-errors.mlir @@ -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 } // ----- diff --git a/test/firrtl/errors.mlir b/test/firrtl/errors.mlir index 85d9006f68..810d88bd19 100644 --- a/test/firrtl/errors.mlir +++ b/test/firrtl/errors.mlir @@ -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<> diff --git a/test/firrtl/lower-to-rtl-module.mlir b/test/firrtl/lower-to-rtl-module.mlir index 1e26dee008..3b3a46f224 100644 --- a/test/firrtl/lower-to-rtl-module.mlir +++ b/test/firrtl/lower-to-rtl-module.mlir @@ -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) { diff --git a/test/rtl/errors.mlir b/test/rtl/errors.mlir index 3b133b60ed..dc3ea860db 100644 --- a/test/rtl/errors.mlir +++ b/test/rtl/errors.mlir @@ -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}} diff --git a/tools/firtool/firtool.cpp b/tools/firtool/firtool.cpp index 3c1f97a1b5..9aa3e889ef 100644 --- a/tools/firtool/firtool.cpp +++ b/tools/firtool/firtool.cpp @@ -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" diff --git a/tools/handshake-runner/handshake-runner.cpp b/tools/handshake-runner/handshake-runner.cpp index d0dd2f7086..20351d04fc 100644 --- a/tools/handshake-runner/handshake-runner.cpp +++ b/tools/handshake-runner/handshake-runner.cpp @@ -29,9 +29,8 @@ #include #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"