Skip to content

Commit bad9554

Browse files
authored
Add umulhi (#290)
1 parent 6c0ad40 commit bad9554

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tools/cgeist/Lib/CGCall.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,20 @@ ValueCategory MLIRScanner::VisitCallExpr(clang::CallExpr *expr) {
639639
V1 = builder.create<arith::ShRUIOp>(loc, V1, c8);
640640
return ValueCategory(builder.create<MulIOp>(loc, V0, V1), false);
641641
}
642+
if (sr->getDecl()->getIdentifier() &&
643+
sr->getDecl()->getName() == "__nv_umulhi") {
644+
mlir::Value V0 = getLLVM(expr->getArg(0));
645+
mlir::Value V1 = getLLVM(expr->getArg(1));
646+
auto I64 = builder.getIntegerType(64);
647+
auto I32 = builder.getIntegerType(32);
648+
V0 = builder.create<ExtUIOp>(loc, I64, V0);
649+
V1 = builder.create<ExtUIOp>(loc, I64, V1);
650+
mlir::Value R = builder.create<arith::MulIOp>(loc, V0, V1);
651+
auto c32 = builder.create<arith::ConstantIntOp>(loc, 32, 64);
652+
R = builder.create<arith::ShRUIOp>(loc, R, c32);
653+
R = builder.create<TruncIOp>(loc, I32, R);
654+
return ValueCategory(R, false);
655+
}
642656
if (sr->getDecl()->getIdentifier() &&
643657
(sr->getDecl()->getName() == "__builtin_frexp" ||
644658
sr->getDecl()->getName() == "__builtin_frexpf" ||

0 commit comments

Comments
 (0)