@@ -1849,15 +1849,14 @@ OperandInfo getOpInfo(const Record *TypeRecord) {
1849
1849
return OperandInfo (findOperandDecoderMethod (TypeRecord), HasCompleteDecoder);
1850
1850
}
1851
1851
1852
- static void parseVarLenInstOperand (const Record &Def ,
1852
+ static void parseVarLenInstOperand (const Record *EncodingDef ,
1853
1853
std::vector<OperandInfo> &Operands,
1854
- const CodeGenInstruction &CGI) {
1855
-
1856
- const RecordVal *RV = Def.getValue (" Inst" );
1854
+ const CodeGenInstruction *Inst) {
1855
+ const RecordVal *RV = EncodingDef->getValue (" Inst" );
1857
1856
VarLenInst VLI (cast<DagInit>(RV->getValue ()), RV);
1858
1857
SmallVector<int > TiedTo;
1859
1858
1860
- for (const auto &[Idx, Op] : enumerate(CGI. Operands )) {
1859
+ for (const auto &[Idx, Op] : enumerate(Inst-> Operands )) {
1861
1860
if (Op.MIOperandInfo && Op.MIOperandInfo ->getNumArgs () > 0 )
1862
1861
for (auto *Arg : Op.MIOperandInfo ->getArgs ())
1863
1862
Operands.push_back (getOpInfo (cast<DefInit>(Arg)->getDef ()));
@@ -1885,15 +1884,15 @@ static void parseVarLenInstOperand(const Record &Def,
1885
1884
}
1886
1885
1887
1886
if (!OpName.empty ()) {
1888
- auto OpSubOpPair = CGI. Operands .parseOperandName (OpName);
1889
- unsigned OpIdx = CGI. Operands .getFlattenedOperandNumber (OpSubOpPair);
1887
+ auto OpSubOpPair = Inst-> Operands .parseOperandName (OpName);
1888
+ unsigned OpIdx = Inst-> Operands .getFlattenedOperandNumber (OpSubOpPair);
1890
1889
Operands[OpIdx].addField (CurrBitPos, EncodingSegment.BitWidth , Offset);
1891
1890
if (!EncodingSegment.CustomDecoder .empty ())
1892
1891
Operands[OpIdx].Decoder = EncodingSegment.CustomDecoder .str ();
1893
1892
1894
1893
int TiedReg = TiedTo[OpSubOpPair.first ];
1895
1894
if (TiedReg != -1 ) {
1896
- unsigned OpIdx = CGI. Operands .getFlattenedOperandNumber (
1895
+ unsigned OpIdx = Inst-> Operands .getFlattenedOperandNumber (
1897
1896
{TiedReg, OpSubOpPair.second });
1898
1897
Operands[OpIdx].addField (CurrBitPos, EncodingSegment.BitWidth , Offset);
1899
1898
}
@@ -1914,12 +1913,12 @@ static void debugDumpRecord(const Record &Rec) {
1914
1913
// / For an operand field named OpName: populate OpInfo.InitValue with the
1915
1914
// / constant-valued bit values, and OpInfo.Fields with the ranges of bits to
1916
1915
// / insert from the decoded instruction.
1917
- static void addOneOperandFields (const Record & EncodingDef, const BitsInit &Bits,
1916
+ static void addOneOperandFields (const Record * EncodingDef, const BitsInit &Bits,
1918
1917
std::map<StringRef, StringRef> &TiedNames,
1919
1918
StringRef OpName, OperandInfo &OpInfo) {
1920
1919
// Some bits of the operand may be required to be 1 depending on the
1921
1920
// instruction's encoding. Collect those bits.
1922
- if (const RecordVal *EncodedValue = EncodingDef. getValue (OpName))
1921
+ if (const RecordVal *EncodedValue = EncodingDef-> getValue (OpName))
1923
1922
if (const BitsInit *OpBits = dyn_cast<BitsInit>(EncodedValue->getValue ()))
1924
1923
for (unsigned I = 0 ; I < OpBits->getNumBits (); ++I)
1925
1924
if (const BitInit *OpBit = dyn_cast<BitInit>(OpBits->getBit (I)))
@@ -1951,31 +1950,30 @@ static void addOneOperandFields(const Record &EncodingDef, const BitsInit &Bits,
1951
1950
}
1952
1951
}
1953
1952
1954
- static unsigned
1955
- populateInstruction ( const CodeGenTarget &Target, const Record & EncodingDef,
1956
- const CodeGenInstruction &CGI , unsigned EncodingID,
1957
- std::map<unsigned , std::vector<OperandInfo>> &Operands ,
1958
- bool IsVarLenInst) {
1959
- const Record &Def = *CGI. TheDef ;
1953
+ static unsigned populateInstruction (
1954
+ const CodeGenTarget &Target, const Record * EncodingDef,
1955
+ const CodeGenInstruction *Inst , unsigned EncodingID,
1956
+ std::map<unsigned , std::vector<OperandInfo>> &EncodingOperands ,
1957
+ bool IsVarLenInst) {
1958
+ const Record &Def = *Inst-> TheDef ;
1960
1959
// If all the bit positions are not specified; do not decode this instruction.
1961
1960
// We are bound to fail! For proper disassembly, the well-known encoding bits
1962
1961
// of the instruction must be fully specified.
1963
1962
1964
- const BitsInit &Bits = getBitsField (EncodingDef, " Inst" );
1963
+ const BitsInit &Bits = getBitsField (* EncodingDef, " Inst" );
1965
1964
if (Bits.allInComplete ())
1966
1965
return 0 ;
1967
1966
1968
- std::vector<OperandInfo> InsnOperands ;
1967
+ std::vector<OperandInfo> Operands ;
1969
1968
1970
1969
// If the instruction has specified a custom decoding hook, use that instead
1971
1970
// of trying to auto-generate the decoder.
1972
- StringRef InstDecoder = EncodingDef. getValueAsString (" DecoderMethod" );
1971
+ StringRef InstDecoder = EncodingDef-> getValueAsString (" DecoderMethod" );
1973
1972
if (!InstDecoder.empty ()) {
1974
1973
bool HasCompleteInstDecoder =
1975
- EncodingDef.getValueAsBit (" hasCompleteDecoder" );
1976
- InsnOperands.push_back (
1977
- OperandInfo (InstDecoder.str (), HasCompleteInstDecoder));
1978
- Operands[EncodingID] = std::move (InsnOperands);
1974
+ EncodingDef->getValueAsBit (" hasCompleteDecoder" );
1975
+ Operands.push_back (OperandInfo (InstDecoder.str (), HasCompleteInstDecoder));
1976
+ EncodingOperands[EncodingID] = std::move (Operands);
1979
1977
return Bits.getNumBits ();
1980
1978
}
1981
1979
@@ -1997,15 +1995,15 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
1997
1995
// Search for tied operands, so that we can correctly instantiate
1998
1996
// operands that are not explicitly represented in the encoding.
1999
1997
std::map<StringRef, StringRef> TiedNames;
2000
- for (const auto &Op : CGI. Operands ) {
1998
+ for (const auto &Op : Inst-> Operands ) {
2001
1999
for (const auto &[J, CI] : enumerate(Op.Constraints )) {
2002
2000
if (!CI.isTied ())
2003
2001
continue ;
2004
2002
std::pair<unsigned , unsigned > SO =
2005
- CGI. Operands .getSubOperandNumber (CI.getTiedOperand ());
2006
- StringRef TiedName = CGI. Operands [SO.first ].SubOpNames [SO.second ];
2003
+ Inst-> Operands .getSubOperandNumber (CI.getTiedOperand ());
2004
+ StringRef TiedName = Inst-> Operands [SO.first ].SubOpNames [SO.second ];
2007
2005
if (TiedName.empty ())
2008
- TiedName = CGI. Operands [SO.first ].Name ;
2006
+ TiedName = Inst-> Operands [SO.first ].Name ;
2009
2007
StringRef MyName = Op.SubOpNames [J];
2010
2008
if (MyName.empty ())
2011
2009
MyName = Op.Name ;
@@ -2016,7 +2014,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
2016
2014
}
2017
2015
2018
2016
if (IsVarLenInst) {
2019
- parseVarLenInstOperand (EncodingDef, InsnOperands, CGI );
2017
+ parseVarLenInstOperand (EncodingDef, Operands, Inst );
2020
2018
} else {
2021
2019
// For each operand, see if we can figure out where it is encoded.
2022
2020
for (const auto &Op : InOutOperands) {
@@ -2047,7 +2045,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
2047
2045
// Then there should not be a custom decoder specified on the top-level
2048
2046
// type.
2049
2047
if (!OpInfo.Decoder .empty ()) {
2050
- PrintError (EncodingDef. getLoc () ,
2048
+ PrintError (EncodingDef,
2051
2049
" DecoderEmitter: operand \" " + OpName + " \" has type \" " +
2052
2050
OpInit->getAsString () +
2053
2051
" \" with a custom DecoderMethod, but also named "
@@ -2063,7 +2061,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
2063
2061
2064
2062
addOneOperandFields (EncodingDef, Bits, TiedNames, SubOpName,
2065
2063
SubOpInfo);
2066
- InsnOperands .push_back (std::move (SubOpInfo));
2064
+ Operands .push_back (std::move (SubOpInfo));
2067
2065
}
2068
2066
continue ;
2069
2067
}
@@ -2079,11 +2077,11 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
2079
2077
// If we have multiple sub-ops, there'd better have a custom
2080
2078
// decoder. (Otherwise we don't know how to populate them properly...)
2081
2079
if (SubOps->getNumArgs () > 1 ) {
2082
- PrintError (EncodingDef. getLoc () ,
2080
+ PrintError (EncodingDef,
2083
2081
" DecoderEmitter: operand \" " + OpName +
2084
2082
" \" uses MIOperandInfo with multiple ops, but doesn't "
2085
2083
" have a custom decoder!" );
2086
- debugDumpRecord (EncodingDef);
2084
+ debugDumpRecord (* EncodingDef);
2087
2085
continue ;
2088
2086
}
2089
2087
}
@@ -2094,10 +2092,10 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
2094
2092
// instruction! (This is a longstanding bug, which will be addressed in an
2095
2093
// upcoming change.)
2096
2094
if (OpInfo.numFields () > 0 )
2097
- InsnOperands .push_back (std::move (OpInfo));
2095
+ Operands .push_back (std::move (OpInfo));
2098
2096
}
2099
2097
}
2100
- Operands [EncodingID] = std::move (InsnOperands );
2098
+ EncodingOperands [EncodingID] = std::move (Operands );
2101
2099
2102
2100
#if 0
2103
2101
LLVM_DEBUG({
@@ -2107,8 +2105,8 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
2107
2105
errs() << '\n';
2108
2106
2109
2107
// Dumps the list of operand info.
2110
- for (unsigned i = 0, e = CGI. Operands.size(); i != e; ++i) {
2111
- const CGIOperandList::OperandInfo &Info = CGI. Operands[i];
2108
+ for (unsigned i = 0, e = Inst-> Operands.size(); i != e; ++i) {
2109
+ const CGIOperandList::OperandInfo &Info = Inst-> Operands[i];
2112
2110
const std::string &OperandName = Info.Name;
2113
2111
const Record &OperandDef = *Info.Rec;
2114
2112
@@ -2618,7 +2616,7 @@ namespace {
2618
2616
for (auto [EncodingID, Encoding] : enumerate(Encodings)) {
2619
2617
const Record *EncodingDef = Encoding.getRecord ();
2620
2618
const CodeGenInstruction *Inst = Encoding.getInstruction ();
2621
- unsigned BitWidth = populateInstruction (Target, * EncodingDef, * Inst,
2619
+ unsigned BitWidth = populateInstruction (Target, EncodingDef, Inst,
2622
2620
EncodingID, Operands, IsVarLenInst);
2623
2621
assert (BitWidth && " Invalid encodings should have been filtered out" );
2624
2622
if (IsVarLenInst) {
0 commit comments