-
Notifications
You must be signed in to change notification settings - Fork 153
[CIR][CIRGen] Implement VisitCXXStdInitializerListExpr to support use of std::initializer_list #764
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Some minor nit and ready to go.
It would be nice in the future to have a cir.initlist
thing - a higher level representation for this (we even have a specialized AST node). Right now it would be really hard to recognize something came from an initializer list if we lower it this early - if you want to work on that at some point it would be welcome. In that world, LoweringPrepare would then lower to what we currently get as of this PR.
There are tests failing! |
@@ -959,6 +949,19 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { | |||
return create<mlir::cir::GetRuntimeMemberOp>(loc, resultTy, objectPtr, | |||
memberPtr); | |||
} | |||
|
|||
/// create a cir.ptr_stride operation to get access to an array element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments should in general start with upper case, please apply the change here, next comment, and try to make sure next PRs address that right away.
… of std::initializer_list (llvm#764) implement VisitCXXStdInitializerListExpr as similar as to [OG](https://github.com/llvm/clangir/blob/7150a050c12119c27e9eb1547aa65f535e4bfbe9/clang/lib/CodeGen/CGExprAgg.cpp#L417): In order to support this implementation, made some changes to get more helper functions. Also added some tests. The generated LLVM code is most similar to OG's llvm code, 3 interesting differences: 1. CIR introduced scope, thus extra branch 2. OG' has comdat for _ZSt1fIiEvSt16initializer_listIT_E function, but we haven't implemented FuncOP's comdat yet. I'll probably try to add it in another PR, but it's not in the scope of this PR. 3. When defining initialized_list type, OG prefers generic type like %"class.std::initializer_list" = type { ptr, ptr }, but CIR prefers instantiated like "%"class.std::initializer_list<const char *>" = type { ptr, ptr }"
… of std::initializer_list (llvm#764) implement VisitCXXStdInitializerListExpr as similar as to [OG](https://github.com/llvm/clangir/blob/7150a050c12119c27e9eb1547aa65f535e4bfbe9/clang/lib/CodeGen/CGExprAgg.cpp#L417): In order to support this implementation, made some changes to get more helper functions. Also added some tests. The generated LLVM code is most similar to OG's llvm code, 3 interesting differences: 1. CIR introduced scope, thus extra branch 2. OG' has comdat for _ZSt1fIiEvSt16initializer_listIT_E function, but we haven't implemented FuncOP's comdat yet. I'll probably try to add it in another PR, but it's not in the scope of this PR. 3. When defining initialized_list type, OG prefers generic type like %"class.std::initializer_list" = type { ptr, ptr }, but CIR prefers instantiated like "%"class.std::initializer_list<const char *>" = type { ptr, ptr }"
… of std::initializer_list (llvm#764) implement VisitCXXStdInitializerListExpr as similar as to [OG](https://github.com/llvm/clangir/blob/7150a050c12119c27e9eb1547aa65f535e4bfbe9/clang/lib/CodeGen/CGExprAgg.cpp#L417): In order to support this implementation, made some changes to get more helper functions. Also added some tests. The generated LLVM code is most similar to OG's llvm code, 3 interesting differences: 1. CIR introduced scope, thus extra branch 2. OG' has comdat for _ZSt1fIiEvSt16initializer_listIT_E function, but we haven't implemented FuncOP's comdat yet. I'll probably try to add it in another PR, but it's not in the scope of this PR. 3. When defining initialized_list type, OG prefers generic type like %"class.std::initializer_list" = type { ptr, ptr }, but CIR prefers instantiated like "%"class.std::initializer_list<const char *>" = type { ptr, ptr }"
… of std::initializer_list (llvm#764) implement VisitCXXStdInitializerListExpr as similar as to [OG](https://github.com/llvm/clangir/blob/7150a050c12119c27e9eb1547aa65f535e4bfbe9/clang/lib/CodeGen/CGExprAgg.cpp#L417): In order to support this implementation, made some changes to get more helper functions. Also added some tests. The generated LLVM code is most similar to OG's llvm code, 3 interesting differences: 1. CIR introduced scope, thus extra branch 2. OG' has comdat for _ZSt1fIiEvSt16initializer_listIT_E function, but we haven't implemented FuncOP's comdat yet. I'll probably try to add it in another PR, but it's not in the scope of this PR. 3. When defining initialized_list type, OG prefers generic type like %"class.std::initializer_list" = type { ptr, ptr }, but CIR prefers instantiated like "%"class.std::initializer_list<const char *>" = type { ptr, ptr }"
… of std::initializer_list (#764) implement VisitCXXStdInitializerListExpr as similar as to [OG](https://github.com/llvm/clangir/blob/7150a050c12119c27e9eb1547aa65f535e4bfbe9/clang/lib/CodeGen/CGExprAgg.cpp#L417): In order to support this implementation, made some changes to get more helper functions. Also added some tests. The generated LLVM code is most similar to OG's llvm code, 3 interesting differences: 1. CIR introduced scope, thus extra branch 2. OG' has comdat for _ZSt1fIiEvSt16initializer_listIT_E function, but we haven't implemented FuncOP's comdat yet. I'll probably try to add it in another PR, but it's not in the scope of this PR. 3. When defining initialized_list type, OG prefers generic type like %"class.std::initializer_list" = type { ptr, ptr }, but CIR prefers instantiated like "%"class.std::initializer_list<const char *>" = type { ptr, ptr }"
… of std::initializer_list (#764) implement VisitCXXStdInitializerListExpr as similar as to [OG](https://github.com/llvm/clangir/blob/7150a050c12119c27e9eb1547aa65f535e4bfbe9/clang/lib/CodeGen/CGExprAgg.cpp#L417): In order to support this implementation, made some changes to get more helper functions. Also added some tests. The generated LLVM code is most similar to OG's llvm code, 3 interesting differences: 1. CIR introduced scope, thus extra branch 2. OG' has comdat for _ZSt1fIiEvSt16initializer_listIT_E function, but we haven't implemented FuncOP's comdat yet. I'll probably try to add it in another PR, but it's not in the scope of this PR. 3. When defining initialized_list type, OG prefers generic type like %"class.std::initializer_list" = type { ptr, ptr }, but CIR prefers instantiated like "%"class.std::initializer_list<const char *>" = type { ptr, ptr }"
implement VisitCXXStdInitializerListExpr as similar as to OG:
In order to support this implementation, made some changes to get more helper functions.
Also added some tests.
The generated LLVM code is most similar to OG's llvm code, 3 interesting differences: