[clang] [CIR] Add VTableAddrPointOp (PR #148730)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 15 04:59:08 PDT 2025
================
@@ -1669,6 +1669,51 @@ def GetGlobalOp : CIR_Op<"get_global",
}];
}
+//===----------------------------------------------------------------------===//
+// VTableAddrPointOp
+//===----------------------------------------------------------------------===//
+
+def VTableAddrPointOp : CIR_Op<"vtable.address_point",
+ [Pure, DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
+ let summary = "Get the vtable (global variable) address point";
+ let description = [{
+ The `vtable.address_point` operation retrieves the effective address
+ (address point) of a C++ virtual table. An object internal `__vptr`
+ gets initializated on top of the value returned by this operation.
+
+ `address_point.index` (vtable index) provides the appropriate vtable within
+ the vtable group (as specified by Itanium ABI), and `address_point.offset`
+ (address point index) the actual address point within that vtable.
+
+ The return type is always a `!cir.ptr<!cir.ptr<() -> i32>>`.
+
+ Example:
+ ```mlir
+ cir.global linkonce_odr @_ZTV1B = ...
+ ...
+ %3 = cir.vtable.address_point(@_ZTV1B, address_point = <index = 0,
+ offset = 2>) : !cir.ptr<!cir.ptr<() -> i32>>
+ ```
+ }];
+
+ let arguments = (ins OptionalAttr<FlatSymbolRefAttr>:$name,
+ Optional<CIR_AnyType>:$sym_addr,
----------------
xlauko wrote:
I believe this should not be CIR_AnyType; should it be CIR_PtrTo<CIR_AnyFuncType> instead? However, neither the description nor the example clarifies what is expected for sym_addr. It would be helpful to include that in the documentation as well.
https://github.com/llvm/llvm-project/pull/148730
More information about the cfe-commits
mailing list