MCPcopy Create free account
hub / github.com/akyoto/q / executeLoad

Method executeLoad

src/codegen/executeLoad.go:9–39  ·  view source on GitHub ↗
(step *Step, instr *ssa.Load)

Source from the content-addressed store, hash-verified

7 "git.urbach.dev/cli/q/src/ssa"
8 "git.urbach.dev/cli/q/src/types"
9)
10
11func (f *Function) executeLoad(step *Step, instr *ssa.Load) {
12 if step.Register == -1 {
13 return
14 }
15
16 memory := instr.Memory
17 address := f.ValueToStep[memory.Address]
18 index := f.ValueToStep[memory.Index]
19 elementType := step.Value.Type()
20 elementSize := elementType.Size()
21 live := slices.Concat(step.Live, []*Step{address, index})
22 baseRegister := f.resolveOperand(address, live)
23 indexRegister := f.resolveOperand(index, live, baseRegister)
24 destination := step.Register
25 isSpilled := f.isSpilled(destination)
26
27 if isSpilled {
28 destination = f.findTempRegister(live, baseRegister, indexRegister)
29 }
30
31 if index.Register == -1 {
32 fixedOffset := index.Value.(*ssa.Int).Int
33 f.Assembler.Append(&asm.LoadFixedOffset{
34 Base: baseRegister,
35 Index: fixedOffset,
36 Destination: destination,
37 Scale: memory.Scale,
38 Length: byte(elementSize),
39 Signed: types.IsSigned(elementType),
40 })
41 } else {
42 f.Assembler.Append(&asm.Load{

Callers 1

executeMethod · 0.95

Calls 4

IsUnsignedFunction · 0.92
TypeMethod · 0.65
SizeMethod · 0.65
AppendMethod · 0.45

Tested by

no test coverage detected