4
ast.go
4
ast.go
@@ -99,9 +99,7 @@ type File struct {
|
||||
}
|
||||
|
||||
func NewFile() *File {
|
||||
return &File{
|
||||
Includes: []string{"textflag.h"},
|
||||
}
|
||||
return &File{}
|
||||
}
|
||||
|
||||
func (f *File) AddSection(s Section) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func Add(x uint64, y uint64) uint64
|
||||
TEXT ·Add(SB), $0-24
|
||||
MOVQ x(FP), AX
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out args.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func StringLen(s string) int
|
||||
TEXT ·StringLen(SB), $0-24
|
||||
MOVQ s_len+8(FP), AX
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out complex.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func Real(z complex128) float64
|
||||
TEXT ·Real(SB), $0-24
|
||||
MOVSD z_real(FP), X0
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out dot.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func Dot(x []float32, y []float32) float32
|
||||
TEXT ·Dot(SB), $0-52
|
||||
MOVQ x_base(FP), AX
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out fnv1a.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func Hash64(data []byte) uint64
|
||||
TEXT ·Hash64(SB), $0-32
|
||||
MOVQ data_base(FP), CX
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out sha1.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func block(h *[5]uint32, m []byte)
|
||||
TEXT ·block(SB), $64-32
|
||||
MOVQ h(FP), AX
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out stadtx.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func Hash(state *State, key []byte) uint64
|
||||
TEXT ·Hash(SB), $0-40
|
||||
MOVQ state(FP), AX
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out sum.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func Sum(xs []uint64) uint64
|
||||
TEXT ·Sum(SB), $0-32
|
||||
MOVQ xs_base(FP), AX
|
||||
|
||||
@@ -14,6 +14,7 @@ var Compile = Concat(
|
||||
FunctionPass(AllocateRegisters),
|
||||
FunctionPass(BindRegisters),
|
||||
FunctionPass(VerifyAllocation),
|
||||
Func(IncludeTextFlagHeader),
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
|
||||
41
pass/textflag.go
Normal file
41
pass/textflag.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package pass
|
||||
|
||||
import (
|
||||
"github.com/mmcloughlin/avo"
|
||||
)
|
||||
|
||||
// IncludeTextFlagHeader includes textflag.h if necessary.
|
||||
func IncludeTextFlagHeader(f *avo.File) error {
|
||||
const textflagheader = "textflag.h"
|
||||
|
||||
// Check if we already have it.
|
||||
for _, path := range f.Includes {
|
||||
if path == textflagheader {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Add it if necessary.
|
||||
if requirestextflags(f) {
|
||||
f.Includes = append(f.Includes, textflagheader)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// requirestextflags returns whether the file uses flags in the textflags.h header.
|
||||
func requirestextflags(f *avo.File) bool {
|
||||
for _, s := range f.Sections {
|
||||
var a avo.Attribute
|
||||
switch s := s.(type) {
|
||||
case *avo.Function:
|
||||
a = s.Attributes
|
||||
case *avo.Global:
|
||||
a = s.Attributes
|
||||
}
|
||||
if a.ContainsTextFlags() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -22,8 +22,6 @@ func TestBasic(t *testing.T) {
|
||||
AssertPrintsLines(t, ctx, printer.NewGoAsm, []string{
|
||||
"// Code generated by avo. DO NOT EDIT.",
|
||||
"",
|
||||
"#include \"textflag.h\"",
|
||||
"",
|
||||
"// func add(x uint64, y uint64) uint64",
|
||||
"TEXT ·add(SB), $0-24",
|
||||
"\tMOVQ\tx(FP), AX",
|
||||
@@ -55,8 +53,6 @@ func TestTextDecl(t *testing.T) {
|
||||
AssertPrintsLines(t, ctx, printer.NewGoAsm, []string{
|
||||
"// Code generated by avo. DO NOT EDIT.",
|
||||
"",
|
||||
"#include \"textflag.h\"",
|
||||
"",
|
||||
"// func noargs()",
|
||||
"TEXT ·noargs(SB), $16", // expect only the frame size
|
||||
"\tRET",
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Code generated by command: go run asm.go -out cast.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func Split(x uint64) (q uint64, l uint32, w uint16, b uint8)
|
||||
TEXT ·Split(SB), $0-23
|
||||
MOVQ x(FP), AX
|
||||
|
||||
Reference in New Issue
Block a user