summaryrefslogtreecommitdiff
path: root/utils/TableGen/IntrinsicEmitter.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-06-06 12:08:01 +0000
committerDuncan Sands <baldrick@free.fr>2008-06-06 12:08:01 +0000
commit83ec4b6711980242ef3c55a4fa36b2d7a39c1bfb (patch)
tree318323f012863299f9ae063e79a47985c2e8dc4b /utils/TableGen/IntrinsicEmitter.cpp
parentcc41940dff771c98321d601e04e60dc8c67b6e87 (diff)
downloadllvm-83ec4b6711980242ef3c55a4fa36b2d7a39c1bfb.tar.gz
llvm-83ec4b6711980242ef3c55a4fa36b2d7a39c1bfb.tar.bz2
llvm-83ec4b6711980242ef3c55a4fa36b2d7a39c1bfb.tar.xz
Wrap MVT::ValueType in a struct to get type safety
and better control the abstraction. Rename the type to MVT. To update out-of-tree patches, the main thing to do is to rename MVT::ValueType to MVT, and rewrite expressions like MVT::getSizeInBits(VT) in the form VT.getSizeInBits(). Use VT.getSimpleVT() to extract a MVT::SimpleValueType for use in switch statements (you will get an assert failure if VT is an extended value type - these shouldn't exist after type legalization). This results in a small speedup of codegen and no new testsuite failures (x86-64 linux). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52044 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/IntrinsicEmitter.cpp')
-rw-r--r--utils/TableGen/IntrinsicEmitter.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp
index 567973a3ca..ab7b58b8ba 100644
--- a/utils/TableGen/IntrinsicEmitter.cpp
+++ b/utils/TableGen/IntrinsicEmitter.cpp
@@ -114,9 +114,9 @@ EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints,
OS << "#endif\n\n";
}
-static void EmitTypeForValueType(std::ostream &OS, MVT::ValueType VT) {
- if (MVT::isInteger(VT)) {
- unsigned BitWidth = MVT::getSizeInBits(VT);
+static void EmitTypeForValueType(std::ostream &OS, MVT::SimpleValueType VT) {
+ if (MVT(VT).isInteger()) {
+ unsigned BitWidth = MVT(VT).getSizeInBits();
OS << "IntegerType::get(" << BitWidth << ")";
} else if (VT == MVT::Other) {
// MVT::OtherVT is used to mean the empty struct type here.
@@ -140,7 +140,7 @@ static void EmitTypeForValueType(std::ostream &OS, MVT::ValueType VT) {
static void EmitTypeGenerate(std::ostream &OS, Record *ArgType,
unsigned &ArgNo) {
- MVT::ValueType VT = getValueType(ArgType->getValueAsDef("VT"));
+ MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
if (ArgType->isSubClassOf("LLVMMatchType")) {
unsigned Number = ArgType->getValueAsInt("Number");
@@ -153,10 +153,11 @@ static void EmitTypeGenerate(std::ostream &OS, Record *ArgType,
// increment it when we actually hit an overloaded type. Getting this wrong
// leads to very subtle bugs!
OS << "Tys[" << ArgNo++ << "]";
- } else if (MVT::isVector(VT)) {
+ } else if (MVT(VT).isVector()) {
+ MVT VVT = VT;
OS << "VectorType::get(";
- EmitTypeForValueType(OS, MVT::getVectorElementType(VT));
- OS << ", " << MVT::getVectorNumElements(VT) << ")";
+ EmitTypeForValueType(OS, VVT.getVectorElementType().getSimpleVT());
+ OS << ", " << VVT.getVectorNumElements() << ")";
} else if (VT == MVT::iPTR) {
OS << "PointerType::getUnqual(";
EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
@@ -225,7 +226,7 @@ void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints,
assert(Number < j && "Invalid matching number!");
OS << "~" << Number;
} else {
- MVT::ValueType VT = getValueType(ArgType->getValueAsDef("VT"));
+ MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
OS << getEnumName(VT);
if (VT == MVT::isVoid && j != 0 && j != ArgTypes.size()-1)
throw "Var arg type not last argument";