[clang] b0270f6 - [clang] Remove Address::deprecated from MveEmitter

Arthur Eubanks via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 09:39:24 PDT 2022


Author: Arthur Eubanks
Date: 2022-03-21T09:39:13-07:00
New Revision: b0270f6e9583c2607e5b8bf0902010ae83a328c7

URL: https://github.com/llvm/llvm-project/commit/b0270f6e9583c2607e5b8bf0902010ae83a328c7
DIFF: https://github.com/llvm/llvm-project/commit/b0270f6e9583c2607e5b8bf0902010ae83a328c7.diff

LOG: [clang] Remove Address::deprecated from MveEmitter

We have to keep track of pointer pointee types with opaque pointers.

Reviewed By: simon_tatham

Differential Revision: https://reviews.llvm.org/D122046

Added: 
    

Modified: 
    clang/utils/TableGen/MveEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index 5b0c03f43e5e4..fae889d68346c 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -212,6 +212,7 @@ class PointerType : public Type {
   std::string llvmName() const override {
     return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")";
   }
+  const Type *getPointeeType() const { return Pointee; }
 
   static bool classof(const Type *T) {
     return T->typeKind() == TypeKind::Pointer;
@@ -702,11 +703,13 @@ class IRBuilderResult : public Result {
 class AddressResult : public Result {
 public:
   Ptr Arg;
+  const Type *Ty;
   unsigned Align;
-  AddressResult(Ptr Arg, unsigned Align) : Arg(Arg), Align(Align) {}
+  AddressResult(Ptr Arg, const Type *Ty, unsigned Align)
+      : Arg(Arg), Ty(Ty), Align(Align) {}
   void genCode(raw_ostream &OS,
                CodeGenParamAllocator &ParamAlloc) const override {
-    OS << "Address::deprecated(" << Arg->varname()
+    OS << "Address(" << Arg->varname() << ", " << Ty->llvmName()
        << ", CharUnits::fromQuantity(" << Align << "))";
   }
   std::string typeName() const override {
@@ -1189,13 +1192,21 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
     if (D->getNumArgs() != 2)
       PrintFatalError("'address' should have two arguments");
     Result::Ptr Arg = getCodeForDagArg(D, 0, Scope, Param);
+
+    const Type *Ty = nullptr;
+    if (auto *DI = dyn_cast<DagInit>(D->getArg(0)))
+      if (auto *PTy = dyn_cast<PointerType>(getType(DI->getOperator(), Param)))
+        Ty = PTy->getPointeeType();
+    if (!Ty)
+      PrintFatalError("'address' pointer argument should be a pointer");
+
     unsigned Alignment;
     if (auto *II = dyn_cast<IntInit>(D->getArg(1))) {
       Alignment = II->getValue();
     } else {
       PrintFatalError("'address' alignment argument should be an integer");
     }
-    return std::make_shared<AddressResult>(Arg, Alignment);
+    return std::make_shared<AddressResult>(Arg, Ty, Alignment);
   } else if (Op->getName() == "unsignedflag") {
     if (D->getNumArgs() != 1)
       PrintFatalError("unsignedflag should have exactly one argument");


        


More information about the cfe-commits mailing list