Add long vector prototype for the builtin function. This is similar to AddTabledBuiltin, but only generates builtins where one type is an arbitrary vector. See comments on "enum ArgClass" for more details.
| 398 | // AddTabledBuiltin, but only generates builtins where one type is an |
| 399 | // arbitrary vector. See comments on "enum ArgClass" for more details. |
| 400 | void AddLongVectorBuiltin(TString& decls, const BuiltInFunction& function) |
| 401 | { |
| 402 | const auto isScalarType = [](int type) { return (type & TypeStringColumnMask) == 0; }; |
| 403 | |
| 404 | // loop across these two: |
| 405 | // 0: the varying arg set, and |
| 406 | // 1: the fixed scalar args |
| 407 | const ArgClass ClassFixed = (ArgClass)(ClassLS | ClassXLS | ClassLS2 | ClassFS | ClassFS2); |
| 408 | for (int fixed = 0; fixed < ((function.classes & ClassFixed) > 0 ? 2 : 1); ++fixed) { |
| 409 | |
| 410 | if (fixed == 0 && (function.classes & ClassXLS)) |
| 411 | continue; |
| 412 | |
| 413 | // Iterate over the different scalar types (needed for ClassRS) |
| 414 | for (int type = 0; type < TypeStringCount; ++type) { |
| 415 | if (!isScalarType(type)) |
| 416 | continue; |
| 417 | |
| 418 | // skip types not selected: go from type to row number to type bit |
| 419 | if ((function.types & (1 << (type >> TypeStringRowShift))) == 0) |
| 420 | continue; |
| 421 | |
| 422 | // skip scalar-only |
| 423 | if (function.classes & ClassV1) |
| 424 | continue; |
| 425 | |
| 426 | // skip 3-vector |
| 427 | if (function.classes & ClassV3) |
| 428 | continue; |
| 429 | |
| 430 | TString decl; |
| 431 | // return type |
| 432 | if (function.classes & ClassB) |
| 433 | decl.append("vector"); |
| 434 | else if (function.classes & ClassRS) |
| 435 | decl.append(TypeString[type & TypeStringScalarMask]); |
| 436 | else |
| 437 | decl.append("vector"); |
| 438 | decl.append(" "); |
| 439 | decl.append(function.name); |
| 440 | decl.append("("); |
| 441 | |
| 442 | // arguments |
| 443 | for (int arg = 0; arg < function.numArguments; ++arg) { |
| 444 | if (arg == function.numArguments - 1 && (function.classes & ClassLO)) |
| 445 | decl.append("out "); |
| 446 | if (arg == 0) { |
| 447 | if (function.classes & ClassCVN) |
| 448 | decl.append("coherent volatile nontemporal "); |
| 449 | if (function.classes & ClassFIO) |
| 450 | decl.append("inout "); |
| 451 | if (function.classes & ClassFO) |
| 452 | decl.append("out "); |
| 453 | } |
| 454 | if ((function.classes & ClassLB) && arg == function.numArguments - 1) |
| 455 | decl.append("vector"); |
| 456 | else if (fixed && ((arg == function.numArguments - 1 && (function.classes & (ClassLS | ClassXLS | |
| 457 | ClassLS2))) || |
no test coverage detected