X7ROOT File Manager
Current Path:
/opt/golang/1.19.4/src/cmd/compile/internal/ssa
opt
/
golang
/
1.19.4
/
src
/
cmd
/
compile
/
internal
/
ssa
/
📁
..
📄
README.md
(8.14 KB)
📄
TODO
(950 B)
📄
addressingmodes.go
(23.64 KB)
📄
bench_test.go
(531 B)
📄
biasedsparsemap.go
(2.71 KB)
📄
block.go
(11.1 KB)
📄
branchelim.go
(11.98 KB)
📄
branchelim_test.go
(5.21 KB)
📄
cache.go
(2.46 KB)
📄
check.go
(16.59 KB)
📄
checkbce.go
(956 B)
📄
compile.go
(18.19 KB)
📄
config.go
(11.7 KB)
📄
copyelim.go
(1.83 KB)
📄
copyelim_test.go
(1.29 KB)
📄
critical.go
(3.19 KB)
📄
cse.go
(9.43 KB)
📄
cse_test.go
(4.25 KB)
📄
deadcode.go
(9.61 KB)
📄
deadcode_test.go
(3.49 KB)
📄
deadstore.go
(9.08 KB)
📄
deadstore_test.go
(4.09 KB)
📄
debug.go
(56.34 KB)
📄
debug_lines_test.go
(8.29 KB)
📄
debug_test.go
(28.75 KB)
📄
decompose.go
(13.41 KB)
📄
dom.go
(7.98 KB)
📄
dom_test.go
(13.34 KB)
📄
expand_calls.go
(63.5 KB)
📄
export_test.go
(3.23 KB)
📄
flagalloc.go
(6.68 KB)
📄
flags_amd64_test.s
(533 B)
📄
flags_arm64_test.s
(699 B)
📄
flags_test.go
(2.49 KB)
📄
func.go
(27.08 KB)
📄
func_test.go
(13.07 KB)
📄
fuse.go
(6.5 KB)
📄
fuse_branchredirect.go
(3.24 KB)
📄
fuse_comparisons.go
(4.04 KB)
📄
fuse_test.go
(7.21 KB)
📁
gen
📄
html.go
(34.72 KB)
📄
id.go
(576 B)
📄
layout.go
(4.82 KB)
📄
lca.go
(3.77 KB)
📄
lca_test.go
(1.65 KB)
📄
likelyadjust.go
(15.24 KB)
📄
location.go
(3.06 KB)
📄
loopbce.go
(10.54 KB)
📄
loopreschedchecks.go
(15.86 KB)
📄
looprotate.go
(2.61 KB)
📄
lower.go
(1.36 KB)
📄
magic.go
(15.77 KB)
📄
magic_test.go
(9.1 KB)
📄
nilcheck.go
(11.06 KB)
📄
nilcheck_test.go
(12.17 KB)
📄
numberlines.go
(7.83 KB)
📄
op.go
(18.65 KB)
📄
opGen.go
(1.01 MB)
📄
opt.go
(308 B)
📄
passbm_test.go
(3.14 KB)
📄
phielim.go
(1.48 KB)
📄
phiopt.go
(8.08 KB)
📄
poset.go
(37.2 KB)
📄
poset_test.go
(18.14 KB)
📄
print.go
(3.85 KB)
📄
prove.go
(41.82 KB)
📄
regalloc.go
(83.69 KB)
📄
regalloc_test.go
(6.49 KB)
📄
rewrite.go
(53.49 KB)
📄
rewrite386.go
(289.01 KB)
📄
rewrite386splitload.go
(4.05 KB)
📄
rewriteAMD64.go
(888.95 KB)
📄
rewriteAMD64splitload.go
(21.41 KB)
📄
rewriteARM.go
(487.7 KB)
📄
rewriteARM64.go
(751.84 KB)
📄
rewriteCond_test.go
(10.62 KB)
📄
rewriteLOONG64.go
(193.44 KB)
📄
rewriteMIPS.go
(174.44 KB)
📄
rewriteMIPS64.go
(195.55 KB)
📄
rewritePPC64.go
(431.6 KB)
📄
rewriteRISCV64.go
(159.66 KB)
📄
rewriteS390X.go
(433.4 KB)
📄
rewriteWasm.go
(109.86 KB)
📄
rewrite_test.go
(6.91 KB)
📄
rewritedec.go
(10.16 KB)
📄
rewritedec64.go
(63.77 KB)
📄
rewritegeneric.go
(617.96 KB)
📄
schedule.go
(18.23 KB)
📄
schedule_test.go
(2.91 KB)
📄
shift_test.go
(4.05 KB)
📄
shortcircuit.go
(12.63 KB)
📄
shortcircuit_test.go
(1.31 KB)
📄
sizeof_test.go
(855 B)
📄
softfloat.go
(1.99 KB)
📄
sparsemap.go
(1.98 KB)
📄
sparseset.go
(1.54 KB)
📄
sparsetree.go
(8.05 KB)
📄
stackalloc.go
(12.79 KB)
📄
stackframe.go
(290 B)
📄
stmtlines_test.go
(2.96 KB)
📁
testdata
📄
tighten.go
(4.3 KB)
📄
trim.go
(4.24 KB)
📄
tuple.go
(1.97 KB)
📄
value.go
(15.21 KB)
📄
writebarrier.go
(19.29 KB)
📄
writebarrier_test.go
(1.75 KB)
📄
xposmap.go
(3.29 KB)
📄
zcse.go
(2.07 KB)
📄
zeroextension_test.go
(1.66 KB)
Editing: flagalloc.go
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssa // flagalloc allocates the flag register among all the flag-generating // instructions. Flag values are recomputed if they need to be // spilled/restored. func flagalloc(f *Func) { // Compute the in-register flag value we want at the end of // each block. This is basically a best-effort live variable // analysis, so it can be much simpler than a full analysis. end := make([]*Value, f.NumBlocks()) po := f.postorder() for n := 0; n < 2; n++ { for _, b := range po { // Walk values backwards to figure out what flag // value we want in the flag register at the start // of the block. var flag *Value for _, c := range b.ControlValues() { if c.Type.IsFlags() { if flag != nil { panic("cannot have multiple controls using flags") } flag = c } } if flag == nil { flag = end[b.ID] } for j := len(b.Values) - 1; j >= 0; j-- { v := b.Values[j] if v == flag { flag = nil } if v.clobbersFlags() { flag = nil } for _, a := range v.Args { if a.Type.IsFlags() { flag = a } } } if flag != nil { for _, e := range b.Preds { p := e.b end[p.ID] = flag } } } } // For blocks which have a flags control value, that's the only value // we can leave in the flags register at the end of the block. (There // is no place to put a flag regeneration instruction.) for _, b := range f.Blocks { if b.Kind == BlockDefer { // Defer blocks internally use/clobber the flags value. end[b.ID] = nil continue } for _, v := range b.ControlValues() { if v.Type.IsFlags() && end[b.ID] != v { end[b.ID] = nil } } } // Compute which flags values will need to be spilled. spill := map[ID]bool{} for _, b := range f.Blocks { var flag *Value if len(b.Preds) > 0 { flag = end[b.Preds[0].b.ID] } for _, v := range b.Values { for _, a := range v.Args { if !a.Type.IsFlags() { continue } if a == flag { continue } // a will need to be restored here. spill[a.ID] = true flag = a } if v.clobbersFlags() { flag = nil } if v.Type.IsFlags() { flag = v } } for _, v := range b.ControlValues() { if v != flag && v.Type.IsFlags() { spill[v.ID] = true } } if v := end[b.ID]; v != nil && v != flag { spill[v.ID] = true } } // Add flag spill and recomputation where they are needed. var remove []*Value // values that should be checked for possible removal var oldSched []*Value for _, b := range f.Blocks { oldSched = append(oldSched[:0], b.Values...) b.Values = b.Values[:0] // The current live flag value (the pre-flagalloc copy). var flag *Value if len(b.Preds) > 0 { flag = end[b.Preds[0].b.ID] // Note: the following condition depends on the lack of critical edges. for _, e := range b.Preds[1:] { p := e.b if end[p.ID] != flag { f.Fatalf("live flag in %s's predecessors not consistent", b) } } } for _, v := range oldSched { if v.Op == OpPhi && v.Type.IsFlags() { f.Fatalf("phi of flags not supported: %s", v.LongString()) } // If v will be spilled, and v uses memory, then we must split it // into a load + a flag generator. if spill[v.ID] && v.MemoryArg() != nil { remove = append(remove, v) if !f.Config.splitLoad(v) { f.Fatalf("can't split flag generator: %s", v.LongString()) } } // Make sure any flag arg of v is in the flags register. // If not, recompute it. for i, a := range v.Args { if !a.Type.IsFlags() { continue } if a == flag { continue } // Recalculate a c := copyFlags(a, b) // Update v. v.SetArg(i, c) // Remember the most-recently computed flag value. flag = a } // Issue v. b.Values = append(b.Values, v) if v.clobbersFlags() { flag = nil } if v.Type.IsFlags() { flag = v } } for i, v := range b.ControlValues() { if v != flag && v.Type.IsFlags() { // Recalculate control value. remove = append(remove, v) c := copyFlags(v, b) b.ReplaceControl(i, c) flag = v } } if v := end[b.ID]; v != nil && v != flag { // Need to reissue flag generator for use by // subsequent blocks. remove = append(remove, v) copyFlags(v, b) // Note: this flag generator is not properly linked up // with the flag users. This breaks the SSA representation. // We could fix up the users with another pass, but for now // we'll just leave it. (Regalloc has the same issue for // standard regs, and it runs next.) // For this reason, take care not to add this flag // generator to the remove list. } } // Save live flag state for later. for _, b := range f.Blocks { b.FlagsLiveAtEnd = end[b.ID] != nil } // Remove any now-dead values. // The number of values to remove is likely small, // and removing them requires processing all values in a block, // so minimize the number of blocks that we touch. // Shrink remove to contain only dead values, and clobber those dead values. for i := 0; i < len(remove); i++ { v := remove[i] if v.Uses == 0 { v.reset(OpInvalid) continue } // Remove v. last := len(remove) - 1 remove[i] = remove[last] remove[last] = nil remove = remove[:last] i-- // reprocess value at i } if len(remove) == 0 { return } removeBlocks := f.newSparseSet(f.NumBlocks()) defer f.retSparseSet(removeBlocks) for _, v := range remove { removeBlocks.add(v.Block.ID) } // Process affected blocks, preserving value order. for _, b := range f.Blocks { if !removeBlocks.contains(b.ID) { continue } i := 0 for j := 0; j < len(b.Values); j++ { v := b.Values[j] if v.Op == OpInvalid { continue } b.Values[i] = v i++ } b.truncateValues(i) } } func (v *Value) clobbersFlags() bool { if opcodeTable[v.Op].clobberFlags { return true } if v.Type.IsTuple() && (v.Type.FieldType(0).IsFlags() || v.Type.FieldType(1).IsFlags()) { // This case handles the possibility where a flag value is generated but never used. // In that case, there's no corresponding Select to overwrite the flags value, // so we must consider flags clobbered by the tuple-generating instruction. return true } return false } // copyFlags copies v (flag generator) into b, returns the copy. // If v's arg is also flags, copy recursively. func copyFlags(v *Value, b *Block) *Value { flagsArgs := make(map[int]*Value) for i, a := range v.Args { if a.Type.IsFlags() || a.Type.IsTuple() { flagsArgs[i] = copyFlags(a, b) } } c := v.copyInto(b) for i, a := range flagsArgs { c.SetArg(i, a) } return c }
Upload File
Create Folder