Index: clang/utils/TableGen/SveEmitter.cpp =================================================================== --- clang/utils/TableGen/SveEmitter.cpp +++ clang/utils/TableGen/SveEmitter.cpp @@ -65,6 +65,7 @@ class SVEType { TypeSpec TS; + bool IsSplat; bool Float, Signed, Immediate, Void, Constant, Pointer; bool DefaultType, IsScalable, Predicate, PredicatePattern, PrefetchOp; unsigned Bitwidth, ElementBitwidth, NumVectors; @@ -73,10 +74,10 @@ SVEType() : SVEType(TypeSpec(), 'v') {} SVEType(TypeSpec TS, char CharMod) - : TS(TS), Float(false), Signed(true), Immediate(false), Void(false), - Constant(false), Pointer(false), DefaultType(false), IsScalable(true), - Predicate(false), PredicatePattern(false), PrefetchOp(false), - Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) { + : TS(TS), IsSplat(false), Float(false), Signed(true), Immediate(false), + Void(false), Constant(false), Pointer(false), DefaultType(false), + IsScalable(true), Predicate(false), PredicatePattern(false), + PrefetchOp(false), Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) { if (!TS.empty()) applyTypespec(); applyModifier(CharMod); @@ -99,6 +100,7 @@ bool isPredicatePattern() const { return PredicatePattern; } bool isPrefetchOp() const { return PrefetchOp; } bool isConstant() const { return Constant; } + bool isSplat() const { return IsSplat; } unsigned getElementSizeInBits() const { return ElementBitwidth; } unsigned getNumVectors() const { return NumVectors; } @@ -210,17 +212,14 @@ /// Return true if the intrinsic takes a splat operand. bool hasSplat() const { - // These prototype modifiers are described in arm_sve.td. - return Proto.find_first_of("ajfrKLR") != std::string::npos; + return llvm::any_of(getTypes(), [](const SVEType &T) { return T.isSplat(); }); } /// Return the parameter index of the splat operand. unsigned getSplatIdx() const { - // These prototype modifiers are described in arm_sve.td. - auto Idx = Proto.find_first_of("ajfrKLR"); - assert(Idx != std::string::npos && Idx > 0 && - "Prototype has no splat operand"); - return Idx - 1; + return std::distance( + &Types[1], //Types.begin(), + llvm::find_if(getTypes(), [](const SVEType &T) { return T.isSplat(); })); } /// Emits the intrinsic declaration to the ostream. @@ -505,8 +504,10 @@ Bitwidth = 16; ElementBitwidth = 1; break; - case 's': case 'a': + IsSplat = true; + LLVM_FALLTHROUGH; + case 's': Bitwidth = ElementBitwidth; NumVectors = 0; break; @@ -578,6 +579,7 @@ ElementBitwidth = 64; break; case 'j': + IsSplat = true; ElementBitwidth = Bitwidth = 64; NumVectors = 0; break;