Skip to content

Commit 6e192d6

Browse files
committed
Implement llvm.fshl.iXX intrinsic
ror/rol llvm simplifications get turned into this intrinsic, which caused Triton to crash because of the missing intrinsic. See issue #1403
1 parent 6731879 commit 6e192d6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/libtriton/ast/llvm/llvmToTriton.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ namespace triton {
4444
}
4545
return node;
4646
}
47+
else if (call->getCalledFunction()->getName().find("llvm.fshl.i") != std::string::npos) {
48+
// (X << (Z % BW)) | (Y >> (BW - (Z % BW)))
49+
// https://llvm.org/docs/LangRef.html#llvm-fshl-intrinsic
50+
auto x = this->do_convert(call->getArgOperand(0));
51+
auto y = this->do_convert(call->getArgOperand(1));
52+
auto z = this->do_convert(call->getArgOperand(2));
53+
auto bw = this->actx->bv(x->getBitvectorSize(), x->getBitvectorSize());
54+
55+
auto LHS = this->actx->bvshl(x, z);
56+
auto RHS = this->actx->bvlshr(y, this->actx->bvsub(bw, z));
57+
58+
return this->actx->bvor(LHS, RHS);
59+
}
4760
/* We symbolize the return of call */
4861
return this->var(instruction->getName().str(), instruction->getType()->getScalarSizeInBits());
4962
}

0 commit comments

Comments
 (0)