[IR] Add ConstraintInfo::hasArg() helper (NFC)

Checking whether a constraint corresponds to an argument is a
recurring pattern.
This commit is contained in:
Nikita Popov 2022-01-07 10:37:26 +01:00
parent c033f0d9b1
commit e4d1779990
5 changed files with 9 additions and 11 deletions
llvm
include/llvm/IR
lib

View File

@ -171,6 +171,11 @@ public:
/// selectAlternative - Point this constraint to the alternative constraint
/// indicated by the index.
void selectAlternative(unsigned index);
/// Whether this constraint corresponds to an argument.
bool hasArg() const {
return Type == isInput || (Type == isOutput && isIndirect);
}
};
/// ParseConstraints - Split up the constraint string into the specific

View File

@ -3927,9 +3927,7 @@ void BitcodeReader::propagateAttributeTypes(CallBase *CB,
const InlineAsm *IA = cast<InlineAsm>(CB->getCalledOperand());
unsigned ArgNo = 0;
for (const InlineAsm::ConstraintInfo &CI : IA->ParseConstraints()) {
bool HasArg = CI.Type == InlineAsm::isInput ||
(CI.Type == InlineAsm::isOutput && CI.isIndirect);
if (!HasArg)
if (!CI.hasArg())
continue;
if (CI.isIndirect && !CB->getAttributes().getParamElementType(ArgNo)) {

View File

@ -297,9 +297,7 @@ bool InlineAsmLowering::lowerInlineAsm(
GISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
// Compute the value type for each operand.
if (OpInfo.Type == InlineAsm::isInput ||
(OpInfo.Type == InlineAsm::isOutput && OpInfo.isIndirect)) {
if (OpInfo.hasArg()) {
OpInfo.CallOperandVal = const_cast<Value *>(Call.getArgOperand(ArgNo++));
if (isa<BasicBlock>(OpInfo.CallOperandVal)) {

View File

@ -8565,8 +8565,7 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
SDISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
// Compute the value type for each operand.
if (OpInfo.Type == InlineAsm::isInput ||
(OpInfo.Type == InlineAsm::isOutput && OpInfo.isIndirect)) {
if (OpInfo.hasArg()) {
OpInfo.CallOperandVal = Call.getArgOperand(ArgNo++);
// Process the call argument. BasicBlocks are labels, currently appearing

View File

@ -2151,9 +2151,7 @@ void Verifier::verifyInlineAsmCall(const CallBase &Call) {
unsigned ArgNo = 0;
for (const InlineAsm::ConstraintInfo &CI : IA->ParseConstraints()) {
// Only deal with constraints that correspond to call arguments.
bool HasArg = CI.Type == InlineAsm::isInput ||
(CI.Type == InlineAsm::isOutput && CI.isIndirect);
if (!HasArg)
if (!CI.hasArg())
continue;
if (CI.isIndirect) {