Skip to content

Commit 32a20d7

Browse files
committed
Rename NonNegInstruction -> PossiblyNonNegInst
1 parent 55d512b commit 32a20d7

File tree

8 files changed

+20
-22
lines changed

8 files changed

+20
-22
lines changed

llvm/include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ enum FastMathMap {
505505
AllowReassoc = (1 << 7)
506506
};
507507

508-
/// Flags for serializing NonNegInstruction's SubclassOptionalData contents.
509-
enum NonNegInstructionOptionalFlags { NNI_NON_NEG = 0 };
508+
/// Flags for serializing PossiblyNonNegInst's SubclassOptionalData contents.
509+
enum PossiblyNonNegInstOptionalFlags { PNNI_NON_NEG = 0 };
510510

511511
/// PossiblyExactOperatorOptionalFlags - Flags for serializing
512512
/// PossiblyExactOperator's SubclassOptionalData contents.

llvm/include/llvm/IR/InstrTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ class CastInst : public UnaryInstruction {
693693
};
694694

695695
/// Instruction that can have a nneg flag (only zext).
696-
class NonNegInstruction : public CastInst {
696+
class PossiblyNonNegInst : public CastInst {
697697
public:
698698
enum { NonNeg = (1 << 0) };
699699

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6386,11 +6386,10 @@ int LLParser::parseInstruction(Instruction *&Inst, BasicBlock *BB,
63866386
case lltok::kw_zext: {
63876387
bool NonNeg = EatIfPresent(lltok::kw_nneg);
63886388
bool Res = parseCast(Inst, PFS, KeywordVal);
6389+
if (Res != 0)
6390+
return Res;
63896391
if (NonNeg)
63906392
Inst->setNonNeg();
6391-
if (Res != 0) {
6392-
return Res;
6393-
}
63946393
return 0;
63956394
}
63966395
case lltok::kw_trunc:

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4893,13 +4893,12 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
48934893
}
48944894
} else {
48954895
auto CastOp = (Instruction::CastOps)Opc;
4896-
48974896
if (!CastInst::castIsValid(CastOp, Op, ResTy))
48984897
return error("Invalid cast");
48994898
I = CastInst::Create(CastOp, Op, ResTy);
49004899
}
4901-
if (OpNum < Record.size() && isa<NonNegInstruction>(I) &&
4902-
(Record[OpNum] & (1 << bitc::NNI_NON_NEG)))
4900+
if (OpNum < Record.size() && isa<PossiblyNonNegInst>(I) &&
4901+
(Record[OpNum] & (1 << bitc::PNNI_NON_NEG)))
49034902
I->setNonNeg(true);
49044903
InstructionList.push_back(I);
49054904
break;

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,9 +1550,9 @@ static uint64_t getOptimizationFlags(const Value *V) {
15501550
Flags |= bitc::AllowContract;
15511551
if (FPMO->hasApproxFunc())
15521552
Flags |= bitc::ApproxFunc;
1553-
} else if (const auto *NNI = dyn_cast<NonNegInstruction>(V)) {
1553+
} else if (const auto *NNI = dyn_cast<PossiblyNonNegInst>(V)) {
15541554
if (NNI->hasNonNeg())
1555-
Flags |= 1 << bitc::NNI_NON_NEG;
1555+
Flags |= 1 << bitc::PNNI_NON_NEG;
15561556
}
15571557

15581558
return Flags;

llvm/lib/IR/AsmWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ static void WriteOptimizationInfo(raw_ostream &Out, const User *U) {
13481348
} else if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
13491349
if (GEP->isInBounds())
13501350
Out << " inbounds";
1351-
} else if (const auto *NNI = dyn_cast<NonNegInstruction>(U)) {
1351+
} else if (const auto *NNI = dyn_cast<PossiblyNonNegInst>(U)) {
13521352
if (NNI->hasNonNeg())
13531353
Out << " nneg";
13541354
}

llvm/lib/IR/Instruction.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ void Instruction::setIsExact(bool b) {
172172
}
173173

174174
void Instruction::setNonNeg(bool b) {
175-
assert(isa<NonNegInstruction>(this) && "Must be zext");
176-
SubclassOptionalData = (SubclassOptionalData & ~NonNegInstruction::NonNeg) |
177-
(b * NonNegInstruction::NonNeg);
175+
assert(isa<PossiblyNonNegInst>(this) && "Must be zext");
176+
SubclassOptionalData = (SubclassOptionalData & ~PossiblyNonNegInst::NonNeg) |
177+
(b * PossiblyNonNegInst::NonNeg);
178178
}
179179

180180
bool Instruction::hasNoUnsignedWrap() const {
@@ -186,8 +186,8 @@ bool Instruction::hasNoSignedWrap() const {
186186
}
187187

188188
bool Instruction::hasNonNeg() const {
189-
assert(isa<NonNegInstruction>(this) && "Must be zext");
190-
return (SubclassOptionalData & NonNegInstruction::NonNeg) != 0;
189+
assert(isa<PossiblyNonNegInst>(this) && "Must be zext");
190+
return (SubclassOptionalData & PossiblyNonNegInst::NonNeg) != 0;
191191
}
192192

193193
bool Instruction::hasPoisonGeneratingFlags() const {
@@ -395,8 +395,8 @@ void Instruction::copyIRFlags(const Value *V, bool IncludeWrapFlags) {
395395
if (auto *DestGEP = dyn_cast<GetElementPtrInst>(this))
396396
DestGEP->setIsInBounds(SrcGEP->isInBounds() || DestGEP->isInBounds());
397397

398-
if (auto *NNI = dyn_cast<NonNegInstruction>(V))
399-
if (isa<NonNegInstruction>(this))
398+
if (auto *NNI = dyn_cast<PossiblyNonNegInst>(V))
399+
if (isa<PossiblyNonNegInst>(this))
400400
setNonNeg(NNI->hasNonNeg());
401401
}
402402

@@ -424,8 +424,8 @@ void Instruction::andIRFlags(const Value *V) {
424424
if (auto *DestGEP = dyn_cast<GetElementPtrInst>(this))
425425
DestGEP->setIsInBounds(SrcGEP->isInBounds() && DestGEP->isInBounds());
426426

427-
if (auto *NNI = dyn_cast<NonNegInstruction>(V))
428-
if (isa<NonNegInstruction>(this))
427+
if (auto *NNI = dyn_cast<PossiblyNonNegInst>(V))
428+
if (isa<PossiblyNonNegInst>(this))
429429
setNonNeg(hasNonNeg() && NNI->hasNonNeg());
430430
}
431431

llvm/lib/IR/Operator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bool Operator::hasPoisonGeneratingFlags() const {
3838
return GEP->isInBounds() || GEP->getInRangeIndex() != std::nullopt;
3939
}
4040
case Instruction::ZExt:
41-
if (auto *NNI = dyn_cast<NonNegInstruction>(this))
41+
if (auto *NNI = dyn_cast<PossiblyNonNegInst>(this))
4242
return NNI->hasNonNeg();
4343
return false;
4444
default:

0 commit comments

Comments
 (0)