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