Skip to content

Commit e4d1779

Browse files
committed
[IR] Add ConstraintInfo::hasArg() helper (NFC)
Checking whether a constraint corresponds to an argument is a recurring pattern.
1 parent c033f0d commit e4d1779

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

llvm/include/llvm/IR/InlineAsm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ class InlineAsm final : public Value {
171171
/// selectAlternative - Point this constraint to the alternative constraint
172172
/// indicated by the index.
173173
void selectAlternative(unsigned index);
174+
175+
/// Whether this constraint corresponds to an argument.
176+
bool hasArg() const {
177+
return Type == isInput || (Type == isOutput && isIndirect);
178+
}
174179
};
175180

176181
/// ParseConstraints - Split up the constraint string into the specific

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3927,9 +3927,7 @@ void BitcodeReader::propagateAttributeTypes(CallBase *CB,
39273927
const InlineAsm *IA = cast<InlineAsm>(CB->getCalledOperand());
39283928
unsigned ArgNo = 0;
39293929
for (const InlineAsm::ConstraintInfo &CI : IA->ParseConstraints()) {
3930-
bool HasArg = CI.Type == InlineAsm::isInput ||
3931-
(CI.Type == InlineAsm::isOutput && CI.isIndirect);
3932-
if (!HasArg)
3930+
if (!CI.hasArg())
39333931
continue;
39343932

39353933
if (CI.isIndirect && !CB->getAttributes().getParamElementType(ArgNo)) {

llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,7 @@ bool InlineAsmLowering::lowerInlineAsm(
297297
GISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
298298

299299
// Compute the value type for each operand.
300-
if (OpInfo.Type == InlineAsm::isInput ||
301-
(OpInfo.Type == InlineAsm::isOutput && OpInfo.isIndirect)) {
302-
300+
if (OpInfo.hasArg()) {
303301
OpInfo.CallOperandVal = const_cast<Value *>(Call.getArgOperand(ArgNo++));
304302

305303
if (isa<BasicBlock>(OpInfo.CallOperandVal)) {

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8565,8 +8565,7 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
85658565
SDISelAsmOperandInfo &OpInfo = ConstraintOperands.back();
85668566

85678567
// Compute the value type for each operand.
8568-
if (OpInfo.Type == InlineAsm::isInput ||
8569-
(OpInfo.Type == InlineAsm::isOutput && OpInfo.isIndirect)) {
8568+
if (OpInfo.hasArg()) {
85708569
OpInfo.CallOperandVal = Call.getArgOperand(ArgNo++);
85718570

85728571
// Process the call argument. BasicBlocks are labels, currently appearing

llvm/lib/IR/Verifier.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,9 +2151,7 @@ void Verifier::verifyInlineAsmCall(const CallBase &Call) {
21512151
unsigned ArgNo = 0;
21522152
for (const InlineAsm::ConstraintInfo &CI : IA->ParseConstraints()) {
21532153
// Only deal with constraints that correspond to call arguments.
2154-
bool HasArg = CI.Type == InlineAsm::isInput ||
2155-
(CI.Type == InlineAsm::isOutput && CI.isIndirect);
2156-
if (!HasArg)
2154+
if (!CI.hasArg())
21572155
continue;
21582156

21592157
if (CI.isIndirect) {

0 commit comments

Comments
 (0)