@@ -662,8 +662,7 @@ std::string edgeCaseTemplArg(std::string &Code) {
662
662
PrintFatalNote (" Edge case for C++ code not handled: " + Code);
663
663
}
664
664
665
- std::string handleDefaultArg (const std::string &TargetName,
666
- std::string &Code) {
665
+ std::string handleDefaultArg (const std::string &TargetName, std::string &Code) {
667
666
static SmallVector<std::pair<std::string, std::string>>
668
667
AArch64TemplFuncWithDefaults = {// Default is 1
669
668
{" printVectorIndex" , " 1" },
@@ -690,8 +689,7 @@ std::string handleDefaultArg(const std::string &TargetName,
690
689
return Code;
691
690
}
692
691
693
- void patchTemplateArgs (const std::string &TargetName,
694
- std::string &Code) {
692
+ void patchTemplateArgs (const std::string &TargetName, std::string &Code) {
695
693
Code = handleDefaultArg (TargetName, Code);
696
694
697
695
size_t B = Code.find_first_of (" <" );
@@ -707,9 +705,9 @@ void patchTemplateArgs(const std::string &TargetName,
707
705
continue ;
708
706
}
709
707
while ((Args.find (" true" ) != std::string::npos) ||
710
- (Args.find (" false" ) != std::string::npos) ||
711
- (Args.find (" ," ) != std::string::npos) ||
712
- (Args.find (" '" ) != std::string::npos)) {
708
+ (Args.find (" false" ) != std::string::npos) ||
709
+ (Args.find (" ," ) != std::string::npos) ||
710
+ (Args.find (" '" ) != std::string::npos)) {
713
711
Args = Regex (" true" ).sub (" 1" , Args);
714
712
Args = Regex (" false" ).sub (" 0" , Args);
715
713
Args = Regex (" *, *" ).sub (" _" , Args);
@@ -1420,8 +1418,8 @@ void PrinterCapstone::asmWriterEmitPrintInstruction(
1420
1418
// Emit a single possibility.
1421
1419
OS << translateToC (TargetName, Commands[0 ]) << " \n\n " ;
1422
1420
} else {
1423
- OS << " switch (((uint32_t)(Bits >> " << (OpcodeInfoBits - BitsLeft) << " ) & "
1424
- << ((1 << NumBits) - 1 ) << " )) {\n "
1421
+ OS << " switch (((uint32_t)(Bits >> " << (OpcodeInfoBits - BitsLeft)
1422
+ << " ) & " << ((1 << NumBits) - 1 ) << " )) {\n "
1425
1423
<< " default: assert(0 && \" Invalid command number.\" );\n " ;
1426
1424
1427
1425
// Print out all the cases.
@@ -2503,7 +2501,8 @@ std::string getReqFeatures(StringRef const &TargetName, AsmMatcherInfo &AMI,
2503
2501
}
2504
2502
for (const auto &OpInfo : CGI->Operands .OperandList ) {
2505
2503
if (OpInfo.OperandType == " MCOI::OPERAND_PCREL" &&
2506
- (CGI->isBranch || CGI->isReturn || CGI->isIndirectBranch || CGI->isCall )) {
2504
+ (CGI->isBranch || CGI->isReturn || CGI->isIndirectBranch ||
2505
+ CGI->isCall )) {
2507
2506
Flags += TargetName.str () + " _GRP_BRANCH_RELATIVE, " ;
2508
2507
}
2509
2508
}
@@ -2652,8 +2651,8 @@ bool compareTypeSuperClasses(ArrayRef<std::pair<Record *, SMRange>> OpTypeSC,
2652
2651
// / @param MatchByTypeSuperClasses If true, a valid match is also if any type
2653
2652
// / super classes are the same.
2654
2653
// / @return True, if the pattern contains a node with the same name (and
2655
- // / optionally the same type name or same super class type) as the given operand.
2656
- // / False otherwise.
2654
+ // / optionally the same type name or same super class type) as the given
2655
+ // / operand. False otherwise.
2657
2656
bool opIsPartOfiPTRPattern (Record const *OpRec, StringRef const &OpName,
2658
2657
DagInit *PatternDag, bool PartOfPTRPattern,
2659
2658
bool MatchByTypeName = false ,
@@ -2747,14 +2746,15 @@ int comparePatternResultToCGIOps(CodeGenInstruction const *CGI,
2747
2746
return -1 ;
2748
2747
}
2749
2748
2750
- std::string getCSOperandType (StringRef const &TargetName,
2751
- CodeGenInstruction const *CGI, Record const *OpRec, StringRef const &OpName,
2749
+ std::string getCSOperandType (
2750
+ StringRef const &TargetName, CodeGenInstruction const *CGI,
2751
+ Record const *OpRec, StringRef const &OpName,
2752
2752
std::map<std::string, std::vector<Record *>> const InsnPatternMap) {
2753
2753
std::string OperandType = getPrimaryCSOperandType (OpRec);
2754
2754
2755
2755
if (TargetName.equals (" AArch64" ) && OperandType != " CS_OP_MEM" ) {
2756
- // The definitions of AArch64 are so broken, when it comes to memory operands,
2757
- // that we just search for the op name enclosed in [].
2756
+ // The definitions of AArch64 are so broken, when it comes to memory
2757
+ // operands, that we just search for the op name enclosed in [].
2758
2758
if (Regex (" \\ [.*\\ $" + OpName.str () + " .*]" ).match (CGI->AsmString ))
2759
2759
return OperandType += " | CS_OP_MEM" ;
2760
2760
}
@@ -2763,10 +2763,12 @@ std::string getCSOperandType(StringRef const &TargetName,
2763
2763
if (OperandType == " CS_OP_MEM" )
2764
2764
// It is only marked as mem, we treat it as immediate.
2765
2765
OperandType += " | CS_OP_IMM" ;
2766
- else if (OpRec->getValue (" Type" ) && getValueType (OpRec->getValueAsDef (" Type" )) ==
2767
- MVT::SimpleValueType::iPTR)
2766
+ else if (OpRec->getValue (" Type" ) &&
2767
+ getValueType (OpRec->getValueAsDef (" Type" )) ==
2768
+ MVT::SimpleValueType::iPTR)
2768
2769
OperandType += " | CS_OP_MEM" ;
2769
- else if (!CGI->TheDef ->isValueUnset (" Pattern" ) && !CGI->TheDef ->getValueAsListInit (" Pattern" )->empty ()) {
2770
+ else if (!CGI->TheDef ->isValueUnset (" Pattern" ) &&
2771
+ !CGI->TheDef ->getValueAsListInit (" Pattern" )->empty ()) {
2770
2772
// Check if operand is part of a pattern with a memory type (iPTR)
2771
2773
ListInit *PatternList = CGI->TheDef ->getValueAsListInit (" Pattern" );
2772
2774
PatternDag = dyn_cast<DagInit>(PatternList->getValues ()[0 ]);
@@ -2794,8 +2796,7 @@ std::string getCSOperandType(StringRef const &TargetName,
2794
2796
}
2795
2797
2796
2798
std::string getCSOperandEncoding (CodeGenInstruction const *CGI,
2797
- Init const *ArgInit,
2798
- const StringRef &OpName) {
2799
+ Init const *ArgInit, const StringRef &OpName) {
2799
2800
BitsInit const *const InstrBits =
2800
2801
!CGI->TheDef ->getValueAsBit (" isPseudo" )
2801
2802
? CGI->TheDef ->getValueAsBitsInit (" Inst" )
@@ -3054,9 +3055,9 @@ uint8_t getOpAccess(CodeGenInstruction const *CGI, std::string OperandType,
3054
3055
}
3055
3056
3056
3057
void addComplexOperand (
3057
- StringRef const &TargetName, CodeGenInstruction const *CGI, Record const *ComplexOp,
3058
- StringRef const &ArgName, bool IsOutOp, std::vector<OpData> &InsOps ,
3059
- std::string const &Encoding,
3058
+ StringRef const &TargetName, CodeGenInstruction const *CGI,
3059
+ Record const *ComplexOp, StringRef const &ArgName, bool IsOutOp,
3060
+ std::vector<OpData> &InsOps, std:: string const &Encoding,
3060
3061
std::map<std::string, std::vector<Record *>> const InsnPatternMap) {
3061
3062
DagInit *SubOps = ComplexOp->getValueAsDag (" MIOperandInfo" );
3062
3063
@@ -3066,13 +3067,14 @@ void addComplexOperand(
3066
3067
Record *SubOp = argInitOpToRecord (ArgInit);
3067
3068
// Determine Operand type
3068
3069
std::string OperandType;
3069
- std::string SubOperandType =
3070
- getCSOperandType ( TargetName, CGI, SubOp, SubOp->getName ().str (), InsnPatternMap);
3070
+ std::string SubOperandType = getCSOperandType (
3071
+ TargetName, CGI, SubOp, SubOp->getName ().str (), InsnPatternMap);
3071
3072
std::string ComplOperandType =
3072
3073
getCSOperandType (TargetName, CGI, ComplexOp, ArgName, InsnPatternMap);
3073
3074
if (ComplOperandType.find (" CS_OP_MEM" ) != std::string::npos)
3074
3075
OperandType = " CS_OP_MEM | " + SubOperandType;
3075
- else if (!CGI->TheDef ->isValueUnset (" Pattern" ) && !CGI->TheDef ->getValueAsListInit (" Pattern" )->empty ()) {
3076
+ else if (!CGI->TheDef ->isValueUnset (" Pattern" ) &&
3077
+ !CGI->TheDef ->getValueAsListInit (" Pattern" )->empty ()) {
3076
3078
OperandType = SubOperandType;
3077
3079
ListInit *PatternList = CGI->TheDef ->getValueAsListInit (" Pattern" );
3078
3080
DagInit *PatternDag = dyn_cast<DagInit>(PatternList->getValues ()[0 ]);
@@ -3144,7 +3146,7 @@ void printInsnOpMapEntry(
3144
3146
if (Rec->getValue (" MIOperandInfo" )) {
3145
3147
if (Rec->getValueAsDag (" MIOperandInfo" )->getNumArgs () > 0 ) {
3146
3148
addComplexOperand (TargetName, CGI, Rec, ArgName, IsOutOp, InsOps,
3147
- Encoding, InsnPatternMap);
3149
+ Encoding, InsnPatternMap);
3148
3150
continue ;
3149
3151
}
3150
3152
}
@@ -3332,7 +3334,8 @@ void printInsnAliasEnum(CodeGenTarget const &Target,
3332
3334
AliasEnum << " \t " + NormAliasMnem + " , // Real instr.: " +
3333
3335
getLLVMInstEnumName (Target.getName (), RealInst) + " \n " ;
3334
3336
3335
- AliasMnemMap << " \t { " + NormAliasMnem + " , \" " + normalizedMnemonic (AliasMnemonic, false ) + " \" },\n " ;
3337
+ AliasMnemMap << " \t { " + NormAliasMnem + " , \" " +
3338
+ normalizedMnemonic (AliasMnemonic, false ) + " \" },\n " ;
3336
3339
}
3337
3340
}
3338
3341
0 commit comments