41 lines · cpp
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-exception6//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 14using namespace llvm;15 16unsigned llvm::parseSDPatternOperatorProperties(const Record *R) {17 unsigned Properties = 0;18 for (const Record *Property : R->getValueAsListOfDefs("Properties")) {19 auto Offset = StringSwitch<unsigned>(Property->getName())20 .Case("SDNPCommutative", SDNPCommutative)21 .Case("SDNPAssociative", SDNPAssociative)22 .Case("SDNPHasChain", SDNPHasChain)23 .Case("SDNPOutGlue", SDNPOutGlue)24 .Case("SDNPInGlue", SDNPInGlue)25 .Case("SDNPOptInGlue", SDNPOptInGlue)26 .Case("SDNPMayStore", SDNPMayStore)27 .Case("SDNPMayLoad", SDNPMayLoad)28 .Case("SDNPSideEffect", SDNPSideEffect)29 .Case("SDNPMemOperand", SDNPMemOperand)30 .Case("SDNPVariadic", SDNPVariadic)31 .Default(-1u);32 if (Offset != -1u)33 Properties |= 1 << Offset;34 else35 PrintFatalError(R->getLoc(), "Unknown SD Node property '" +36 Property->getName() + "' on node '" +37 R->getName() + "'!");38 }39 return Properties;40}41