mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.ssa] cmd/compile: add constBool helpers
Change-Id: I1f93ea65bbdc895cd4eff7545e1688a64d85aae5 Reviewed-on: https://go-review.googlesource.com/14520 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
f5c53e0deb
commit
cea441427e
2 changed files with 15 additions and 8 deletions
|
|
@ -266,6 +266,14 @@ func (b *Block) NewValue3I(line int32, op Op, t Type, aux int64, arg0, arg1, arg
|
|||
}
|
||||
|
||||
// ConstInt returns an int constant representing its argument.
|
||||
func (f *Func) ConstBool(line int32, t Type, c bool) *Value {
|
||||
// TODO: cache?
|
||||
i := int64(0)
|
||||
if c {
|
||||
i = 1
|
||||
}
|
||||
return f.Entry.NewValue0I(line, OpConstBool, t, i)
|
||||
}
|
||||
func (f *Func) ConstInt8(line int32, t Type, c int8) *Value {
|
||||
// TODO: cache?
|
||||
return f.Entry.NewValue0I(line, OpConst8, t, int64(c))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue