本文整理汇总了C++中Vunit::makeConst方法的典型用法代码示例。如果您正苦于以下问题:C++ Vunit::makeConst方法的具体用法?C++ Vunit::makeConst怎么用?C++ Vunit::makeConst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vunit
的用法示例。
在下文中一共展示了Vunit::makeConst方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.
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 = tmp->isA(Type::Bool) ? vunit.makeConst(tmp->boolVal())
: 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));
}
}
}
}
示例2: make_const
Vreg make_const(Vunit& unit, Type type) {
if (type.subtypeOfAny(TUninit, TInitNull)) {
// Return undefined value.
return unit.makeConst(Vconst::Quad);
}
if (type <= TNullptr) return unit.makeConst(0);
assertx(type.hasConstVal());
if (type <= TBool) return unit.makeConst(type.boolVal());
if (type <= TDbl) return unit.makeConst(type.dblVal());
return unit.makeConst(type.rawVal());
}