committed by
GitHub
parent
b0ac74488c
commit
cde7e9483b
@@ -63,12 +63,14 @@ TEXT ·FieldUint64(SB), NOSPLIT, $0-184
|
|||||||
RET
|
RET
|
||||||
|
|
||||||
// func FieldFloat32(s Struct) float32
|
// func FieldFloat32(s Struct) float32
|
||||||
|
// Requires: SSE
|
||||||
TEXT ·FieldFloat32(SB), NOSPLIT, $0-180
|
TEXT ·FieldFloat32(SB), NOSPLIT, $0-180
|
||||||
MOVSS s_Float32+16(FP), X0
|
MOVSS s_Float32+16(FP), X0
|
||||||
MOVSS X0, ret+176(FP)
|
MOVSS X0, ret+176(FP)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// func FieldFloat64(s Struct) float64
|
// func FieldFloat64(s Struct) float64
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·FieldFloat64(SB), NOSPLIT, $0-184
|
TEXT ·FieldFloat64(SB), NOSPLIT, $0-184
|
||||||
MOVSD s_Float64+24(FP), X0
|
MOVSD s_Float64+24(FP), X0
|
||||||
MOVSD X0, ret+176(FP)
|
MOVSD X0, ret+176(FP)
|
||||||
@@ -99,18 +101,21 @@ TEXT ·FieldArrayOneC(SB), NOSPLIT, $0-178
|
|||||||
RET
|
RET
|
||||||
|
|
||||||
// func FieldComplex64Imag(s Struct) float32
|
// func FieldComplex64Imag(s Struct) float32
|
||||||
|
// Requires: SSE
|
||||||
TEXT ·FieldComplex64Imag(SB), NOSPLIT, $0-180
|
TEXT ·FieldComplex64Imag(SB), NOSPLIT, $0-180
|
||||||
MOVSS s_Complex64_imag+156(FP), X0
|
MOVSS s_Complex64_imag+156(FP), X0
|
||||||
MOVSS X0, ret+176(FP)
|
MOVSS X0, ret+176(FP)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// func FieldComplex128Real(s Struct) float64
|
// func FieldComplex128Real(s Struct) float64
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·FieldComplex128Real(SB), NOSPLIT, $0-184
|
TEXT ·FieldComplex128Real(SB), NOSPLIT, $0-184
|
||||||
MOVSD s_Complex128_real+160(FP), X0
|
MOVSD s_Complex128_real+160(FP), X0
|
||||||
MOVSD X0, ret+176(FP)
|
MOVSD X0, ret+176(FP)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// func DereferenceFloat32(s *Struct) float32
|
// func DereferenceFloat32(s *Struct) float32
|
||||||
|
// Requires: SSE
|
||||||
TEXT ·DereferenceFloat32(SB), NOSPLIT, $0-12
|
TEXT ·DereferenceFloat32(SB), NOSPLIT, $0-12
|
||||||
MOVQ s+0(FP), AX
|
MOVQ s+0(FP), AX
|
||||||
MOVSS 16(AX), X0
|
MOVSS 16(AX), X0
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ Generated assembly:
|
|||||||
[embedmd]:# (complex.s s /.*func Norm/ /RET/)
|
[embedmd]:# (complex.s s /.*func Norm/ /RET/)
|
||||||
```s
|
```s
|
||||||
// func Norm(z complex128) float64
|
// func Norm(z complex128) float64
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·Norm(SB), NOSPLIT, $0-24
|
TEXT ·Norm(SB), NOSPLIT, $0-24
|
||||||
MOVSD z_real+0(FP), X0
|
MOVSD z_real+0(FP), X0
|
||||||
MOVSD z_imag+8(FP), X1
|
MOVSD z_imag+8(FP), X1
|
||||||
|
|||||||
@@ -3,18 +3,21 @@
|
|||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
// func Real(z complex128) float64
|
// func Real(z complex128) float64
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·Real(SB), NOSPLIT, $0-24
|
TEXT ·Real(SB), NOSPLIT, $0-24
|
||||||
MOVSD z_real+0(FP), X0
|
MOVSD z_real+0(FP), X0
|
||||||
MOVSD X0, ret+16(FP)
|
MOVSD X0, ret+16(FP)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// func Imag(z complex128) float64
|
// func Imag(z complex128) float64
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·Imag(SB), NOSPLIT, $0-24
|
TEXT ·Imag(SB), NOSPLIT, $0-24
|
||||||
MOVSD z_imag+8(FP), X0
|
MOVSD z_imag+8(FP), X0
|
||||||
MOVSD X0, ret+16(FP)
|
MOVSD X0, ret+16(FP)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// func Norm(z complex128) float64
|
// func Norm(z complex128) float64
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·Norm(SB), NOSPLIT, $0-24
|
TEXT ·Norm(SB), NOSPLIT, $0-24
|
||||||
MOVSD z_real+0(FP), X0
|
MOVSD z_real+0(FP), X0
|
||||||
MOVSD z_imag+8(FP), X1
|
MOVSD z_imag+8(FP), X1
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
// func Dot(x []float32, y []float32) float32
|
// func Dot(x []float32, y []float32) float32
|
||||||
|
// Requires: AVX, FMA3, SSE
|
||||||
TEXT ·Dot(SB), NOSPLIT, $0-52
|
TEXT ·Dot(SB), NOSPLIT, $0-52
|
||||||
MOVQ x_base+0(FP), AX
|
MOVQ x_base+0(FP), AX
|
||||||
MOVQ y_base+24(FP), CX
|
MOVQ y_base+24(FP), CX
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
// func EncodeInt(lat float64, lng float64) uint64
|
// func EncodeInt(lat float64, lng float64) uint64
|
||||||
|
// Requires: BMI2, SSE2
|
||||||
TEXT ·EncodeInt(SB), NOSPLIT, $0-24
|
TEXT ·EncodeInt(SB), NOSPLIT, $0-24
|
||||||
MOVSD lat+0(FP), X0
|
MOVSD lat+0(FP), X0
|
||||||
MOVSD lng+8(FP), X1
|
MOVSD lng+8(FP), X1
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ TEXT ·Interval(SB), NOSPLIT, $0-32
|
|||||||
RET
|
RET
|
||||||
|
|
||||||
// func Butterfly(x0 float64, x1 float64) (y0 float64, y1 float64)
|
// func Butterfly(x0 float64, x1 float64) (y0 float64, y1 float64)
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·Butterfly(SB), NOSPLIT, $0-32
|
TEXT ·Butterfly(SB), NOSPLIT, $0-32
|
||||||
MOVSD x0+0(FP), X0
|
MOVSD x0+0(FP), X0
|
||||||
MOVSD x1+8(FP), X1
|
MOVSD x1+8(FP), X1
|
||||||
@@ -36,6 +37,7 @@ TEXT ·Septuple(SB), NOSPLIT, $0-15
|
|||||||
RET
|
RET
|
||||||
|
|
||||||
// func CriticalLine(t float64) complex128
|
// func CriticalLine(t float64) complex128
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·CriticalLine(SB), NOSPLIT, $0-24
|
TEXT ·CriticalLine(SB), NOSPLIT, $0-24
|
||||||
MOVSD t+0(FP), X0
|
MOVSD t+0(FP), X0
|
||||||
MOVSD half<>+0(SB), X1
|
MOVSD half<>+0(SB), X1
|
||||||
@@ -47,6 +49,7 @@ DATA half<>+0(SB)/8, $(0.5)
|
|||||||
GLOBL half<>(SB), RODATA|NOPTR, $8
|
GLOBL half<>(SB), RODATA|NOPTR, $8
|
||||||
|
|
||||||
// func NewStruct(w uint16, p [2]float64, q uint64) Struct
|
// func NewStruct(w uint16, p [2]float64, q uint64) Struct
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·NewStruct(SB), NOSPLIT, $0-64
|
TEXT ·NewStruct(SB), NOSPLIT, $0-64
|
||||||
MOVW w+0(FP), AX
|
MOVW w+0(FP), AX
|
||||||
MOVSD p_0+8(FP), X0
|
MOVSD p_0+8(FP), X0
|
||||||
|
|||||||
@@ -92,6 +92,11 @@ func construct(i inst.Instruction, f inst.Form, s signature) string {
|
|||||||
fmt.Fprintf(buf, "\tInputs: %s,\n", operandsWithAction(f, inst.R, s))
|
fmt.Fprintf(buf, "\tInputs: %s,\n", operandsWithAction(f, inst.R, s))
|
||||||
fmt.Fprintf(buf, "\tOutputs: %s,\n", operandsWithAction(f, inst.W, s))
|
fmt.Fprintf(buf, "\tOutputs: %s,\n", operandsWithAction(f, inst.W, s))
|
||||||
|
|
||||||
|
// ISAs.
|
||||||
|
if len(f.ISA) > 0 {
|
||||||
|
fmt.Fprintf(buf, "\tISA: %#v,\n", f.ISA)
|
||||||
|
}
|
||||||
|
|
||||||
// Branch variables.
|
// Branch variables.
|
||||||
if i.IsBranch() {
|
if i.IsBranch() {
|
||||||
fmt.Fprintf(buf, "\tIsBranch: true,\n")
|
fmt.Fprintf(buf, "\tIsBranch: true,\n")
|
||||||
|
|||||||
6
ir/ir.go
6
ir/ir.go
@@ -47,6 +47,9 @@ type Instruction struct {
|
|||||||
IsConditional bool
|
IsConditional bool
|
||||||
CancellingInputs bool
|
CancellingInputs bool
|
||||||
|
|
||||||
|
// ISA is the list of required instruction set extensions.
|
||||||
|
ISA []string
|
||||||
|
|
||||||
// CFG.
|
// CFG.
|
||||||
Pred []*Instruction
|
Pred []*Instruction
|
||||||
Succ []*Instruction
|
Succ []*Instruction
|
||||||
@@ -166,6 +169,9 @@ type Function struct {
|
|||||||
|
|
||||||
// Register allocation.
|
// Register allocation.
|
||||||
Allocation reg.Allocation
|
Allocation reg.Allocation
|
||||||
|
|
||||||
|
// ISA is the list of required instruction set extensions.
|
||||||
|
ISA []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Function) section() {}
|
func (f *Function) section() {}
|
||||||
|
|||||||
31
pass/isa.go
Normal file
31
pass/isa.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package pass
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sort"
|
||||||
|
|
||||||
|
"github.com/mmcloughlin/avo/ir"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RequiredISAExtensions determines ISA extensions required for the given
|
||||||
|
// function. Populates the ISA field.
|
||||||
|
func RequiredISAExtensions(fn *ir.Function) error {
|
||||||
|
// Collect ISA set.
|
||||||
|
set := map[string]bool{}
|
||||||
|
for _, i := range fn.Instructions() {
|
||||||
|
for _, isa := range i.ISA {
|
||||||
|
set[isa] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(set) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate the function's ISA field with the unique sorted list.
|
||||||
|
for isa := range set {
|
||||||
|
fn.ISA = append(fn.ISA, isa)
|
||||||
|
}
|
||||||
|
sort.Strings(fn.ISA)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
25
pass/isa_test.go
Normal file
25
pass/isa_test.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package pass
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mmcloughlin/avo/ir"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRequiredISAExtensions(t *testing.T) {
|
||||||
|
f := ir.NewFunction("ISAs")
|
||||||
|
f.AddInstruction(&ir.Instruction{ISA: nil})
|
||||||
|
f.AddInstruction(&ir.Instruction{ISA: []string{"B", "A"}})
|
||||||
|
f.AddInstruction(&ir.Instruction{ISA: []string{"A", "C"}})
|
||||||
|
|
||||||
|
err := RequiredISAExtensions(f)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expect := []string{"A", "B", "C"}
|
||||||
|
if !reflect.DeepEqual(f.ISA, expect) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ var Compile = Concat(
|
|||||||
FunctionPass(VerifyAllocation),
|
FunctionPass(VerifyAllocation),
|
||||||
Func(IncludeTextFlagHeader),
|
Func(IncludeTextFlagHeader),
|
||||||
FunctionPass(PruneSelfMoves),
|
FunctionPass(PruneSelfMoves),
|
||||||
|
FunctionPass(RequiredISAExtensions),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Interface for a processing pass.
|
// Interface for a processing pass.
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ func (p *goasm) function(f *ir.Function) {
|
|||||||
p.NL()
|
p.NL()
|
||||||
p.Comment(f.Stub())
|
p.Comment(f.Stub())
|
||||||
|
|
||||||
|
if len(f.ISA) > 0 {
|
||||||
|
p.Comment("Requires: " + strings.Join(f.ISA, ", "))
|
||||||
|
}
|
||||||
|
|
||||||
// Reference: https://github.com/golang/go/blob/b115207baf6c2decc3820ada4574ef4e5ad940ec/src/cmd/internal/obj/util.go#L166-L176
|
// Reference: https://github.com/golang/go/blob/b115207baf6c2decc3820ada4574ef4e5ad940ec/src/cmd/internal/obj/util.go#L166-L176
|
||||||
//
|
//
|
||||||
// if p.As == ATEXT {
|
// if p.As == ATEXT {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
// func Issue50(x uint32) uint32
|
// func Issue50(x uint32) uint32
|
||||||
|
// Requires: SSE2
|
||||||
TEXT ·Issue50(SB), NOSPLIT, $0-12
|
TEXT ·Issue50(SB), NOSPLIT, $0-12
|
||||||
MOVL x+0(FP), AX
|
MOVL x+0(FP), AX
|
||||||
MOVQ AX, X0
|
MOVQ AX, X0
|
||||||
|
|||||||
1955
x86/zctors.go
1955
x86/zctors.go
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user