[cfe-commits] [PATCH] AArch64 backend: Clang changes

John McCall rjmccall at apple.com
Tue Jan 29 11:01:36 PST 2013


On Jan 28, 2013, at 6:33 AM, Tim Northover <tim.northover at arm.com> wrote:
>  Merge to ToT (changes to how ItaniumABI is constructed).

+  case TargetCXXABI::GenericAArch64:
+    return  new ItaniumCXXABI(CGM, /*IsARM=*/true);

Weird spacing.

+  } else if (IsARM) {
+    llvm::Type *SizeTy = CGF.ConvertType(getContext().getSizeType());
+    guardTy = cast<llvm::IntegerType>(SizeTy);

This is actually just CGF.SizeTy.

+    llvm::Value *Test1 = Builder.getInt(llvm::APInt(guardTy->getBitWidth(), 1));

llvm::ConstantInt::get(guardTy, 1)

Otherwise, this looks fine to me.

 /// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
-/// do not have a prototype. Arguments that have type float are promoted to
-/// double. All other argument types are converted by UsualUnaryConversions().
+/// do not have a prototype. Arguments that have type float or __fp16
+/// are promoted to double. All other argument types are converted by
+/// UsualUnaryConversions().
 ExprResult Sema::DefaultArgumentPromotion(Expr *E) {
   QualType Ty = E->getType();
   assert(!Ty.isNull() && "DefaultArgumentPromotion - missing type");
@@ -592,8 +593,11 @@
     return Owned(E);
   E = Res.take();
 
-  // If this is a 'float' (CVR qualified or typedef) promote to double.
-  if (Ty->isSpecificBuiltinType(BuiltinType::Float))
+  // If this is a 'float' or '__fp16' (CVR qualified or typedef) promote to
+  // double.
+  const BuiltinType *BTy = Ty->getAs<BuiltinType>();
+  if (BTy && (BTy->getKind() == BuiltinType::Half ||
+              BTy->getKind() == BuiltinType::Float))
     E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).take();
 

This is a non-platform-specific change and ought to be split out.  It looks fine
to me, so you can go ahead and commit it, with tests;  but please do so
separately.

-  if (!BTy ||
-      (VecKind == VectorType::NeonPolyVector &&
-       BTy->getKind() != BuiltinType::SChar &&
-       BTy->getKind() != BuiltinType::Short) ||
-      (BTy->getKind() != BuiltinType::SChar &&
-       BTy->getKind() != BuiltinType::UChar &&
-       BTy->getKind() != BuiltinType::Short &&
-       BTy->getKind() != BuiltinType::UShort &&
-       BTy->getKind() != BuiltinType::Int &&
-       BTy->getKind() != BuiltinType::UInt &&
-       BTy->getKind() != BuiltinType::LongLong &&
-       BTy->getKind() != BuiltinType::ULongLong &&
-       BTy->getKind() != BuiltinType::Float)) {
+  llvm::Triple::ArchType Arch = S.Context.getTargetInfo().getTriple().getArch();
+  bool GoodType;
+  if (!BTy)
+    GoodType = false;
+  else if (VecKind == VectorType::NeonPolyVector &&
+           Arch == llvm::Triple::aarch64) {
+    // AArch64 polynomial vectors are unsigned
+    GoodType = BTy->getKind() == BuiltinType::UChar ||
+               BTy->getKind() == BuiltinType::UShort;
+  } else if (VecKind == VectorType::NeonPolyVector &&
+             Arch != llvm::Triple::aarch64) {
+    // AArch32 polynomial vector are signed.
+    GoodType = BTy->getKind() == BuiltinType::SChar ||
+               BTy->getKind() == BuiltinType::Short;
+  } else {
+    // Non-polynomial vector types: the usual suspects are allowed, as well as
+    // float64_t on AArch64.
+    GoodType = BTy->getKind() == BuiltinType::SChar ||
+               BTy->getKind() == BuiltinType::UChar ||
+               BTy->getKind() == BuiltinType::Short ||
+               BTy->getKind() == BuiltinType::UShort ||
+               BTy->getKind() == BuiltinType::Int ||
+               BTy->getKind() == BuiltinType::UInt ||
+               BTy->getKind() == BuiltinType::LongLong ||
+               BTy->getKind() == BuiltinType::ULongLong ||
+               BTy->getKind() == BuiltinType::Float ||
+               BTy->getKind() == BuiltinType::Half ||
+               (Arch == llvm::Triple::aarch64 && 
+                BTy->getKind() == BuiltinType::Double);
+  }

This is just begging to be split into a separate function that returns GoodType.

Beyond that, I'd like someone to review the tblgen changes, but that can wait
until post-commit  review.  Go with my blessings. :)

John.



More information about the cfe-commits mailing list