-static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType,
- unsigned &ArgNo) {
- MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
-
- if (ArgType->isSubClassOf("LLVMMatchType")) {
- unsigned Number = ArgType->getValueAsInt("Number");
- assert(Number < ArgNo && "Invalid matching number!");
- if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
- OS << "VectorType::getExtendedElementVectorType"
- << "(dyn_cast<VectorType>(Tys[" << Number << "]))";
- else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
- OS << "VectorType::getTruncatedElementVectorType"
- << "(dyn_cast<VectorType>(Tys[" << Number << "]))";
- else
- OS << "Tys[" << Number << "]";
- } else if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::vAny) {
- // NOTE: The ArgNo variable here is not the absolute argument number, it is
- // the index of the "arbitrary" type in the Tys array passed to the
- // Intrinsic::getDeclaration function. Consequently, we only want to
- // increment it when we actually hit an overloaded type. Getting this wrong
- // leads to very subtle bugs!
- OS << "Tys[" << ArgNo++ << "]";
- } else if (EVT(VT).isVector()) {
- EVT VVT = VT;
- OS << "VectorType::get(";
- EmitTypeForValueType(OS, VVT.getVectorElementType().getSimpleVT().SimpleTy);
- OS << ", " << VVT.getVectorNumElements() << ")";
- } else if (VT == MVT::iPTR) {
- OS << "PointerType::getUnqual(";
- EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
- OS << ")";
- } else if (VT == MVT::iPTRAny) {
- // Make sure the user has passed us an argument type to overload. If not,
- // treat it as an ordinary (not overloaded) intrinsic.
- OS << "(" << ArgNo << " < numTys) ? Tys[" << ArgNo
- << "] : PointerType::getUnqual(";
- EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
- OS << ")";
- ++ArgNo;
- } else if (VT == MVT::isVoid) {
- if (ArgNo == 0)
- OS << "Type::getVoidTy(Context)";
- else
- // MVT::isVoid is used to mean varargs here.
- OS << "...";
- } else {
- EmitTypeForValueType(OS, VT);
+#if defined(_MSC_VER) && !defined(__clang__)
+#pragma optimize("",on)
+#endif
+
+/// ComputeFixedEncoding - If we can encode the type signature for this
+/// intrinsic into 32 bits, return it. If not, return ~0U.
+static void ComputeFixedEncoding(const CodeGenIntrinsic &Int,
+ std::vector<unsigned char> &TypeSig) {
+ std::vector<unsigned char> ArgCodes;
+
+ if (Int.IS.RetVTs.empty())
+ TypeSig.push_back(IIT_Done);
+ else if (Int.IS.RetVTs.size() == 1 &&
+ Int.IS.RetVTs[0] == MVT::isVoid)
+ TypeSig.push_back(IIT_Done);
+ else {
+ switch (Int.IS.RetVTs.size()) {
+ case 1: break;
+ case 2: TypeSig.push_back(IIT_STRUCT2); break;
+ case 3: TypeSig.push_back(IIT_STRUCT3); break;
+ case 4: TypeSig.push_back(IIT_STRUCT4); break;
+ case 5: TypeSig.push_back(IIT_STRUCT5); break;
+ default: llvm_unreachable("Unhandled case in struct");
+ }
+
+ for (unsigned i = 0, e = Int.IS.RetVTs.size(); i != e; ++i)
+ EncodeFixedType(Int.IS.RetTypeDefs[i], ArgCodes, TypeSig);