[clang] [CIR] Upstream support for accessing structure members (PR #136383)
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 21 10:46:54 PDT 2025
================
@@ -1310,6 +1310,70 @@ def GetGlobalOp : CIR_Op<"get_global",
let hasVerifier = 0;
}
+//===----------------------------------------------------------------------===//
+// GetMemberOp
+//===----------------------------------------------------------------------===//
+
+def GetMemberOp : CIR_Op<"get_member"> {
+ let summary = "Get the address of a member of a record";
+ let description = [{
+ The `cir.get_member` operation gets the address of a particular named
+ member from the input record.
+
+ It expects a pointer to the base record as well as the name of the member
+ and its field index.
----------------
bcardosolopes wrote:
> Or are they 'flattened' and the index is consistent?
This one. For a bit of extra context: whenever something more complex is going on CIRGen takes care of it such that the final getmember is reliable.
> One thing that might be interesting if we don't encode it is sometimes casts between types are legal if they have a 'common initial sequence' depending on language mode and use
Indeed interesting. If this turns out to help CIRGen / optimization we should be all in for it in the future. Any compelling use case in mind?
https://github.com/llvm/llvm-project/pull/136383
More information about the cfe-commits
mailing list