@@ -566,8 +566,6 @@ static void printPredicates(ArrayRef<const Record *> Predicates, StringRef Name,
566
566
567
567
static void mergeCondAndCode (raw_ostream &CombinedStream, StringRef CondStr,
568
568
StringRef CodeStr) {
569
- // Remove first indentation and last '&&'.
570
- CondStr = CondStr.drop_front (8 ).drop_back (4 );
571
569
CombinedStream.indent (4 ) << " if (" << CondStr << " ) {\n " ;
572
570
CombinedStream << CodeStr;
573
571
CombinedStream.indent (4 ) << " return true;\n " ;
@@ -704,17 +702,18 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &OS,
704
702
});
705
703
getReqFeatures (FeaturesSet, AnyOfFeatureSets, ReqFeatures);
706
704
705
+ ListSeparator CondSep (" &&\n " );
706
+
707
707
// Emit checks for all required features.
708
708
for (auto &Op : FeaturesSet) {
709
709
StringRef Not = Op.first ? " !" : " " ;
710
- CondStream.indent (8 ) << Not << " STI.getFeatureBits()[" << TargetName
711
- << " ::" << Op.second << " ]"
712
- << " &&\n " ;
710
+ CondStream << CondSep << Not << " STI.getFeatureBits()[" << TargetName
711
+ << " ::" << Op.second << " ]" ;
713
712
}
714
713
715
714
// Emit checks for all required feature groups.
716
715
for (auto &Set : AnyOfFeatureSets) {
717
- CondStream. indent ( 8 ) << " (" ;
716
+ CondStream << CondSep << " (" ;
718
717
for (auto &Op : Set) {
719
718
bool IsLast = &Op == &*Set.rbegin ();
720
719
StringRef Not = Op.first ? " !" : " " ;
@@ -723,7 +722,7 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &OS,
723
722
if (!IsLast)
724
723
CondStream << " || " ;
725
724
}
726
- CondStream << " ) && \n " ;
725
+ CondStream << " )" ;
727
726
}
728
727
729
728
// Start Source Inst operands validation.
@@ -735,32 +734,31 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &OS,
735
734
case OpData::Operand:
736
735
if (SourceOperandMap[OpNo].OpInfo .TiedOpIdx != -1 ) {
737
736
if (Source.Operands [OpNo].Rec ->isSubClassOf (" RegisterClass" ))
738
- CondStream.indent (8 ) << " (MI.getOperand(" << OpNo
739
- << " ).isReg()) && (MI.getOperand("
740
- << SourceOperandMap[OpNo].OpInfo .TiedOpIdx
741
- << " ).isReg()) &&\n "
742
- << indent (8 ) << " (MI.getOperand(" << OpNo
743
- << " ).getReg() == MI.getOperand("
744
- << SourceOperandMap[OpNo].OpInfo .TiedOpIdx
745
- << " ).getReg()) &&\n " ;
737
+ CondStream << CondSep << " MI.getOperand(" << OpNo
738
+ << " ).isReg() && MI.getOperand("
739
+ << SourceOperandMap[OpNo].OpInfo .TiedOpIdx
740
+ << " ).isReg()" << CondSep << " (MI.getOperand(" << OpNo
741
+ << " ).getReg() == MI.getOperand("
742
+ << SourceOperandMap[OpNo].OpInfo .TiedOpIdx
743
+ << " ).getReg())" ;
746
744
else
747
745
PrintFatalError (" Unexpected tied operand types!" );
748
746
}
749
747
750
748
// We don't need to do anything for source instruction operand checks.
751
749
break ;
752
750
case OpData::Imm:
753
- CondStream. indent ( 8 )
754
- << " (MI.getOperand(" << OpNo << " ).isImm()) && \n "
755
- << " (MI.getOperand( " << OpNo
756
- << " ).getImm() == " << SourceOperandMap[OpNo]. ImmVal << " ) && \n " ;
751
+ CondStream << CondSep << " MI.getOperand( " << OpNo << " ).isImm() "
752
+ << CondSep << " (MI.getOperand(" << OpNo
753
+ << " ).getImm() == " << SourceOperandMap[ OpNo]. ImmVal
754
+ << " )" ;
757
755
break ;
758
756
case OpData::Reg: {
759
757
const Record *Reg = SourceOperandMap[OpNo].RegRec ;
760
- CondStream. indent ( 8 ) << " ( MI.getOperand(" << OpNo << " ).isReg()) && \n "
761
- << indent ( 8 ) << " (MI.getOperand(" << OpNo
762
- << " ).getReg() == " << TargetName
763
- << " :: " << Reg-> getName () << " ) && \n " ;
758
+ CondStream << CondSep << " MI.getOperand(" << OpNo << " ).isReg()"
759
+ << CondSep << " (MI.getOperand(" << OpNo
760
+ << " ).getReg() == " << TargetName << " :: " << Reg-> getName ()
761
+ << " ) " ;
764
762
break ;
765
763
}
766
764
}
@@ -797,15 +795,14 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &OS,
797
795
// Don't check register class if this is a tied operand, it was done
798
796
// for the operand it's tied to.
799
797
if (DestOperand.getTiedRegister () == -1 ) {
800
- CondStream. indent ( 8 ) << " MI.getOperand(" << OpIdx << " ).isReg()" ;
798
+ CondStream << CondSep << " MI.getOperand(" << OpIdx << " ).isReg()" ;
801
799
if (EType == EmitterType::CheckCompress)
802
800
CondStream << " && MI.getOperand(" << OpIdx
803
801
<< " ).getReg().isPhysical()" ;
804
- CondStream << " &&\n "
805
- << indent (8 ) << TargetName << " MCRegisterClasses["
802
+ CondStream << CondSep << TargetName << " MCRegisterClasses["
806
803
<< TargetName << " ::" << ClassRec->getName ()
807
804
<< " RegClassID].contains(MI.getOperand(" << OpIdx
808
- << " ).getReg()) && \n " ;
805
+ << " ).getReg())" ;
809
806
}
810
807
811
808
if (CompressOrUncompress)
@@ -816,38 +813,33 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &OS,
816
813
if (CompressOrUncompress) {
817
814
unsigned Entry = getPredicates (MCOpPredicateMap, MCOpPredicates,
818
815
DagRec, " MCOperandPredicate" );
819
- CondStream.indent (8 )
820
- << ValidatorName << " ("
821
- << " MI.getOperand(" << OpIdx << " ), STI, " << Entry << " /* "
822
- << DagRec->getName () << " */) &&\n " ;
816
+ CondStream << CondSep << ValidatorName << " ("
817
+ << " MI.getOperand(" << OpIdx << " ), STI, " << Entry
818
+ << " /* " << DagRec->getName () << " */)" ;
823
819
// Also check DestRec if different than DagRec.
824
820
if (DagRec != DestRec) {
825
821
Entry = getPredicates (MCOpPredicateMap, MCOpPredicates, DestRec,
826
822
" MCOperandPredicate" );
827
- CondStream.indent (8 )
828
- << ValidatorName << " ("
829
- << " MI.getOperand(" << OpIdx << " ), STI, " << Entry
830
- << " /* " << DestRec->getName () << " */) &&\n " ;
823
+ CondStream << CondSep << ValidatorName << " ("
824
+ << " MI.getOperand(" << OpIdx << " ), STI, " << Entry
825
+ << " /* " << DestRec->getName () << " */)" ;
831
826
}
832
827
} else {
833
828
unsigned Entry =
834
829
getPredicates (ImmLeafPredicateMap, ImmLeafPredicates, DagRec,
835
830
" ImmediateCode" );
836
- CondStream.indent (8 )
837
- << " MI.getOperand(" << OpIdx << " ).isImm() &&\n " ;
838
- CondStream.indent (8 )
839
- << TargetName << " ValidateMachineOperand("
840
- << " MI.getOperand(" << OpIdx << " ), &STI, " << Entry << " /* "
841
- << DagRec->getName () << " */) &&\n " ;
831
+ CondStream << CondSep << " MI.getOperand(" << OpIdx << " ).isImm()" ;
832
+ CondStream << CondSep << TargetName << " ValidateMachineOperand("
833
+ << " MI.getOperand(" << OpIdx << " ), &STI, " << Entry
834
+ << " /* " << DagRec->getName () << " */)" ;
842
835
if (DagRec != DestRec) {
843
836
Entry = getPredicates (ImmLeafPredicateMap, ImmLeafPredicates,
844
837
DestRec, " ImmediateCode" );
845
- CondStream.indent (8 )
846
- << " MI.getOperand(" << OpIdx << " ).isImm() &&\n " ;
847
- CondStream.indent (8 )
848
- << TargetName << " ValidateMachineOperand("
849
- << " MI.getOperand(" << OpIdx << " ), &STI, " << Entry
850
- << " /* " << DestRec->getName () << " */) &&\n " ;
838
+ CondStream << CondSep << " MI.getOperand(" << OpIdx
839
+ << " ).isImm()" ;
840
+ CondStream << CondSep << TargetName << " ValidateMachineOperand("
841
+ << " MI.getOperand(" << OpIdx << " ), &STI, " << Entry
842
+ << " /* " << DestRec->getName () << " */)" ;
851
843
}
852
844
}
853
845
if (CompressOrUncompress)
@@ -860,20 +852,18 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &OS,
860
852
if (CompressOrUncompress) {
861
853
unsigned Entry = getPredicates (MCOpPredicateMap, MCOpPredicates,
862
854
DestRec, " MCOperandPredicate" );
863
- CondStream.indent (8 )
864
- << ValidatorName << " ("
865
- << " MCOperand::createImm(" << DestOperandMap[OpNo].ImmVal
866
- << " ), STI, " << Entry << " /* " << DestRec->getName ()
867
- << " */) &&\n " ;
855
+ CondStream << CondSep << ValidatorName << " ("
856
+ << " MCOperand::createImm(" << DestOperandMap[OpNo].ImmVal
857
+ << " ), STI, " << Entry << " /* " << DestRec->getName ()
858
+ << " */)" ;
868
859
} else {
869
860
unsigned Entry =
870
861
getPredicates (ImmLeafPredicateMap, ImmLeafPredicates, DestRec,
871
862
" ImmediateCode" );
872
- CondStream.indent (8 )
873
- << TargetName
874
- << " ValidateMachineOperand(MachineOperand::CreateImm("
875
- << DestOperandMap[OpNo].ImmVal << " ), &STI, " << Entry << " /* "
876
- << DestRec->getName () << " */) &&\n " ;
863
+ CondStream << CondSep << TargetName
864
+ << " ValidateMachineOperand(MachineOperand::CreateImm("
865
+ << DestOperandMap[OpNo].ImmVal << " ), &STI, " << Entry
866
+ << " /* " << DestRec->getName () << " */)" ;
877
867
}
878
868
if (CompressOrUncompress)
879
869
CodeStream.indent (6 ) << " OutInst.addOperand(MCOperand::createImm("
0 commit comments