Skip to content

Commit

Permalink
Bump LLVM to 10407be542aeb2b59477b167bbba3716538dc722. (#7550)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Martin Erhart <maerhart@outlook.com>
  • Loading branch information
mikeurbach and maerhart authored Sep 1, 2024
1 parent ce6901d commit c2c0473
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
4 changes: 2 additions & 2 deletions integration_test/Target/ExportSystemC/basic.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ systemc.module @systemCTypes (%p0: !systemc.in<!systemc.int_base>,
systemc.module @emitcEmission () {
systemc.ctor {
%0 = "emitc.constant"() {value = #emitc.opaque<"5"> : !emitc.opaque<"int">} : () -> !emitc.opaque<"int">
%five = systemc.cpp.variable %0 : !emitc.opaque<"int">
%1 = emitc.apply "&"(%five) : (!emitc.opaque<"int">) -> !emitc.ptr<!emitc.opaque<"int">>
%f = "emitc.variable"() {value=#emitc.opaque<"5">, name="f"} : () -> !emitc.lvalue<!emitc.opaque<"int">>
%1 = emitc.apply "&"(%f) : (!emitc.lvalue<!emitc.opaque<"int">>) -> !emitc.ptr<!emitc.opaque<"int">>
%2 = emitc.apply "*"(%1) : (!emitc.ptr<!emitc.opaque<"int">>) -> !emitc.opaque<"int">
%3 = emitc.cast %2: !emitc.opaque<"int"> to !emitc.opaque<"long">
emitc.call_opaque "printf" (%3) {args=["result: %ld\n", 0 : index]} : (!emitc.opaque<"long">) -> ()
Expand Down
5 changes: 0 additions & 5 deletions lib/Conversion/SeqToSV/SeqToSV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ struct ModuleLoweringState {
InitialOpLowering(hw::HWModuleOp module)
: builder(module.getModuleBody()), module(module) {}

~InitialOpLowering() {
for (auto [placeHolder, _] : mapping)
placeHolder.getDefiningOp()->erase();
}

// Lower initial ops.
LogicalResult lower();
LogicalResult lower(seq::InitialOp initialOp);
Expand Down
41 changes: 39 additions & 2 deletions lib/Target/ExportSystemC/Patterns/EmitCEmissionPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,36 @@ struct ConstantEmitter : OpEmissionPattern<ConstantOp> {
p.emitAttr(value.getDefiningOp<ConstantOp>().getValue());
}
};

/// Emit an emitc.variable operation.
struct VariableEmitter : OpEmissionPattern<VariableOp> {
using OpEmissionPattern::OpEmissionPattern;

MatchResult matchInlinable(Value value) override {
if (auto varOp = value.getDefiningOp<VariableOp>()) {
if (!varOp->getAttrOfType<StringAttr>("name"))
return {};
return Precedence::VAR;
}
return {};
}

void emitInlined(Value value, EmissionPrinter &p) override {
p << value.getDefiningOp()->getAttrOfType<StringAttr>("name").getValue();
}

void emitStatement(VariableOp op, EmissionPrinter &p) override {
p.emitType(op.getResult().getType());
p << " " << op->getAttrOfType<StringAttr>("name").getValue();

if (op.getValue()) {
p << " = ";
p.emitAttr(op.getValue());
}

p << ";\n";
}
};
} // namespace

//===----------------------------------------------------------------------===//
Expand All @@ -180,6 +210,13 @@ struct PointerTypeEmitter : TypeEmissionPattern<PointerType> {
p << "*";
}
};

/// Emit an emitc.ptr type.
struct LValueTypeEmitter : TypeEmissionPattern<LValueType> {
void emitType(LValueType type, EmissionPrinter &p) override {
p.emitType(type.getValueType());
}
};
} // namespace

namespace {
Expand All @@ -201,12 +238,12 @@ struct OpaqueAttrEmitter : AttrEmissionPattern<OpaqueAttr> {
void circt::ExportSystemC::populateEmitCOpEmitters(
OpEmissionPatternSet &patterns, MLIRContext *context) {
patterns.add<IncludeEmitter, ApplyOpEmitter, CallOpEmitter, CastOpEmitter,
ConstantEmitter>(context);
ConstantEmitter, VariableEmitter>(context);
}

void circt::ExportSystemC::populateEmitCTypeEmitters(
TypeEmissionPatternSet &patterns) {
patterns.add<OpaqueTypeEmitter, PointerTypeEmitter>();
patterns.add<OpaqueTypeEmitter, PointerTypeEmitter, LValueTypeEmitter>();
}

void circt::ExportSystemC::populateEmitCAttrEmitters(
Expand Down
1 change: 1 addition & 0 deletions lib/Tools/circt-bmc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_circt_library(CIRCTBMCTransforms

MLIRFuncDialect
MLIRIR
MLIRLLVMDialect
MLIRSupport
MLIRSCFDialect
MLIRTransforms
Expand Down
2 changes: 1 addition & 1 deletion llvm
Submodule llvm updated 6121 files
6 changes: 4 additions & 2 deletions test/Target/ExportSystemC/basic.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ systemc.module @emitcEmission () {
%five = systemc.cpp.variable %0 : !emitc.opaque<"int">

// Test: emitc.apply "&" without having to emit parentheses
// CHECK-NEXT: int* fiveptr = &five;
%1 = emitc.apply "&"(%five) : (!emitc.opaque<"int">) -> !emitc.ptr<!emitc.opaque<"int">>
// CHECK-NEXT: int f = 5;
// CHECK-NEXT: int* fiveptr = &f;
%f = "emitc.variable"() {value=#emitc.opaque<"5">, name="f"} : () -> !emitc.lvalue<!emitc.opaque<"int">>
%1 = emitc.apply "&"(%f) : (!emitc.lvalue<!emitc.opaque<"int">>) -> !emitc.ptr<!emitc.opaque<"int">>
%fiveptr = systemc.cpp.variable %1: !emitc.ptr<!emitc.opaque<"int">>

// Test: emitc.apply "&" with parentheses to conform to the precedence rules
Expand Down

0 comments on commit c2c0473

Please sign in to comment.