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
6 changes: 1 addition & 5 deletions mlir/lib/Target/Cpp/TranslateToCpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,11 +749,7 @@ static LogicalResult printOperation(CppEmitter &emitter,
if (t.getType().isIndex()) {
int64_t idx = t.getInt();
Value operand = op.getOperand(idx);
if (!emitter.hasValueInScope(operand))
return op.emitOpError("operand ")
<< idx << "'s value not defined in scope";
os << emitter.getOrCreateName(operand);
return success();
return emitter.emitOperand(operand);
}
}
if (failed(emitter.emitAttribute(op.getLoc(), attr)))
Expand Down
21 changes: 21 additions & 0 deletions mlir/test/Target/Cpp/expressions.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,24 @@ func.func @expression_with_load_and_call(%arg0: !emitc.ptr<i32>) -> i1 {
}
return %result : i1
}


// CPP-DEFAULT: void expression_with_call_opaque_with_args_array(int32_t [[v1:v.+]], int32_t [[v2:v.+]]) {
// CPP-DEFAULT-NEXT: bool [[v3:v.+]] = f(([[v1]] < [[v2]]));
// CPP-DEFAULT-NEXT: return;
// CPP-DEFAULT-NEXT: }

// CPP-DECLTOP: void expression_with_call_opaque_with_args_array(int32_t [[v1:v.+]], int32_t [[v2:v.+]]) {
// CPP-DECLTOP-NEXT: bool [[v3:v.+]];
// CPP-DECLTOP-NEXT: [[v3]] = f(([[v1]] < [[v2]]));
// CPP-DECLTOP-NEXT: return;
// CPP-DECLTOP-NEXT: }

emitc.func @expression_with_call_opaque_with_args_array(%0 : i32, %1 : i32) {
%2 = expression : i1 {
%3 = cmp lt, %0, %1 : (i32, i32) -> i1
%4 = emitc.call_opaque "f"(%3) {"args" = [0: index]} : (i1) -> i1
yield %4 : i1
}
return
}