Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 如何在LLVM中获得循环边界?_Loops_Llvm_Bounds_Nest - Fatal编程技术网

Loops 如何在LLVM中获得循环边界?

Loops 如何在LLVM中获得循环边界?,loops,llvm,bounds,nest,Loops,Llvm,Bounds,Nest,我想通过使用LLVMAPI获得循环边界。下面是代码的一部分,如下所示。我不知道获得边界是否正确。那么,还有其他我没有考虑过的情况吗 typedef std::vector<Loop*> LoopNest; typedef std::vector<const Value*> LoopNestBounds; ... void getLoopNestBounds(const LoopNest &Nest, LoopNestBounds &LBounds) {

我想通过使用LLVMAPI获得循环边界。下面是代码的一部分,如下所示。我不知道获得边界是否正确。那么,还有其他我没有考虑过的情况吗

typedef std::vector<Loop*> LoopNest;
typedef std::vector<const Value*> LoopNestBounds;
...
void getLoopNestBounds(const LoopNest &Nest, LoopNestBounds &LBounds) {
    ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
    for (unsigned d = 0, n = Nestsize(); d != n; ++d) {
        if (SE.hasLoopInvariantBackedgeTakenCount(Nest[d])) {
            const SCEV *C = SE.getBackedgeTakenCount(Nest[d]);
            const SCEVConstant *CC = dyn_cast<const SCEVConstant>(C);
            LBounds.push_back(CC->getValue());
            errs() << CC->getValue()->getValue() << " iterations\n";
        }
        else {
            LBounds.push_back(0);
            errs() << "---- 0 iterations for the nest ----" << "\n";
        }
    }
}

注意:LLVM的版本是3.0。

为什么不使用ScalarRevolution Analysis中的GetSmallConstanttTripCount函数呢?哦,我不知道ScalarRevolution Analysis有这样一个函数!函数getSmallConstantTripCount更简单。谢谢~