SDNodeProperties.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //===- SDNodeProperties.cpp -----------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "SDNodeProperties.h"
  9. #include "llvm/ADT/StringSwitch.h"
  10. #include "llvm/TableGen/Error.h"
  11. #include "llvm/TableGen/Record.h"
  12. using namespace llvm;
  13. unsigned llvm::parseSDPatternOperatorProperties(Record *R) {
  14. unsigned Properties = 0;
  15. for (Record *Property : R->getValueAsListOfDefs("Properties")) {
  16. auto Offset = StringSwitch<unsigned>(Property->getName())
  17. .Case("SDNPCommutative", SDNPCommutative)
  18. .Case("SDNPAssociative", SDNPAssociative)
  19. .Case("SDNPHasChain", SDNPHasChain)
  20. .Case("SDNPOutGlue", SDNPOutGlue)
  21. .Case("SDNPInGlue", SDNPInGlue)
  22. .Case("SDNPOptInGlue", SDNPOptInGlue)
  23. .Case("SDNPMayStore", SDNPMayStore)
  24. .Case("SDNPMayLoad", SDNPMayLoad)
  25. .Case("SDNPSideEffect", SDNPSideEffect)
  26. .Case("SDNPMemOperand", SDNPMemOperand)
  27. .Case("SDNPVariadic", SDNPVariadic)
  28. .Default(-1u);
  29. if (Offset != -1u)
  30. Properties |= 1 << Offset;
  31. else
  32. PrintFatalError(R->getLoc(), "Unknown SD Node property '" +
  33. Property->getName() + "' on node '" +
  34. R->getName() + "'!");
  35. }
  36. return Properties;
  37. }