llvm.org GIT mirror llvm / 8cb107d
TableGen: Use DefInit::getDef() instead of the type's getRecord() The former simply makes more sense: we want to access the data here in the backend, not information about the type. More importantly, removing users of RecordRecTy::getRecord() allows us more freedom to refactor the frontend. Change-Id: Iee8905fd22cdb9b11c42ca03246c03d8fe4dd77f git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326699 91177308-0d34-0410-b5e6-96231b3b80d8 Nicolai Haehnle 2 years ago
1 changed file(s) with 13 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
17001700 static std::string findOperandDecoderMethod(TypedInit *TI) {
17011701 std::string Decoder;
17021702
1703 RecordRecTy *Type = cast(TI->getType());
1704 Record *TypeRecord = Type->getRecord();
1705
1706 RecordVal *DecoderString = TypeRecord->getValue("DecoderMethod");
1703 Record *Record = cast(TI)->getDef();
1704
1705 RecordVal *DecoderString = Record->getValue("DecoderMethod");
17071706 StringInit *String = DecoderString ?
17081707 dyn_cast(DecoderString->getValue()) : nullptr;
17091708 if (String) {
17121711 return Decoder;
17131712 }
17141713
1715 if (TypeRecord->isSubClassOf("RegisterOperand"))
1716 TypeRecord = TypeRecord->getValueAsDef("RegClass");
1717
1718 if (TypeRecord->isSubClassOf("RegisterClass")) {
1719 Decoder = "Decode" + TypeRecord->getName().str() + "RegisterClass";
1720 } else if (TypeRecord->isSubClassOf("PointerLikeRegClass")) {
1714 if (Record->isSubClassOf("RegisterOperand"))
1715 Record = Record->getValueAsDef("RegClass");
1716
1717 if (Record->isSubClassOf("RegisterClass")) {
1718 Decoder = "Decode" + Record->getName().str() + "RegisterClass";
1719 } else if (Record->isSubClassOf("PointerLikeRegClass")) {
17211720 Decoder = "DecodePointerLikeRegClass" +
1722 utostr(TypeRecord->getValueAsInt("RegClassKind"));
1721 utostr(Record->getValueAsInt("RegClassKind"));
17231722 }
17241723
17251724 return Decoder;
18771876 CGI.Operands[SO.first].MIOperandInfo->getNumArgs()) {
18781877 Init *Arg = CGI.Operands[SO.first].MIOperandInfo->
18791878 getArg(SO.second);
1880 if (TypedInit *TI = cast(Arg)) {
1881 RecordRecTy *Type = cast(TI->getType());
1882 TypeRecord = Type->getRecord();
1883 }
1879 if (DefInit *DI = cast(Arg))
1880 TypeRecord = DI->getDef();
18841881 }
18851882
18861883 bool isReg = false;
19581955 // to interpret it. As a first step, require the target to provide
19591956 // callbacks for decoding register classes.
19601957 std::string Decoder = findOperandDecoderMethod(TI);
1961 Record *TypeRecord = cast<RecordRecTy>(TI->getType())->getRecord();
1958 Record *TypeRecord = cast<DefInit>(TI)->getDef();
19621959
19631960 RecordVal *HasCompleteDecoderVal =
19641961 TypeRecord->getValue("hasCompleteDecoder");