operand: fix integer float data (#393)
Issue #387 pointed out that integer float data is printed incorrectly, such that it is not parsed correctly by the Go assembler. Specifically, integer values need the decimal point, otherwise they will be treated as integers. For example, 1 must be represented as `$(1.)` or `$(1.0)` to be parsed correctly. This PR fixes that problem and adds a regression test. The root of the problem was that the formatting verb `%#v` does not have the right behavior for integers. We fix it by deferring to custom `String()` function for the float operand types. Fixes #387 Closes #388
This commit is contained in:
committed by
GitHub
parent
9bef88dadc
commit
0d789c8353
45
tests/fixedbugs/issue387/issue387.s
Normal file
45
tests/fixedbugs/issue387/issue387.s
Normal file
@@ -0,0 +1,45 @@
|
||||
// Code generated by command: go run asm.go -out issue387.s -stubs stub.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
DATA f32<>+0(SB)/4, $(0.0)
|
||||
DATA f32<>+4(SB)/4, $(1.0)
|
||||
DATA f32<>+8(SB)/4, $(2.0)
|
||||
DATA f32<>+12(SB)/4, $(3.0)
|
||||
DATA f32<>+16(SB)/4, $(4.0)
|
||||
DATA f32<>+20(SB)/4, $(5.0)
|
||||
DATA f32<>+24(SB)/4, $(6.0)
|
||||
DATA f32<>+28(SB)/4, $(7.0)
|
||||
DATA f32<>+32(SB)/4, $(8.0)
|
||||
DATA f32<>+36(SB)/4, $(9.0)
|
||||
GLOBL f32<>(SB), RODATA|NOPTR, $40
|
||||
|
||||
// func Float32(i int) float32
|
||||
// Requires: SSE
|
||||
TEXT ·Float32(SB), NOSPLIT, $0-12
|
||||
MOVQ i+0(FP), AX
|
||||
LEAQ f32<>+0(SB), CX
|
||||
MOVSS (CX)(AX*4), X0
|
||||
MOVSS X0, ret+8(FP)
|
||||
RET
|
||||
|
||||
DATA f64<>+0(SB)/8, $(0.0)
|
||||
DATA f64<>+8(SB)/8, $(1.0)
|
||||
DATA f64<>+16(SB)/8, $(2.0)
|
||||
DATA f64<>+24(SB)/8, $(3.0)
|
||||
DATA f64<>+32(SB)/8, $(4.0)
|
||||
DATA f64<>+40(SB)/8, $(5.0)
|
||||
DATA f64<>+48(SB)/8, $(6.0)
|
||||
DATA f64<>+56(SB)/8, $(7.0)
|
||||
DATA f64<>+64(SB)/8, $(8.0)
|
||||
DATA f64<>+72(SB)/8, $(9.0)
|
||||
GLOBL f64<>(SB), RODATA|NOPTR, $80
|
||||
|
||||
// func Float64(i int) float64
|
||||
// Requires: SSE2
|
||||
TEXT ·Float64(SB), NOSPLIT, $0-16
|
||||
MOVQ i+0(FP), AX
|
||||
LEAQ f64<>+0(SB), CX
|
||||
MOVSD (CX)(AX*8), X0
|
||||
MOVSD X0, ret+8(FP)
|
||||
RET
|
||||
Reference in New Issue
Block a user