[llvm-branch-commits] [WIP] Introduce a G_PTRTOADDR GIsel node (PR #140300)

Tim Gymnich via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jun 12 02:08:54 PDT 2025


================
@@ -7407,6 +7412,34 @@ LegalizerHelper::LegalizeResult LegalizerHelper::lowerTRUNC(MachineInstr &MI) {
   return UnableToLegalize;
 }
 
+LegalizerHelper::LegalizeResult
+LegalizerHelper::lowerPTRTOADDR(MachineInstr &MI) {
+  // Lower G_PTRTOADDR as a truncate to address width of G_PTROINT and then
+  // zero extend to the target width if there is no native support for it.
+  MachineRegisterInfo &MRI = *MIRBuilder.getMRI();
+  const DataLayout &DL = MIRBuilder.getDataLayout();
+  assert(MI.getOpcode() == TargetOpcode::G_PTRTOADDR);
+  auto DstReg = MI.getOperand(0).getReg();
+  auto SrcReg = MI.getOperand(1).getReg();
----------------
tgymnich wrote:

```suggestion
  Register DstReg = MI.getOperand(0).getReg();
  Register SrcReg = MI.getOperand(1).getReg();
```

https://github.com/llvm/llvm-project/pull/140300


More information about the llvm-branch-commits mailing list