examples/sha1: single block

This commit is contained in:
Michael McLoughlin
2018-12-21 00:30:59 -08:00
parent 224cccd2b1
commit f464082484
8 changed files with 1525 additions and 11 deletions

19
ast.go
View File

@@ -10,15 +10,6 @@ type Asm interface {
Asm() string
}
// GoType represents a Golang type.
type GoType interface{}
// Parameter represents a parameter to an assembly function.
type Parameter struct {
Name string
Type GoType
}
type Operand interface {
Asm
}
@@ -112,6 +103,7 @@ func NewFile() *File {
type Function struct {
Name string
Signature *gotypes.Signature
LocalSize int
Nodes []Node
@@ -133,6 +125,12 @@ func (f *Function) SetSignature(s *gotypes.Signature) {
f.Signature = s
}
func (f *Function) AllocLocal(size int) operand.Mem {
ptr := operand.NewStackAddr(f.LocalSize)
f.LocalSize += size
return ptr
}
func (f *Function) AddInstruction(i *Instruction) {
f.AddNode(i)
}
@@ -164,8 +162,7 @@ func (f *Function) Stub() string {
// FrameBytes returns the size of the stack frame in bytes.
func (f *Function) FrameBytes() int {
// TODO(mbm): implement Function.FrameBytes()
return 0
return f.LocalSize
}
// ArgumentBytes returns the size of the arguments in bytes.