| 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 | |
| 9 | #include "SDNodeProperties.h" |
| 10 | #include "llvm/ADT/StringSwitch.h" |
| 11 | #include "llvm/TableGen/Error.h" |
| 12 | #include "llvm/TableGen/Record.h" |
| 13 | |
| 14 | using namespace llvm; |
| 15 | |
| 16 | unsigned llvm::parseSDPatternOperatorProperties(const Record *R) { |
| 17 | unsigned Properties = 0; |
| 18 | for (const Record *Property : R->getValueAsListOfDefs(FieldName: "Properties" )) { |
| 19 | auto Offset = StringSwitch<unsigned>(Property->getName()) |
| 20 | .Case(S: "SDNPCommutative" , Value: SDNPCommutative) |
| 21 | .Case(S: "SDNPAssociative" , Value: SDNPAssociative) |
| 22 | .Case(S: "SDNPHasChain" , Value: SDNPHasChain) |
| 23 | .Case(S: "SDNPOutGlue" , Value: SDNPOutGlue) |
| 24 | .Case(S: "SDNPInGlue" , Value: SDNPInGlue) |
| 25 | .Case(S: "SDNPOptInGlue" , Value: SDNPOptInGlue) |
| 26 | .Case(S: "SDNPMayStore" , Value: SDNPMayStore) |
| 27 | .Case(S: "SDNPMayLoad" , Value: SDNPMayLoad) |
| 28 | .Case(S: "SDNPSideEffect" , Value: SDNPSideEffect) |
| 29 | .Case(S: "SDNPMemOperand" , Value: SDNPMemOperand) |
| 30 | .Case(S: "SDNPVariadic" , Value: SDNPVariadic) |
| 31 | .Default(Value: -1u); |
| 32 | if (Offset != -1u) |
| 33 | Properties |= 1 << Offset; |
| 34 | else |
| 35 | PrintFatalError(ErrorLoc: R->getLoc(), Msg: "Unknown SD Node property '" + |
| 36 | Property->getName() + "' on node '" + |
| 37 | R->getName() + "'!" ); |
| 38 | } |
| 39 | return Properties; |
| 40 | } |
| 41 | |