From f0c6890f32c0d5ee7f3973181eb83fcb0a50dc1a Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 4 Nov 2019 12:40:25 +0000 Subject: [ARM,MVE] Integer-type nitpicks in MVE intrinsics. A few integer types in the ACLE definitions of MVE intrinsics are given as 'int' or 'unsigned' instead of fixed-size types like uint32_t. Usually these are the ones where the size isn't that important, such as immediate offsets in loads (which have a range limited by the instruction encoding) or the carry flag in vadcq which can only be 0 or 1 anyway. With this change, follows that exact type naming, so that the function prototypes look identical to the ones in ACLE, instead of replacing int and unsigned with int32_t and uint32_t. Reviewers: dmgreen Subscribers: kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69790 --- clang/include/clang/Basic/arm_mve.td | 8 ++++---- clang/include/clang/Basic/arm_mve_defs.td | 10 +++++++++- clang/utils/TableGen/MveEmitter.cpp | 10 ++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'clang') diff --git a/clang/include/clang/Basic/arm_mve.td b/clang/include/clang/Basic/arm_mve.td index 30a76511a3c..aca0d9fa925 100644 --- a/clang/include/clang/Basic/arm_mve.td +++ b/clang/include/clang/Basic/arm_mve.td @@ -98,22 +98,22 @@ def urshrl: Intrinsic; let params = T.Int32 in { -def vadcq: Intrinsic:$carry), +def vadcq: Intrinsic:$carry), (seq (IRInt<"vadc", [Vector]> $a, $b, (shl (load $carry), 29)):$pair, (store (and 1, (lshr (xval $pair, 1), 29)), $carry), (xval $pair, 0))>; -def vadciq: Intrinsic:$carry), +def vadciq: Intrinsic:$carry), (seq (IRInt<"vadc", [Vector]> $a, $b, 0):$pair, (store (and 1, (lshr (xval $pair, 1), 29)), $carry), (xval $pair, 0))>; def vadcq_m: Intrinsic:$carry, Predicate:$pred), + Ptr:$carry, Predicate:$pred), (seq (IRInt<"vadc_predicated", [Vector, Predicate]> $inactive, $a, $b, (shl (load $carry), 29), $pred):$pair, (store (and 1, (lshr (xval $pair, 1), 29)), $carry), (xval $pair, 0))>; def vadciq_m: Intrinsic:$carry, Predicate:$pred), + Ptr:$carry, Predicate:$pred), (seq (IRInt<"vadc_predicated", [Vector, Predicate]> $inactive, $a, $b, 0, $pred):$pair, (store (and 1, (lshr (xval $pair, 1), 29)), $carry), diff --git a/clang/include/clang/Basic/arm_mve_defs.td b/clang/include/clang/Basic/arm_mve_defs.td index 9025ca81145..14afc04a825 100644 --- a/clang/include/clang/Basic/arm_mve_defs.td +++ b/clang/include/clang/Basic/arm_mve_defs.td @@ -125,7 +125,9 @@ def Void : Type; class PrimitiveType: Type { string kind = kind_; int size = size_; + string nameOverride = ""; } + // The type records defined by these foreaches have names like s32, f16, u8. foreach size = [8, 16, 32, 64] in foreach kind = ["u", "s"] in @@ -134,6 +136,12 @@ foreach size = [16, 32] in foreach kind = ["f"] in def kind # size: PrimitiveType; +// Sometimes we need to refer to a type by a different name in C, when +// ACLE defines a function parameter to be something like 'unsigned' +// rather than uint32_t. +def uint: PrimitiveType<"u", 32> { let nameOverride = "unsigned"; } +def sint: PrimitiveType<"s", 32> { let nameOverride = "int"; } + // VecOf expects t to be a scalar, and gives a 128-bit vector of whatever it // is. class VecOf: ComplexType<(CTO_Vec t)>; @@ -222,7 +230,7 @@ def imm_1248 : Immediate> { // memory access size is n bytes (e.g. 1 for vldrb_[whatever], 2 for vldrh, // ...). The set of valid immediates for these is {0*n, 1*n, ..., 127*n}. class imm_mem7bit - : Immediate> { + : Immediate> { let extra = !if(!eq(membytes, 1), ?, "Multiple"); let extraarg = !cast(membytes); } diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 1f9752261fb..ddec171d671 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -229,6 +229,7 @@ public: class ScalarType : public CRegularNamedType { ScalarTypeKind Kind; unsigned Bits; + std::string NameOverride; public: ScalarType(const Record *Record) : CRegularNamedType(TypeKind::Scalar) { @@ -237,6 +238,7 @@ public: .Case("u", ScalarTypeKind::UnsignedInt) .Case("f", ScalarTypeKind::Float); Bits = Record->getValueAsInt("size"); + NameOverride = Record->getValueAsString("nameOverride"); } unsigned sizeInBits() const override { return Bits; } ScalarTypeKind kind() const { return Kind; } @@ -244,6 +246,11 @@ public: std::string cNameBase() const override { return toCPrefix(Kind) + utostr(Bits); } + std::string cName() const override { + if (NameOverride.empty()) + return CRegularNamedType::cName(); + return NameOverride; + } std::string llvmName() const override { if (Kind == ScalarTypeKind::Float) { if (Bits == 16) @@ -261,6 +268,7 @@ public: } bool isInteger() const { return Kind != ScalarTypeKind::Float; } bool requiresFloat() const override { return !isInteger(); } + bool hasNonstandardName() const { return !NameOverride.empty(); } static bool classof(const Type *T) { return T->typeKind() == TypeKind::Scalar; @@ -1263,6 +1271,8 @@ void MveEmitter::EmitHeader(raw_ostream &OS) { "typedef float float32_t;\n"; for (const auto &kv : ScalarTypes) { const ScalarType *ST = kv.second.get(); + if (ST->hasNonstandardName()) + continue; raw_ostream &OS = parts[ST->requiresFloat() ? Float : 0]; const VectorType *VT = getVectorType(ST); -- cgit v1.2.3