forked from OSchip/llvm-project
[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 <stdint.h> 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, <arm_mve.h> 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
This commit is contained in:
parent
26bc7cb05e
commit
f0c6890f32
|
@ -98,22 +98,22 @@ def urshrl: Intrinsic<u64, (args u64:$value, imm_1to32:$shift),
|
||||||
(u64 (xval $pair, 0))))>;
|
(u64 (xval $pair, 0))))>;
|
||||||
|
|
||||||
let params = T.Int32 in {
|
let params = T.Int32 in {
|
||||||
def vadcq: Intrinsic<Vector, (args Vector:$a, Vector:$b, Ptr<u32>:$carry),
|
def vadcq: Intrinsic<Vector, (args Vector:$a, Vector:$b, Ptr<uint>:$carry),
|
||||||
(seq (IRInt<"vadc", [Vector]> $a, $b, (shl (load $carry), 29)):$pair,
|
(seq (IRInt<"vadc", [Vector]> $a, $b, (shl (load $carry), 29)):$pair,
|
||||||
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
|
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
|
||||||
(xval $pair, 0))>;
|
(xval $pair, 0))>;
|
||||||
def vadciq: Intrinsic<Vector, (args Vector:$a, Vector:$b, Ptr<u32>:$carry),
|
def vadciq: Intrinsic<Vector, (args Vector:$a, Vector:$b, Ptr<uint>:$carry),
|
||||||
(seq (IRInt<"vadc", [Vector]> $a, $b, 0):$pair,
|
(seq (IRInt<"vadc", [Vector]> $a, $b, 0):$pair,
|
||||||
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
|
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
|
||||||
(xval $pair, 0))>;
|
(xval $pair, 0))>;
|
||||||
def vadcq_m: Intrinsic<Vector, (args Vector:$inactive, Vector:$a, Vector:$b,
|
def vadcq_m: Intrinsic<Vector, (args Vector:$inactive, Vector:$a, Vector:$b,
|
||||||
Ptr<u32>:$carry, Predicate:$pred),
|
Ptr<uint>:$carry, Predicate:$pred),
|
||||||
(seq (IRInt<"vadc_predicated", [Vector, Predicate]> $inactive, $a, $b,
|
(seq (IRInt<"vadc_predicated", [Vector, Predicate]> $inactive, $a, $b,
|
||||||
(shl (load $carry), 29), $pred):$pair,
|
(shl (load $carry), 29), $pred):$pair,
|
||||||
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
|
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
|
||||||
(xval $pair, 0))>;
|
(xval $pair, 0))>;
|
||||||
def vadciq_m: Intrinsic<Vector, (args Vector:$inactive, Vector:$a, Vector:$b,
|
def vadciq_m: Intrinsic<Vector, (args Vector:$inactive, Vector:$a, Vector:$b,
|
||||||
Ptr<u32>:$carry, Predicate:$pred),
|
Ptr<uint>:$carry, Predicate:$pred),
|
||||||
(seq (IRInt<"vadc_predicated", [Vector, Predicate]> $inactive, $a, $b,
|
(seq (IRInt<"vadc_predicated", [Vector, Predicate]> $inactive, $a, $b,
|
||||||
0, $pred):$pair,
|
0, $pred):$pair,
|
||||||
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
|
(store (and 1, (lshr (xval $pair, 1), 29)), $carry),
|
||||||
|
|
|
@ -125,7 +125,9 @@ def Void : Type;
|
||||||
class PrimitiveType<string kind_, int size_>: Type {
|
class PrimitiveType<string kind_, int size_>: Type {
|
||||||
string kind = kind_;
|
string kind = kind_;
|
||||||
int size = size_;
|
int size = size_;
|
||||||
|
string nameOverride = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// The type records defined by these foreaches have names like s32, f16, u8.
|
// The type records defined by these foreaches have names like s32, f16, u8.
|
||||||
foreach size = [8, 16, 32, 64] in
|
foreach size = [8, 16, 32, 64] in
|
||||||
foreach kind = ["u", "s"] in
|
foreach kind = ["u", "s"] in
|
||||||
|
@ -134,6 +136,12 @@ foreach size = [16, 32] in
|
||||||
foreach kind = ["f"] in
|
foreach kind = ["f"] in
|
||||||
def kind # size: PrimitiveType<kind, size>;
|
def kind # size: PrimitiveType<kind, size>;
|
||||||
|
|
||||||
|
// 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<t> expects t to be a scalar, and gives a 128-bit vector of whatever it
|
// VecOf<t> expects t to be a scalar, and gives a 128-bit vector of whatever it
|
||||||
// is.
|
// is.
|
||||||
class VecOf<Type t>: ComplexType<(CTO_Vec t)>;
|
class VecOf<Type t>: ComplexType<(CTO_Vec t)>;
|
||||||
|
@ -222,7 +230,7 @@ def imm_1248 : Immediate<u32, IB_ConstRange<1, 8>> {
|
||||||
// memory access size is n bytes (e.g. 1 for vldrb_[whatever], 2 for vldrh,
|
// 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}.
|
// ...). The set of valid immediates for these is {0*n, 1*n, ..., 127*n}.
|
||||||
class imm_mem7bit<int membytes>
|
class imm_mem7bit<int membytes>
|
||||||
: Immediate<u32, IB_ConstRange<0, !mul(membytes, 127)>> {
|
: Immediate<sint, IB_ConstRange<0, !mul(membytes, 127)>> {
|
||||||
let extra = !if(!eq(membytes, 1), ?, "Multiple");
|
let extra = !if(!eq(membytes, 1), ?, "Multiple");
|
||||||
let extraarg = !cast<string>(membytes);
|
let extraarg = !cast<string>(membytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,6 +229,7 @@ public:
|
||||||
class ScalarType : public CRegularNamedType {
|
class ScalarType : public CRegularNamedType {
|
||||||
ScalarTypeKind Kind;
|
ScalarTypeKind Kind;
|
||||||
unsigned Bits;
|
unsigned Bits;
|
||||||
|
std::string NameOverride;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScalarType(const Record *Record) : CRegularNamedType(TypeKind::Scalar) {
|
ScalarType(const Record *Record) : CRegularNamedType(TypeKind::Scalar) {
|
||||||
|
@ -237,6 +238,7 @@ public:
|
||||||
.Case("u", ScalarTypeKind::UnsignedInt)
|
.Case("u", ScalarTypeKind::UnsignedInt)
|
||||||
.Case("f", ScalarTypeKind::Float);
|
.Case("f", ScalarTypeKind::Float);
|
||||||
Bits = Record->getValueAsInt("size");
|
Bits = Record->getValueAsInt("size");
|
||||||
|
NameOverride = Record->getValueAsString("nameOverride");
|
||||||
}
|
}
|
||||||
unsigned sizeInBits() const override { return Bits; }
|
unsigned sizeInBits() const override { return Bits; }
|
||||||
ScalarTypeKind kind() const { return Kind; }
|
ScalarTypeKind kind() const { return Kind; }
|
||||||
|
@ -244,6 +246,11 @@ public:
|
||||||
std::string cNameBase() const override {
|
std::string cNameBase() const override {
|
||||||
return toCPrefix(Kind) + utostr(Bits);
|
return toCPrefix(Kind) + utostr(Bits);
|
||||||
}
|
}
|
||||||
|
std::string cName() const override {
|
||||||
|
if (NameOverride.empty())
|
||||||
|
return CRegularNamedType::cName();
|
||||||
|
return NameOverride;
|
||||||
|
}
|
||||||
std::string llvmName() const override {
|
std::string llvmName() const override {
|
||||||
if (Kind == ScalarTypeKind::Float) {
|
if (Kind == ScalarTypeKind::Float) {
|
||||||
if (Bits == 16)
|
if (Bits == 16)
|
||||||
|
@ -261,6 +268,7 @@ public:
|
||||||
}
|
}
|
||||||
bool isInteger() const { return Kind != ScalarTypeKind::Float; }
|
bool isInteger() const { return Kind != ScalarTypeKind::Float; }
|
||||||
bool requiresFloat() const override { return !isInteger(); }
|
bool requiresFloat() const override { return !isInteger(); }
|
||||||
|
bool hasNonstandardName() const { return !NameOverride.empty(); }
|
||||||
|
|
||||||
static bool classof(const Type *T) {
|
static bool classof(const Type *T) {
|
||||||
return T->typeKind() == TypeKind::Scalar;
|
return T->typeKind() == TypeKind::Scalar;
|
||||||
|
@ -1263,6 +1271,8 @@ void MveEmitter::EmitHeader(raw_ostream &OS) {
|
||||||
"typedef float float32_t;\n";
|
"typedef float float32_t;\n";
|
||||||
for (const auto &kv : ScalarTypes) {
|
for (const auto &kv : ScalarTypes) {
|
||||||
const ScalarType *ST = kv.second.get();
|
const ScalarType *ST = kv.second.get();
|
||||||
|
if (ST->hasNonstandardName())
|
||||||
|
continue;
|
||||||
raw_ostream &OS = parts[ST->requiresFloat() ? Float : 0];
|
raw_ostream &OS = parts[ST->requiresFloat() ? Float : 0];
|
||||||
const VectorType *VT = getVectorType(ST);
|
const VectorType *VT = getVectorType(ST);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue