Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ def EmitC_VerbatimOp : EmitC_Op<"verbatim"> {
FailureOr<SmallVector<::mlir::emitc::ReplacementItem>> parseFormatString();
}];

let arguments = (ins StrAttr:$value, Variadic<EmitCType>:$fmtArgs);
let arguments = (ins StrAttr:$value, Variadic<AnyTypeOf<[EmitCType, EmitC_LValueType]>>:$fmtArgs);

let builders = [OpBuilder<(ins "::mlir::StringAttr":$value),
[{ build($_builder, $_state, value, {}); }]>];
Expand Down
16 changes: 12 additions & 4 deletions mlir/test/Dialect/EmitC/ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,20 @@ emitc.verbatim "typedef float f32;"
// The value is not interpreted as format string if there are no operands.
emitc.verbatim "{} { }"

func.func @test_verbatim(%arg0 : !emitc.ptr<i32>, %arg1 : i32) {
func.func @test_verbatim(%arg0 : !emitc.ptr<i32>, %arg1 : i32, %arg2: !emitc.array<3x!emitc.ptr<i32>>) {
%a = "emitc.variable"() <{value = #emitc.opaque<"1">}> : () -> !emitc.lvalue<i32>

// Check that the lvalue type can be used by verbatim.
emitc.verbatim "++{};" args %a : !emitc.lvalue<i32>

// Check that the array type can be used by verbatim.
emitc.verbatim "*{}[0] = 1;" args %arg2 : !emitc.array<3x!emitc.ptr<i32>>

emitc.verbatim "{} + {};" args %arg0, %arg1 : !emitc.ptr<i32>, i32

// Check there is no ambiguity whether %a is the argument to the emitc.verbatim op.
emitc.verbatim "a"
%a = "emitc.constant"(){value = 42 : i32} : () -> i32
// Check there is no ambiguity whether %b is the argument to the emitc.verbatim op.
emitc.verbatim "b"
%b = "emitc.constant"(){value = 42 : i32} : () -> i32

return
}
Expand Down
Loading