diff options
author | Chris Lattner <sabre@nondot.org> | 2005-09-28 18:28:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-09-28 18:28:29 +0000 |
commit | a1a68ae0617610c816e590879ce121af058ba60c (patch) | |
tree | c8c07b900071d9f80e2341e7edc34e808fff77b9 | |
parent | 6bcf1b7eed0fabed92298cedce0fcacdc55fdfd7 (diff) | |
download | external_llvm-a1a68ae0617610c816e590879ce121af058ba60c.zip external_llvm-a1a68ae0617610c816e590879ce121af058ba60c.tar.gz external_llvm-a1a68ae0617610c816e590879ce121af058ba60c.tar.bz2 |
collect commutativity information
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23499 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | utils/TableGen/DAGISelEmitter.cpp | 16 | ||||
-rw-r--r-- | utils/TableGen/DAGISelEmitter.h | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index 9f5e387..dde7f67 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -137,6 +137,22 @@ SDNodeInfo::SDNodeInfo(Record *R) : Def(R) { NumResults = TypeProfile->getValueAsInt("NumResults"); NumOperands = TypeProfile->getValueAsInt("NumOperands"); + // Parse the properties. + Properties = 0; + ListInit *LI = R->getValueAsListInit("Properties"); + for (unsigned i = 0, e = LI->getSize(); i != e; ++i) { + DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(i)); + assert(DI && "Properties list must be list of defs!"); + if (DI->getDef()->getName() == "SDNPCommutative") { + Properties |= 1 << SDNPCommutative; + } else { + std::cerr << "Unknown SD Node property '" << DI->getDef()->getName() + << "' on node '" << R->getName() << "'!\n"; + exit(1); + } + } + + // Parse the type constraints. ListInit *Constraints = TypeProfile->getValueAsListInit("Constraints"); for (unsigned i = 0, e = Constraints->getSize(); i != e; ++i) { diff --git a/utils/TableGen/DAGISelEmitter.h b/utils/TableGen/DAGISelEmitter.h index 8ec7299..48f941d 100644 --- a/utils/TableGen/DAGISelEmitter.h +++ b/utils/TableGen/DAGISelEmitter.h @@ -69,6 +69,7 @@ namespace llvm { Record *Def; std::string EnumName; std::string SDClassName; + unsigned Properties; unsigned NumResults; int NumOperands; std::vector<SDTypeConstraint> TypeConstraints; @@ -84,6 +85,13 @@ namespace llvm { const std::vector<SDTypeConstraint> &getTypeConstraints() const { return TypeConstraints; } + + // SelectionDAG node properties. + enum SDNP { SDNPCommutative }; + + /// hasProperty - Return true if this node has the specified property. + /// + bool hasProperty(enum SDNP Prop) const { return Properties & (1 << Prop); } /// ApplyTypeConstraints - Given a node in a pattern, apply the type /// constraints for this node to the operands of the node. This returns |