[llvm-commits] CVS: llvm/utils/TableGen/IntrinsicEmitter.cpp IntrinsicEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Mar 9 14:31:01 PST 2006
Changes in directory llvm/utils/TableGen:
IntrinsicEmitter.cpp updated: 1.3 -> 1.4
IntrinsicEmitter.h updated: 1.3 -> 1.4
---
Log message:
Parse mod/ref properties, autogen mod/ref information
---
Diffs of the changes: (+47 -0)
IntrinsicEmitter.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++
IntrinsicEmitter.h | 2 ++
2 files changed, 47 insertions(+)
Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
diff -u llvm/utils/TableGen/IntrinsicEmitter.cpp:1.3 llvm/utils/TableGen/IntrinsicEmitter.cpp:1.4
--- llvm/utils/TableGen/IntrinsicEmitter.cpp:1.3 Thu Mar 9 16:05:04 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp Thu Mar 9 16:30:49 2006
@@ -26,6 +26,7 @@
CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
std::string DefName = R->getName();
+ ModRef = WriteMem;
if (DefName.size() <= 4 ||
std::string(DefName.begin(), DefName.begin()+4) != "int_")
@@ -54,6 +55,29 @@
}
if (ArgTypes.size() == 0)
throw "Intrinsic '"+DefName+"' needs at least a type for the ret value!";
+
+ // Parse the intrinsic properties.
+ ListInit *PropList = R->getValueAsListInit("Properties");
+ for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) {
+ DefInit *DI = dynamic_cast<DefInit*>(PropList->getElement(i));
+ assert(DI && "Invalid list type!");
+ Record *Property = DI->getDef();
+ assert(Property->isSubClassOf("IntrinsicProperty") &&
+ "Expected a property!");
+
+ if (Property->getName() == "InstrNoMem")
+ ModRef = NoMem;
+ else if (Property->getName() == "InstrReadArgMem")
+ ModRef = ReadArgMem;
+ else if (Property->getName() == "IntrReadMem")
+ ModRef = ReadMem;
+ else if (Property->getName() == "InstrWriteArgMem")
+ ModRef = WriteArgMem;
+ else if (Property->getName() == "IntrWriteMem")
+ ModRef = WriteMem;
+ else
+ assert(0 && "Unknown property!");
+ }
}
//===----------------------------------------------------------------------===//
@@ -73,6 +97,9 @@
// Emit the intrinsic verifier.
EmitVerifier(Ints, OS);
+
+ // Emit mod/ref info for each function.
+ EmitModRefInfo(Ints, OS);
}
void IntrinsicEmitter::EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints,
@@ -146,3 +173,21 @@
OS << "#endif\n\n";
}
+void IntrinsicEmitter::EmitModRefInfo(const std::vector<CodeGenIntrinsic> &Ints,
+ std::ostream &OS) {
+ OS << "// BasicAliasAnalysis code.\n";
+ OS << "#ifdef GET_MODREF_BEHAVIOR\n";
+ for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
+ switch (Ints[i].ModRef) {
+ default: break;
+ case CodeGenIntrinsic::NoMem:
+ OS << " NoMemoryTable.push_back(\"" << Ints[i].Name << "\");\n";
+ break;
+ case CodeGenIntrinsic::ReadArgMem:
+ case CodeGenIntrinsic::ReadMem:
+ OS << " OnlyReadsMemoryTable.push_back(\"" << Ints[i].Name << "\");\n";
+ break;
+ }
+ }
+ OS << "#endif\n\n";
+}
Index: llvm/utils/TableGen/IntrinsicEmitter.h
diff -u llvm/utils/TableGen/IntrinsicEmitter.h:1.3 llvm/utils/TableGen/IntrinsicEmitter.h:1.4
--- llvm/utils/TableGen/IntrinsicEmitter.h:1.3 Thu Mar 9 16:05:04 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.h Thu Mar 9 16:30:49 2006
@@ -33,6 +33,8 @@
std::ostream &OS);
void EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints,
std::ostream &OS);
+ void EmitModRefInfo(const std::vector<CodeGenIntrinsic> &Ints,
+ std::ostream &OS);
};
} // End llvm namespace
More information about the llvm-commits
mailing list