Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>,
Nathan =?utf-8?q?Gau=C3=ABr?= <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>


================
@@ -1804,6 +1804,46 @@ class ConvergenceControlInst : public IntrinsicInst {
   CreateLoop(BasicBlock &BB, ConvergenceControlInst *Parent);
 };
 
+class StructuredGEPInst : public IntrinsicInst {
+public:
+  static bool classof(const IntrinsicInst *I) {
+    return I->getIntrinsicID() == Intrinsic::structured_gep;
+  }
+
+  static bool classof(const Value *V) {
+    return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
+  }
+
+  Type *getBaseType() const {
+    return getParamAttr(0, Attribute::ElementType).getValueAsType();
+  }
+
+  unsigned getIndicesCount() const { return getNumOperands() - 2; }
+
+  Value *getIndexOperand(size_t Index) const {
+    assert(Index < getIndicesCount());
+    return getOperand(Index + 1);
+  }
+
+  Type *getResultElementType() const {
+    Type *CurrentType = getBaseType();
+    for (unsigned I = 0; I < getIndicesCount(); I++) {
+      if (ArrayType *AT = dyn_cast<ArrayType>(CurrentType)) {
+        CurrentType = AT->getElementType();
+      } else if (StructType *ST = dyn_cast<StructType>(CurrentType)) {
+        ConstantInt *CI = cast<ConstantInt>(getIndexOperand(I));
+        CurrentType = ST->getElementType(CI->getZExtValue());
+      } else {
+        // FIXME(Keenuts): add testing reaching those places once initial
+        // implementation has landed.
+        assert(0);
----------------
nikic wrote:

Prefer llvm_unreachable over assert(0).

https://github.com/llvm/llvm-project/pull/176145
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to