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
32 changes: 16 additions & 16 deletions clang/lib/CIR/Dialect/IR/CIRDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2859,22 +2859,6 @@ static ::mlir::ParseResult parseCallCommon(::mlir::OpAsmParser &parser,
allResultTypes = opsFnTy.getResults();
result.addTypes(allResultTypes);

auto &builder = parser.getBuilder();
Attribute extraAttrs;
if (::mlir::succeeded(parser.parseOptionalKeyword("extra"))) {
if (parser.parseLParen().failed())
return failure();
if (parser.parseAttribute(extraAttrs).failed())
return failure();
if (parser.parseRParen().failed())
return failure();
} else {
NamedAttrList empty;
extraAttrs = mlir::cir::ExtraFuncAttributesAttr::get(
builder.getContext(), empty.getDictionary(builder.getContext()));
}
result.addAttribute(extraAttrsAttrName, extraAttrs);

if (parser.resolveOperands(ops, operandsTypes, opsLoc, result.operands))
return ::mlir::failure();

Expand All @@ -2894,6 +2878,7 @@ static ::mlir::ParseResult parseCallCommon(::mlir::OpAsmParser &parser,
return ::mlir::failure();
}

auto &builder = parser.getBuilder();
if (parser.parseOptionalKeyword("cc").succeeded()) {
if (parser.parseLParen().failed())
return failure();
Expand All @@ -2906,6 +2891,21 @@ static ::mlir::ParseResult parseCallCommon(::mlir::OpAsmParser &parser,
builder.getContext(), callingConv));
}

Attribute extraAttrs;
if (::mlir::succeeded(parser.parseOptionalKeyword("extra"))) {
if (parser.parseLParen().failed())
return failure();
if (parser.parseAttribute(extraAttrs).failed())
return failure();
if (parser.parseRParen().failed())
return failure();
} else {
NamedAttrList empty;
extraAttrs = mlir::cir::ExtraFuncAttributesAttr::get(
builder.getContext(), empty.getDictionary(builder.getContext()));
}
result.addAttribute(extraAttrsAttrName, extraAttrs);

// If exception is present and there are cleanups, this should be latest thing
// present (after all attributes, etc).
mlir::Region *cleanupRegion = nullptr;
Expand Down
13 changes: 10 additions & 3 deletions clang/test/CIR/IR/call.cir
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ module {
cir.return %arg0 : !s32i
}

cir.func private @my_add(%a: !s32i, %b: !s32i) -> !s32i cc(spir_function) extra(#fn_attr)

cir.func @ind(%fnptr: !fnptr, %a : !s32i) {
%r = cir.call %fnptr(%a) : (!fnptr, !s32i) -> !s32i
// CHECK: %0 = cir.call %arg0(%arg1) : (!cir.ptr<!cir.func<!s32i (!s32i)>>, !s32i) -> !s32i
// Check parse->pretty-print round-trip on extra() attribute
%7 = cir.call @_ZNSt5arrayIiLm8192EEixEm(%a) : (!s32i) -> !s32i extra(#fn_attr1)
// CHECK: %1 = cir.call @_ZNSt5arrayIiLm8192EEixEm(%arg1) : (!s32i) -> !s32i extra(#fn_attr1)
// Frankenstein's example from clang/test/CIR/Lowering/call-op-call-conv.cir
%3 = cir.try_call @my_add(%r, %7) ^continue, ^landing_pad : (!s32i, !s32i) -> !s32i cc(spir_function) extra(#fn_attr1)
// CHECK: %2 = cir.try_call @my_add(%0, %1) ^bb1, ^bb2 : (!s32i, !s32i) -> !s32i cc(spir_function) extra(#fn_attr1)
^continue:
cir.br ^landing_pad
^landing_pad:
cir.return
}
}

// CHECK: %0 = cir.call %arg0(%arg1) : (!cir.ptr<!cir.func<!s32i (!s32i)>>, !s32i) -> !s32i
// CHECK: %1 = cir.call @_ZNSt5arrayIiLm8192EEixEm(%arg1) : (!s32i) -> !s32i extra(#fn_attr1)
Loading