简体   繁体   English

如何知道某个数字可以在 ARM 中表示为 32 位立即数?

[英]How to know that a certain number can be represented as 32 bit immediate in ARM?

Given a number x, how can we tell that it can be represented as 32-bit immediate.给定一个数 x,我们怎么知道它可以表示为 32 位立即数。 Does any kind of formula exists?是否存在任何类型的公式? If yes, is that formula exhaustive, ie, covers all the possible cases?如果是,该公式是否详尽无遗,即涵盖所有可能的情况? ARM decomposes the rightmost 12 bits in the instruction set as 4 bit rotate-bit and 8 bit value bit. ARM 将指令集中最右边的 12 位分解为 4 位循环位和 8 位值位。

I would look into open source compilers and how they do it...我会研究开源编译器以及它们是如何做到的......

https://github.com/gcc-mirror/gcc/blob/cbca62831cb7c1c7c20d67fcf929f156b09923bf/gcc/config/arm/arm.c#L4387 https://github.com/gcc-mirror/gcc/blob/cbca62831cb7c1c7c20d67fcf929f156b09923bf/gcc/config/arm/arm.c#L4387

/* Return TRUE if int I is a valid immediate ARM constant.  */
int
const_ok_for_arm (HOST_WIDE_INT i)
{
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM