@@ -943,24 +943,23 @@ SubtargetEmitter::findWriteResources(const CodeGenSchedRW &SchedWrite,
943
943
944
944
// Check this processor's list of write resources.
945
945
const Record *ResDef = nullptr ;
946
- for (const Record *WR : ProcModel.WriteResDefs ) {
947
- if (!WR->isSubClassOf (" WriteRes" ))
948
- continue ;
949
- const Record *WRDef = WR->getValueAsDef (" WriteType" );
950
- if (AliasDef == WRDef || SchedWrite.TheDef == WRDef) {
951
- if (ResDef) {
952
- PrintFatalError (WR->getLoc (), " Resources are defined for both "
953
- " SchedWrite and its alias on processor " +
954
- ProcModel.ModelName );
955
- }
956
- ResDef = WR;
957
- // If there is no AliasDef and we find a match, we can early exit since
958
- // there is no need to verify whether there are resources defined for both
959
- // SchedWrite and its alias.
960
- if (!AliasDef)
961
- break ;
946
+
947
+ auto I = ProcModel.WriteResMap .find (SchedWrite.TheDef );
948
+ if (I != ProcModel.WriteResMap .end ())
949
+ ResDef = I->second ;
950
+
951
+ if (AliasDef) {
952
+ I = ProcModel.WriteResMap .find (AliasDef);
953
+ if (I != ProcModel.WriteResMap .end ()) {
954
+ if (ResDef)
955
+ PrintFatalError (I->second ->getLoc (),
956
+ " Resources are defined for both SchedWrite and its "
957
+ " alias on processor " +
958
+ ProcModel.ModelName );
959
+ ResDef = I->second ;
962
960
}
963
961
}
962
+
964
963
// TODO: If ProcModel has a base model (previous generation processor),
965
964
// then call FindWriteResources recursively with that model here.
966
965
if (!ResDef) {
@@ -1003,24 +1002,24 @@ SubtargetEmitter::findReadAdvance(const CodeGenSchedRW &SchedRead,
1003
1002
1004
1003
// Check this processor's ReadAdvanceList.
1005
1004
const Record *ResDef = nullptr ;
1006
- for (const Record *RA : ProcModel.ReadAdvanceDefs ) {
1007
- if (!RA->isSubClassOf (" ReadAdvance" ))
1008
- continue ;
1009
- const Record *RADef = RA->getValueAsDef (" ReadType" );
1010
- if (AliasDef == RADef || SchedRead.TheDef == RADef) {
1011
- if (ResDef) {
1012
- PrintFatalError (RA->getLoc (), " Resources are defined for both "
1013
- " SchedRead and its alias on processor " +
1014
- ProcModel.ModelName );
1015
- }
1016
- ResDef = RA;
1017
- // If there is no AliasDef and we find a match, we can early exit since
1018
- // there is no need to verify whether there are resources defined for both
1019
- // SchedRead and its alias.
1020
- if (!AliasDef)
1021
- break ;
1005
+
1006
+ auto I = ProcModel.ReadAdvanceMap .find (SchedRead.TheDef );
1007
+ if (I != ProcModel.ReadAdvanceMap .end ())
1008
+ ResDef = I->second ;
1009
+
1010
+ if (AliasDef) {
1011
+ I = ProcModel.ReadAdvanceMap .find (AliasDef);
1012
+ if (I != ProcModel.ReadAdvanceMap .end ()) {
1013
+ if (ResDef)
1014
+ PrintFatalError (
1015
+ I->second ->getLoc (),
1016
+ " Resources are defined for both SchedRead and its alias on "
1017
+ " processor " +
1018
+ ProcModel.ModelName );
1019
+ ResDef = I->second ;
1022
1020
}
1023
1021
}
1022
+
1024
1023
// TODO: If ProcModel has a base model (previous generation processor),
1025
1024
// then call FindReadAdvance recursively with that model here.
1026
1025
if (!ResDef && SchedRead.TheDef ->getName () != " ReadDefault" ) {
0 commit comments