llvm.org GIT mirror llvm / 8409bfb
llvm-mc/AsmMatcher: Fix two thinkos in determining whether two classes are related. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78706 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
1 changed file(s) with 23 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
324324 /// MCInst; this is not valid for Token or register kinds.
325325 std::string RenderMethod;
326326
327 /// For register classes, the records for all the registers in this class.
328 std::set Registers;
329
330 public:
327331 /// isRegisterClass() - Check if this is a register class.
328332 bool isRegisterClass() const {
329333 return Kind >= RegisterClass0 && Kind < UserClass0;
341345 if (Kind == Token || RHS.Kind == Token)
342346 return Kind == Token && RHS.Kind == Token;
343347
344 // Registers are only related to registers.
345 if (isRegisterClass() || RHS.isRegisterClass())
346 return isRegisterClass() && RHS.isRegisterClass();
348 // Registers classes are only related to registers classes, and only if
349 // their intersection is non-empty.
350 if (isRegisterClass() || RHS.isRegisterClass()) {
351 if (!isRegisterClass() || !RHS.isRegisterClass())
352 return false;
353
354 std::set Tmp;
355 std::insert_iterator< std::set > II(Tmp, Tmp.begin());
356 std::set_intersection(Registers.begin(), Registers.end(),
357 RHS.Registers.begin(), RHS.Registers.end(),
358 II);
359
360 return !Tmp.empty();
361 }
347362
348363 // Otherwise we have two users operands; they are related if they are in the
349364 // same class hierarchy.
365 //
366 // FIXME: This is an oversimplification, they should only be related if they
367 // intersect, however we don't have that information.
350368 assert(isUserClass() && RHS.isUserClass() && "Unexpected class!");
351369 const ClassInfo *Root = this;
352370 while (!Root->SuperClasses.empty())
353371 Root = Root->SuperClasses.front();
354372
355 const ClassInfo *RHSRoot = this;
373 const ClassInfo *RHSRoot = &RHS;
356374 while (!RHSRoot->SuperClasses.empty())
357375 RHSRoot = RHSRoot->SuperClasses.front();
358376
673691 CI->ValueName = "";
674692 CI->PredicateMethod = ""; // unused
675693 CI->RenderMethod = "addRegOperands";
694 CI->Registers = *it;
676695 Classes.push_back(CI);
677696 RegisterSetClasses.insert(std::make_pair(*it, CI));
678697 }