llvm中的立即数测试

发布于 2024-11-03 11:55:47 字数 210 浏览 2 评论 0原文

在LLVM中,我想测试LoopInfo传递获得的行程计数是否是立即数 数字。例如,以下循环的

for(i=0; i<10; i++) { ... }

行程计数为 10,并且它是一个立即数。可以调用Loop的成员函数getTripCount()来获取代表行程计数的Value。我如何确定这个值是否是立即数?

In LLVM, I'd like to test whether the trip count obtained by LoopInfo pass is an immediate
number. For example, the following loop

for(i=0; i<10; i++) { ... }

has a trip count of 10, and it's an immediate number. The member function getTripCount() of Loop can be called to get a Value representing the trip count. How can I decide this value is an immediate number or not?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰つ倒转 2024-11-10 11:55:47

使用标量演化分析提供的以下 getter:

unsigned ScalarEvolution::getSmallConstantTripCount(Loop *L, BasicBlock *ExitingBlock)

/// getSmallConstantTripCount - Returns the maximum trip count of this loop as a
/// normal unsigned value. Returns 0 if the trip count is unknown or not
/// constant. Will also return 0 if the maximum trip count is very large (>=
/// 2^32).
///
/// This "trip count" assumes that control exits via ExitingBlock. More
/// precisely, it is the number of times that control may reach ExitingBlock
/// before taking the branch. For loops with multiple exits, it may not be the
/// number times that the loop header executes because the loop may exit
/// prematurely via another branch.

Use the following getter provided by the Scalar Evolution analysis:

unsigned ScalarEvolution::getSmallConstantTripCount(Loop *L, BasicBlock *ExitingBlock)

/// getSmallConstantTripCount - Returns the maximum trip count of this loop as a
/// normal unsigned value. Returns 0 if the trip count is unknown or not
/// constant. Will also return 0 if the maximum trip count is very large (>=
/// 2^32).
///
/// This "trip count" assumes that control exits via ExitingBlock. More
/// precisely, it is the number of times that control may reach ExitingBlock
/// before taking the branch. For loops with multiple exits, it may not be the
/// number times that the loop header executes because the loop may exit
/// prematurely via another branch.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文