diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:25:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:25:22 +0000 |
commit | f6ad4dcef54c5ce997a4bad5a6d86de229015700 (patch) | |
tree | 7cfa4e31ace5c2bd95c72b154d15af494b2bcbef /src/cmd/compile/internal/ssa/lower.go | |
parent | Initial commit. (diff) | |
download | golang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.tar.xz golang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.zip |
Adding upstream version 1.22.1.upstream/1.22.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/lower.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/lower.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/lower.go b/src/cmd/compile/internal/ssa/lower.go new file mode 100644 index 0000000..e4aac47 --- /dev/null +++ b/src/cmd/compile/internal/ssa/lower.go @@ -0,0 +1,52 @@ +// 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 + +// convert to machine-dependent ops. +func lower(f *Func) { + // repeat rewrites until we find no more rewrites + applyRewrite(f, f.Config.lowerBlock, f.Config.lowerValue, removeDeadValues) +} + +// lateLower applies those rules that need to be run after the general lower rules. +func lateLower(f *Func) { + // repeat rewrites until we find no more rewrites + if f.Config.lateLowerValue != nil { + applyRewrite(f, f.Config.lateLowerBlock, f.Config.lateLowerValue, removeDeadValues) + } +} + +// checkLower checks for unlowered opcodes and fails if we find one. +func checkLower(f *Func) { + // Needs to be a separate phase because it must run after both + // lowering and a subsequent dead code elimination (because lowering + // rules may leave dead generic ops behind). + for _, b := range f.Blocks { + for _, v := range b.Values { + if !opcodeTable[v.Op].generic { + continue // lowered + } + switch v.Op { + case OpSP, OpSPanchored, OpSB, OpInitMem, OpArg, OpArgIntReg, OpArgFloatReg, OpPhi, OpVarDef, OpVarLive, OpKeepAlive, OpSelect0, OpSelect1, OpSelectN, OpConvert, OpInlMark, OpWBend: + continue // ok not to lower + case OpMakeResult: + if b.Controls[0] == v { + continue + } + case OpGetG: + if f.Config.hasGReg { + // has hardware g register, regalloc takes care of it + continue // ok not to lower + } + } + s := "not lowered: " + v.String() + ", " + v.Op.String() + " " + v.Type.SimpleString() + + for _, a := range v.Args { + s += " " + a.Type.SimpleString() + } + f.Fatalf("%s", s) + } + } +} |