llgo/ssa: b.CString

This commit is contained in:
xushiwei
2024-04-29 14:34:26 +08:00
parent 4eb2ddaf15
commit 1610894a80
3 changed files with 8 additions and 8 deletions

View File

@@ -82,12 +82,6 @@ func (p Program) Null(t Type) Expr {
return Expr{llvm.ConstNull(t.ll), t}
}
// CStringVal returns a c-style string constant expression.
func (p Program) CStringVal(v string) Expr {
t := p.CString()
return Expr{llvm.ConstString(v, true), t}
}
// StringVal returns string constant expression.
func (p Program) StringVal(v string) Expr {
t := p.String()
@@ -153,6 +147,11 @@ func (b Builder) Const(v constant.Value, typ Type) Expr {
panic("todo")
}
// CString returns a c-style string constant expression.
func (b Builder) CString(v string) Expr {
return Expr{llvm.CreateGlobalStringPtr(b.impl, v), b.Prog.CString()}
}
// -----------------------------------------------------------------------------
const (