[llvm] [SandboxIR] Add missing VectorType functions (PR #107650)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 15:54:17 PDT 2024


================
@@ -317,7 +317,32 @@ class StructType : public Type {
 class VectorType : public Type {
 public:
   static VectorType *get(Type *ElementType, ElementCount EC);
-  // TODO: add missing functions
+  static VectorType *get(Type *ElementType, unsigned NumElements,
+                         bool Scalable) {
+    return VectorType::get(ElementType,
+                           ElementCount::get(NumElements, Scalable));
+  }
+  // Needs tests
+  Type *getElementType() const;
+
+  static VectorType *get(Type *ElementType, const VectorType *Other) {
+    return VectorType::get(ElementType, Other->getElementCount());
+  }
+
+  inline ElementCount getElementCount() const {
+    return cast<llvm::VectorType>(LLVMTy)->getElementCount();
+  }
+  static VectorType *getInteger(Context &Ctx, VectorType *VTy);
----------------
vporpo wrote:

We don't need the `Ctx` argument, you can get it like: `VTy->getContext()`. Same for the rest of the functions.

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


More information about the llvm-commits mailing list