Commit 8cfeb69e by Jim Stichnoth

Subzero: Cleanup Inst==>Instr.

In the beginning, Ice::Inst was called IceInst, and patterns like "IceInst *Inst = ..." made perfect sense. After the Ice:: name change, "Inst *Inst = ..." continued to compile, mostly. However, shadowing a type name is clumsy and newer code tends to use "Inst *Instr", so we might as well switch all the instances over. Some are still called "I" and those are left alone. BUG= none R=kschimpf@google.com Review URL: https://codereview.chromium.org/1665423002 .
parent 282d7afd
......@@ -898,13 +898,13 @@ bool Cfg::validateLiveness() const {
Ostream &Str = Ctx->getStrDump();
for (CfgNode *Node : Nodes) {
Inst *FirstInst = nullptr;
for (Inst &Inst : Node->getInsts()) {
if (Inst.isDeleted())
for (Inst &Instr : Node->getInsts()) {
if (Instr.isDeleted())
continue;
if (FirstInst == nullptr)
FirstInst = &Inst;
InstNumberT InstNumber = Inst.getNumber();
if (Variable *Dest = Inst.getDest()) {
FirstInst = &Instr;
InstNumberT InstNumber = Instr.getNumber();
if (Variable *Dest = Instr.getDest()) {
if (!Dest->getIgnoreLiveness()) {
bool Invalid = false;
constexpr bool IsDest = true;
......@@ -916,24 +916,24 @@ bool Cfg::validateLiveness() const {
// of the block, because a Phi temporary may be live at the end of
// the previous block, and if it is also assigned in the first
// instruction of this block, the adjacent live ranges get merged.
if (static_cast<class Inst *>(&Inst) != FirstInst &&
!Inst.isDestRedefined() &&
if (static_cast<class Inst *>(&Instr) != FirstInst &&
!Instr.isDestRedefined() &&
Dest->getLiveRange().containsValue(InstNumber - 1, IsDest))
Invalid = true;
if (Invalid) {
Valid = false;
Str << "Liveness error: inst " << Inst.getNumber() << " dest ";
Str << "Liveness error: inst " << Instr.getNumber() << " dest ";
Dest->dump(this);
Str << " live range " << Dest->getLiveRange() << "\n";
}
}
}
FOREACH_VAR_IN_INST(Var, Inst) {
FOREACH_VAR_IN_INST(Var, Instr) {
static constexpr bool IsDest = false;
if (!Var->getIgnoreLiveness() &&
!Var->getLiveRange().containsValue(InstNumber, IsDest)) {
Valid = false;
Str << "Liveness error: inst " << Inst.getNumber() << " var ";
Str << "Liveness error: inst " << Instr.getNumber() << " var ";
Var->dump(this);
Str << " live range " << Var->getLiveRange() << "\n";
}
......
......@@ -39,16 +39,16 @@ IceString CfgNode::getName() const {
// Adds an instruction to either the Phi list or the regular instruction list.
// Validates that all Phis are added before all regular instructions.
void CfgNode::appendInst(Inst *Inst) {
void CfgNode::appendInst(Inst *Instr) {
++InstCountEstimate;
if (auto *Phi = llvm::dyn_cast<InstPhi>(Inst)) {
if (auto *Phi = llvm::dyn_cast<InstPhi>(Instr)) {
if (!Insts.empty()) {
Func->setError("Phi instruction added to the middle of a block");
return;
}
Phis.push_back(Phi);
} else {
Insts.push_back(Inst);
Insts.push_back(Instr);
}
}
......@@ -1429,13 +1429,13 @@ void CfgNode::profileExecutionCount(VariableDeclaration *Var) {
Constant *OrderAcquireRelease =
Context->getConstantInt32(Intrinsics::MemoryOrderAcquireRelease);
auto *Inst = InstIntrinsicCall::create(
auto *Instr = InstIntrinsicCall::create(
Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
Inst->addArg(AtomicRMWOp);
Inst->addArg(Counter);
Inst->addArg(One);
Inst->addArg(OrderAcquireRelease);
Insts.push_front(Inst);
Instr->addArg(AtomicRMWOp);
Instr->addArg(Counter);
Instr->addArg(One);
Instr->addArg(OrderAcquireRelease);
Insts.push_front(Instr);
}
} // end of namespace Ice
......@@ -72,7 +72,7 @@ public:
/// @{
InstList &getInsts() { return Insts; }
PhiList &getPhis() { return Phis; }
void appendInst(Inst *Inst);
void appendInst(Inst *Instr);
void renumberInstructions();
/// Rough and generally conservative estimate of the number of instructions in
/// the block. It is updated when an instruction is added, but not when
......
......@@ -258,7 +258,7 @@ public:
bool getKnownFrameOffset() const { return KnownFrameOffset; }
void setKnownFrameOffset() { KnownFrameOffset = true; }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Alloca; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Alloca; }
private:
InstAlloca(Cfg *Func, Variable *Dest, Operand *ByteCount,
......@@ -295,8 +295,8 @@ public:
static const char *getOpName(OpKind Op);
bool isCommutative() const;
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) {
return Inst->getKind() == Arithmetic;
static bool classof(const Inst *Instr) {
return Instr->getKind() == Arithmetic;
}
private:
......@@ -322,7 +322,7 @@ public:
}
bool isVarAssign() const override;
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Assign; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Assign; }
private:
InstAssign(Cfg *Func, Variable *Dest, Operand *Source);
......@@ -362,7 +362,7 @@ public:
bool isUnconditionalBranch() const override { return isUnconditional(); }
bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override;
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Br; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Br; }
private:
/// Conditional branch
......@@ -401,7 +401,7 @@ public:
bool isTailcall() const { return HasTailCall; }
bool isTargetHelperCall() const { return IsTargetHelperCall; }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Call; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Call; }
Type getReturnType() const;
protected:
......@@ -442,7 +442,7 @@ public:
}
OpKind getCastKind() const { return CastKind; }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Cast; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Cast; }
private:
InstCast(Cfg *Func, OpKind CastKind, Variable *Dest, Operand *Source);
......@@ -464,8 +464,8 @@ public:
}
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) {
return Inst->getKind() == ExtractElement;
static bool classof(const Inst *Instr) {
return Instr->getKind() == ExtractElement;
}
private:
......@@ -495,7 +495,7 @@ public:
}
FCond getCondition() const { return Condition; }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Fcmp; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Fcmp; }
private:
InstFcmp(Cfg *Func, FCond Condition, Variable *Dest, Operand *Source1,
......@@ -526,7 +526,7 @@ public:
}
ICond getCondition() const { return Condition; }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Icmp; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Icmp; }
private:
InstIcmp(Cfg *Func, ICond Condition, Variable *Dest, Operand *Source1,
......@@ -549,8 +549,8 @@ public:
}
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) {
return Inst->getKind() == InsertElement;
static bool classof(const Inst *Instr) {
return Instr->getKind() == InsertElement;
}
private:
......@@ -572,8 +572,8 @@ public:
return new (Func->allocate<InstIntrinsicCall>())
InstIntrinsicCall(Func, NumArgs, Dest, CallTarget, Info);
}
static bool classof(const Inst *Inst) {
return Inst->getKind() == IntrinsicCall;
static bool classof(const Inst *Instr) {
return Instr->getKind() == IntrinsicCall;
}
Intrinsics::IntrinsicInfo getIntrinsicInfo() const { return Info; }
......@@ -603,7 +603,7 @@ public:
}
Operand *getSourceAddress() const { return getSrc(0); }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Load; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Load; }
private:
InstLoad(Cfg *Func, Variable *Dest, Operand *SourceAddr);
......@@ -627,7 +627,7 @@ public:
Liveness *Liveness);
Inst *lower(Cfg *Func);
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Phi; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Phi; }
private:
InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest);
......@@ -661,7 +661,7 @@ public:
}
NodeList getTerminatorEdges() const override { return NodeList(); }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Ret; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Ret; }
private:
InstRet(Cfg *Func, Operand *RetValue);
......@@ -683,7 +683,7 @@ public:
Operand *getTrueOperand() const { return getSrc(1); }
Operand *getFalseOperand() const { return getSrc(2); }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Select; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Select; }
private:
InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, Operand *Source1,
......@@ -709,7 +709,7 @@ public:
Variable *getRmwBeacon() const;
void setRmwBeacon(Variable *Beacon);
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Store; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Store; }
private:
InstStore(Cfg *Func, Operand *Data, Operand *Addr);
......@@ -742,7 +742,7 @@ public:
NodeList getTerminatorEdges() const override;
bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override;
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == Switch; }
static bool classof(const Inst *Instr) { return Instr->getKind() == Switch; }
private:
InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source, CfgNode *LabelDefault);
......@@ -770,8 +770,8 @@ public:
}
NodeList getTerminatorEdges() const override { return NodeList(); }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) {
return Inst->getKind() == Unreachable;
static bool classof(const Inst *Instr) {
return Instr->getKind() == Unreachable;
}
private:
......@@ -795,8 +795,8 @@ public:
void emitIAS(const Cfg * /* Func */) const override {}
void dump(const Cfg *Func) const override;
Option getOption() const { return BundleOption; }
static bool classof(const Inst *Inst) {
return Inst->getKind() == BundleLock;
static bool classof(const Inst *Instr) {
return Instr->getKind() == BundleLock;
}
private:
......@@ -817,8 +817,8 @@ public:
void emit(const Cfg *Func) const override;
void emitIAS(const Cfg * /* Func */) const override {}
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) {
return Inst->getKind() == BundleUnlock;
static bool classof(const Inst *Instr) {
return Instr->getKind() == BundleUnlock;
}
private:
......@@ -849,7 +849,7 @@ public:
void emit(const Cfg *Func) const override;
void emitIAS(const Cfg * /* Func */) const override {}
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == FakeDef; }
static bool classof(const Inst *Instr) { return Instr->getKind() == FakeDef; }
private:
InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src);
......@@ -874,7 +874,7 @@ public:
void emit(const Cfg *Func) const override;
void emitIAS(const Cfg * /* Func */) const override {}
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == FakeUse; }
static bool classof(const Inst *Instr) { return Instr->getKind() == FakeUse; }
private:
InstFakeUse(Cfg *Func, Variable *Src, uint32_t Weight);
......@@ -902,7 +902,9 @@ public:
void emit(const Cfg *Func) const override;
void emitIAS(const Cfg * /* Func */) const override {}
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == FakeKill; }
static bool classof(const Inst *Instr) {
return Instr->getKind() == FakeKill;
}
private:
InstFakeKill(Cfg *Func, const Inst *Linked);
......@@ -936,7 +938,9 @@ public:
return Targets[I];
}
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() == JumpTable; }
static bool classof(const Inst *Instr) {
return Instr->getKind() == JumpTable;
}
static IceString makeName(const IceString &FuncName, SizeT Id) {
return ".L" + FuncName + "$jumptable$__" + std::to_string(Id);
......@@ -964,7 +968,7 @@ class InstTarget : public Inst {
public:
uint32_t getEmitInstCount() const override { return 1; }
void dump(const Cfg *Func) const override;
static bool classof(const Inst *Inst) { return Inst->getKind() >= Target; }
static bool classof(const Inst *Instr) { return Instr->getKind() >= Target; }
protected:
InstTarget(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest)
......
......@@ -135,106 +135,107 @@ void InstARM32::emitUsingTextFixup(const Cfg *Func) const {
void InstARM32::emitIAS(const Cfg *Func) const { emitUsingTextFixup(Func); }
void InstARM32Pred::emitUnaryopGPR(const char *Opcode,
const InstARM32Pred *Inst, const Cfg *Func,
const InstARM32Pred *Instr, const Cfg *Func,
bool NeedsWidthSuffix) {
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 1);
Type SrcTy = Inst->getSrc(0)->getType();
assert(Instr->getSrcSize() == 1);
Type SrcTy = Instr->getSrc(0)->getType();
Str << "\t" << Opcode;
if (NeedsWidthSuffix)
Str << getWidthString(SrcTy);
Str << Inst->getPredicate() << "\t";
Inst->getDest()->emit(Func);
Str << Instr->getPredicate() << "\t";
Instr->getDest()->emit(Func);
Str << ", ";
Inst->getSrc(0)->emit(Func);
Instr->getSrc(0)->emit(Func);
}
void InstARM32Pred::emitUnaryopFP(const char *Opcode, const InstARM32Pred *Inst,
const Cfg *Func) {
void InstARM32Pred::emitUnaryopFP(const char *Opcode,
const InstARM32Pred *Instr, const Cfg *Func) {
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 1);
Type SrcTy = Inst->getSrc(0)->getType();
Str << "\t" << Opcode << Inst->getPredicate() << getVecWidthString(SrcTy)
assert(Instr->getSrcSize() == 1);
Type SrcTy = Instr->getSrc(0)->getType();
Str << "\t" << Opcode << Instr->getPredicate() << getVecWidthString(SrcTy)
<< "\t";
Inst->getDest()->emit(Func);
Instr->getDest()->emit(Func);
Str << ", ";
Inst->getSrc(0)->emit(Func);
Instr->getSrc(0)->emit(Func);
}
void InstARM32Pred::emitTwoAddr(const char *Opcode, const InstARM32Pred *Inst,
void InstARM32Pred::emitTwoAddr(const char *Opcode, const InstARM32Pred *Instr,
const Cfg *Func) {
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 2);
Variable *Dest = Inst->getDest();
assert(Dest == Inst->getSrc(0));
Str << "\t" << Opcode << Inst->getPredicate() << "\t";
assert(Instr->getSrcSize() == 2);
Variable *Dest = Instr->getDest();
assert(Dest == Instr->getSrc(0));
Str << "\t" << Opcode << Instr->getPredicate() << "\t";
Dest->emit(Func);
Str << ", ";
Inst->getSrc(1)->emit(Func);
Instr->getSrc(1)->emit(Func);
}
void InstARM32Pred::emitThreeAddr(const char *Opcode, const InstARM32Pred *Inst,
const Cfg *Func, bool SetFlags) {
void InstARM32Pred::emitThreeAddr(const char *Opcode,
const InstARM32Pred *Instr, const Cfg *Func,
bool SetFlags) {
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 2);
Str << "\t" << Opcode << (SetFlags ? "s" : "") << Inst->getPredicate()
assert(Instr->getSrcSize() == 2);
Str << "\t" << Opcode << (SetFlags ? "s" : "") << Instr->getPredicate()
<< "\t";
Inst->getDest()->emit(Func);
Instr->getDest()->emit(Func);
Str << ", ";
Inst->getSrc(0)->emit(Func);
Instr->getSrc(0)->emit(Func);
Str << ", ";
Inst->getSrc(1)->emit(Func);
Instr->getSrc(1)->emit(Func);
}
void InstARM32::emitThreeAddrFP(const char *Opcode, const InstARM32 *Inst,
void InstARM32::emitThreeAddrFP(const char *Opcode, const InstARM32 *Instr,
const Cfg *Func) {
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 2);
Str << "\t" << Opcode << getVecWidthString(Inst->getDest()->getType())
assert(Instr->getSrcSize() == 2);
Str << "\t" << Opcode << getVecWidthString(Instr->getDest()->getType())
<< "\t";
Inst->getDest()->emit(Func);
Instr->getDest()->emit(Func);
Str << ", ";
Inst->getSrc(0)->emit(Func);
Instr->getSrc(0)->emit(Func);
Str << ", ";
Inst->getSrc(1)->emit(Func);
Instr->getSrc(1)->emit(Func);
}
void InstARM32::emitFourAddrFP(const char *Opcode, const InstARM32 *Inst,
void InstARM32::emitFourAddrFP(const char *Opcode, const InstARM32 *Instr,
const Cfg *Func) {
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 3);
assert(Inst->getSrc(0) == Inst->getDest());
Str << "\t" << Opcode << getVecWidthString(Inst->getDest()->getType())
assert(Instr->getSrcSize() == 3);
assert(Instr->getSrc(0) == Instr->getDest());
Str << "\t" << Opcode << getVecWidthString(Instr->getDest()->getType())
<< "\t";
Inst->getDest()->emit(Func);
Instr->getDest()->emit(Func);
Str << ", ";
Inst->getSrc(1)->emit(Func);
Instr->getSrc(1)->emit(Func);
Str << ", ";
Inst->getSrc(2)->emit(Func);
Instr->getSrc(2)->emit(Func);
}
void InstARM32Pred::emitFourAddr(const char *Opcode, const InstARM32Pred *Inst,
void InstARM32Pred::emitFourAddr(const char *Opcode, const InstARM32Pred *Instr,
const Cfg *Func) {
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 3);
Str << "\t" << Opcode << Inst->getPredicate() << "\t";
Inst->getDest()->emit(Func);
assert(Instr->getSrcSize() == 3);
Str << "\t" << Opcode << Instr->getPredicate() << "\t";
Instr->getDest()->emit(Func);
Str << ", ";
Inst->getSrc(0)->emit(Func);
Instr->getSrc(0)->emit(Func);
Str << ", ";
Inst->getSrc(1)->emit(Func);
Instr->getSrc(1)->emit(Func);
Str << ", ";
Inst->getSrc(2)->emit(Func);
Instr->getSrc(2)->emit(Func);
}
template <InstARM32::InstKindARM32 K>
......@@ -268,16 +269,16 @@ template <> void InstARM32Mls::emitIAS(const Cfg *Func) const {
emitUsingTextFixup(Func);
}
void InstARM32Pred::emitCmpLike(const char *Opcode, const InstARM32Pred *Inst,
void InstARM32Pred::emitCmpLike(const char *Opcode, const InstARM32Pred *Instr,
const Cfg *Func) {
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 2);
Str << "\t" << Opcode << Inst->getPredicate() << "\t";
Inst->getSrc(0)->emit(Func);
assert(Instr->getSrcSize() == 2);
Str << "\t" << Opcode << Instr->getPredicate() << "\t";
Instr->getSrc(0)->emit(Func);
Str << ", ";
Inst->getSrc(1)->emit(Func);
Instr->getSrc(1)->emit(Func);
}
OperandARM32Mem::OperandARM32Mem(Cfg * /* Func */, Type Ty, Variable *Base,
......
......@@ -1034,28 +1034,28 @@ void InstImpl<TraitsType>::InstX86Idiv::emitIAS(const Cfg *Func) const {
// pblendvb and blendvps take xmm0 as a final implicit argument.
template <typename TraitsType>
void InstImpl<TraitsType>::emitVariableBlendInst(const char *Opcode,
const Inst *Inst,
const Inst *Instr,
const Cfg *Func) {
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 3);
assert(llvm::cast<Variable>(Inst->getSrc(2))->getRegNum() ==
assert(Instr->getSrcSize() == 3);
assert(llvm::cast<Variable>(Instr->getSrc(2))->getRegNum() ==
RegisterSet::Reg_xmm0);
Str << "\t" << Opcode << "\t";
Inst->getSrc(1)->emit(Func);
Instr->getSrc(1)->emit(Func);
Str << ", ";
Inst->getDest()->emit(Func);
Instr->getDest()->emit(Func);
}
template <typename TraitsType>
void InstImpl<TraitsType>::emitIASVariableBlendInst(
const Inst *Inst, const Cfg *Func, const XmmEmitterRegOp &Emitter) {
assert(Inst->getSrcSize() == 3);
assert(llvm::cast<Variable>(Inst->getSrc(2))->getRegNum() ==
const Inst *Instr, const Cfg *Func, const XmmEmitterRegOp &Emitter) {
assert(Instr->getSrcSize() == 3);
assert(llvm::cast<Variable>(Instr->getSrc(2))->getRegNum() ==
RegisterSet::Reg_xmm0);
const Variable *Dest = Inst->getDest();
const Operand *Src = Inst->getSrc(1);
const Variable *Dest = Instr->getDest();
const Operand *Src = Instr->getSrc(1);
emitIASRegOpTyXMM(Func, Dest->getType(), Dest, Src, Emitter);
}
......
......@@ -214,26 +214,26 @@ void LinearScan::initForInfOnly() {
CfgVector<InstNumberT> LREnd(Vars.size(), Inst::NumberSentinel);
DefUseErrorList DefsWithoutUses, UsesBeforeDefs;
for (CfgNode *Node : Func->getNodes()) {
for (Inst &Inst : Node->getInsts()) {
if (Inst.isDeleted())
for (Inst &Instr : Node->getInsts()) {
if (Instr.isDeleted())
continue;
FOREACH_VAR_IN_INST(Var, Inst) {
FOREACH_VAR_IN_INST(Var, Instr) {
if (Var->isRematerializable())
continue;
if (Var->getIgnoreLiveness())
continue;
if (Var->hasReg() || Var->mustHaveReg()) {
SizeT VarNum = Var->getIndex();
LREnd[VarNum] = Inst.getNumber();
LREnd[VarNum] = Instr.getNumber();
if (!Var->getIsArg() && LRBegin[VarNum] == Inst::NumberSentinel)
UsesBeforeDefs.push_back(VarNum);
}
}
if (const Variable *Var = Inst.getDest()) {
if (const Variable *Var = Instr.getDest()) {
if (!Var->isRematerializable() && !Var->getIgnoreLiveness() &&
(Var->hasReg() || Var->mustHaveReg())) {
if (LRBegin[Var->getIndex()] == Inst::NumberSentinel) {
LRBegin[Var->getIndex()] = Inst.getNumber();
LRBegin[Var->getIndex()] = Instr.getNumber();
++NumVars;
}
}
......
......@@ -22,14 +22,14 @@
namespace Ice {
CaseClusterArray CaseCluster::clusterizeSwitch(Cfg *Func,
const InstSwitch *Inst) {
const InstSwitch *Instr) {
CaseClusterArray CaseClusters;
// Load the cases
SizeT NumCases = Inst->getNumCases();
SizeT NumCases = Instr->getNumCases();
CaseClusters.reserve(NumCases);
for (SizeT I = 0; I < NumCases; ++I)
CaseClusters.emplace_back(Inst->getValue(I), Inst->getLabel(I));
CaseClusters.emplace_back(Instr->getValue(I), Instr->getLabel(I));
// Sort the cases
std::sort(CaseClusters.begin(), CaseClusters.end(),
......@@ -75,7 +75,7 @@ CaseClusterArray CaseCluster::clusterizeSwitch(Cfg *Func,
// Replace everything with a jump table
InstJumpTable *JumpTable =
InstJumpTable::create(Func, TotalRange, Inst->getLabelDefault());
InstJumpTable::create(Func, TotalRange, Instr->getLabelDefault());
for (const CaseCluster &Case : CaseClusters) {
// Case.High could be UINT64_MAX which makes the loop awkward. Unwrap the
// last iteration to avoid wrap around problems.
......
......@@ -60,7 +60,7 @@ public:
/// Discover cases which can be clustered together and return the clusters
/// ordered by case value.
static CaseClusterArray clusterizeSwitch(Cfg *Func, const InstSwitch *Inst);
static CaseClusterArray clusterizeSwitch(Cfg *Func, const InstSwitch *Instr);
private:
CaseClusterKind Kind;
......
......@@ -70,9 +70,9 @@ void LoweringContext::rewind() {
availabilityReset();
}
void LoweringContext::insert(Inst *Inst) {
getNode()->getInsts().insert(Next, Inst);
LastInserted = Inst;
void LoweringContext::insert(Inst *Instr) {
getNode()->getInsts().insert(Next, Instr);
LastInserted = Instr;
}
void LoweringContext::skipDeleted(InstList::iterator &I) const {
......@@ -350,76 +350,76 @@ void TargetLowering::doNopInsertion(RandomNumberGenerator &RNG) {
// should delete any additional instructions it consumes.
void TargetLowering::lower() {
assert(!Context.atEnd());
Inst *Inst = Context.getCur();
Inst->deleteIfDead();
if (!Inst->isDeleted() && !llvm::isa<InstFakeDef>(Inst) &&
!llvm::isa<InstFakeUse>(Inst)) {
Inst *Instr = Context.getCur();
Instr->deleteIfDead();
if (!Instr->isDeleted() && !llvm::isa<InstFakeDef>(Instr) &&
!llvm::isa<InstFakeUse>(Instr)) {
// Mark the current instruction as deleted before lowering, otherwise the
// Dest variable will likely get marked as non-SSA. See
// Variable::setDefinition(). However, just pass-through FakeDef and
// FakeUse instructions that might have been inserted prior to lowering.
Inst->setDeleted();
switch (Inst->getKind()) {
Instr->setDeleted();
switch (Instr->getKind()) {
case Inst::Alloca:
lowerAlloca(llvm::cast<InstAlloca>(Inst));
lowerAlloca(llvm::cast<InstAlloca>(Instr));
break;
case Inst::Arithmetic:
lowerArithmetic(llvm::cast<InstArithmetic>(Inst));
lowerArithmetic(llvm::cast<InstArithmetic>(Instr));
break;
case Inst::Assign:
lowerAssign(llvm::cast<InstAssign>(Inst));
lowerAssign(llvm::cast<InstAssign>(Instr));
break;
case Inst::Br:
lowerBr(llvm::cast<InstBr>(Inst));
lowerBr(llvm::cast<InstBr>(Instr));
break;
case Inst::Call:
lowerCall(llvm::cast<InstCall>(Inst));
lowerCall(llvm::cast<InstCall>(Instr));
break;
case Inst::Cast:
lowerCast(llvm::cast<InstCast>(Inst));
lowerCast(llvm::cast<InstCast>(Instr));
break;
case Inst::ExtractElement:
lowerExtractElement(llvm::cast<InstExtractElement>(Inst));
lowerExtractElement(llvm::cast<InstExtractElement>(Instr));
break;
case Inst::Fcmp:
lowerFcmp(llvm::cast<InstFcmp>(Inst));
lowerFcmp(llvm::cast<InstFcmp>(Instr));
break;
case Inst::Icmp:
lowerIcmp(llvm::cast<InstIcmp>(Inst));
lowerIcmp(llvm::cast<InstIcmp>(Instr));
break;
case Inst::InsertElement:
lowerInsertElement(llvm::cast<InstInsertElement>(Inst));
lowerInsertElement(llvm::cast<InstInsertElement>(Instr));
break;
case Inst::IntrinsicCall: {
auto *Call = llvm::cast<InstIntrinsicCall>(Inst);
auto *Call = llvm::cast<InstIntrinsicCall>(Instr);
if (Call->getIntrinsicInfo().ReturnsTwice)
setCallsReturnsTwice(true);
lowerIntrinsicCall(Call);
break;
}
case Inst::Load:
lowerLoad(llvm::cast<InstLoad>(Inst));
lowerLoad(llvm::cast<InstLoad>(Instr));
break;
case Inst::Phi:
lowerPhi(llvm::cast<InstPhi>(Inst));
lowerPhi(llvm::cast<InstPhi>(Instr));
break;
case Inst::Ret:
lowerRet(llvm::cast<InstRet>(Inst));
lowerRet(llvm::cast<InstRet>(Instr));
break;
case Inst::Select:
lowerSelect(llvm::cast<InstSelect>(Inst));
lowerSelect(llvm::cast<InstSelect>(Instr));
break;
case Inst::Store:
lowerStore(llvm::cast<InstStore>(Inst));
lowerStore(llvm::cast<InstStore>(Instr));
break;
case Inst::Switch:
lowerSwitch(llvm::cast<InstSwitch>(Inst));
lowerSwitch(llvm::cast<InstSwitch>(Instr));
break;
case Inst::Unreachable:
lowerUnreachable(llvm::cast<InstUnreachable>(Inst));
lowerUnreachable(llvm::cast<InstUnreachable>(Instr));
break;
default:
lowerOther(Inst);
lowerOther(Instr);
break;
}
......@@ -482,15 +482,16 @@ void TargetLowering::markRedefinitions() {
// Find (non-SSA) instructions where the Dest variable appears in some source
// operand, and set the IsDestRedefined flag to keep liveness analysis
// consistent.
for (auto Inst = Context.getCur(), E = Context.getNext(); Inst != E; ++Inst) {
if (Inst->isDeleted())
for (auto Instr = Context.getCur(), E = Context.getNext(); Instr != E;
++Instr) {
if (Instr->isDeleted())
continue;
Variable *Dest = Inst->getDest();
Variable *Dest = Instr->getDest();
if (Dest == nullptr)
continue;
FOREACH_VAR_IN_INST(Var, *Inst) {
FOREACH_VAR_IN_INST(Var, *Instr) {
if (Var == Dest) {
Inst->setDestRedefined();
Instr->setDestRedefined();
break;
}
}
......@@ -537,12 +538,12 @@ void TargetLowering::getVarStackSlotParams(
const VariablesMetadata *VMetadata = Func->getVMetadata();
llvm::BitVector IsVarReferenced(Func->getNumVariables());
for (CfgNode *Node : Func->getNodes()) {
for (Inst &Inst : Node->getInsts()) {
if (Inst.isDeleted())
for (Inst &Instr : Node->getInsts()) {
if (Instr.isDeleted())
continue;
if (const Variable *Var = Inst.getDest())
if (const Variable *Var = Instr.getDest())
IsVarReferenced[Var->getIndex()] = true;
FOREACH_VAR_IN_INST(Var, Inst) {
FOREACH_VAR_IN_INST(Var, Instr) {
IsVarReferenced[Var->getIndex()] = true;
}
}
......
......@@ -90,7 +90,7 @@ public:
InstList::iterator getCur() const { return Cur; }
InstList::iterator getNext() const { return Next; }
InstList::iterator getEnd() const { return End; }
void insert(Inst *Inst);
void insert(Inst *Instr);
template <typename Inst, typename... Args> Inst *insert(Args &&... A) {
auto *New = Inst::create(Node->getCfg(), std::forward<Args>(A)...);
insert(New);
......@@ -365,24 +365,24 @@ protected:
size_t TypeToRegisterSetSize,
std::function<IceString(int32_t)> getRegName,
std::function<IceString(RegClass)> getRegClassName);
virtual void lowerAlloca(const InstAlloca *Inst) = 0;
virtual void lowerArithmetic(const InstArithmetic *Inst) = 0;
virtual void lowerAssign(const InstAssign *Inst) = 0;
virtual void lowerBr(const InstBr *Inst) = 0;
virtual void lowerCall(const InstCall *Inst) = 0;
virtual void lowerCast(const InstCast *Inst) = 0;
virtual void lowerFcmp(const InstFcmp *Inst) = 0;
virtual void lowerExtractElement(const InstExtractElement *Inst) = 0;
virtual void lowerIcmp(const InstIcmp *Inst) = 0;
virtual void lowerInsertElement(const InstInsertElement *Inst) = 0;
virtual void lowerIntrinsicCall(const InstIntrinsicCall *Inst) = 0;
virtual void lowerLoad(const InstLoad *Inst) = 0;
virtual void lowerPhi(const InstPhi *Inst) = 0;
virtual void lowerRet(const InstRet *Inst) = 0;
virtual void lowerSelect(const InstSelect *Inst) = 0;
virtual void lowerStore(const InstStore *Inst) = 0;
virtual void lowerSwitch(const InstSwitch *Inst) = 0;
virtual void lowerUnreachable(const InstUnreachable *Inst) = 0;
virtual void lowerAlloca(const InstAlloca *Instr) = 0;
virtual void lowerArithmetic(const InstArithmetic *Instr) = 0;
virtual void lowerAssign(const InstAssign *Instr) = 0;
virtual void lowerBr(const InstBr *Instr) = 0;
virtual void lowerCall(const InstCall *Instr) = 0;
virtual void lowerCast(const InstCast *Instr) = 0;
virtual void lowerFcmp(const InstFcmp *Instr) = 0;
virtual void lowerExtractElement(const InstExtractElement *Instr) = 0;
virtual void lowerIcmp(const InstIcmp *Instr) = 0;
virtual void lowerInsertElement(const InstInsertElement *Instr) = 0;
virtual void lowerIntrinsicCall(const InstIntrinsicCall *Instr) = 0;
virtual void lowerLoad(const InstLoad *Instr) = 0;
virtual void lowerPhi(const InstPhi *Instr) = 0;
virtual void lowerRet(const InstRet *Instr) = 0;
virtual void lowerSelect(const InstSelect *Instr) = 0;
virtual void lowerStore(const InstStore *Instr) = 0;
virtual void lowerSwitch(const InstSwitch *Instr) = 0;
virtual void lowerUnreachable(const InstUnreachable *Instr) = 0;
virtual void lowerOther(const Inst *Instr);
virtual void genTargetHelperCallFor(Inst *Instr) = 0;
......
......@@ -188,16 +188,16 @@ protected:
SBC_Yes,
};
void lowerAlloca(const InstAlloca *Inst) override;
SafeBoolChain lowerInt1Arithmetic(const InstArithmetic *Inst);
void lowerAlloca(const InstAlloca *Instr) override;
SafeBoolChain lowerInt1Arithmetic(const InstArithmetic *Instr);
void lowerInt64Arithmetic(InstArithmetic::OpKind Op, Variable *Dest,
Operand *Src0, Operand *Src1);
void lowerArithmetic(const InstArithmetic *Inst) override;
void lowerAssign(const InstAssign *Inst) override;
void lowerBr(const InstBr *Inst) override;
void lowerCall(const InstCall *Inst) override;
void lowerCast(const InstCast *Inst) override;
void lowerExtractElement(const InstExtractElement *Inst) override;
void lowerArithmetic(const InstArithmetic *Instr) override;
void lowerAssign(const InstAssign *Instr) override;
void lowerBr(const InstBr *Instr) override;
void lowerCall(const InstCall *Instr) override;
void lowerCast(const InstCast *Instr) override;
void lowerExtractElement(const InstExtractElement *Instr) override;
/// CondWhenTrue is a helper type returned by every method in the lowering
/// that emits code to set the condition codes.
......@@ -240,15 +240,15 @@ protected:
void lowerIcmp(const InstIcmp *Instr) override;
void lowerAtomicRMW(Variable *Dest, uint32_t Operation, Operand *Ptr,
Operand *Val);
void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override;
void lowerInsertElement(const InstInsertElement *Inst) override;
void lowerLoad(const InstLoad *Inst) override;
void lowerPhi(const InstPhi *Inst) override;
void lowerRet(const InstRet *Inst) override;
void lowerSelect(const InstSelect *Inst) override;
void lowerStore(const InstStore *Inst) override;
void lowerSwitch(const InstSwitch *Inst) override;
void lowerUnreachable(const InstUnreachable *Inst) override;
void lowerIntrinsicCall(const InstIntrinsicCall *Instr) override;
void lowerInsertElement(const InstInsertElement *Instr) override;
void lowerLoad(const InstLoad *Instr) override;
void lowerPhi(const InstPhi *Instr) override;
void lowerRet(const InstRet *Instr) override;
void lowerSelect(const InstSelect *Instr) override;
void lowerStore(const InstStore *Instr) override;
void lowerSwitch(const InstSwitch *Instr) override;
void lowerUnreachable(const InstUnreachable *Instr) override;
void prelowerPhis() override;
uint32_t getCallStackArgumentsSizeBytes(const InstCall *Instr) override;
void genTargetHelperCallFor(Inst *Instr) override;
......@@ -1086,9 +1086,9 @@ private:
void postambleCtpop64(const InstCall *Instr);
void preambleDivRem(const InstCall *Instr);
std::unordered_map<Operand *, void (TargetARM32::*)(const InstCall *Inst)>
std::unordered_map<Operand *, void (TargetARM32::*)(const InstCall *Instr)>
ARM32HelpersPreamble;
std::unordered_map<Operand *, void (TargetARM32::*)(const InstCall *Inst)>
std::unordered_map<Operand *, void (TargetARM32::*)(const InstCall *Instr)>
ARM32HelpersPostamble;
class ComputationTracker {
......
......@@ -241,26 +241,26 @@ protected:
dispatchToConcrete(&Traits::ConcreteTarget::initSandbox);
}
void lowerAlloca(const InstAlloca *Inst) override;
void lowerAlloca(const InstAlloca *Instr) override;
void lowerArguments() override;
void lowerArithmetic(const InstArithmetic *Inst) override;
void lowerAssign(const InstAssign *Inst) override;
void lowerBr(const InstBr *Inst) override;
void lowerCall(const InstCall *Inst) override;
void lowerCast(const InstCast *Inst) override;
void lowerExtractElement(const InstExtractElement *Inst) override;
void lowerFcmp(const InstFcmp *Inst) override;
void lowerIcmp(const InstIcmp *Inst) override;
void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override;
void lowerInsertElement(const InstInsertElement *Inst) override;
void lowerLoad(const InstLoad *Inst) override;
void lowerPhi(const InstPhi *Inst) override;
void lowerRet(const InstRet *Inst) override;
void lowerSelect(const InstSelect *Inst) override;
void lowerStore(const InstStore *Inst) override;
void lowerSwitch(const InstSwitch *Inst) override;
void lowerUnreachable(const InstUnreachable *Inst) override;
void lowerArithmetic(const InstArithmetic *Instr) override;
void lowerAssign(const InstAssign *Instr) override;
void lowerBr(const InstBr *Instr) override;
void lowerCall(const InstCall *Instr) override;
void lowerCast(const InstCast *Instr) override;
void lowerExtractElement(const InstExtractElement *Instr) override;
void lowerFcmp(const InstFcmp *Instr) override;
void lowerIcmp(const InstIcmp *Instr) override;
void lowerIntrinsicCall(const InstIntrinsicCall *Instr) override;
void lowerInsertElement(const InstInsertElement *Instr) override;
void lowerLoad(const InstLoad *Instr) override;
void lowerPhi(const InstPhi *Instr) override;
void lowerRet(const InstRet *Instr) override;
void lowerSelect(const InstSelect *Instr) override;
void lowerStore(const InstStore *Instr) override;
void lowerSwitch(const InstSwitch *Instr) override;
void lowerUnreachable(const InstUnreachable *Instr) override;
void lowerOther(const Inst *Instr) override;
void lowerRMW(const InstX86FakeRMW *RMW);
void prelowerPhis() override;
......@@ -1053,7 +1053,7 @@ private:
/// Emit the code for instructions with a vector type.
void lowerIcmpVector(const InstIcmp *Icmp);
void lowerFcmpVector(const InstFcmp *Icmp);
void lowerSelectVector(const InstSelect *Inst);
void lowerSelectVector(const InstSelect *Instr);
/// Helpers for select lowering.
void lowerSelectMove(Variable *Dest, BrCond Cond, Operand *SrcT,
......
......@@ -2743,17 +2743,17 @@ void FunctionParser::ProcessRecord() {
Ice::Variable *Dest = (ReturnType == Ice::IceType_void)
? nullptr
: getNextInstVar(ReturnType);
std::unique_ptr<Ice::InstCall> Inst;
std::unique_ptr<Ice::InstCall> Instr;
if (IntrinsicInfo) {
Inst.reset(Ice::InstIntrinsicCall::create(Func.get(), Params.size(), Dest,
Callee, IntrinsicInfo->Info));
Instr.reset(Ice::InstIntrinsicCall::create(
Func.get(), Params.size(), Dest, Callee, IntrinsicInfo->Info));
} else {
Inst.reset(Ice::InstCall::create(Func.get(), Params.size(), Dest, Callee,
IsTailCall));
Instr.reset(Ice::InstCall::create(Func.get(), Params.size(), Dest, Callee,
IsTailCall));
}
for (Ice::Operand *Param : Params)
Inst->addArg(Param);
CurrentNode->appendInst(Inst.release());
Instr->addArg(Param);
CurrentNode->appendInst(Instr.release());
return;
}
case naclbitc::FUNC_CODE_INST_FORWARDTYPEREF: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment