Commit ae953202 by Jim Stichnoth

Subzero: Convert NULL->nullptr.

This is limited to the src directory, and not (yet) the crosstest directory. BUG= none R=jfb@chromium.org Review URL: https://codereview.chromium.org/814353002
parent 31c95590
......@@ -23,7 +23,7 @@
namespace Ice {
thread_local const Cfg *Cfg::CurrentCfg = NULL;
thread_local const Cfg *Cfg::CurrentCfg = nullptr;
ArenaAllocator *getCurrentCfgAllocator() {
return Cfg::getCurrentCfgAllocator();
......@@ -32,23 +32,23 @@ ArenaAllocator *getCurrentCfgAllocator() {
Cfg::Cfg(GlobalContext *Ctx)
: Ctx(Ctx), FunctionName(""), ReturnType(IceType_void),
IsInternalLinkage(false), HasError(false), FocusedTiming(false),
ErrorMessage(""), Entry(NULL), NextInstNumber(Inst::NumberInitial),
ErrorMessage(""), Entry(nullptr), NextInstNumber(Inst::NumberInitial),
Allocator(new ArenaAllocator()), Live(nullptr),
Target(TargetLowering::createLowering(Ctx->getTargetArch(), this)),
VMetadata(new VariablesMetadata(this)),
TargetAssembler(
TargetLowering::createAssembler(Ctx->getTargetArch(), this)),
CurrentNode(NULL) {
CurrentNode(nullptr) {
assert(!Ctx->isIRGenerationDisabled() &&
"Attempt to build cfg when IR generation disabled");
}
Cfg::~Cfg() {
// TODO(stichnot,kschimpf): Set CurrentCfg=NULL in the dtor for
// TODO(stichnot,kschimpf): Set CurrentCfg=nullptr in the dtor for
// safety. This can't be done currently because the translator
// manages the Cfg by creating a new Cfg (which sets CurrentCfg to
// the new value), then deleting the old Cfg (which would then reset
// CurrentCfg to NULL).
// CurrentCfg to nullptr).
}
void Cfg::setError(const IceString &Message) {
......@@ -338,12 +338,12 @@ bool Cfg::validateLiveness() const {
bool Valid = true;
Ostream &Str = Ctx->getStrDump();
for (CfgNode *Node : Nodes) {
Inst *FirstInst = NULL;
Inst *FirstInst = nullptr;
for (auto Inst = Node->getInsts().begin(), E = Node->getInsts().end();
Inst != E; ++Inst) {
if (Inst->isDeleted())
continue;
if (FirstInst == NULL)
if (FirstInst == nullptr)
FirstInst = Inst;
InstNumberT InstNumber = Inst->getNumber();
if (Variable *Dest = Inst->getDest()) {
......@@ -410,7 +410,7 @@ void Cfg::doBranchOpt() {
for (auto I = Nodes.begin(), E = Nodes.end(); I != E; ++I) {
auto NextNode = I;
++NextNode;
(*I)->doBranchOpt(NextNode == E ? NULL : *NextNode);
(*I)->doBranchOpt(NextNode == E ? nullptr : *NextNode);
}
}
......
......@@ -154,7 +154,7 @@ public:
// Manage the CurrentNode field, which is used for validating the
// Variable::DefNode field during dumping/emitting.
void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; }
void resetCurrentNode() { setCurrentNode(NULL); }
void resetCurrentNode() { setCurrentNode(nullptr); }
const CfgNode *getCurrentNode() const { return CurrentNode; }
void emit();
......
......@@ -164,7 +164,7 @@ void CfgNode::placePhiStores() {
// Keep track of the dest variable of a compare instruction, so that
// we insert the new instruction at the SafeInsertionPoint if the
// compare's dest matches the Phi-lowered assignment's source.
Variable *CmpInstDest = NULL;
Variable *CmpInstDest = nullptr;
// If the current insertion point is at a conditional branch
// instruction, and the previous instruction is a compare
// instruction, then we move the insertion point before the compare
......@@ -553,8 +553,8 @@ void CfgNode::livenessLightweight() {
bool CfgNode::liveness(Liveness *Liveness) {
SizeT NumVars = Liveness->getNumVarsInNode(this);
LivenessBV Live(NumVars);
LiveBeginEndMap *LiveBegin = NULL;
LiveBeginEndMap *LiveEnd = NULL;
LiveBeginEndMap *LiveBegin = nullptr;
LiveBeginEndMap *LiveEnd = nullptr;
// Mark the beginning and ending of each variable's live range
// with the sentinel instruction number 0.
if (Liveness->getMode() == Liveness_Intervals) {
......@@ -723,7 +723,7 @@ void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum,
void CfgNode::contractIfEmpty() {
if (InEdges.empty())
return;
Inst *Branch = NULL;
Inst *Branch = nullptr;
for (auto I = Insts.begin(), E = Insts.end(); I != E; ++I) {
if (I->isDeleted())
continue;
......
......@@ -78,7 +78,7 @@ public:
UndefPool() : NextPoolID(0), Pool(IceType_NUM) {}
ConstantUndef *getOrAdd(GlobalContext *Ctx, Type Ty) {
if (Pool[Ty] == NULL)
if (Pool[Ty] == nullptr)
Pool[Ty] = ConstantUndef::create(Ctx, Ty, NextPoolID++);
return Pool[Ty];
}
......@@ -325,7 +325,7 @@ Constant *GlobalContext::getConstantInt(Type Ty, int64_t Value) {
default:
llvm_unreachable("Bad integer type for getConstant");
}
return NULL;
return nullptr;
}
Constant *GlobalContext::getConstantInt1(int8_t ConstantInt1) {
......
......@@ -235,18 +235,18 @@ InstAssign::InstAssign(Cfg *Func, Variable *Dest, Operand *Source)
// semantics, there is at most one edge from one node to another.
InstBr::InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue,
CfgNode *TargetFalse)
: InstHighLevel(Func, Inst::Br, 1, NULL), TargetFalse(TargetFalse),
: InstHighLevel(Func, Inst::Br, 1, nullptr), TargetFalse(TargetFalse),
TargetTrue(TargetTrue) {
if (TargetTrue == TargetFalse) {
TargetTrue = NULL; // turn into unconditional version
TargetTrue = nullptr; // turn into unconditional version
} else {
addSource(Source);
}
}
InstBr::InstBr(Cfg *Func, CfgNode *Target)
: InstHighLevel(Func, Inst::Br, 0, NULL), TargetFalse(Target),
TargetTrue(NULL) {}
: InstHighLevel(Func, Inst::Br, 0, nullptr), TargetFalse(Target),
TargetTrue(nullptr) {}
NodeList InstBr::getTerminatorEdges() const {
NodeList OutEdges;
......@@ -331,7 +331,7 @@ Operand *InstPhi::getOperandForTarget(CfgNode *Target) const {
return getSrc(I);
}
llvm_unreachable("Phi target not found");
return NULL;
return nullptr;
}
// Updates liveness for a particular operand based on the given
......@@ -369,7 +369,7 @@ Inst *InstPhi::lower(Cfg *Func) {
}
InstRet::InstRet(Cfg *Func, Operand *RetValue)
: InstHighLevel(Func, Ret, RetValue ? 1 : 0, NULL) {
: InstHighLevel(Func, Ret, RetValue ? 1 : 0, nullptr) {
if (RetValue)
addSource(RetValue);
}
......@@ -384,14 +384,14 @@ InstSelect::InstSelect(Cfg *Func, Variable *Dest, Operand *Condition,
}
InstStore::InstStore(Cfg *Func, Operand *Data, Operand *Addr)
: InstHighLevel(Func, Inst::Store, 2, NULL) {
: InstHighLevel(Func, Inst::Store, 2, nullptr) {
addSource(Data);
addSource(Addr);
}
InstSwitch::InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source,
CfgNode *LabelDefault)
: InstHighLevel(Func, Inst::Switch, 1, NULL), LabelDefault(LabelDefault),
: InstHighLevel(Func, Inst::Switch, 1, nullptr), LabelDefault(LabelDefault),
NumCases(NumCases) {
addSource(Source);
Values = Func->allocateArrayOf<uint64_t>(NumCases);
......@@ -399,7 +399,7 @@ InstSwitch::InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source,
// Initialize in case buggy code doesn't set all entries
for (SizeT I = 0; I < NumCases; ++I) {
Values[I] = 0;
Labels[I] = NULL;
Labels[I] = nullptr;
}
}
......@@ -434,7 +434,7 @@ bool InstSwitch::repointEdge(CfgNode *OldNode, CfgNode *NewNode) {
}
InstUnreachable::InstUnreachable(Cfg *Func)
: InstHighLevel(Func, Inst::Unreachable, 0, NULL) {}
: InstHighLevel(Func, Inst::Unreachable, 0, nullptr) {}
InstFakeDef::InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src)
: InstHighLevel(Func, Inst::FakeDef, Src ? 1 : 0, Dest) {
......@@ -444,16 +444,16 @@ InstFakeDef::InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src)
}
InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src)
: InstHighLevel(Func, Inst::FakeUse, 1, NULL) {
: InstHighLevel(Func, Inst::FakeUse, 1, nullptr) {
assert(Src);
addSource(Src);
}
InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked)
: InstHighLevel(Func, Inst::FakeKill, 0, NULL), Linked(Linked) {}
: InstHighLevel(Func, Inst::FakeKill, 0, nullptr), Linked(Linked) {}
Type InstCall::getReturnType() const {
if (Dest == NULL)
if (Dest == nullptr)
return IceType_void;
return Dest->getType();
}
......
......@@ -321,7 +321,7 @@ public:
static InstBr *create(Cfg *Func, CfgNode *Target) {
return new (Func->allocate<InstBr>()) InstBr(Func, Target);
}
bool isUnconditional() const { return getTargetTrue() == NULL; }
bool isUnconditional() const { return getTargetTrue() == nullptr; }
Operand *getCondition() const {
assert(!isUnconditional());
return getSrc(0);
......@@ -346,7 +346,7 @@ private:
~InstBr() override {}
CfgNode *TargetFalse; // Doubles as unconditional branch target
CfgNode *TargetTrue; // NULL if unconditional branch
CfgNode *TargetTrue; // nullptr if unconditional branch
};
// Call instruction. The call target is captured as getSrc(0), and
......@@ -615,7 +615,7 @@ class InstRet : public InstHighLevel {
InstRet &operator=(const InstRet &) = delete;
public:
static InstRet *create(Cfg *Func, Operand *RetValue = NULL) {
static InstRet *create(Cfg *Func, Operand *RetValue = nullptr) {
return new (Func->allocate<InstRet>()) InstRet(Func, RetValue);
}
bool hasRetValue() const { return getSrcSize(); }
......@@ -760,7 +760,8 @@ class InstFakeDef : public InstHighLevel {
InstFakeDef &operator=(const InstFakeDef &) = delete;
public:
static InstFakeDef *create(Cfg *Func, Variable *Dest, Variable *Src = NULL) {
static InstFakeDef *create(Cfg *Func, Variable *Dest,
Variable *Src = nullptr) {
return new (Func->allocate<InstFakeDef>()) InstFakeDef(Func, Dest, Src);
}
void emit(const Cfg *Func) const override;
......
......@@ -90,7 +90,7 @@ OperandX8632Mem::OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base,
: OperandX8632(kMem, Ty), Base(Base), Offset(Offset), Index(Index),
Shift(Shift), SegmentReg(SegmentReg) {
assert(Shift <= 3);
Vars = NULL;
Vars = nullptr;
NumVars = 0;
if (Base)
++NumVars;
......@@ -137,7 +137,7 @@ InstX8632Shrd::InstX8632Shrd(Cfg *Func, Variable *Dest, Variable *Source1,
}
InstX8632Label::InstX8632Label(Cfg *Func, TargetX8632 *Target)
: InstX8632(Func, InstX8632::Label, 0, NULL),
: InstX8632(Func, InstX8632::Label, 0, nullptr),
Number(Target->makeNextLabelNumber()) {}
IceString InstX8632Label::getName(const Cfg *Func) const {
......@@ -147,13 +147,13 @@ IceString InstX8632Label::getName(const Cfg *Func) const {
InstX8632Br::InstX8632Br(Cfg *Func, const CfgNode *TargetTrue,
const CfgNode *TargetFalse,
const InstX8632Label *Label, CondX86::BrCond Condition)
: InstX8632(Func, InstX8632::Br, 0, NULL), Condition(Condition),
: InstX8632(Func, InstX8632::Br, 0, nullptr), Condition(Condition),
TargetTrue(TargetTrue), TargetFalse(TargetFalse), Label(Label) {}
bool InstX8632Br::optimizeBranch(const CfgNode *NextNode) {
// If there is no next block, then there can be no fallthrough to
// optimize.
if (NextNode == NULL)
if (NextNode == nullptr)
return false;
// Intra-block conditional branches can't be optimized.
if (Label)
......@@ -161,29 +161,29 @@ bool InstX8632Br::optimizeBranch(const CfgNode *NextNode) {
// If there is no fallthrough node, such as a non-default case label
// for a switch instruction, then there is no opportunity to
// optimize.
if (getTargetFalse() == NULL)
if (getTargetFalse() == nullptr)
return false;
// Unconditional branch to the next node can be removed.
if (Condition == CondX86::Br_None && getTargetFalse() == NextNode) {
assert(getTargetTrue() == NULL);
assert(getTargetTrue() == nullptr);
setDeleted();
return true;
}
// If the fallthrough is to the next node, set fallthrough to NULL
// If the fallthrough is to the next node, set fallthrough to nullptr
// to indicate.
if (getTargetFalse() == NextNode) {
TargetFalse = NULL;
TargetFalse = nullptr;
return true;
}
// If TargetTrue is the next node, and TargetFalse is non-NULL
// If TargetTrue is the next node, and TargetFalse is not nullptr
// (which was already tested above), then invert the branch
// condition, swap the targets, and set new fallthrough to NULL.
// condition, swap the targets, and set new fallthrough to nullptr.
if (getTargetTrue() == NextNode) {
assert(Condition != CondX86::Br_None);
Condition = InstX8632BrAttributes[Condition].Opposite;
TargetTrue = getTargetFalse();
TargetFalse = NULL;
TargetFalse = nullptr;
return true;
}
return false;
......@@ -237,7 +237,7 @@ InstX8632Cmpxchg8b::InstX8632Cmpxchg8b(Cfg *Func, OperandX8632Mem *Addr,
Variable *Edx, Variable *Eax,
Variable *Ecx, Variable *Ebx,
bool Locked)
: InstX8632Lockable(Func, InstX8632::Cmpxchg, 5, NULL, Locked) {
: InstX8632Lockable(Func, InstX8632::Cmpxchg, 5, nullptr, Locked) {
assert(Edx->getRegNum() == RegX8632::Reg_edx);
assert(Eax->getRegNum() == RegX8632::Reg_eax);
assert(Ecx->getRegNum() == RegX8632::Reg_ecx);
......@@ -256,56 +256,56 @@ InstX8632Cvt::InstX8632Cvt(Cfg *Func, Variable *Dest, Operand *Source,
}
InstX8632Icmp::InstX8632Icmp(Cfg *Func, Operand *Src0, Operand *Src1)
: InstX8632(Func, InstX8632::Icmp, 2, NULL) {
: InstX8632(Func, InstX8632::Icmp, 2, nullptr) {
addSource(Src0);
addSource(Src1);
}
InstX8632Ucomiss::InstX8632Ucomiss(Cfg *Func, Operand *Src0, Operand *Src1)
: InstX8632(Func, InstX8632::Ucomiss, 2, NULL) {
: InstX8632(Func, InstX8632::Ucomiss, 2, nullptr) {
addSource(Src0);
addSource(Src1);
}
InstX8632UD2::InstX8632UD2(Cfg *Func)
: InstX8632(Func, InstX8632::UD2, 0, NULL) {}
: InstX8632(Func, InstX8632::UD2, 0, nullptr) {}
InstX8632Test::InstX8632Test(Cfg *Func, Operand *Src1, Operand *Src2)
: InstX8632(Func, InstX8632::Test, 2, NULL) {
: InstX8632(Func, InstX8632::Test, 2, nullptr) {
addSource(Src1);
addSource(Src2);
}
InstX8632Mfence::InstX8632Mfence(Cfg *Func)
: InstX8632(Func, InstX8632::Mfence, 0, NULL) {
: InstX8632(Func, InstX8632::Mfence, 0, nullptr) {
HasSideEffects = true;
}
InstX8632Store::InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem)
: InstX8632(Func, InstX8632::Store, 2, NULL) {
: InstX8632(Func, InstX8632::Store, 2, nullptr) {
addSource(Value);
addSource(Mem);
}
InstX8632StoreP::InstX8632StoreP(Cfg *Func, Variable *Value,
OperandX8632Mem *Mem)
: InstX8632(Func, InstX8632::StoreP, 2, NULL) {
: InstX8632(Func, InstX8632::StoreP, 2, nullptr) {
addSource(Value);
addSource(Mem);
}
InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Variable *Value,
OperandX8632Mem *Mem)
: InstX8632(Func, InstX8632::StoreQ, 2, NULL) {
: InstX8632(Func, InstX8632::StoreQ, 2, nullptr) {
addSource(Value);
addSource(Mem);
}
InstX8632Nop::InstX8632Nop(Cfg *Func, InstX8632Nop::NopVariant Variant)
: InstX8632(Func, InstX8632::Nop, 0, NULL), Variant(Variant) {}
: InstX8632(Func, InstX8632::Nop, 0, nullptr), Variant(Variant) {}
InstX8632Fld::InstX8632Fld(Cfg *Func, Operand *Src)
: InstX8632(Func, InstX8632::Fld, 1, NULL) {
: InstX8632(Func, InstX8632::Fld, 1, nullptr) {
addSource(Src);
}
......@@ -316,12 +316,12 @@ InstX8632Pop::InstX8632Pop(Cfg *Func, Variable *Dest)
: InstX8632(Func, InstX8632::Pop, 0, Dest) {}
InstX8632Push::InstX8632Push(Cfg *Func, Variable *Source)
: InstX8632(Func, InstX8632::Push, 1, NULL) {
: InstX8632(Func, InstX8632::Push, 1, nullptr) {
addSource(Source);
}
InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source)
: InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) {
: InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, nullptr) {
if (Source)
addSource(Source);
}
......
......@@ -67,7 +67,7 @@ public:
SegReg_NUM
};
static OperandX8632Mem *create(Cfg *Func, Type Ty, Variable *Base,
Constant *Offset, Variable *Index = NULL,
Constant *Offset, Variable *Index = nullptr,
uint16_t Shift = 0,
SegmentRegisters SegmentReg = DefaultSegment) {
return new (Func->allocate<OperandX8632Mem>())
......@@ -165,7 +165,7 @@ public:
// Inherit dump() and emit() from Variable.
private:
SpillVariable(Type Ty, SizeT Index)
: Variable(SpillVariableKind, Ty, Index), LinkedTo(NULL) {}
: Variable(SpillVariableKind, Ty, Index), LinkedTo(nullptr) {}
Variable *LinkedTo;
};
......@@ -344,14 +344,14 @@ public:
static InstX8632Br *create(Cfg *Func, CfgNode *TargetTrue,
CfgNode *TargetFalse, CondX86::BrCond Condition) {
assert(Condition != CondX86::Br_None);
const InstX8632Label *NoLabel = NULL;
const InstX8632Label *NoLabel = nullptr;
return new (Func->allocate<InstX8632Br>())
InstX8632Br(Func, TargetTrue, TargetFalse, NoLabel, Condition);
}
// Create an unconditional branch to a node.
static InstX8632Br *create(Cfg *Func, CfgNode *Target) {
const CfgNode *NoCondTarget = NULL;
const InstX8632Label *NoLabel = NULL;
const CfgNode *NoCondTarget = nullptr;
const InstX8632Label *NoLabel = nullptr;
return new (Func->allocate<InstX8632Br>())
InstX8632Br(Func, NoCondTarget, Target, NoLabel, CondX86::Br_None);
}
......@@ -361,8 +361,8 @@ public:
static InstX8632Br *create(Cfg *Func, CfgNode *Target,
CondX86::BrCond Condition) {
assert(Condition != CondX86::Br_None);
const CfgNode *NoUncondTarget = NULL;
const InstX8632Label *NoLabel = NULL;
const CfgNode *NoUncondTarget = nullptr;
const InstX8632Label *NoLabel = nullptr;
return new (Func->allocate<InstX8632Br>())
InstX8632Br(Func, Target, NoUncondTarget, NoLabel, Condition);
}
......@@ -370,8 +370,8 @@ public:
// Condition==Br_None) to a label in the current block.
static InstX8632Br *create(Cfg *Func, InstX8632Label *Label,
CondX86::BrCond Condition) {
const CfgNode *NoCondTarget = NULL;
const CfgNode *NoUncondTarget = NULL;
const CfgNode *NoCondTarget = nullptr;
const CfgNode *NoUncondTarget = nullptr;
return new (Func->allocate<InstX8632Br>())
InstX8632Br(Func, NoCondTarget, NoUncondTarget, Label, Condition);
}
......@@ -1486,7 +1486,7 @@ class InstX8632Ret : public InstX8632 {
InstX8632Ret &operator=(const InstX8632Ret &) = delete;
public:
static InstX8632Ret *create(Cfg *Func, Variable *Source = NULL) {
static InstX8632Ret *create(Cfg *Func, Variable *Source = nullptr) {
return new (Func->allocate<InstX8632Ret>()) InstX8632Ret(Func, Source);
}
void emit(const Cfg *Func) const override;
......
......@@ -217,7 +217,7 @@ const Intrinsics::FullIntrinsicInfo *
Intrinsics::find(const IceString &Name) const {
auto it = Map.find(Name);
if (it == Map.end())
return NULL;
return nullptr;
return &it->second;
}
......@@ -231,7 +231,7 @@ Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call,
SizeT &ArgIndex) const {
assert(NumTypes >= 1);
Variable *Result = Call->getDest();
if (Result == NULL) {
if (Result == nullptr) {
if (Signature[0] != Ice::IceType_void)
return Intrinsics::BadReturnType;
} else if (Signature[0] != Result->getType()) {
......
......@@ -51,11 +51,11 @@ void Liveness::init() {
// Resize each LivenessNode::LiveToVarMap, and the global
// LiveToVarMap. Reset the counts to 0.
for (SizeT i = 0; i < NumNodes; ++i) {
Nodes[i].LiveToVarMap.assign(Nodes[i].NumLocals, NULL);
Nodes[i].LiveToVarMap.assign(Nodes[i].NumLocals, nullptr);
Nodes[i].NumLocals = 0;
Nodes[i].NumNonDeadPhis = 0;
}
LiveToVarMap.assign(NumGlobals, NULL);
LiveToVarMap.assign(NumGlobals, nullptr);
// Sort each variable into the appropriate LiveToVarMap. Also set
// VarToLiveMap.
......
......@@ -179,7 +179,7 @@ void VariableTracking::markUse(MetadataKind TrackingKind, const Inst *Instr,
if (MakeMulti) {
MultiBlock = MBS_MultiBlock;
SingleUseNode = NULL;
SingleUseNode = nullptr;
}
}
......@@ -195,7 +195,7 @@ void VariableTracking::markDef(MetadataKind TrackingKind, const Inst *Instr,
if (TrackingKind == VMK_All) {
const Inst *LastInstruction =
Definitions.empty() ? FirstOrSingleDefinition : Definitions.back();
assert(LastInstruction == NULL ||
assert(LastInstruction == nullptr ||
Instr->getNumber() >= LastInstruction->getNumber());
}
#endif
......@@ -204,13 +204,13 @@ void VariableTracking::markDef(MetadataKind TrackingKind, const Inst *Instr,
markUse(TrackingKind, Instr, Node, IsFromDef, IsImplicit);
if (TrackingKind == VMK_Uses)
return;
if (FirstOrSingleDefinition == NULL)
if (FirstOrSingleDefinition == nullptr)
FirstOrSingleDefinition = Instr;
else if (TrackingKind == VMK_All)
Definitions.push_back(Instr);
switch (MultiDef) {
case MDS_Unknown:
assert(SingleDefNode == NULL);
assert(SingleDefNode == nullptr);
MultiDef = MDS_SingleDef;
SingleDefNode = Node;
break;
......@@ -220,18 +220,18 @@ void VariableTracking::markDef(MetadataKind TrackingKind, const Inst *Instr,
MultiDef = MDS_MultiDefSingleBlock;
} else {
MultiDef = MDS_MultiDefMultiBlock;
SingleDefNode = NULL;
SingleDefNode = nullptr;
}
break;
case MDS_MultiDefSingleBlock:
assert(SingleDefNode);
if (Node != SingleDefNode) {
MultiDef = MDS_MultiDefMultiBlock;
SingleDefNode = NULL;
SingleDefNode = nullptr;
}
break;
case MDS_MultiDefMultiBlock:
assert(SingleDefNode == NULL);
assert(SingleDefNode == nullptr);
break;
}
}
......@@ -240,13 +240,13 @@ const Inst *VariableTracking::getFirstDefinition() const {
switch (MultiDef) {
case MDS_Unknown:
case MDS_MultiDefMultiBlock:
return NULL;
return nullptr;
case MDS_SingleDef:
case MDS_MultiDefSingleBlock:
assert(FirstOrSingleDefinition);
return FirstOrSingleDefinition;
}
return NULL;
return nullptr;
}
const Inst *VariableTracking::getSingleDefinition() const {
......@@ -254,12 +254,12 @@ const Inst *VariableTracking::getSingleDefinition() const {
case MDS_Unknown:
case MDS_MultiDefMultiBlock:
case MDS_MultiDefSingleBlock:
return NULL;
return nullptr;
case MDS_SingleDef:
assert(FirstOrSingleDefinition);
return FirstOrSingleDefinition;
}
return NULL;
return nullptr;
}
void VariablesMetadata::init(MetadataKind TrackingKind) {
......@@ -270,7 +270,7 @@ void VariablesMetadata::init(MetadataKind TrackingKind) {
// Mark implicit args as being used in the entry node.
for (Variable *Var : Func->getImplicitArgs()) {
const Inst *NoInst = NULL;
const Inst *NoInst = nullptr;
const CfgNode *EntryNode = Func->getEntryNode();
const bool IsFromDef = false;
const bool IsImplicit = true;
......@@ -356,7 +356,7 @@ bool VariablesMetadata::isMultiBlock(const Variable *Var) const {
const Inst *VariablesMetadata::getFirstDefinition(const Variable *Var) const {
assert(Kind != VMK_Uses);
if (!isTracked(Var))
return NULL; // conservative answer
return nullptr; // conservative answer
SizeT VarNum = Var->getIndex();
return Metadata[VarNum].getFirstDefinition();
}
......@@ -364,7 +364,7 @@ const Inst *VariablesMetadata::getFirstDefinition(const Variable *Var) const {
const Inst *VariablesMetadata::getSingleDefinition(const Variable *Var) const {
assert(Kind != VMK_Uses);
if (!isTracked(Var))
return NULL; // conservative answer
return nullptr; // conservative answer
SizeT VarNum = Var->getIndex();
return Metadata[VarNum].getSingleDefinition();
}
......@@ -380,7 +380,7 @@ VariablesMetadata::getLatterDefinitions(const Variable *Var) const {
const CfgNode *VariablesMetadata::getLocalUseNode(const Variable *Var) const {
if (!isTracked(Var))
return NULL; // conservative answer
return nullptr; // conservative answer
SizeT VarNum = Var->getIndex();
return Metadata[VarNum].getNode();
}
......@@ -397,7 +397,7 @@ void Variable::emit(const Cfg *Func) const {
void Variable::dump(const Cfg *Func, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
if (Func == NULL) {
if (Func == nullptr) {
Str << "%" << getName(Func);
return;
}
......
......@@ -62,7 +62,7 @@ public:
}
virtual void emit(const Cfg *Func) const = 0;
// The dump(Func,Str) implementation must be sure to handle the
// situation where Func==NULL.
// situation where Func==nullptr.
virtual void dump(const Cfg *Func, Ostream &Str) const = 0;
void dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
......@@ -72,7 +72,7 @@ public:
}
void dump(Ostream &Str) const {
if (ALLOW_DUMP)
dump(NULL, Str);
dump(nullptr, Str);
}
// Query whether this object was allocated in isolation, or added to
......@@ -86,7 +86,7 @@ public:
protected:
Operand(OperandKind Kind, Type Ty)
: Ty(Ty), Kind(Kind), NumVars(0), Vars(NULL) {}
: Ty(Ty), Kind(Kind), NumVars(0), Vars(nullptr) {}
const Type Ty;
const OperandKind Kind;
......@@ -122,7 +122,7 @@ public:
protected:
Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID)
: Operand(Kind, Ty), PoolEntryID(PoolEntryID) {
Vars = NULL;
Vars = nullptr;
NumVars = 0;
}
~Constant() override {}
......@@ -457,8 +457,8 @@ public:
Variable *getLo() const { return LoVar; }
Variable *getHi() const { return HiVar; }
void setLoHi(Variable *Lo, Variable *Hi) {
assert(LoVar == NULL);
assert(HiVar == NULL);
assert(LoVar == nullptr);
assert(HiVar == nullptr);
LoVar = Lo;
HiVar = Hi;
}
......@@ -483,7 +483,7 @@ protected:
: Operand(K, Ty), Number(Index), NameIndex(Cfg::IdentifierIndexInvalid),
IsArgument(false), IsImplicitArgument(false), IgnoreLiveness(false),
StackOffset(0), RegNum(NoRegister), RegNumTmp(NoRegister), Weight(1),
LoVar(NULL), HiVar(NULL) {
LoVar(nullptr), HiVar(nullptr) {
Vars = VarsReal;
Vars[0] = this;
NumVars = 1;
......@@ -550,8 +550,8 @@ public:
MBS_MultiBlock
};
VariableTracking()
: MultiDef(MDS_Unknown), MultiBlock(MBS_Unknown), SingleUseNode(NULL),
SingleDefNode(NULL), FirstOrSingleDefinition(NULL) {}
: MultiDef(MDS_Unknown), MultiBlock(MBS_Unknown), SingleUseNode(nullptr),
SingleDefNode(nullptr), FirstOrSingleDefinition(nullptr) {}
MultiDefState getMultiDef() const { return MultiDef; }
MultiBlockState getMultiBlock() const { return MultiBlock; }
const Inst *getFirstDefinition() const;
......@@ -603,10 +603,10 @@ public:
// the same block, e.g. T after the lowered sequence "T=B; T+=C;
// A=T", for which getFirstDefinition(T) would return the "T=B"
// instruction. For variables with definitions span multiple
// blocks, NULL is returned.
// blocks, nullptr is returned.
const Inst *getFirstDefinition(const Variable *Var) const;
// Returns the definition instruction of the given Variable, when
// the variable has exactly one definition. Otherwise, NULL is
// the variable has exactly one definition. Otherwise, nullptr is
// returned.
const Inst *getSingleDefinition(const Variable *Var) const;
// Returns the list of all definition instructions of the given
......@@ -622,7 +622,7 @@ public:
// entry block.
bool isMultiBlock(const Variable *Var) const;
// Returns the node that the given Variable is used in, assuming
// isMultiBlock() returns false. Otherwise, NULL is returned.
// isMultiBlock() returns false. Otherwise, nullptr is returned.
const CfgNode *getLocalUseNode(const Variable *Var) const;
private:
......
......@@ -410,7 +410,7 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull,
// but is never modified. Furthermore, overlap is only allowed
// when preferred Variable definition instructions do not appear
// within the current Variable's live range.
Variable *Prefer = NULL;
Variable *Prefer = nullptr;
int32_t PreferReg = Variable::NoRegister;
bool AllowOverlap = false;
if (FindPreference) {
......
......@@ -98,7 +98,7 @@ TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) {
return IceTargetARM64::create(Func);
#endif
Func->setError("Unsupported target");
return NULL;
return nullptr;
}
TargetLowering::TargetLowering(Cfg *Func)
......@@ -113,7 +113,7 @@ Assembler *TargetLowering::createAssembler(TargetArch Target, Cfg *Func) {
if (Target == Target_X8632)
return new x86::AssemblerX86();
Func->setError("Unsupported target");
return NULL;
return nullptr;
}
void TargetLowering::doAddressOpt() {
......@@ -267,7 +267,7 @@ TargetGlobalInitLowering::createLowering(TargetArch Target,
return IceTargetGlobalInitARM64::create(Ctx);
#endif
llvm_unreachable("Unsupported target");
return NULL;
return nullptr;
}
TargetGlobalInitLowering::~TargetGlobalInitLowering() {}
......
......@@ -37,18 +37,18 @@ class LoweringContext {
LoweringContext &operator=(const LoweringContext &) = delete;
public:
LoweringContext() : Node(NULL), LastInserted(NULL) {}
LoweringContext() : Node(nullptr), LastInserted(nullptr) {}
~LoweringContext() {}
void init(CfgNode *Node);
Inst *getNextInst() const {
if (Next == End)
return NULL;
return nullptr;
return Next;
}
Inst *getNextInst(InstList::iterator &Iter) const {
advanceForward(Iter);
if (Iter == End)
return NULL;
return nullptr;
return Iter;
}
CfgNode *getNode() const { return Node; }
......
......@@ -292,12 +292,12 @@ protected:
Context.insert(InstX8632Lea::create(Func, Dest, Src0));
}
void _mfence() { Context.insert(InstX8632Mfence::create(Func)); }
// If Dest=NULL is passed in, then a new variable is created, marked
// as infinite register allocation weight, and returned through the
// in/out Dest argument.
// If Dest=nullptr is passed in, then a new variable is created,
// marked as infinite register allocation weight, and returned
// through the in/out Dest argument.
void _mov(Variable *&Dest, Operand *Src0,
int32_t RegNum = Variable::NoRegister) {
if (Dest == NULL)
if (Dest == nullptr)
Dest = makeReg(Src0->getType(), RegNum);
Context.insert(InstX8632Mov::create(Func, Dest, Src0));
}
......@@ -396,7 +396,7 @@ protected:
void _pxor(Variable *Dest, Operand *Src0) {
Context.insert(InstX8632Pxor::create(Func, Dest, Src0));
}
void _ret(Variable *Src0 = NULL) {
void _ret(Variable *Src0 = nullptr) {
Context.insert(InstX8632Ret::create(Func, Src0));
}
void _rol(Variable *Dest, Operand *Src0) {
......
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