1 //===- NeonEmitter.cpp - Generate arm_neon.h for use with clang -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This tablegen backend is responsible for emitting arm_neon.h, which includes
11 // a declaration and definition of each function specified by the ARM NEON
12 // compiler interface. See ARM document DUI0348B.
14 // Each NEON instruction is implemented in terms of 1 or more functions which
15 // are suffixed with the element type of the input vectors. Functions may be
16 // implemented in terms of generic vector operations such as +, *, -, etc. or
17 // by calling a __builtin_-prefixed function which will be handled by clang's
20 // Additional validation code can be generated by this file when runHeader() is
21 // called, rather than the normal run() entry point.
23 //===----------------------------------------------------------------------===//
25 #include "NeonEmitter.h"
26 #include "llvm/ADT/SmallString.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/StringExtras.h"
33 /// ParseTypes - break down a string such as "fQf" into a vector of StringRefs,
34 /// which each StringRef representing a single type declared in the string.
35 /// for "fQf" we would end up with 2 StringRefs, "f", and "Qf", representing
36 /// 2xfloat and 4xfloat respectively.
37 static void ParseTypes(Record *r, std::string &s,
38 SmallVectorImpl<StringRef> &TV) {
39 const char *data = s.data();
42 for (unsigned i = 0, e = s.size(); i != e; ++i, ++len) {
43 if (data[len] == 'P' || data[len] == 'Q' || data[len] == 'U')
55 throw TGError(r->getLoc(),
56 "Unexpected letter: " + std::string(data + len, 1));
59 TV.push_back(StringRef(data, len + 1));
65 /// Widen - Convert a type code into the next wider type. char -> short,
66 /// short -> int, etc.
67 static char Widen(const char t) {
75 default: throw "unhandled type in widen!";
80 /// Narrow - Convert a type code into the next smaller type. short -> char,
81 /// float -> half float, etc.
82 static char Narrow(const char t) {
92 default: throw "unhandled type in widen!";
97 /// For a particular StringRef, return the base type code, and whether it has
98 /// the quad-vector, polynomial, or unsigned modifiers set.
99 static char ClassifyType(StringRef ty, bool &quad, bool &poly, bool &usgn) {
103 if (ty[off] == 'Q') {
109 if (ty[off] == 'P') {
114 // remember unsigned.
115 if (ty[off] == 'U') {
120 // base type to get the type string for.
124 /// ModType - Transform a type code and its modifiers based on a mod code. The
125 /// mod code definitions may be found at the top of arm_neon.td.
126 static char ModType(const char mod, char type, bool &quad, bool &poly,
127 bool &usgn, bool &scal, bool &cnst, bool &pntr) {
190 /// TypeString - for a modifier and type, generate the name of the typedef for
191 /// that type. If generic is true, emit the generic vector type rather than
192 /// the public NEON type. QUc -> uint8x8t_t / __neon_uint8x8_t.
193 static std::string TypeString(const char mod, StringRef typestr,
194 bool generic = false) {
207 // base type to get the type string for.
208 char type = ClassifyType(typestr, quad, poly, usgn);
210 // Based on the modifying character, change the type and width if necessary.
211 type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr);
223 s += poly ? "poly8" : "int8";
226 s += quad ? "x16" : "x8";
229 s += poly ? "poly16" : "int16";
232 s += quad ? "x8" : "x4";
238 s += quad ? "x4" : "x2";
244 s += quad ? "x2" : "x1";
250 s += quad ? "x8" : "x4";
256 s += quad ? "x4" : "x2";
259 throw "unhandled type!";
270 // Append _t, finishing the type string typedef type.
282 /// TypeString - for a modifier and type, generate the clang BuiltinsARM.def
283 /// prototype code for the function. See the top of clang's Builtins.def for
284 /// a description of the type strings.
285 static std::string BuiltinTypeString(const char mod, StringRef typestr,
286 ClassKind ck, bool ret) {
299 // base type to get the type string for.
300 char type = ClassifyType(typestr, quad, poly, usgn);
302 // Based on the modifying character, change the type and width if necessary.
303 type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr);
312 usgn = usgn | poly | ((ck == ClassI || ck == ClassW) && scal && type != 'f');
332 // Since the return value must be one type, return a vector type of the
333 // appropriate width which we will bitcast.
336 return quad ? "V32c" : "V16c";
338 return quad ? "V48c" : "V24c";
340 return quad ? "V64c" : "V32c";
341 if (mod == 'f' || (ck != ClassB && type == 'f'))
342 return quad ? "V4f" : "V2f";
343 if (ck != ClassB && type == 's')
344 return quad ? "V8s" : "V4s";
345 if (ck != ClassB && type == 'i')
346 return quad ? "V4i" : "V2i";
347 if (ck != ClassB && type == 'l')
348 return quad ? "V2LLi" : "V1LLi";
350 return quad ? "V16c" : "V8c";
353 // Non-return array types are passed as individual vectors.
355 return quad ? "V16cV16c" : "V8cV8c";
357 return quad ? "V16cV16cV16c" : "V8cV8cV8c";
359 return quad ? "V16cV16cV16cV16c" : "V8cV8cV8cV8c";
361 if (mod == 'f' || (ck != ClassB && type == 'f'))
362 return quad ? "V4f" : "V2f";
363 if (ck != ClassB && type == 's')
364 return quad ? "V8s" : "V4s";
365 if (ck != ClassB && type == 'i')
366 return quad ? "V4i" : "V2i";
367 if (ck != ClassB && type == 'l')
368 return quad ? "V2LLi" : "V1LLi";
370 return quad ? "V16c" : "V8c";
373 /// MangleName - Append a type or width suffix to a base neon function name,
374 /// and insert a 'q' in the appropriate location if the operation works on
375 /// 128b rather than 64b. E.g. turn "vst2_lane" into "vst2q_lane_f32", etc.
376 static std::string MangleName(const std::string &name, StringRef typestr,
378 if (name == "vcvt_f32_f16")
384 char type = ClassifyType(typestr, quad, poly, usgn);
386 std::string s = name;
391 case ClassS: s += poly ? "_p8" : usgn ? "_u8" : "_s8"; break;
392 case ClassI: s += "_i8"; break;
393 case ClassW: s += "_8"; break;
399 case ClassS: s += poly ? "_p16" : usgn ? "_u16" : "_s16"; break;
400 case ClassI: s += "_i16"; break;
401 case ClassW: s += "_16"; break;
407 case ClassS: s += usgn ? "_u32" : "_s32"; break;
408 case ClassI: s += "_i32"; break;
409 case ClassW: s += "_32"; break;
415 case ClassS: s += usgn ? "_u64" : "_s64"; break;
416 case ClassI: s += "_i64"; break;
417 case ClassW: s += "_64"; break;
424 case ClassI: s += "_f16"; break;
425 case ClassW: s += "_16"; break;
432 case ClassI: s += "_f32"; break;
433 case ClassW: s += "_32"; break;
438 throw "unhandled type!";
444 // Insert a 'q' before the first '_' character so that it ends up before
445 // _lane or _n on vector-scalar operations.
447 size_t pos = s.find('_');
448 s = s.insert(pos, "q");
453 // Generate the string "(argtype a, argtype b, ...)"
454 static std::string GenArgs(const std::string &proto, StringRef typestr) {
455 bool define = proto.find('i') != std::string::npos;
461 for (unsigned i = 1, e = proto.size(); i != e; ++i, ++arg) {
463 s += TypeString(proto[i], typestr);
475 static std::string Duplicate(unsigned nElts, StringRef typestr,
476 const std::string &a) {
479 s = "(__neon_" + TypeString('d', typestr) + "){ ";
480 for (unsigned i = 0; i != nElts; ++i) {
490 // Generate the definition for this intrinsic, e.g. "a + b" for OpAdd.
491 // If structTypes is true, the NEON types are structs of vector types rather
492 // than vector types, and the call becomes "a.val + b.val"
493 static std::string GenOpString(OpKind op, const std::string &proto,
494 StringRef typestr, bool structTypes = true) {
495 bool dummy, quad = false;
496 char type = ClassifyType(typestr, quad, dummy, dummy);
499 case 'c': nElts = 8; break;
500 case 's': nElts = 4; break;
501 case 'i': nElts = 2; break;
502 case 'l': nElts = 1; break;
503 case 'h': nElts = 4; break;
504 case 'f': nElts = 2; break;
507 std::string ts = TypeString(proto[0], typestr);
508 std::string s = ts + " r; r";
516 if (proto.size() > 1)
517 a = (structTypes && proto[1] != 'l' && proto[1] != 's') ? "a.val" : "a";
518 b = structTypes ? "b.val" : "b";
519 c = structTypes ? "c.val" : "c";
529 b = Duplicate(nElts << (int)quad, typestr, "b");
534 c = Duplicate(nElts << (int)quad, typestr, "c");
536 s += a + " + ( " + b + " * " + c + " )";
539 c = Duplicate(nElts << (int)quad, typestr, "c");
541 s += a + " - ( " + b + " * " + c + " )";
544 s += "(__neon_" + ts + ")(" + a + " == " + b + ")";
547 s += "(__neon_" + ts + ")(" + a + " >= " + b + ")";
550 s += "(__neon_" + ts + ")(" + a + " <= " + b + ")";
553 s += "(__neon_" + ts + ")(" + a + " > " + b + ")";
556 s += "(__neon_" + ts + ")(" + a + " < " + b + ")";
580 s += "(__neon_" + ts + ")" + a;
583 s += "__builtin_shufflevector((__neon_int64x1_t)" + a;
584 s += ", (__neon_int64x1_t)" + b + ", 0, 1)";
587 s += "(__neon_int64x1_t)(((__neon_int64x2_t)" + a + ")[1])";
590 s += "(__neon_int64x1_t)(((__neon_int64x2_t)" + a + ")[0])";
593 s += Duplicate(nElts << (int)quad, typestr, a);
596 // ((0 & 1) | (~0 & 2))
597 ts = TypeString(proto[1], typestr);
598 s += "( " + a + " & (__neon_" + ts + ")" + b + ") | ";
599 s += "(~" + a + " & (__neon_" + ts + ")" + c + ")";
602 s += "__builtin_shufflevector(" + a + ", " + a;
603 for (unsigned i = 2; i <= nElts << (int)quad; i += 2)
604 for (unsigned j = 0; j != 2; ++j)
605 s += ", " + utostr(i - j - 1);
610 s += "__builtin_shufflevector(" + a + ", " + a;
611 for (unsigned i = nElts; i <= nElts << (1 + (int)quad); i += nElts)
612 for (unsigned j = 0; j != nElts; ++j)
613 s += ", " + utostr(i - j - 1);
617 s += "__builtin_shufflevector(" + a + ", " + a;
618 for (unsigned i = nElts; i <= nElts << (int)quad; i += nElts)
619 for (unsigned j = 0; j != nElts; ++j)
620 s += ", " + utostr(i - j - 1);
624 throw "unknown OpKind!";
631 static unsigned GetNeonEnum(const std::string &proto, StringRef typestr) {
632 unsigned mod = proto[0];
635 if (mod == 'v' || mod == 'f')
645 // base type to get the type string for.
646 char type = ClassifyType(typestr, quad, poly, usgn);
648 // Based on the modifying character, change the type and width if necessary.
649 type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr);
676 throw "unhandled type!";
682 // Generate the definition for this intrinsic, e.g. __builtin_neon_cls(a)
683 // If structTypes is true, the NEON types are structs of vector types rather
684 // than vector types, and the call becomes __builtin_neon_cls(a.val)
685 static std::string GenBuiltin(const std::string &name, const std::string &proto,
686 StringRef typestr, ClassKind ck,
687 bool structTypes = true) {
688 bool dummy, quad = false;
689 char type = ClassifyType(typestr, quad, dummy, dummy);
692 case 'c': nElts = 8; break;
693 case 's': nElts = 4; break;
694 case 'i': nElts = 2; break;
695 case 'l': nElts = 1; break;
696 case 'h': nElts = 4; break;
697 case 'f': nElts = 2; break;
699 if (quad) nElts <<= 1;
704 bool unioning = (proto[0] == '2' || proto[0] == '3' || proto[0] == '4');
705 bool define = proto.find('i') != std::string::npos;
707 // If all types are the same size, bitcasting the args will take care
708 // of arg checking. The actual signedness etc. will be taken care of with
710 if (proto.find('s') == std::string::npos)
713 if (proto[0] != 'v') {
714 std::string ts = TypeString(proto[0], typestr);
718 s += "(" + ts + "){(__neon_" + ts + ")";
722 s += TypeString(proto[0], typestr, true) + " val; ";
723 s += TypeString(proto[0], typestr, false) + " s; ";
730 if (structTypes && proto[0] != 's' && proto[0] != 'i' && proto[0] != 'l')
737 bool splat = proto.find('a') != std::string::npos;
739 s += "__builtin_neon_";
741 std::string vname(name, 0, name.size()-2);
742 s += MangleName(vname, typestr, ck);
744 s += MangleName(name, typestr, ck);
748 for (unsigned i = 1, e = proto.size(); i != e; ++i, ++arg) {
749 std::string args = std::string(&arg, 1);
751 args = "(" + args + ")";
753 // Handle multiple-vector values specially, emitting each subvector as an
754 // argument to the __builtin.
755 if (structTypes && (proto[i] == '2' || proto[i] == '3' || proto[i] == '4')){
756 for (unsigned vi = 0, ve = proto[i] - '0'; vi != ve; ++vi) {
757 s += args + ".val[" + utostr(vi) + "]";
767 if (splat && (i + 1) == e)
768 s += Duplicate(nElts, typestr, args);
772 if (structTypes && proto[i] != 's' && proto[i] != 'i' && proto[i] != 'l' &&
773 proto[i] != 'p' && proto[i] != 'c' && proto[i] != 'a') {
780 // Extra constant integer to hold type class enum for this function, e.g. s8
782 s += ", " + utostr(GetNeonEnum(proto, typestr));
789 if (proto[0] != 'v') {
803 static std::string GenBuiltinDef(const std::string &name,
804 const std::string &proto,
805 StringRef typestr, ClassKind ck) {
806 std::string s("BUILTIN(__builtin_neon_");
808 // If all types are the same size, bitcasting the args will take care
809 // of arg checking. The actual signedness etc. will be taken care of with
811 if (proto.find('s') == std::string::npos)
814 s += MangleName(name, typestr, ck);
817 for (unsigned i = 0, e = proto.size(); i != e; ++i)
818 s += BuiltinTypeString(proto[i], typestr, ck, i == 0);
820 // Extra constant integer to hold type class enum for this function, e.g. s8
828 /// run - Read the records in arm_neon.td and output arm_neon.h. arm_neon.h
829 /// is comprised of type definitions and function declarations.
830 void NeonEmitter::run(raw_ostream &OS) {
831 EmitSourceFileHeader("ARM NEON Header", OS);
833 // FIXME: emit license into file?
835 OS << "#ifndef __ARM_NEON_H\n";
836 OS << "#define __ARM_NEON_H\n\n";
838 OS << "#ifndef __ARM_NEON__\n";
839 OS << "#error \"NEON support not enabled\"\n";
842 OS << "#include <stdint.h>\n\n";
844 // Emit NEON-specific scalar typedefs.
845 OS << "typedef float float32_t;\n";
846 OS << "typedef uint8_t poly8_t;\n";
847 OS << "typedef uint16_t poly16_t;\n";
848 OS << "typedef uint16_t float16_t;\n";
850 // Emit Neon vector typedefs.
851 std::string TypedefTypes("cQcsQsiQilQlUcQUcUsQUsUiQUiUlQUlhQhfQfPcQPcPsQPs");
852 SmallVector<StringRef, 24> TDTypeVec;
853 ParseTypes(0, TypedefTypes, TDTypeVec);
855 // Emit vector typedefs.
856 for (unsigned v = 1; v != 5; ++v) {
857 for (unsigned i = 0, e = TDTypeVec.size(); i != e; ++i) {
858 bool dummy, quad = false;
859 (void) ClassifyType(TDTypeVec[i], quad, dummy, dummy);
860 OS << "typedef __attribute__(( __vector_size__(";
862 OS << utostr(8*v*(quad ? 2 : 1)) << ") )) ";
866 OS << TypeString('s', TDTypeVec[i]);
869 char t = (v == 1) ? 'd' : '0' + v;
870 OS << TypeString(t, TDTypeVec[i]) << ";\n";
875 // Emit struct typedefs.
876 for (unsigned vi = 1; vi != 5; ++vi) {
877 for (unsigned i = 0, e = TDTypeVec.size(); i != e; ++i) {
878 std::string ts = TypeString('d', TDTypeVec[i]);
879 std::string vs = (vi > 1) ? TypeString('0' + vi, TDTypeVec[i]) : ts;
880 OS << "typedef struct __" << vs << " {\n";
881 OS << " __neon_" << ts << " val";
883 OS << "[" << utostr(vi) << "]";
884 OS << ";\n} " << vs << ";\n\n";
888 OS << "#define __ai static __attribute__((__always_inline__))\n\n";
890 std::vector<Record*> RV = Records.getAllDerivedDefinitions("Inst");
892 // Unique the return+pattern types, and assign them.
893 for (unsigned i = 0, e = RV.size(); i != e; ++i) {
895 std::string name = LowercaseString(R->getName());
896 std::string Proto = R->getValueAsString("Prototype");
897 std::string Types = R->getValueAsString("Types");
899 SmallVector<StringRef, 16> TypeVec;
900 ParseTypes(R, Types, TypeVec);
902 OpKind k = OpMap[R->getValueAsDef("Operand")->getName()];
904 bool define = Proto.find('i') != std::string::npos;
906 for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) {
907 assert(!Proto.empty() && "");
909 // static always inline + return type
913 OS << "__ai " << TypeString(Proto[0], TypeVec[ti]);
915 // Function name with type suffix
916 OS << " " << MangleName(name, TypeVec[ti], ClassS);
918 // Function arguments
919 OS << GenArgs(Proto, TypeVec[ti]);
928 OS << GenOpString(k, Proto, TypeVec[ti]);
930 if (R->getSuperClasses().size() < 2)
931 throw TGError(R->getLoc(), "Builtin has no class kind");
933 ClassKind ck = ClassMap[R->getSuperClasses()[1]];
936 throw TGError(R->getLoc(), "Builtin has no class kind");
937 OS << GenBuiltin(name, Proto, TypeVec[ti], ck);
945 OS << "#undef __ai\n\n";
946 OS << "#endif /* __ARM_NEON_H */\n";
949 static unsigned RangeFromType(StringRef typestr) {
950 // base type to get the type string for.
951 bool quad = false, dummy = false;
952 char type = ClassifyType(typestr, quad, dummy, dummy);
956 return (8 << (int)quad) - 1;
959 return (4 << (int)quad) - 1;
962 return (2 << (int)quad) - 1;
964 return (1 << (int)quad) - 1;
966 throw "unhandled type!";
971 /// runHeader - Emit a file with sections defining:
972 /// 1. the NEON section of BuiltinsARM.def.
973 /// 2. the SemaChecking code for the type overload checking.
974 /// 3. the SemaChecking code for validation of intrinsic immedate arguments.
975 void NeonEmitter::runHeader(raw_ostream &OS) {
976 std::vector<Record*> RV = Records.getAllDerivedDefinitions("Inst");
978 StringMap<OpKind> EmittedMap;
980 // Generate BuiltinsARM.def for NEON
981 OS << "#ifdef GET_NEON_BUILTINS\n";
982 for (unsigned i = 0, e = RV.size(); i != e; ++i) {
984 OpKind k = OpMap[R->getValueAsDef("Operand")->getName()];
988 std::string Proto = R->getValueAsString("Prototype");
990 // Functions with 'a' (the splat code) in the type prototype should not get
991 // their own builtin as they use the non-splat variant.
992 if (Proto.find('a') != std::string::npos)
995 std::string Types = R->getValueAsString("Types");
996 SmallVector<StringRef, 16> TypeVec;
997 ParseTypes(R, Types, TypeVec);
999 if (R->getSuperClasses().size() < 2)
1000 throw TGError(R->getLoc(), "Builtin has no class kind");
1002 std::string name = LowercaseString(R->getName());
1003 ClassKind ck = ClassMap[R->getSuperClasses()[1]];
1005 for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) {
1006 // Generate the BuiltinsARM.def declaration for this builtin, ensuring
1007 // that each unique BUILTIN() macro appears only once in the output
1009 std::string bd = GenBuiltinDef(name, Proto, TypeVec[ti], ck);
1010 if (EmittedMap.count(bd))
1013 EmittedMap[bd] = OpNone;
1019 // Generate the overloaded type checking code for SemaChecking.cpp
1020 OS << "#ifdef GET_NEON_OVERLOAD_CHECK\n";
1021 for (unsigned i = 0, e = RV.size(); i != e; ++i) {
1023 OpKind k = OpMap[R->getValueAsDef("Operand")->getName()];
1027 std::string Proto = R->getValueAsString("Prototype");
1028 std::string Types = R->getValueAsString("Types");
1029 std::string name = LowercaseString(R->getName());
1031 // Functions with 'a' (the splat code) in the type prototype should not get
1032 // their own builtin as they use the non-splat variant.
1033 if (Proto.find('a') != std::string::npos)
1036 // Functions which have a scalar argument cannot be overloaded, no need to
1037 // check them if we are emitting the type checking code.
1038 if (Proto.find('s') != std::string::npos)
1041 SmallVector<StringRef, 16> TypeVec;
1042 ParseTypes(R, Types, TypeVec);
1044 if (R->getSuperClasses().size() < 2)
1045 throw TGError(R->getLoc(), "Builtin has no class kind");
1047 int si = -1, qi = -1;
1048 unsigned mask = 0, qmask = 0;
1049 for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) {
1050 // Generate the switch case(s) for this builtin for the type validation.
1051 bool quad = false, poly = false, usgn = false;
1052 (void) ClassifyType(TypeVec[ti], quad, poly, usgn);
1056 qmask |= 1 << GetNeonEnum(Proto, TypeVec[ti]);
1059 mask |= 1 << GetNeonEnum(Proto, TypeVec[ti]);
1063 OS << "case ARM::BI__builtin_neon_"
1064 << MangleName(name, TypeVec[si], ClassB)
1065 << ": mask = " << "0x" << utohexstr(mask) << "; break;\n";
1067 OS << "case ARM::BI__builtin_neon_"
1068 << MangleName(name, TypeVec[qi], ClassB)
1069 << ": mask = " << "0x" << utohexstr(qmask) << "; break;\n";
1073 // Generate the intrinsic range checking code for shift/lane immediates.
1074 OS << "#ifdef GET_NEON_IMMEDIATE_CHECK\n";
1075 for (unsigned i = 0, e = RV.size(); i != e; ++i) {
1078 OpKind k = OpMap[R->getValueAsDef("Operand")->getName()];
1082 std::string name = LowercaseString(R->getName());
1083 std::string Proto = R->getValueAsString("Prototype");
1084 std::string Types = R->getValueAsString("Types");
1086 // Functions with 'a' (the splat code) in the type prototype should not get
1087 // their own builtin as they use the non-splat variant.
1088 if (Proto.find('a') != std::string::npos)
1091 // Functions which do not have an immediate do not need to have range
1092 // checking code emitted.
1093 if (Proto.find('i') == std::string::npos)
1096 SmallVector<StringRef, 16> TypeVec;
1097 ParseTypes(R, Types, TypeVec);
1099 if (R->getSuperClasses().size() < 2)
1100 throw TGError(R->getLoc(), "Builtin has no class kind");
1102 ClassKind ck = ClassMap[R->getSuperClasses()[1]];
1104 for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) {
1105 std::string namestr, shiftstr, rangestr;
1107 // Builtins which are overloaded by type will need to have their upper
1108 // bound computed at Sema time based on the type constant.
1109 if (Proto.find('s') == std::string::npos) {
1111 if (R->getValueAsBit("isShift")) {
1112 shiftstr = ", true";
1114 // Right shifts have an 'r' in the name, left shifts do not.
1115 if (name.find('r') != std::string::npos)
1116 rangestr = "l = 1; ";
1118 rangestr += "u = RFT(TV" + shiftstr + ")";
1120 rangestr = "u = " + utostr(RangeFromType(TypeVec[ti]));
1122 // Make sure cases appear only once.
1123 namestr = MangleName(name, TypeVec[ti], ck);
1124 if (EmittedMap.count(namestr))
1126 EmittedMap[namestr] = OpNone;
1128 unsigned immidx = 0;
1129 for (unsigned ii = 1, ie = Proto.size(); ii != ie; ++ii) {
1130 switch (Proto[ii]) {
1131 default: immidx += 1; break;
1132 case '2': immidx += 2; break;
1133 case '3': immidx += 3; break;
1134 case '4': immidx += 4; break;
1135 case 'i': ie = ii + 1; break;
1138 OS << "case ARM::BI__builtin_neon_" << MangleName(name, TypeVec[ti], ck)
1139 << ": i = " << immidx << "; " << rangestr << "; break;\n";