我想寫一個LLVM傳遞計算向量類型的指令。
的說明,如:LLVM傳遞向量計數向量類型指令
%24 = or <2 x i64> %21, %23
%25 = bitcast <16 x i8> %12 to <8 x i16>
%26 = shl <8 x i16> %25, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
%27 = bitcast <8 x i16> %26 to <2 x i64>
我寫了這個代碼:
for (auto &F : M) {
for (auto &B : F) {
for (auto &I : B) {
if (auto* VI = dyn_cast<InsertElementInst>(&I)) {
Value* op = VI->getOperand(0);
if (op->getType()->isVectorTy()){
++vcount;
}
}
但由於某些原因if (auto* VI = dyn_cast<InsertElementInst>(&I))
是永遠不會滿足。 任何想法爲什麼?
在此先感謝。
你不會需要'dyn_cast'可言,因爲'I'應該已經是一個'指令&'這裏。 –
@Ismail:如此修改。 –
感謝您的回答。但我不明白我將如何計算通過使用指令返回矢量類型的指令。 – Dinz