InlineAsm::~InlineAsm() {
}
-
-InlineAsm *InlineAsm::get(FunctionType *Ty, StringRef AsmString,
+InlineAsm *InlineAsm::get(FunctionType *FTy, StringRef AsmString,
StringRef Constraints, bool hasSideEffects,
bool isAlignStack, AsmDialect asmDialect) {
- InlineAsmKeyType Key(AsmString, Constraints, hasSideEffects, isAlignStack,
- asmDialect);
- LLVMContextImpl *pImpl = Ty->getContext().pImpl;
- return pImpl->InlineAsms.getOrCreate(PointerType::getUnqual(Ty), Key);
+ InlineAsmKeyType Key(AsmString, Constraints, FTy, hasSideEffects,
+ isAlignStack, asmDialect);
+ LLVMContextImpl *pImpl = FTy->getContext().pImpl;
+ return pImpl->InlineAsms.getOrCreate(PointerType::getUnqual(FTy), Key);
}
-InlineAsm::InlineAsm(PointerType *Ty, const std::string &asmString,
+InlineAsm::InlineAsm(FunctionType *FTy, const std::string &asmString,
const std::string &constraints, bool hasSideEffects,
bool isAlignStack, AsmDialect asmDialect)
- : Value(Ty, Value::InlineAsmVal),
- AsmString(asmString), Constraints(constraints),
- HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
- Dialect(asmDialect) {
+ : Value(PointerType::getUnqual(FTy), Value::InlineAsmVal),
+ AsmString(asmString), Constraints(constraints), FTy(FTy),
+ HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
+ Dialect(asmDialect) {
// Do various checks on the constraint string and type.
assert(Verify(getFunctionType(), constraints) &&
}
FunctionType *InlineAsm::getFunctionType() const {
- return cast<FunctionType>(getType()->getElementType());
+ return FTy;
}
///Default constructor.
unsigned multipleAlternativeCount = Str.count('|') + 1;
unsigned multipleAlternativeIndex = 0;
ConstraintCodeVector *pCodes = &Codes;
-
+
// Initialize
- isMultipleAlternative = (multipleAlternativeCount > 1 ? true : false);
+ isMultipleAlternative = multipleAlternativeCount > 1;
if (isMultipleAlternative) {
multipleAlternatives.resize(multipleAlternativeCount);
pCodes = &multipleAlternatives[0].Codes;
if (*I == '~') {
Type = isClobber;
++I;
+
+ // '{' must immediately follow '~'.
+ if (I != E && *I != '{')
+ return true;
} else if (*I == '=') {
++I;
Type = isOutput;
}
-
+
if (*I == '*') {
isIndirect = true;
++I;
}
-
+
if (I == E) return true; // Just a prefix, like "==" or "~".
// Parse the modifiers.
// If Operand N already has a matching input, reject this. An output
// can't be constrained to the same value as multiple inputs.
if (isMultipleAlternative) {
+ if (multipleAlternativeIndex >=
+ ConstraintsSoFar[N].multipleAlternatives.size())
+ return true;
InlineAsm::SubConstraintInfo &scInfo =
ConstraintsSoFar[N].multipleAlternatives[multipleAlternativeIndex];
if (scInfo.MatchingInput != -1)
// Note that operand #n has a matching input.
scInfo.MatchingInput = ConstraintsSoFar.size();
} else {
- if (ConstraintsSoFar[N].hasMatchingInput())
+ if (ConstraintsSoFar[N].hasMatchingInput() &&
+ (size_t)ConstraintsSoFar[N].MatchingInput !=
+ ConstraintsSoFar.size())
return true;
// Note that operand #n has a matching input.
ConstraintsSoFar[N].MatchingInput = ConstraintsSoFar.size();
I = ConstraintEnd;
if (I != E) {
++I;
- if (I == E) { Result.clear(); break; } // don't allow "xyz,"
+ if (I == E) {
+ Result.clear();
+ break;
+ } // don't allow "xyz,"
}
}
break;
default:
StructType *STy = dyn_cast<StructType>(Ty->getReturnType());
- if (STy == 0 || STy->getNumElements() != NumOutputs)
+ if (!STy || STy->getNumElements() != NumOutputs)
return false;
break;
}
if (Ty->getNumParams() != NumInputs) return false;
return true;
}
-