[PATCH] D55914: [GlobalISel][InstructionSelect] Add support for selecting pointer types with TableGen

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 19 20:35:38 PST 2018


tstellar created this revision.
tstellar added reviewers: dsanders, rtereshin.
Herald added subscribers: tpr, kristof.beyls, rovka.

There is no way to represent pointer types in TableGen, so have the instruction
selector convert pointer types to scalar types in GIM_SwitchType.

This will be tested by CodeGen/AMDGPU/GlobalIsel/smrd.ll once AMDGPU moves
load selection logic into TableGen.


Repository:
  rL LLVM

https://reviews.llvm.org/D55914

Files:
  include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h


Index: include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
===================================================================
--- include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
+++ include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
@@ -205,7 +205,12 @@
         CurrentIdx = Default;
         break;
       }
-      const LLT Ty = MRI.getType(MO.getReg());
+
+      // TableGen is unable to match pointer types, so convert pointers
+      // to an integer type of the same size.
+      LLT Ty = MRI.getType(MO.getReg());
+      if (Ty.isPointer())
+        Ty = LLT::scalar(Ty.getSizeInBits());
       const auto TyI = ISelInfo.TypeIDMap.find(Ty);
       if (TyI == ISelInfo.TypeIDMap.end()) {
         CurrentIdx = Default;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55914.179010.patch
Type: text/x-patch
Size: 750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181220/a35e3c06/attachment.bin>


More information about the llvm-commits mailing list