-
Notifications
You must be signed in to change notification settings - Fork 156
[CIR][CodeGen] Introduce CIR CXXSpecialMember attribute #1711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 18 commits
8c7235c
904732f
d4c51f3
c3480fd
f10b62f
15a4a12
f6aaa4d
5de2d7a
0a8fd5b
ffe23ba
d6c0f3a
db31493
c40a840
b7318cb
470b556
5e8de9b
1861174
f640087
0cb89ab
631455b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2529,6 +2529,7 @@ ParseResult cir::FuncOp::parse(OpAsmParser &parser, OperationState &state) { | |||||||||||||||||
auto visibilityNameAttr = getGlobalVisibilityAttrName(state.name); | ||||||||||||||||||
auto dsoLocalNameAttr = getDsoLocalAttrName(state.name); | ||||||||||||||||||
auto annotationsNameAttr = getAnnotationsAttrName(state.name); | ||||||||||||||||||
auto cxxSpecialMemberAttr = getCxxSpecialMemberAttrName(state.name); | ||||||||||||||||||
if (::mlir::succeeded(parser.parseOptionalKeyword(builtinNameAttr.strref()))) | ||||||||||||||||||
state.addAttribute(builtinNameAttr, parser.getBuilder().getUnitAttr()); | ||||||||||||||||||
if (::mlir::succeeded( | ||||||||||||||||||
|
@@ -2609,6 +2610,20 @@ ParseResult cir::FuncOp::parse(OpAsmParser &parser, OperationState &state) { | |||||||||||||||||
state.addAttribute(annotationsNameAttr, annotations); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// Parse CXXSpecialMember attribute | ||||||||||||||||||
if (parser.parseOptionalKeyword("special_member").succeeded()) { | ||||||||||||||||||
cir::CXXCtorAttr ctorAttr; | ||||||||||||||||||
cir::CXXDtorAttr dtorAttr; | ||||||||||||||||||
if (parser.parseLess().failed()) | ||||||||||||||||||
return failure(); | ||||||||||||||||||
if (auto oa = parser.parseOptionalAttribute(ctorAttr); oa.has_value()) | ||||||||||||||||||
state.addAttribute(cxxSpecialMemberAttr, ctorAttr); | ||||||||||||||||||
if (auto oa = parser.parseOptionalAttribute(dtorAttr); oa.has_value()) | ||||||||||||||||||
state.addAttribute(cxxSpecialMemberAttr, dtorAttr); | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
right, updated! |
||||||||||||||||||
if (parser.parseGreater().failed()) | ||||||||||||||||||
return failure(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// If additional attributes are present, parse them. | ||||||||||||||||||
if (parser.parseOptionalAttrDictWithKeyword(state.attributes)) | ||||||||||||||||||
return failure(); | ||||||||||||||||||
|
@@ -2789,6 +2804,13 @@ void cir::FuncOp::print(OpAsmPrinter &p) { | |||||||||||||||||
p.printAttribute(annotations); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
if (auto specialMemberAttr = getCxxSpecialMember()) { | ||||||||||||||||||
assert((mlir::isa<cir::CXXCtorAttr, cir::CXXDtorAttr>(*specialMemberAttr))); | ||||||||||||||||||
p << " special_member<"; | ||||||||||||||||||
p.printAttribute(*specialMemberAttr); | ||||||||||||||||||
p << '>'; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
function_interface_impl::printFunctionAttributes( | ||||||||||||||||||
p, *this, | ||||||||||||||||||
// These are all omitted since they are custom printed already. | ||||||||||||||||||
|
@@ -2799,7 +2821,7 @@ void cir::FuncOp::print(OpAsmPrinter &p) { | |||||||||||||||||
getLinkageAttrName(), getCallingConvAttrName(), getNoProtoAttrName(), | ||||||||||||||||||
getSymVisibilityAttrName(), getArgAttrsAttrName(), getResAttrsAttrName(), | ||||||||||||||||||
getComdatAttrName(), getGlobalVisibilityAttrName(), | ||||||||||||||||||
getAnnotationsAttrName()}); | ||||||||||||||||||
getAnnotationsAttrName(), getCxxSpecialMemberAttrName()}); | ||||||||||||||||||
|
||||||||||||||||||
if (auto aliaseeName = getAliasee()) { | ||||||||||||||||||
p << " alias("; | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// RUN: cir-opt %s -o %t.cir | ||
// RUN: FileCheck --input-file=%t.cir %s | ||
|
||
!s32i = !cir.int<s, 32> | ||
!rec_S = !cir.record<struct "S" {!s32i}> | ||
module { | ||
cir.func private @_ZN1SC1ERKS_(!cir.ptr<!rec_S>, !cir.ptr<!rec_S>) special_member<#cir.cxx_ctor<!rec_S, copy>> | ||
cir.func private @_ZN1SC2Ei(!cir.ptr<!rec_S>, !cir.ptr<!rec_S>) | ||
cir.func private @_ZN1SC2Ev(!cir.ptr<!rec_S>) special_member<#cir.cxx_ctor<!rec_S, default>> | ||
cir.func private @_ZN1SD2Ev(!cir.ptr<!rec_S>) special_member<#cir.cxx_dtor<!rec_S>> | ||
} | ||
|
||
// CHECK: !s32i = !cir.int<s, 32> | ||
// CHECK: !rec_S = !cir.record<struct "S" {!s32i}> | ||
// CHECK: module { | ||
// CHECK: cir.func private @_ZN1SC1ERKS_(!cir.ptr<!rec_S>, !cir.ptr<!rec_S>) special_member<#cir.cxx_ctor<!rec_S, copy>> | ||
// CHECK: cir.func private @_ZN1SC2Ei(!cir.ptr<!rec_S>, !cir.ptr<!rec_S>) | ||
// CHECK: cir.func private @_ZN1SC2Ev(!cir.ptr<!rec_S>) special_member<#cir.cxx_ctor<!rec_S, default>> | ||
// CHECK: cir.func private @_ZN1SD2Ev(!cir.ptr<!rec_S>) special_member<#cir.cxx_dtor<!rec_S>> | ||
// CHECK: } |
Uh oh!
There was an error while loading. Please reload this page.