Optimize 0.0 floating point constants. (#344)
* Optimize 0.0 floating point constants. Rather than using the existing process of emitting bit patterns and moving them into floating point registers, use the `xorps` instruction to zero out the register. * is_zero predicate function will not accept negative zero. Fixed formatting for encoding recipe and filetests.
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
x86 Encodings.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from cdsl.predicates import IsZero32BitFloat, IsZero64BitFloat
|
||||
from cdsl.predicates import IsUnsignedInt, Not, And
|
||||
from base.predicates import IsColocatedFunc, IsColocatedData, LengthEquals
|
||||
from base import instructions as base
|
||||
from base.formats import UnaryImm, FuncAddr, Call, LoadComplex, StoreComplex
|
||||
from base.formats import UnaryIeee32, UnaryIeee64, UnaryImm
|
||||
from base.formats import FuncAddr, Call, LoadComplex, StoreComplex
|
||||
from .defs import X86_64, X86_32
|
||||
from . import recipes as r
|
||||
from . import settings as cfg
|
||||
@@ -604,6 +606,18 @@ X86_64.enc(base.uextend.i64.i32, *r.umr(0x89))
|
||||
# Floating point
|
||||
#
|
||||
|
||||
# floating-point constants equal to 0.0 can be encoded using either
|
||||
# `xorps` or `xorpd`, for 32-bit and 64-bit floats respectively.
|
||||
X86_32.enc(base.f32const, *r.f32imm_z(0x0f, 0x57),
|
||||
instp=IsZero32BitFloat(UnaryIeee32.imm))
|
||||
X86_32.enc(base.f64const, *r.f64imm_z(0x66, 0x0f, 0x57),
|
||||
instp=IsZero64BitFloat(UnaryIeee64.imm))
|
||||
|
||||
enc_x86_64_instp(base.f32const, r.f32imm_z,
|
||||
IsZero32BitFloat(UnaryIeee32.imm), 0x0f, 0x57)
|
||||
enc_x86_64_instp(base.f64const, r.f64imm_z,
|
||||
IsZero64BitFloat(UnaryIeee64.imm), 0x66, 0x0f, 0x57)
|
||||
|
||||
# movd
|
||||
enc_both(base.bitcast.f32.i32, r.frurm, 0x66, 0x0f, 0x6e)
|
||||
enc_both(base.bitcast.i32.f32, r.rfumr, 0x66, 0x0f, 0x7e)
|
||||
|
||||
Reference in New Issue
Block a user