return false;
}
-
- /// getCallOperandValEVT - Return the EVT of the Value* that this operand
- /// corresponds to. If there is no Value* for this operand, it returns
- /// MVT::Other.
- EVT getCallOperandValEVT(LLVMContext &Context, const TargetLowering &TLI,
- const DataLayout &DL,
- llvm::Type *ParamElemType) const {
- if (!CallOperandVal) return MVT::Other;
-
- if (isa<BasicBlock>(CallOperandVal))
- return TLI.getProgramPointerTy(DL);
-
- llvm::Type *OpTy = CallOperandVal->getType();
-
- // FIXME: code duplicated from TargetLowering::ParseConstraints().
- // If this is an indirect operand, the operand is a pointer to the
- // accessed type.
- if (isIndirect) {
- OpTy = ParamElemType;
- assert(OpTy && "Indirect operand must have elementtype attribute");
- }
-
- // Look for vector wrapped in a struct. e.g. { <16 x i8> }.
- if (StructType *STy = dyn_cast<StructType>(OpTy))
- if (STy->getNumElements() == 1)
- OpTy = STy->getElementType(0);
-
- // If OpTy is not a single value, it may be a struct/union that we
- // can tile with integers.
- if (!OpTy->isSingleValueType() && OpTy->isSized()) {
- unsigned BitSize = DL.getTypeSizeInBits(OpTy);
- switch (BitSize) {
- default: break;
- case 1:
- case 8:
- case 16:
- case 32:
- case 64:
- case 128:
- OpTy = IntegerType::get(Context, BitSize);
- break;
- }
- }
-
- return TLI.getAsmOperandValueType(DL, OpTy, true);
- }
};
bool HasSideEffect = IA->hasSideEffects();
ExtraFlags ExtraInfo(Call);
- unsigned ArgNo = 0; // ArgNo - The argument of the CallInst.
- unsigned ResNo = 0; // ResNo - The result number of the next output.
for (auto &T : TargetConstraints) {
ConstraintOperands.push_back(SDISelAsmOperandInfo(T));
SDISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
- // Compute the value type for each operand.
- if (OpInfo.hasArg()) {
- OpInfo.CallOperandVal = Call.getArgOperand(ArgNo);
+ if (OpInfo.CallOperandVal)
OpInfo.CallOperand = getValue(OpInfo.CallOperandVal);
- Type *ParamElemTy = Call.getParamElementType(ArgNo);
- EVT VT = OpInfo.getCallOperandValEVT(*DAG.getContext(), TLI,
- DAG.getDataLayout(), ParamElemTy);
- OpInfo.ConstraintVT = VT.isSimple() ? VT.getSimpleVT() : MVT::Other;
- ArgNo++;
- } else if (OpInfo.Type == InlineAsm::isOutput && !OpInfo.isIndirect) {
- // The return value of the call is this value. As such, there is no
- // corresponding argument.
- assert(!Call.getType()->isVoidTy() && "Bad inline asm!");
- if (StructType *STy = dyn_cast<StructType>(Call.getType())) {
- OpInfo.ConstraintVT = TLI.getSimpleValueType(
- DAG.getDataLayout(), STy->getElementType(ResNo));
- } else {
- assert(ResNo == 0 && "Asm only has one result!");
- OpInfo.ConstraintVT = TLI.getAsmOperandValueType(
- DAG.getDataLayout(), Call.getType()).getSimpleVT();
- }
- ++ResNo;
- } else {
- OpInfo.ConstraintVT = MVT::Other;
- }
if (!HasSideEffect)
HasSideEffect = OpInfo.hasMemory(TLI);
case 32:
case 64:
case 128:
- OpInfo.ConstraintVT =
- MVT::getVT(IntegerType::get(OpTy->getContext(), BitSize), true);
+ OpTy = IntegerType::get(OpTy->getContext(), BitSize);
break;
}
- } else if (PointerType *PT = dyn_cast<PointerType>(OpTy)) {
- unsigned PtrSize = DL.getPointerSizeInBits(PT->getAddressSpace());
- OpInfo.ConstraintVT = MVT::getIntegerVT(PtrSize);
- } else {
- OpInfo.ConstraintVT = MVT::getVT(OpTy, true);
}
+ EVT VT = getAsmOperandValueType(DL, OpTy, true);
+ OpInfo.ConstraintVT = VT.isSimple() ? VT.getSimpleVT() : MVT::Other;
ArgNo++;
}
}