[PATCH] Allow encoded 8-bit floating point constants in ARM vmov instructions

David Peixotto dpeixott at codeaurora.org
Fri Dec 20 13:48:30 PST 2013

On 12/20/2013 1:39 PM, Renato Golin wrote:
> The patch looks good to me, and it doesn't introduce too many changes
> nor obscure code, so it should be ok to let this in. The tests also look
> great, thanks!
> I'd still want Jim to share his opinion, though.

Yep, I agree.

> Two specific comments:
> -    double RealVal = ARM_AM::getFPImmFloat(Val);
> -    Val = APFloat(APFloat::IEEEdouble,
> RealVal).bitcastToAPInt().getZExtValue();
> +    float RealVal = ARM_AM::getFPImmFloat(Val);
> +    Val = APFloat(RealVal).bitcastToAPInt().getZExtValue();
> Nice catch, you don't need a double.

Yes, storing the operand as a float is actually required to get the 
parsing to work correctly. In the ARMOperand::isFPImm() function it 
converts the operand to a float and checks to see if it can be encoded 
as an 8-bit operand. When we kept the parsed value as a double, this 
check failed because the lower 32-bits of the double was zero so it 
looked like the float 0.0f which cannot be encoded by the 8-bit encoding.

> -        Mnemonic == "vfms" || Mnemonic == "vfnms" ||
> +        Mnemonic == "vfms" || Mnemonic == "vfnms" || Mnemonic ==
> "fconsts" ||
> Was the fconstd already there?

This code is a white list of instructions that end in 's' but do not 
actually set the flags so fconstd is not needed here.

More information about the llvm-commits mailing list