llgo/ssa: SizeOf, MakeSlice, VoidPtr

This commit is contained in:
xushiwei
2024-05-03 23:10:02 +08:00
parent 223c24450e
commit f1bb42f554
20 changed files with 595 additions and 467 deletions

View File

@@ -91,11 +91,19 @@ type aType struct {
type Type = *aType
/*
// TODO(xsw):
// how to generate platform independent code?
func (p Program) SizeOf(typ Type, n ...int64) uint64 {
size := p.td.TypeStoreSize(typ.ll)
if len(n) != 0 {
size *= uint64(n[0])
}
return size
}
func (p Program) Slice(typ Type) Type {
return p.Type(types.NewSlice(typ.t))
}
*/
func (p Program) Pointer(typ Type) Type {
return p.Type(types.NewPointer(typ.t))