Files
clang-p2996/mlir/test/mlir-translate/split-markers.mlir
Ingo Müller 516ccce7fa [mlir] Make the split markers of splitAndProcessBuffer configurable. (#84765)
This allows to define custom splitters, which is interesting for
non-MLIR inputs and outputs to `mlir-translate`. For example, one may
use `; -----` as a splitter of `.ll` files. The splitters are now passed
as arguments into `splitAndProcessBuffer`, the input splitter defaulting
to the previous default (`// -----`) and the output splitter defaulting
to the empty string, which also corresponds to the previous default. The
behavior of the input split marker should not change at all; however,
outputs now have one new line *more* than before if there is no splitter
(old: `insertMarkerInOutput = false`, new: `outputSplitMarker = ""`) and
one new line *less* if there is one. The value of the input splitter is
exposed as a command line options of `mlir-translate` and other tools as
an optional value to the previously existing flag `-split-input-file`,
which defaults to the default splitter if not specified; the value of
the output splitter is exposed with the new `-output-split-marker`,
which default to the empty string in `mlir-translate` and the default
splitter in the other tools. In short, the previous usage or omission of
the flags should result in previous behavior (modulo the new lines
mentioned before).
2024-03-14 13:55:50 +01:00

36 lines
1.1 KiB
MLIR

// Check that (1) the output split marker is inserted and (2) the input file is
// split using the default split marker.
// RUN: mlir-translate %s -split-input-file -mlir-to-llvmir \
// RUN: -output-split-marker="; -----" \
// RUN: | FileCheck -check-prefix=CHECK-OUTPUT %s
// With the second command, check that (3) the input split marker is used and
// (4) the output split marker is empty if not specified.
// RUN: mlir-translate %s -split-input-file="// ""-----" -mlir-to-llvmir \
// RUN: -output-split-marker="; -----" \
// RUN: | mlir-translate -split-input-file -import-llvm \
// RUN: -split-input-file="; -----" \
// RUN: | FileCheck -check-prefix=CHECK-ROUNDTRIP %s
// Check that (5) the input is not split if `-split-input-file` is not given.
// RUN: mlir-translate %s -mlir-to-llvmir \
// RUN: | FileCheck -check-prefix=CHECK-NOSPLIT %s
// CHECK-OUTPUT: ModuleID
// CHECK-OUTPUT: ; -----
// CHECK-OUTPUT-NEXT: ModuleID
// CHECK-ROUNDTRIP: module {{.*}} {
// CHECK-ROUNDTRIP-NEXT: }
// CHECK-ROUNDTRIP-EMPTY:
// CHECK-ROUNDTRIP: module
// CHECK-NOSPLIT: ModuleID
// CHECK-NOSPLIT-NOT: ModuleID
module {}
// -----
module {}