本文整理汇总了C++中Vunit::makeReg方法的典型用法代码示例。如果您正苦于以下问题:C++ Vunit::makeReg方法的具体用法?C++ Vunit::makeReg怎么用?C++ Vunit::makeReg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vunit
的用法示例。
在下文中一共展示了Vunit::makeReg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assignRegs
// Assign virtual registers to all SSATmps used or defined in reachable
// blocks. This assigns a value register to constants defined by DefConst,
// because some HHIR instructions require them. Ordinary Gen values with
// a known DataType only get one register. Assign "wide" locations when
// possible (when all uses and defs can be wide). These will be assigned
// SIMD registers later.
void assignRegs(IRUnit& unit, Vunit& vunit, CodegenState& state,
const BlockList& blocks, BackEnd* backend) {
// visit instructions to find tmps eligible to use SIMD registers
auto const try_wide = !packed_tv && RuntimeOption::EvalHHIRAllocSIMDRegs;
boost::dynamic_bitset<> not_wide(unit.numTmps());
StateVector<SSATmp,SSATmp*> tmps(unit, nullptr);
for (auto block : blocks) {
for (auto& inst : *block) {
for (uint32_t i = 0, n = inst.numSrcs(); i < n; i++) {
auto s = inst.src(i);
tmps[s] = s;
if (!try_wide || !backend->storesCell(inst, i)) {
not_wide.set(s->id());
}
}
for (auto& d : inst.dsts()) {
tmps[&d] = &d;
if (!try_wide || inst.isControlFlow() || !backend->loadsCell(inst)) {
not_wide.set(d.id());
}
}
}
}
// visit each tmp, assign 1 or 2 registers to each.
auto cns = [&](uint64_t c) { return vunit.makeConst(c); };
for (auto tmp : tmps) {
if (!tmp) continue;
auto forced = forceAlloc(*tmp);
if (forced != InvalidReg) {
state.locs[tmp] = Vloc{forced};
UNUSED Reg64 r = forced;
FTRACE(kRegAllocLevel, "force t{} in {}\n", tmp->id(), reg::regname(r));
continue;
}
if (tmp->inst()->is(DefConst)) {
auto c = cns(tmp->rawVal());
state.locs[tmp] = Vloc{c};
FTRACE(kRegAllocLevel, "const t{} in %{}\n", tmp->id(), size_t(c));
} else {
if (tmp->numWords() == 2) {
if (!not_wide.test(tmp->id())) {
auto r = vunit.makeReg();
state.locs[tmp] = Vloc{Vloc::kWide, r};
FTRACE(kRegAllocLevel, "def t{} in wide %{}\n", tmp->id(), size_t(r));
} else {
auto data = vunit.makeReg();
auto type = vunit.makeReg();
state.locs[tmp] = Vloc{data, type};
FTRACE(kRegAllocLevel, "def t{} in %{},%{}\n", tmp->id(),
size_t(data), size_t(type));
}
} else {
auto data = vunit.makeReg();
state.locs[tmp] = Vloc{data};
FTRACE(kRegAllocLevel, "def t{} in %{}\n", tmp->id(), size_t(data));
}
}
}
}
示例2: assert
jit::vector<VMoveInfo>
doVregMoves(Vunit& unit, MovePlan& moves) {
constexpr auto N = 64;
assert(std::max(x64::abi.all().size(), arm::abi.all().size()) == N);
jit::vector<VMoveInfo> howTo;
CycleInfo cycle_mem[N];
List<CycleInfo> cycles(cycle_mem, 0, N);
PhysReg::Map<int> outDegree;
PhysReg::Map<int> index;
for (auto reg : moves) {
// Ignore moves from a register to itself
if (reg == moves[reg]) moves[reg] = InvalidReg;
index[reg] = -1;
}
// Iterate over the nodes filling in outDegree[] and cycles[] as we go
int nextIndex = 0;
for (auto reg : moves) {
// skip registers we've visited already.
if (index[reg] >= 0) continue;
// Begin walking a path from reg.
for (auto node = reg;;) {
assert(nextIndex < N);
index[node] = nextIndex++;
auto next = moves[node];
if (next != InvalidReg) {
++outDegree[next];
if (index[next] < 0) {
// There is an edge from node to next, and next has not been
// visited. Extend current path to include next, then loop.
node = next;
continue;
}
// next already visited; check if next is on current path.
if (index[next] >= index[reg]) {
// found a cycle.
cycles.push_back({ next, nextIndex - index[next] });
}
}
break;
}
}
// Handle all moves that aren't part of a cycle. Only nodes with outdegree
// zero are put into the queue, which is how nodes in a cycle get excluded.
{
PhysReg q[N];
int qBack = 0;
auto enque = [&](PhysReg r) { assert(qBack < N); q[qBack++] = r; };
for (auto node : outDegree) {
if (outDegree[node] == 0) enque(node);
}
for (int i = 0; i < qBack; ++i) {
auto node = q[i];
if (moves[node] == InvalidReg) continue;
auto nextNode = moves[node];
howTo.push_back({VMoveInfo::Kind::Move, nextNode, node});
--outDegree[nextNode];
if (outDegree[nextNode] == 0) enque(nextNode);
}
}
// Deal with any cycles we encountered
for (auto const& cycle : cycles) {
// can't use xchg if one of the registers is SIMD
bool hasSIMDReg = cycleHasSIMDReg(cycle, moves);
if (cycle.length == 2 && !hasSIMDReg) {
auto v = cycle.node;
auto w = moves[v];
howTo.push_back({VMoveInfo::Kind::Xchg, w, v});
} else if (cycle.length == 3 && !hasSIMDReg) {
auto v = cycle.node;
auto w = moves[v];
howTo.push_back({VMoveInfo::Kind::Xchg, w, v});
auto x = moves[w];
howTo.push_back({VMoveInfo::Kind::Xchg, x, w});
} else {
auto t = unit.makeReg();
auto v = cycle.node;
howTo.push_back({VMoveInfo::Kind::Move, v, t});
auto w = v;
auto x = moves[w];
while (x != v) {
howTo.push_back({VMoveInfo::Kind::Move, x, w});
w = x;
x = moves[w];
}
howTo.push_back({VMoveInfo::Kind::Move, t, w});
}
}
return howTo;
}
示例3: assignRegs
// Assign virtual registers to all SSATmps used or defined in reachable
// blocks. This assigns a value register to constants defined by DefConst,
// because some HHIR instructions require them. Ordinary Gen values with
// a known DataType only get one register. Assign "wide" locations when
// possible (when all uses and defs can be wide). These will be assigned
// SIMD registers later.
void assignRegs(IRUnit& unit, Vunit& vunit, irlower::IRLS& state,
const BlockList& blocks) {
// visit instructions to find tmps eligible to use SIMD registers
auto const try_wide = RuntimeOption::EvalHHIRAllocSIMDRegs;
boost::dynamic_bitset<> not_wide(unit.numTmps());
StateVector<SSATmp,SSATmp*> tmps(unit, nullptr);
for (auto block : blocks) {
for (auto& inst : *block) {
for (uint32_t i = 0, n = inst.numSrcs(); i < n; i++) {
auto s = inst.src(i);
tmps[s] = s;
if (!try_wide || !storesCell(inst, i)) {
not_wide.set(s->id());
}
}
for (auto& d : inst.dsts()) {
tmps[d] = d;
if (!try_wide || inst.isControlFlow() || !loadsCell(inst.op())) {
not_wide.set(d->id());
}
}
}
}
// visit each tmp, assign 1 or 2 registers to each.
for (auto tmp : tmps) {
if (!tmp) continue;
auto forced = forceAlloc(*tmp);
if (forced != InvalidReg) {
state.locs[tmp] = Vloc{forced};
UNUSED Reg64 r = forced;
FTRACE(kRegAllocLevel, "force t{} in {}\n", tmp->id(), reg::regname(r));
continue;
}
if (tmp->inst()->is(DefConst)) {
auto const type = tmp->type();
Vreg c;
if (type.subtypeOfAny(TNull, TNullptr)) {
c = vunit.makeConst(0);
} else if (type <= TBool) {
c = vunit.makeConst(tmp->boolVal());
} else if (type <= TDbl) {
c = vunit.makeConst(tmp->dblVal());
} else {
c = vunit.makeConst(tmp->rawVal());
}
state.locs[tmp] = Vloc{c};
FTRACE(kRegAllocLevel, "const t{} in %{}\n", tmp->id(), size_t(c));
} else {
if (tmp->numWords() == 2) {
if (!not_wide.test(tmp->id())) {
auto r = vunit.makeReg();
state.locs[tmp] = Vloc{Vloc::kWide, r};
FTRACE(kRegAllocLevel, "def t{} in wide %{}\n", tmp->id(), size_t(r));
} else {
auto data = vunit.makeReg();
auto type = vunit.makeReg();
state.locs[tmp] = Vloc{data, type};
FTRACE(kRegAllocLevel, "def t{} in %{},%{}\n", tmp->id(),
size_t(data), size_t(type));
}
} else {
auto data = vunit.makeReg();
state.locs[tmp] = Vloc{data};
FTRACE(kRegAllocLevel, "def t{} in %{}\n", tmp->id(), size_t(data));
}
}
}
}