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

Function createSteps

src/codegen/createSteps.go:6–44  ·  view source on GitHub ↗

createSteps builds a series of instructions from the SSA values in the IR.

(ir ssa.IR)

Source from the content-addressed store, hash-verified

4
5// createSteps builds a series of instructions from the SSA values in the IR.
6func createSteps(ir ssa.IR) IR {
7 count := ir.CountValues() + len(ir.Blocks) - 1
8 storage := make([]Step, count)
9 steps := make([]*Step, count)
10 valueToStep := make(map[ssa.Value]*Step, count)
11 blockToRegion := make(map[*ssa.Block]region, len(ir.Blocks))
12 i := Index(0)
13
14 for _, block := range ir.Blocks {
15 if block != ir.Blocks[0] {
16 step := &storage[i]
17 step.Index = i
18 step.Value = &Label{Name: block.Label}
19 step.Block = block
20 step.Register = -1
21 steps[i] = step
22 i++
23 }
24
25 blockToRegion[block] = region{
26 Start: uint32(i),
27 End: uint32(i + Index(len(block.Instructions))),
28 }
29
30 for _, instr := range block.Instructions {
31 step := &storage[i]
32 step.Index = i
33 step.Value = instr
34 step.Block = block
35 step.Register = -1
36 step.Live = make([]*Step, 0, 4)
37 steps[i] = step
38 valueToStep[instr] = step
39 i++
40 }
41 }
42
43 return IR{steps, valueToStep, blockToRegion}
44}

Callers 1

CompileToAssemblyMethod · 0.85

Calls 2

IndexTypeAlias · 0.85
CountValuesMethod · 0.80

Tested by

no test coverage detected