Lines Matching full:field
11 // function generated is either a direct lookup (when a single primary key field
42 static int64_t getInt(const Record *R, StringRef Field) {
43 return getAsInt(R->getValueInit(Field));
70 SMLoc Loc; // Source location of PrimaryKey or Key field definition.
88 for (const auto &Field : Fields) {
89 if (Name == Field.Name)
90 return &Field;
117 std::string primaryRepresentation(SMLoc Loc, const GenericField &Field,
120 if (Field.IsCode || SI->hasCodeFormat())
128 else if (Field.IsIntrinsic)
130 else if (Field.IsInstruction)
132 else if (Field.Enum) {
133 auto *Entry = Field.Enum->EntryMap[cast<DefInit>(I)->getDef()];
136 Twine("Entry for field '") + Field.Name + "' is null");
139 PrintFatalError(Loc, Twine("invalid field type for field '") + Field.Name +
159 const GenericField &Field, TypeContext Ctx) {
160 if (isa<StringRecTy>(Field.RecType)) {
166 } else if (const BitsRecTy *BI = dyn_cast<BitsRecTy>(Field.RecType)) {
178 "', key field '" + Field.Name +
180 } else if (isa<BitRecTy>(Field.RecType)) {
182 } else if (Field.Enum || Field.IsIntrinsic || Field.IsInstruction)
186 Index.Name + "', key field '" + Field.Name +
187 "' has invalid type: " + Field.RecType->getAsString());
198 bool parseFieldType(GenericField &Field, const Init *II);
210 // For search indices that consists of a single field whose numeric value is
215 const GenericField &Field = Index.Fields[0];
219 if (Field.IsInstruction) {
220 const Record *TheDef = Rec->getValueAsDef(Field.Name);
223 if (Field.Enum) {
224 const Record *EnumEntry = Rec->getValueAsDef(Field.Name);
225 return Field.Enum->EntryMap[EnumEntry]->second;
227 assert(isa<BitsRecTy>(Field.RecType) && "unexpected field type");
229 return getInt(Rec, Field.Name);
236 for (const auto &Field : Index.Fields) {
237 const Init *LHSI = LHS->getValueInit(Field.Name);
238 const Init *RHSI = RHS->getValueInit(Field.Name);
240 if (isa<BitsRecTy>(Field.RecType) || isa<IntRecTy>(Field.RecType)) {
247 } else if (Field.IsIntrinsic) {
256 } else if (Field.IsInstruction) {
273 } else if (Field.Enum) {
276 int64_t LHSv = Field.Enum->EntryMap[LHSr]->second;
277 int64_t RHSv = Field.Enum->EntryMap[RHSr]->second;
283 std::string LHSs = primaryRepresentation(Index.Loc, Field, LHSI);
284 std::string RHSs = primaryRepresentation(Index.Loc, Field, RHSI);
286 if (isa<StringRecTy>(Field.RecType)) {
338 for (const auto &Field : Index.Fields) {
340 << searchableFieldType(Table, Index, Field, TypeInStaticStruct) << " "
341 << Field.Name << ";\n";
365 for (const auto &Field : Index.Fields) {
367 Index.Loc, Field, Entry.first->getValueInit(Field.Name));
368 if (isa<StringRecTy>(Field.RecType))
398 const GenericField &Field = Index.Fields[0];
400 Index.Loc, Field, IndexRows[0]->getValueInit(Field.Name));
402 Index.Loc, Field, IndexRows.back()->getValueInit(Field.Name));
404 '(' + searchableFieldType(Table, Index, Field, TypeInStaticStruct) +
406 OS << " if (" << TS << Field.Name << " != std::clamp(" << TS << Field.Name
412 OS << " size_t Idx = " << Field.Name << " - " << FirstRepr << ";\n";
425 for (const auto &Field : Index.Fields) {
426 OS << " " << searchableFieldType(Table, Index, Field, TypeInTempStruct)
427 << " " << Field.Name << ";\n";
432 for (const auto &Field : Index.Fields) {
433 OS << LS << Field.Name;
434 if (isa<StringRecTy>(Field.RecType)) {
440 "case-insensitive comparison of field '" +
441 Field.Name + "'");
451 for (const auto &Field : Index.Fields) {
452 if (isa<StringRecTy>(Field.RecType)) {
453 OS << " int Cmp" << Field.Name << " = StringRef(LHS." << Field.Name
454 << ").compare(RHS." << Field.Name << ");\n";
455 OS << " if (Cmp" << Field.Name << " < 0) return true;\n";
456 OS << " if (Cmp" << Field.Name << " > 0) return false;\n";
457 } else if (Field.Enum) {
460 OS << " if ((unsigned)LHS." << Field.Name << " < (unsigned)RHS."
461 << Field.Name << ")\n";
463 OS << " if ((unsigned)LHS." << Field.Name << " > (unsigned)RHS."
464 << Field.Name << ")\n";
467 OS << " if (LHS." << Field.Name << " < RHS." << Field.Name
470 OS << " if (LHS." << Field.Name << " > RHS." << Field.Name
496 for (const auto &Field : Index.Fields)
497 OS << " ||\n Key." << Field.Name << " != Idx->" << Field.Name;
522 for (const auto &Field : Index.Fields)
523 OS << LS << searchableFieldType(Table, Index, Field, TypeInArgument) << " "
524 << Field.Name;
553 for (const auto &Field : Table.Fields)
555 << primaryRepresentation(Table.Locs[0], Field,
556 Entry->getValueInit(Field.Name));
572 bool SearchableTableEmitter::parseFieldType(GenericField &Field,
581 Field.IsCode = true;
587 Field.Enum = EnumMap[TypeRec];
588 Field.RecType = RecordRecTy::get(Field.Enum->Class);
606 const GenericField *Field = Table.getFieldByName(FieldName);
607 if (!Field)
611 "', 'PrimaryKey' or 'Key' refers to nonexistent field '" +
614 Index->Fields.push_back(*Field);
620 "supported for a first key field of type string");
663 for (auto &Field : Table.Fields) {
664 auto TI = dyn_cast<TypedInit>(EntryRec->getValueInit(Field.Name));
668 "' is missing field '" + Field.Name +
671 if (!Field.RecType) {
672 Field.RecType = TI->getType();
674 const RecTy *Ty = resolveTypes(Field.RecType, TI->getType());
676 PrintFatalError(EntryRec->getValue(Field.Name),
677 Twine("Field '") + Field.Name + "' of table '" +
680 Field.RecType->getAsString());
681 Field.RecType = Ty;
690 for (auto &Field : Table.Fields) {
691 if (!Field.RecType)
692 PrintFatalError(Twine("Cannot determine type of field '") + Field.Name +
695 if (auto RecordTy = dyn_cast<RecordRecTy>(Field.RecType)) {
697 Field.IsIntrinsic = true;
699 Field.IsInstruction = true;
768 PrintFatalNote("The 'TypeOf_xxx' field must be a string naming a "
867 for (const RecordVal &Field : Class->getValues()) {
868 std::string FieldName = std::string(Field.getName());
882 for (const auto &Field :
885 (Twine("lookup") + Table->CppTypeName + "By" + Field).str();
887 parseSearchIndex(*Table, Class->getValue(Field), Name, {Field},