MCPcopy Create free account
hub / github.com/Chemiculs/qengine / initWorkData

Method initWorkData

src/qengine/extern/asmjit/core/funcargscontext.cpp:20–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20ASMJIT_FAVOR_SIZE Error FuncArgsContext::initWorkData(const FuncFrame& frame, const FuncArgsAssignment& args, const RAConstraints* constraints) noexcept {
21 Arch arch = frame.arch();
22 const FuncDetail& func = *args.funcDetail();
23
24 _archTraits = &ArchTraits::byArch(arch);
25 _constraints = constraints;
26 _arch = arch;
27
28 // Initialize `_archRegs`.
29 for (RegGroup group : RegGroupVirtValues{})
30 _workData[group]._archRegs = _constraints->availableRegs(group);
31
32 if (frame.hasPreservedFP())
33 _workData[size_t(RegGroup::kGp)]._archRegs &= ~Support::bitMask(archTraits().fpRegId());
34
35 // Extract information from all function arguments/assignments and build Var[] array.
36 uint32_t varId = 0;
37 for (uint32_t argIndex = 0; argIndex < Globals::kMaxFuncArgs; argIndex++) {
38 for (uint32_t valueIndex = 0; valueIndex < Globals::kMaxValuePack; valueIndex++) {
39 const FuncValue& dst_ = args.arg(argIndex, valueIndex);
40 if (!dst_.isAssigned())
41 continue;
42
43 const FuncValue& src_ = func.arg(argIndex, valueIndex);
44 if (ASMJIT_UNLIKELY(!src_.isAssigned()))
45 return DebugUtils::errored(kErrorInvalidState);
46
47 Var& var = _vars[varId];
48 var.init(src_, dst_);
49
50 FuncValue& src = var.cur;
51 FuncValue& dst = var.out;
52
53 RegGroup dstGroup = RegGroup::kMaxValue;
54 uint32_t dstId = BaseReg::kIdBad;
55 WorkData* dstWd = nullptr;
56
57 // Not supported.
58 if (src.isIndirect())
59 return DebugUtils::errored(kErrorInvalidAssignment);
60
61 if (dst.isReg()) {
62 RegType dstType = dst.regType();
63 if (ASMJIT_UNLIKELY(!archTraits().hasRegType(dstType)))
64 return DebugUtils::errored(kErrorInvalidRegType);
65
66 // Copy TypeId from source if the destination doesn't have it. The RA used by BaseCompiler would never
67 // leave TypeId undefined, but users of FuncAPI can just assign phys regs without specifying the type.
68 if (!dst.hasTypeId())
69 dst.setTypeId(archTraits().regTypeToTypeId(dst.regType()));
70
71 dstGroup = archTraits().regTypeToGroup(dstType);
72 if (ASMJIT_UNLIKELY(dstGroup > RegGroup::kMaxVirt))
73 return DebugUtils::errored(kErrorInvalidRegGroup);
74
75 dstWd = &_workData[dstGroup];
76 dstId = dst.regId();
77 if (ASMJIT_UNLIKELY(dstId >= 32 || !Support::bitTest(dstWd->archRegs(), dstId)))

Callers 2

emitArgsAssignmentMethod · 0.80
updateFuncFrameMethod · 0.80

Calls 15

bitMaskFunction · 0.85
erroredFunction · 0.85
bitTestFunction · 0.85
is32BitFunction · 0.85
ctzFunction · 0.85
funcDetailMethod · 0.80
hasPreservedFPMethod · 0.80
fpRegIdMethod · 0.80
argMethod · 0.80
isIndirectMethod · 0.80
hasTypeIdMethod · 0.80
setTypeIdMethod · 0.80

Tested by

no test coverage detected