[llvm-branch-commits] [llvm] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)
Alexander Richardson via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri May 9 23:19:49 PDT 2025
================
@@ -4904,13 +4907,43 @@ class PtrToIntInst : public CastInst {
// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Instruction *I) {
- return I->getOpcode() == PtrToInt;
+ return I->getOpcode() == PtrToInt || I->getOpcode() == PtrToAddr;
+ }
+ static bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
+};
+
+/// This class represents a cast from a pointer to an address (non-capturing
+/// ptrtoint). Inherits from PtrToIntInst since it is a less restrictive version
+/// of ptrtoint, so treating it as ptrtoint is conservatively correct.
+class PtrToAddrInst : public PtrToIntInst {
----------------
arichardson wrote:
I was not sure if it makes sense to inherit here since most of the time we use switch statements instead of isa<>, but I figured this would help with initial implementation.
https://github.com/llvm/llvm-project/pull/139357
More information about the llvm-branch-commits
mailing list