reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced

References

utils/TableGen/SearchableTableEmitter.cpp
  297   OS << "\n";
  298   emitLookupDeclaration(Table, Index, OS);
  299   OS << " {\n";
  311     OS << "  struct IndexType {\n";
  313       OS << "    " << searchableFieldType(Field, TypeInStaticStruct) << " "
  316     OS << "    unsigned _index;\n";
  317     OS << "  };\n";
  319     OS << "  static const struct IndexType Index[] = {\n";
  336       OS << "    { ";
  340           OS << ", ";
  347         OS << Repr;
  349       OS << ", " << Entry.second << " },\n";
  352     OS << "  };\n\n";
  373     OS << "  auto Table = makeArrayRef(" << IndexName << ");\n";
  374     OS << "  size_t Idx = " << Index.Fields[0].Name << ";\n";
  375     OS << "  return Idx >= Table.size() ? nullptr : ";
  377       OS << "&Table[Idx]";
  379       OS << "&" << Table.Name << "[Table[Idx]._index]";
  380     OS << ";\n";
  381     OS << "}\n";
  391     OS << "  if ((" << Field.Name << " < " << FirstRepr << ") ||\n";
  392     OS << "      (" << Field.Name << " > " << LastRepr << "))\n";
  393     OS << "    return nullptr;\n\n";
  396   OS << "  struct KeyType {\n";
  398     OS << "    " << searchableFieldType(Field, TypeInTempStruct) << " "
  401   OS << "  };\n";
  402   OS << "  KeyType Key = { ";
  406       OS << ", ";
  409     OS << Field.Name;
  411       OS << ".upper()";
  418   OS << " };\n";
  420   OS << "  auto Table = makeArrayRef(" << IndexName << ");\n";
  421   OS << "  auto Idx = std::lower_bound(Table.begin(), Table.end(), Key,\n";
  422   OS << "    [](const " << IndexTypeName << " &LHS, const KeyType &RHS) {\n";
  426       OS << "      int Cmp" << Field.Name << " = StringRef(LHS." << Field.Name
  428       OS << "      if (Cmp" << Field.Name << " < 0) return true;\n";
  429       OS << "      if (Cmp" << Field.Name << " > 0) return false;\n";
  433       OS << "      if ((unsigned)LHS." << Field.Name << " < (unsigned)RHS."
  435       OS << "        return true;\n";
  436       OS << "      if ((unsigned)LHS." << Field.Name << " > (unsigned)RHS."
  438       OS << "        return false;\n";
  440       OS << "      if (LHS." << Field.Name << " < RHS." << Field.Name << ")\n";
  441       OS << "        return true;\n";
  442       OS << "      if (LHS." << Field.Name << " > RHS." << Field.Name << ")\n";
  443       OS << "        return false;\n";
  447   OS << "      return false;\n";
  448   OS << "    });\n\n";
  450   OS << "  if (Idx == Table.end()";
  453     OS << " ||\n      Key." << Field.Name << " != Idx->" << Field.Name;
  454   OS << ")\n    return nullptr;\n";
  457     OS << "  return &*Idx;\n";
  459     OS << "  return &" << Table.Name << "[Idx->_index];\n";
  461   OS << "}\n";