-
Notifications
You must be signed in to change notification settings - Fork 103
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
[CIR] Add integer result type for cir.global_view #1248
base: main
Are you sure you want to change the base?
Conversation
clang/test/CIR/Lowering/globals.cir
Outdated
@@ -198,4 +205,17 @@ module { | |||
} | |||
// MLIR: %0 = llvm.mlir.addressof @zero_array | |||
|
|||
cir.func @const_global_addr() -> !u64i { | |||
%0 = cir.const #cir.global_addr<@".str"> : !u64i |
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.
Sounds like this is equivalent to a global view with zero index? Why can't this be modeled ash cir.const #cir.global_view<@".str">
?
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.
cir.global_addr is of integer types, and I'm not sure if it's appropriate to make cir.global_view an integer type. If it's OK I could just update cir.global_view instead of introducing a new one.
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.
My take is that we want here is a constant pointer coming out of cir.const
, followed up by a cast to integer?
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.
My take is that we want here is a constant pointer coming out of cir.const, followed up by a cast to integer?
In this case, yes. But I'm actually proposing this attribute for the following scenario where you don't have space for additional operations:
%0 = cir.const #cir.const_struct {
#cir.global_addr @aaa,
#cir.global_addr @bbb
}
And I'm looking at this scenario because recently I'm working on the LLVM lowering of member function pointers. Upon ABI lowering, a member function pointer is lowered to a struct with two fields of type ptrdiff_t
. When the member function pointer represents a non-virtual member function, the first field stores the address of the target function as an integer. Thus to represent constant member function pointers I need an attribute that works like #cir.global_addr
.
0622358
to
61d5469
Compare
61d5469
to
d530ee9
Compare
I have updated this PR and removed the |
This PR updates the
#cir.global_view
attribute and make it accept integer types as its result type.