Skip to content

Commit

Permalink
[LLVM] Update submodule to latest version from Feb. 15 (e769fb86). (#792
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ingomueller-net authored Feb 20, 2024
1 parent 7610e38 commit 6a84d0f
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 40 deletions.
4 changes: 2 additions & 2 deletions benchmarks/inner_product/iterators.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func.func private @sum_float(%lhs : !float_type, %rhs : !float_type) -> !float_t
// Main program.
//
func.func @main(%input: !tabular.tabular_view<!element_type,!element_type>,
%output: !llvm.ptr<!element_type>)
%output: !llvm.ptr)
attributes { llvm.emit_c_interface } {
%stream = iterators.tabular_view_to_stream %input
to !iterators.stream<!tuple_type>
Expand All @@ -57,6 +57,6 @@ func.func @main(%input: !tabular.tabular_view<!element_type,!element_type>,
%reduced = "iterators.reduce"(%summed) {reduceFuncRef = @sum_int}
: (!iterators.stream<!element_type>) -> (!iterators.stream<!element_type>)
%result:2 = iterators.stream_to_value %reduced : !iterators.stream<!element_type>
llvm.store %result#0, %output : !llvm.ptr<!element_type>
llvm.store %result#0, %output : !element_type, !llvm.ptr
return
}
4 changes: 2 additions & 2 deletions include/structured/Conversion/TabularToLLVM/TabularToLLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ namespace tabular {
/// Maps types from the Tabular dialect to corresponding types in LLVM.
class TabularTypeConverter : public TypeConverter {
public:
TabularTypeConverter(LLVMTypeConverter &llvmTypeConverter);
TabularTypeConverter(LLVMTypeConverter *llvmTypeConverter);

/// Maps a TabularViewType to an LLVMStruct of pointers, i.e., to a "struct of
/// arrays".
static std::optional<Type> convertTabularViewType(Type type);

private:
LLVMTypeConverter llvmTypeConverter;
LLVMTypeConverter *llvmTypeConverter;
};

/// Populate the given list with patterns that convert from Tabular to LLVM.
Expand Down
15 changes: 6 additions & 9 deletions lib/Conversion/IteratorsToLLVM/IteratorsToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ class IteratorsTypeConverter : public TypeConverter {

/// Return a symbol reference to the printf function, inserting it into the
/// module if necessary.
static FlatSymbolRefAttr lookupOrInsertPrintf(OpBuilder &builder,
ModuleOp module) {
static LLVMFuncOp lookupOrInsertPrintf(OpBuilder &builder, ModuleOp module) {
Location loc = module->getLoc();
ImplicitLocOpBuilder b(loc, builder);
MLIRContext *context = builder.getContext();
Type i32 = builder.getI32Type();

if (module.lookupSymbol<LLVMFuncOp>("printf"))
return SymbolRefAttr::get(context, "printf");
if (auto funcOp = module.lookupSymbol<LLVMFuncOp>("printf"))
return funcOp;

// Create a function declaration for printf, the signature is:
// * `i32 (i8*, ...)`
Expand All @@ -77,8 +76,7 @@ static FlatSymbolRefAttr lookupOrInsertPrintf(OpBuilder &builder,
// Insert the printf function into the body of the parent module.
OpBuilder::InsertionGuard insertGuard(b);
b.setInsertionPointToStart(module.getBody());
b.create<LLVMFuncOp>("printf", printfFunctionType);
return SymbolRefAttr::get(context, "printf");
return b.create<LLVMFuncOp>("printf", printfFunctionType);
}

/// Return a value representing an access into a global string with the given
Expand Down Expand Up @@ -276,7 +274,6 @@ struct PrintOpLowering : public OpConversionPattern<PrintOp> {
matchAndRewrite(PrintOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
Location loc = op->getLoc();
Type i32 = rewriter.getI32Type();

// Assemble format string and arguments for the SSA value.
SmallString<128> format; // op.getPrefix();
Expand All @@ -302,8 +299,8 @@ struct PrintOpLowering : public OpConversionPattern<PrintOp> {
arguments[0] = formatSpec;

// Generate call to printf.
FlatSymbolRefAttr printfRef = lookupOrInsertPrintf(rewriter, module);
rewriter.create<LLVM::CallOp>(loc, i32, printfRef, arguments);
LLVMFuncOp printfOp = lookupOrInsertPrintf(rewriter, module);
rewriter.create<LLVM::CallOp>(loc, printfOp, arguments);
rewriter.eraseOp(op);
return success();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Conversion/StatesToLLVM/StatesToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Func/Transforms/FuncConversions.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/Dialect/SCF/Transforms/Patterns.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/Transforms/DialectConversion.h"
#include "structured/Dialect/Iterators/IR/Iterators.h"
Expand Down
8 changes: 4 additions & 4 deletions lib/Conversion/TabularToLLVM/TabularToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Func/Transforms/FuncConversions.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/Dialect/SCF/Transforms/Patterns.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/Transforms/DialectConversion.h"
#include "structured/Dialect/Tabular/IR/Tabular.h"
Expand All @@ -35,15 +35,15 @@ struct ConvertTabularToLLVMPass
};
} // namespace

TabularTypeConverter::TabularTypeConverter(LLVMTypeConverter &llvmTypeConverter)
TabularTypeConverter::TabularTypeConverter(LLVMTypeConverter *llvmTypeConverter)
: llvmTypeConverter(llvmTypeConverter) {
addConversion([](Type type) { return type; });
addConversion(convertTabularViewType);

// Convert MemRefType using LLVMTypeConverter.
addConversion([&](Type type) -> std::optional<Type> {
if (type.isa<MemRefType>())
return llvmTypeConverter.convertType(type);
return this->llvmTypeConverter->convertType(type);
return std::nullopt;
});
}
Expand Down Expand Up @@ -129,7 +129,7 @@ void mlir::tabular::populateTabularToLLVMConversionPatterns(
void ConvertTabularToLLVMPass::runOnOperation() {
auto module = getOperation();
LLVMTypeConverter llvmTypeConverter(&getContext());
TabularTypeConverter typeConverter(llvmTypeConverter);
TabularTypeConverter typeConverter(&llvmTypeConverter);

// Convert the remaining ops of this dialect using dialect conversion.
ConversionTarget target(getContext());
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/Iterators/IR/Iterators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ LogicalResult ExtractValueOp::inferReturnTypes(
DictionaryAttr attributes, OpaqueProperties properties, RegionRange regions,
SmallVectorImpl<Type> &inferredReturnTypes) {
auto stateType = operands[0].getType().cast<StateType>();
auto indexAttr = attributes.getAs<IntegerAttr>("index");
auto typedProperties = properties.as<ExtractValueOp::Properties *>();
auto indexAttr = typedProperties->getIndex();
int64_t index = indexAttr.getValue().getSExtValue();
Type fieldType = stateType.getFieldTypes()[index];
inferredReturnTypes.assign({fieldType});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Func/Transforms/OneToNFuncConversions.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/Dialect/SCF/Transforms/Patterns.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/OneToNTypeConversion.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/Tuple/Transforms/DecomposeTuples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "structured/Dialect/Tuple/Transforms/DecomposeTuples.h"

#include "mlir/Dialect/Func/Transforms/OneToNFuncConversions.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/Dialect/SCF/Transforms/Patterns.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/OneToNTypeConversion.h"
#include "structured/Dialect/Tuple/IR/Tuple.h"
Expand Down
1 change: 0 additions & 1 deletion python/mlir_structured/dialects/IteratorsOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#ifndef PYTHON_BINDINGS_ITERATORS_OPS
#define PYTHON_BINDINGS_ITERATORS_OPS

include "mlir/Bindings/Python/Attributes.td"
include "structured/Dialect/Iterators/IR/IteratorsOps.td"

#endif // PYTHON_BINDINGS_ITERATORS_OPS
1 change: 0 additions & 1 deletion python/mlir_structured/dialects/TabularOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#ifndef PYTHON_BINDINGS_TABULAR_OPS
#define PYTHON_BINDINGS_TABULAR_OPS

include "mlir/Bindings/Python/Attributes.td"
include "structured/Dialect/Tabular/IR/TabularOps.td"

#endif // PYTHON_BINDINGS_TABULAR_OPS
1 change: 0 additions & 1 deletion python/mlir_structured/dialects/TupleOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#ifndef PYTHON_BINDINGS_TUPLE_OPS
#define PYTHON_BINDINGS_TUPLE_OPS

include "mlir/Bindings/Python/Attributes.td"
include "structured/Dialect/Tuple/IR/TupleOps.td"

#endif // PYTHON_BINDINGS_TUPLE_OPS
2 changes: 1 addition & 1 deletion test/Conversion/IteratorsToLLVM/printconstant.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func.func @main() {
// CHECK-DAG: %[[V6:.*]] = llvm.getelementptr %[[V4]][0] : (!llvm.ptr) -> !llvm.ptr, i8
// CHECK-DAG: %[[V7:.*]] = tuple.to_elements %[[V3]] : tuple<i32>
// CHECK-DAG: %[[Vb:.*]] = arith.extui %[[V7]] : i32 to i64
// CHECK-NEXT: %[[V8:.*]] = llvm.call @printf(%[[V6]], %[[Vb]]) : (!llvm.ptr, i64) -> i32
// CHECK-NEXT: %[[V8:.*]] = llvm.call @printf(%[[V6]], %[[Vb]]) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32

%three_field_tuple = "iterators.constanttuple"() { values = [1 : i32, 2 : i32, 3 : i32] } : () -> tuple<i32, i32, i32>
// CHECK-DAG: %[[V5:.*]] = arith.constant 1 : i32
Expand Down
4 changes: 2 additions & 2 deletions test/Conversion/IteratorsToLLVM/sink.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ func.func @main() {
// CHECK-DAG: %[[V6:.*]] = llvm.getelementptr %[[V4]][0] : (!llvm.ptr) -> !llvm.ptr, i8
// CHECK-DAG: %[[V7:.*]] = tuple.to_elements %[[arg2:.*]] : tuple<i32>
// CHECK-DAG: %[[V9:.*]] = arith.extui %[[V7]] : i32 to i64
// CHECK-NEXT: %[[V8:.*]] = llvm.call @printf(%[[V6]], %[[V9]]) : (!llvm.ptr, i64) -> i32
// CHECK-NEXT: %[[V8:.*]] = llvm.call @printf(%[[V6]], %[[V9]]) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
// CHECK-NEXT: scf.yield %[[arg1]] : [[rootStateType]]
// CHECK-NEXT: }
// CHECK-NEXT: %[[V3:.*]] = call @[[rootIteratorName]].close.{{[0-9]+}}(%[[V2]]#0) : ([[rootStateType]]) -> [[rootStateType]]
// CHECK-DAG: %[[Va:.*]] = llvm.mlir.addressof @iterators.frmt_spec.0 : !llvm.ptr
// CHECK-DAG: %[[Vc:.*]] = llvm.getelementptr %[[Va]][0] : (!llvm.ptr) -> !llvm.ptr, i8
// CHECK-NEXT: %[[Vd:.*]] = llvm.call @printf(%[[Vc]]) : (!llvm.ptr) -> i32
// CHECK-NEXT: %[[Vd:.*]] = llvm.call @printf(%[[Vc]]) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr) -> i32
return
// CHECK-NEXT: return
}
Expand Down
8 changes: 4 additions & 4 deletions test/Dialect/Iterators/constant-stream.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ func.func @main() {
// CHECK-LABEL: func.func @main() {
%empty = "iterators.constantstream"() { value = [] } :
() -> (!iterators.stream<tuple<i32>>)
// CHECK-NEXT: %[[V0:constantstream.*]] = "iterators.constantstream"() {value = []} : () -> !iterators.stream<tuple<i32>>
// CHECK-NEXT: %[[V0:constantstream.*]] = "iterators.constantstream"() <{value = []}> : () -> !iterators.stream<tuple<i32>>
%i32 = "iterators.constantstream"() { value = [[42 : i32]] } :
() -> (!iterators.stream<tuple<i32>>)
// CHECK-NEXT: %[[V1:constantstream.*]] = "iterators.constantstream"() {value = {{\[}}[42 : i32]]} : () -> !iterators.stream<tuple<i32>>
// CHECK-NEXT: %[[V1:constantstream.*]] = "iterators.constantstream"() <{value = {{\[}}[42 : i32]]}> : () -> !iterators.stream<tuple<i32>>
%f32 = "iterators.constantstream"() { value = [[42. : f32]] } :
() -> (!iterators.stream<tuple<f32>>)
// CHECK-NEXT: %[[V2:constantstream.*]] = "iterators.constantstream"() {value = {{\[}}[4.200000e+01 : f32]]} : () -> !iterators.stream<tuple<f32>>
// CHECK-NEXT: %[[V2:constantstream.*]] = "iterators.constantstream"() <{value = {{\[}}[4.200000e+01 : f32]]}> : () -> !iterators.stream<tuple<f32>>
%i32i64 = "iterators.constantstream"() { value = [[42 : i32, 1337 : i64]] } :
() -> (!iterators.stream<tuple<i32, i64>>)
// CHECK-NEXT: %[[V3:constantstream.*]] = "iterators.constantstream"() {value = {{\[}}[42 : i32, 1337]]} : () -> !iterators.stream<tuple<i32, i64>>
// CHECK-NEXT: %[[V3:constantstream.*]] = "iterators.constantstream"() <{value = {{\[}}[42 : i32, 1337]]}> : () -> !iterators.stream<tuple<i32, i64>>
return
// CHECK-NEXT: return
}
Expand Down
6 changes: 3 additions & 3 deletions test/Dialect/Iterators/constant.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
func.func @main() {
// CHECK-LABEL: func.func @main() {
%empty_tuple = "iterators.constanttuple"() { values = [] } : () -> tuple<>
// CHECK-NEXT: %[[V0:tuple.*]] = "iterators.constanttuple"() {values = []} : () -> tuple<>
// CHECK-NEXT: %[[V0:tuple.*]] = "iterators.constanttuple"() <{values = []}> : () -> tuple<>
%one_field_tuple = "iterators.constanttuple"()
{ values = [1 : i32] } : () -> tuple<i32>
// CHECK-NEXT: %[[V0:tuple.*]] = "iterators.constanttuple"() {values = [1 : i32]} : () -> tuple<i32>
// CHECK-NEXT: %[[V0:tuple.*]] = "iterators.constanttuple"() <{values = [1 : i32]}> : () -> tuple<i32>
%three_field_tuple = "iterators.constanttuple"()
{ values = [1 : i32, 2 : i32, 3 : i32] } : () -> tuple<i32, i32, i32>
// CHECK-NEXT: %[[V0:tuple.*]] = "iterators.constanttuple"() {values = [1 : i32, 2 : i32, 3 : i32]} : () -> tuple<i32, i32, i32>
// CHECK-NEXT: %[[V0:tuple.*]] = "iterators.constanttuple"() <{values = [1 : i32, 2 : i32, 3 : i32]}> : () -> tuple<i32, i32, i32>
return
// CHECK-NEXT: return
}
Expand Down
2 changes: 1 addition & 1 deletion test/Dialect/Iterators/filter.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func.func @main() {
%filtered = "iterators.filter"(%input) {predicateRef = @is_positive_tuple} :
(!iterators.stream<tuple<i32>>) ->
(!iterators.stream<tuple<i32>>)
// CHECK-NEXT: %[[V1:filtered.*]] = "iterators.filter"(%[[V0]]) {predicateRef = @is_positive_tuple} : (!iterators.stream<tuple<i32>>) -> !iterators.stream<tuple<i32>>
// CHECK-NEXT: %[[V1:filtered.*]] = "iterators.filter"(%[[V0]]) <{predicateRef = @is_positive_tuple}> : (!iterators.stream<tuple<i32>>) -> !iterators.stream<tuple<i32>>
return
// CHECK-NEXT: return
}
Expand Down
2 changes: 1 addition & 1 deletion test/Dialect/Iterators/map.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func.func @main() {
// CHECK-NEXT: %[[V0:.*]] = "iterators.constantstream"{{.*}}
%unpacked = "iterators.map"(%input) {mapFuncRef = @unpack_i32} :
(!iterators.stream<tuple<i32>>) -> (!iterators.stream<i32>)
// CHECK-NEXT: %[[V1:mapped.*]] = "iterators.map"(%[[V0]]) {mapFuncRef = @unpack_i32} : (!iterators.stream<tuple<i32>>) -> !iterators.stream<i32>
// CHECK-NEXT: %[[V1:mapped.*]] = "iterators.map"(%[[V0]]) <{mapFuncRef = @unpack_i32}> : (!iterators.stream<tuple<i32>>) -> !iterators.stream<i32>
return
// CHECK-NEXT: return
}
Expand Down
2 changes: 1 addition & 1 deletion test/Dialect/Iterators/reduce.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func.func @main() {
%reduced = "iterators.reduce"(%input) {reduceFuncRef = @sum_tuple} :
(!iterators.stream<tuple<i32>>) ->
(!iterators.stream<tuple<i32>>)
// CHECK-NEXT: %[[V1:reduced.*]] = "iterators.reduce"(%[[V0]]) {reduceFuncRef = @sum_tuple} : (!iterators.stream<tuple<i32>>) -> !iterators.stream<tuple<i32>>
// CHECK-NEXT: %[[V1:reduced.*]] = "iterators.reduce"(%[[V0]]) <{reduceFuncRef = @sum_tuple}> : (!iterators.stream<tuple<i32>>) -> !iterators.stream<tuple<i32>>
return
// CHECK-NEXT: return
}
Expand Down
2 changes: 1 addition & 1 deletion test/python/dialects/iterators/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def testParse():
'%0 = "iterators.constantstream"() {value = []} : () -> (!iterators.stream<tuple<i32>>)'
)
# CHECK: module {
# CHECK-NEXT: %[[V0:.*]] = "iterators.constantstream"() {value = []} : () -> !iterators.stream<tuple<i32>>
# CHECK-NEXT: %[[V0:.*]] = "iterators.constantstream"() <{value = []}> : () -> !iterators.stream<tuple<i32>>
# CHECK-NEXT: }
print(mod)

Expand Down
2 changes: 1 addition & 1 deletion third_party/llvm-project
1 change: 0 additions & 1 deletion tools/structured-opt/structured-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ int main(int argc, char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal(executable);
#endif

llvm::InitLLVM y(argc, argv);
registerAllPasses();
registerStructuredConversionPasses();
registerIteratorsPasses();
Expand Down

0 comments on commit 6a84d0f

Please sign in to comment.