diff --git a/lib/Conversion/HWToLLVM/HWToLLVM.cpp b/lib/Conversion/HWToLLVM/HWToLLVM.cpp index 30cb144af4..27895e2eb6 100644 --- a/lib/Conversion/HWToLLVM/HWToLLVM.cpp +++ b/lib/Conversion/HWToLLVM/HWToLLVM.cpp @@ -165,9 +165,20 @@ struct ArrayGetOpConversion : public ConvertOpToLLVMPattern { op->getLoc(), IntegerType::get(rewriter.getContext(), 32), rewriter.getI32IntegerAttr(0)); auto zextIndex = zextByOne(op->getLoc(), rewriter, op.getIndex()); - auto gep = rewriter.create( - op->getLoc(), LLVM::LLVMPointerType::get(elemTy), arrPtr, - ArrayRef({zeroC, zextIndex})); + + // During the ongoing migration to opaque types, use the constructor that + // accepts an element type when the array pointer type is opaque, and + // otherwise use the typed pointer constructor. + LLVM::GEPOp gep; + if (cast(arrPtr.getType()).isOpaque()) + gep = rewriter.create( + op->getLoc(), LLVM::LLVMPointerType::get(rewriter.getContext()), + elemTy, arrPtr, ArrayRef({zeroC, zextIndex})); + else + gep = rewriter.create( + op->getLoc(), LLVM::LLVMPointerType::get(elemTy), arrPtr, + ArrayRef({zeroC, zextIndex})); + rewriter.replaceOpWithNewOp(op, elemTy, gep); return success(); @@ -205,9 +216,18 @@ struct ArraySliceOpConversion auto zextIndex = zextByOne(op->getLoc(), rewriter, op.getLowIndex()); - auto gep = rewriter.create( - op->getLoc(), LLVM::LLVMPointerType::get(elemTy), arrPtr, - ArrayRef({zeroC, zextIndex})); + // During the ongoing migration to opaque types, use the constructor that + // accepts an element type when the array pointer type is opaque, and + // otherwise use the typed pointer constructor. + LLVM::GEPOp gep; + if (cast(arrPtr.getType()).isOpaque()) + gep = rewriter.create( + op->getLoc(), LLVM::LLVMPointerType::get(rewriter.getContext()), + elemTy, arrPtr, ArrayRef({zeroC, zextIndex})); + else + gep = rewriter.create( + op->getLoc(), LLVM::LLVMPointerType::get(elemTy), arrPtr, + ArrayRef({zeroC, zextIndex})); auto cast = rewriter.create( op->getLoc(), LLVM::LLVMPointerType::get(dstTy), gep); diff --git a/llvm b/llvm index cc3d2533cc..5f5faf407b 160000 --- a/llvm +++ b/llvm @@ -1 +1 @@ -Subproject commit cc3d2533cc2e4ea06981b86ede5087fbf801e789 +Subproject commit 5f5faf407b42342708ce31a1ca3095ddff10dad8 diff --git a/test/Conversion/HWToLLVM/convert_aggregates.mlir b/test/Conversion/HWToLLVM/convert_aggregates.mlir index ca465141b5..4bb967091f 100644 --- a/test/Conversion/HWToLLVM/convert_aggregates.mlir +++ b/test/Conversion/HWToLLVM/convert_aggregates.mlir @@ -98,30 +98,30 @@ func.func @convertArray(%arg0 : i1, %arg1: !hw.array<2xi32>, %arg2: i32, %arg3: // CHECK: @convertConstArray func.func @convertConstArray(%arg0 : i1) { // COM: Test: simple constant array converted to constant global - // CHECK: %[[VAL_2:.*]] = llvm.mlir.addressof @[[GLOB1]] : !llvm.ptr> - // CHECK-NEXT: %[[VAL_3:.*]] = llvm.load %[[VAL_2]] : !llvm.ptr> + // CHECK: %[[VAL_2:.*]] = llvm.mlir.addressof @[[GLOB1]] : !llvm.ptr + // CHECK-NEXT: %[[VAL_3:.*]] = llvm.load %[[VAL_2]] : !llvm.ptr -> !llvm.array<2 x i32> %0 = hw.aggregate_constant [0 : i32, 1 : i32] : !hw.array<2xi32> // COM: Test: when the array argument is already a load from a pointer, // COM: then don't allocate on the stack again but take that pointer directly as a shortcut // CHECK-NEXT: %[[VAL_4:.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK-NEXT: %[[VAL_5:.*]] = llvm.zext %arg0 : i1 to i2 - // CHECK-NEXT: %[[VAL_6:.*]] = llvm.getelementptr %[[VAL_2]][%[[VAL_4]], %[[VAL_5]]] : (!llvm.ptr>, i32, i2) -> !llvm.ptr - // CHECK-NEXT: %{{.+}} = llvm.load %[[VAL_6]] : !llvm.ptr + // CHECK-NEXT: %[[VAL_6:.*]] = llvm.getelementptr %[[VAL_2]][%[[VAL_4]], %[[VAL_5]]] : (!llvm.ptr, i32, i2) -> !llvm.ptr, i32 + // CHECK-NEXT: %{{.+}} = llvm.load %[[VAL_6]] : !llvm.ptr -> i32 %1 = hw.array_get %0[%arg0] : !hw.array<2xi32>, i1 // COM: Test: nested constant array can also converted to a constant global - // CHECK: %[[VAL_7:.*]] = llvm.mlir.addressof @[[GLOB2]] : !llvm.ptr>> - // CHECK-NEXT: %{{.+}} = llvm.load %[[VAL_7]] : !llvm.ptr>> + // CHECK: %[[VAL_7:.*]] = llvm.mlir.addressof @[[GLOB2]] : !llvm.ptr + // CHECK-NEXT: %{{.+}} = llvm.load %[[VAL_7]] : !llvm.ptr -> !llvm.array<2 x array<2 x i32>> %2 = hw.aggregate_constant [[0 : i32, 1 : i32], [2 : i32, 3 : i32]] : !hw.array<2x!hw.array<2xi32>> // COM: the same constants only create one global (note: even if they are in different functions). - // CHECK: %[[VAL_8:.*]] = llvm.mlir.addressof @[[GLOB2]] : !llvm.ptr>> - // CHECK-NEXT: %{{.+}} = llvm.load %[[VAL_8]] : !llvm.ptr>> + // CHECK: %[[VAL_8:.*]] = llvm.mlir.addressof @[[GLOB2]] : !llvm.ptr + // CHECK-NEXT: %{{.+}} = llvm.load %[[VAL_8]] : !llvm.ptr -> !llvm.array<2 x array<2 x i32>> %3 = hw.aggregate_constant [[0 : i32, 1 : i32], [2 : i32, 3 : i32]] : !hw.array<2x!hw.array<2xi32>> - // CHECK: %[[VAL_9:.+]] = llvm.mlir.addressof @[[GLOB3]] : !llvm.ptr>> - // CHECK-NEXT: {{%.+}} = llvm.load %[[VAL_9]] : !llvm.ptr>> + // CHECK: %[[VAL_9:.+]] = llvm.mlir.addressof @[[GLOB3]] : !llvm.ptr + // CHECK-NEXT: {{%.+}} = llvm.load %[[VAL_9]] : !llvm.ptr -> !llvm.array<2 x struct<(i1, i32)>> %4 = hw.aggregate_constant [[0 : i32, 1 : i1], [2 : i32, 0 : i1]] : !hw.array<2x!hw.struct> return @@ -138,8 +138,8 @@ func.func @convertConstArray(%arg0 : i1) { // CHECK: @convertConstStruct func.func @convertConstStruct() { - // CHECK-NEXT: [[V0:%.+]] = llvm.mlir.addressof @[[GLOB4]] : !llvm.ptr> - // CHECK-NEXT: [[V1:%.+]] = llvm.load [[V0]] : !llvm.ptr> + // CHECK-NEXT: [[V0:%.+]] = llvm.mlir.addressof @[[GLOB4]] : !llvm.ptr + // CHECK-NEXT: [[V1:%.+]] = llvm.load [[V0]] : !llvm.ptr -> !llvm.struct<(i2, i32)> %0 = hw.aggregate_constant [0 : i32, 1 : i2] : !hw.struct // CHECK-NEXT: {{%.+}} = llvm.mlir.constant(0 : i32) : i32 %1 = hw.struct_extract %0["a"] : !hw.struct diff --git a/test/Conversion/LLHDToLLVM/convert_signals.mlir b/test/Conversion/LLHDToLLVM/convert_signals.mlir index e325bbdc19..61cd69d333 100644 --- a/test/Conversion/LLHDToLLVM/convert_signals.mlir +++ b/test/Conversion/LLHDToLLVM/convert_signals.mlir @@ -64,8 +64,8 @@ llhd.entity @convert_prb (%sI1 : !llhd.sig, %sArr : !llhd.sig>, i32) -> !llvm.ptr> // CHECK: %[[VAL_7:.*]] = llvm.mlir.constant(false) : i1 // CHECK: %[[VAL_8:.*]] = llvm.mlir.constant(0 : i5) : i5 -// CHECK: %[[VAL_9:.*]] = llvm.mlir.addressof @{{.+}} : !llvm.ptr> -// CHECK: %[[VAL_10:.*]] = llvm.load %[[VAL_9]] : !llvm.ptr> +// CHECK: %[[VAL_9:.*]] = llvm.mlir.addressof @{{.+}} : !llvm.ptr +// CHECK: %[[VAL_10:.*]] = llvm.load %[[VAL_9]] : !llvm.ptr // CHECK: %[[VAL_13:.*]] = llvm.mlir.constant(dense<[1000, 0, 0]> : tensor<3xi64>) : !llvm.array<3 x i64> // CHECK: %[[VAL_14:.*]] = llvm.mlir.constant(1 : i64) : i64 // CHECK: %[[VAL_15:.*]] = llvm.mlir.constant(1 : i32) : i32 diff --git a/test/Conversion/LLHDToLLVM/signal-init.mlir b/test/Conversion/LLHDToLLVM/signal-init.mlir index 7bf6801e94..c94e5128b4 100644 --- a/test/Conversion/LLHDToLLVM/signal-init.mlir +++ b/test/Conversion/LLHDToLLVM/signal-init.mlir @@ -10,13 +10,11 @@ llhd.entity @root() -> () { llhd.entity @initSig () -> () { %1 = hw.aggregate_constant [ 0 : i1, 1 : i1] : !hw.array<2xi1> %2 = hw.aggregate_constant [ 0 : i1, 1 : i5] : !hw.struct - // CHECK: [[V0:%.+]] = llvm.mlir.addressof @{{.+}} : !llvm.ptr> - // CHECK: [[V1:%.+]] = llvm.load [[V0]] : !llvm.ptr> - // CHECK: llvm.store [[V1]], {{%.+}} : !llvm.ptr> + // CHECK: [[V0:%.+]] = llvm.mlir.addressof @{{.+}} : !llvm.ptr + // CHECK: [[V1:%.+]] = llvm.load [[V0]] : !llvm.ptr %3 = llhd.sig "sig1" %1 : !hw.array<2xi1> - // CHECK: [[V2:%.+]] = llvm.mlir.addressof @{{.+}} : !llvm.ptr> - // CHECK: [[V3:%.+]] = llvm.load [[V2]] : !llvm.ptr> - // CHECK: llvm.store [[V3]], {{%.+}} : !llvm.ptr> + // CHECK: [[V2:%.+]] = llvm.mlir.addressof @{{.+}} : !llvm.ptr + // CHECK: [[V3:%.+]] = llvm.load [[V2]] : !llvm.ptr %4 = llhd.sig "sig2" %2 : !hw.struct } @@ -38,7 +36,6 @@ func.func @getInitValue() -> (i32, i32, i32) { // CHECK: [[E1:%.+]] = llvm.extractvalue [[RETURN]][0] : !llvm.struct<(i32, i32, i32)> // CHECK: [[E2:%.+]] = llvm.extractvalue [[RETURN]][1] : !llvm.struct<(i32, i32, i32)> // CHECK: [[E3:%.+]] = llvm.extractvalue [[RETURN]][2] : !llvm.struct<(i32, i32, i32)> -// CHECK: llvm.store [[E2]], {{%.+}} : !llvm.ptr llhd.entity @initMultipleResults () -> () { %0, %1, %2 = func.call @getInitValue() : () -> (i32, i32, i32) %3 = llhd.sig "sig" %1 : i32 diff --git a/test/Dialect/FIRRTL/errors.mlir b/test/Dialect/FIRRTL/errors.mlir index ad1d94aa64..5b517927f5 100644 --- a/test/Dialect/FIRRTL/errors.mlir +++ b/test/Dialect/FIRRTL/errors.mlir @@ -436,7 +436,7 @@ firrtl.module @X(in %a : !firrtl.uint<4>) { firrtl.circuit "BadPort" { firrtl.module @BadPort(in %a : !firrtl.uint<1>) { - // expected-error @+1 {{'firrtl.attach' op operand #0 must be analog type, but got '!firrtl.uint<1>'}} + // expected-error @+1 {{'firrtl.attach' op operand #0 must be variadic of analog type, but got '!firrtl.uint<1>'}} firrtl.attach %a, %a : !firrtl.uint<1>, !firrtl.uint<1> } } diff --git a/test/Dialect/HWArith/signedness-error.mlir b/test/Dialect/HWArith/signedness-error.mlir index 1234e3d36b..a294ba6c54 100644 --- a/test/Dialect/HWArith/signedness-error.mlir +++ b/test/Dialect/HWArith/signedness-error.mlir @@ -2,7 +2,7 @@ hw.module @signlessOperands() { %c1_1 = arith.constant 1 : i1 - // expected-error @+1 {{'hwarith.add' op operand #0 must be an arbitrary precision integer with signedness semantics, but got 'i1'}} + // expected-error @+1 {{'hwarith.add' op operand #0 must be variadic of an arbitrary precision integer with signedness semantics, but got 'i1'}} %0 = hwarith.add %c1_1, %c1_1 : (i1, i1) -> i2 } diff --git a/test/Dialect/SystemC/module-error.mlir b/test/Dialect/SystemC/module-error.mlir index 88de322c2b..822da4cc81 100644 --- a/test/Dialect/SystemC/module-error.mlir +++ b/test/Dialect/SystemC/module-error.mlir @@ -407,7 +407,7 @@ systemc.module @sensitivityNotInCtor() { systemc.module @sensitivityNoChannelType() { systemc.ctor { %var = systemc.cpp.variable : i1 - // expected-error @+1 {{operand #0 must be a SystemC sc_in type or a SystemC sc_inout type or a SystemC sc_out type or a SystemC sc_signal type, but got 'i1'}} + // expected-error @+1 {{operand #0 must be variadic of a SystemC sc_in type or a SystemC sc_inout type or a SystemC sc_out type or a SystemC sc_signal type, but got 'i1'}} systemc.sensitive %var : i1 } }