[PATCH] D57117: GlobalISel: Add helper to LLT to get a scalar or vector

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 23 13:41:22 PST 2019


arsenm updated this revision to Diff 183168.
arsenm added a comment.

Add a second version


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57117/new/

https://reviews.llvm.org/D57117

Files:
  include/llvm/Support/LowLevelTypeImpl.h


Index: include/llvm/Support/LowLevelTypeImpl.h
===================================================================
--- include/llvm/Support/LowLevelTypeImpl.h
+++ include/llvm/Support/LowLevelTypeImpl.h
@@ -70,6 +70,15 @@
                ScalarTy.isPointer() ? ScalarTy.getAddressSpace() : 0};
   }
 
+  static LLT scalarOrVector(uint16_t NumElements, LLT ScalarTy) {
+    return NumElements == 1 ? ScalarTy : LLT::vector(NumElements, ScalarTy);
+  }
+
+  static LLT scalarOrVector(uint16_t NumElements, unsigned ScalarSize) {
+    LLT ScalarTy = LLT::scalar(ScalarSize);
+    return NumElements == 1 ? ScalarTy : LLT::vector(NumElements, ScalarTy);
+  }
+
   explicit LLT(bool isPointer, bool isVector, uint16_t NumElements,
                unsigned SizeInBits, unsigned AddressSpace) {
     init(isPointer, isVector, NumElements, SizeInBits, AddressSpace);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57117.183168.patch
Type: text/x-patch
Size: 859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190123/d9fcf001/attachment.bin>


More information about the llvm-commits mailing list