Matt Arsenault | 303327d | 2017-12-20 19:36:28 +0000 | [diff] [blame] | 1 | //===- SDNodeProperties.cpp -----------------------------------------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Matt Arsenault | 303327d | 2017-12-20 19:36:28 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "SDNodeProperties.h" |
| 10 | #include "llvm/TableGen/Error.h" |
| 11 | #include "llvm/TableGen/Record.h" |
| 12 | |
| 13 | using namespace llvm; |
| 14 | |
| 15 | unsigned llvm::parseSDPatternOperatorProperties(Record *R) { |
| 16 | unsigned Properties = 0; |
| 17 | for (Record *Property : R->getValueAsListOfDefs("Properties")) { |
| 18 | if (Property->getName() == "SDNPCommutative") { |
| 19 | Properties |= 1 << SDNPCommutative; |
| 20 | } else if (Property->getName() == "SDNPAssociative") { |
| 21 | Properties |= 1 << SDNPAssociative; |
| 22 | } else if (Property->getName() == "SDNPHasChain") { |
| 23 | Properties |= 1 << SDNPHasChain; |
| 24 | } else if (Property->getName() == "SDNPOutGlue") { |
| 25 | Properties |= 1 << SDNPOutGlue; |
| 26 | } else if (Property->getName() == "SDNPInGlue") { |
| 27 | Properties |= 1 << SDNPInGlue; |
| 28 | } else if (Property->getName() == "SDNPOptInGlue") { |
| 29 | Properties |= 1 << SDNPOptInGlue; |
| 30 | } else if (Property->getName() == "SDNPMayStore") { |
| 31 | Properties |= 1 << SDNPMayStore; |
| 32 | } else if (Property->getName() == "SDNPMayLoad") { |
| 33 | Properties |= 1 << SDNPMayLoad; |
| 34 | } else if (Property->getName() == "SDNPSideEffect") { |
| 35 | Properties |= 1 << SDNPSideEffect; |
| 36 | } else if (Property->getName() == "SDNPMemOperand") { |
| 37 | Properties |= 1 << SDNPMemOperand; |
| 38 | } else if (Property->getName() == "SDNPVariadic") { |
| 39 | Properties |= 1 << SDNPVariadic; |
| 40 | } else { |
Daniel Sanders | dff673b | 2019-02-12 17:36:57 +0000 | [diff] [blame] | 41 | PrintFatalError(R->getLoc(), "Unknown SD Node property '" + |
| 42 | Property->getName() + "' on node '" + |
| 43 | R->getName() + "'!"); |
Matt Arsenault | 303327d | 2017-12-20 19:36:28 +0000 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
| 47 | return Properties; |
| 48 | } |