if (inst->getOpcode() == llvm::Instruction::AShr) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::AShrOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setExactFlag(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::Add) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::AddOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setIntegerOverflowFlags(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::AddrSpaceCast) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::AddrSpaceCastOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::Alloca) { FailureOr _llvmir_gen_operand_arraySize = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arraySize)) return failure(); auto *allocaInst = cast(inst); Type allocatedType = moduleImport.convertType(allocaInst->getAllocatedType()); unsigned alignment = allocaInst->getAlign().value(); moduleImport.mapValue(inst) = LLVM::AllocaOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arraySize, alignment == 0 ? IntegerAttr() : odsBuilder.getI64IntegerAttr(alignment), allocatedType, allocaInst->isUsedWithInAlloca()); return success(); } if (inst->getOpcode() == llvm::Instruction::And) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::AndOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); return success(); } if (inst->getOpcode() == llvm::Instruction::AtomicCmpXchg) { FailureOr _llvmir_gen_operand_ptr = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_ptr)) return failure(); FailureOr _llvmir_gen_operand_cmp = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_cmp)) return failure(); FailureOr _llvmir_gen_operand_val = moduleImport.convertValue(llvmOperands[2]); if (failed(_llvmir_gen_operand_val)) return failure(); auto *cmpXchgInst = cast(inst); unsigned alignment = cmpXchgInst->getAlign().value(); moduleImport.mapValue(inst) = LLVM::AtomicCmpXchgOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_ptr, *_llvmir_gen_operand_cmp, *_llvmir_gen_operand_val, convertAtomicOrderingFromLLVM(cmpXchgInst->getSuccessOrdering()), convertAtomicOrderingFromLLVM(cmpXchgInst->getFailureOrdering()), getLLVMSyncScope(cmpXchgInst), alignment, cmpXchgInst->isWeak(), cmpXchgInst->isVolatile()); return success(); } if (inst->getOpcode() == llvm::Instruction::AtomicRMW) { FailureOr _llvmir_gen_operand_ptr = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_ptr)) return failure(); FailureOr _llvmir_gen_operand_val = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_val)) return failure(); auto *atomicInst = cast(inst); unsigned alignment = atomicInst->getAlign().value(); moduleImport.mapValue(inst) = LLVM::AtomicRMWOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), convertAtomicBinOpFromLLVM(atomicInst->getOperation()), *_llvmir_gen_operand_ptr, *_llvmir_gen_operand_val, convertAtomicOrderingFromLLVM(atomicInst->getOrdering()), getLLVMSyncScope(atomicInst), alignment, atomicInst->isVolatile()); return success(); } if (inst->getOpcode() == llvm::Instruction::BitCast) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::BitcastOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::ExtractElement) { FailureOr _llvmir_gen_operand_vector = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_vector)) return failure(); FailureOr _llvmir_gen_operand_position = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_position)) return failure(); moduleImport.mapValue(inst) = LLVM::ExtractElementOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_vector, *_llvmir_gen_operand_position); return success(); } if (inst->getOpcode() == llvm::Instruction::ExtractValue) { FailureOr _llvmir_gen_operand_container = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_container)) return failure(); auto *evInst = cast(inst); moduleImport.mapValue(inst) = LLVM::ExtractValueOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_container, getPositionFromIndices(evInst->getIndices())); return success(); } if (inst->getOpcode() == llvm::Instruction::FAdd) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::FAddOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::FCmp) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto *fCmpInst = cast(inst); auto op = ::mlir::LLVM::FCmpOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), convertFCmpPredicateFromLLVM(fCmpInst->getPredicate()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::FDiv) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::FDivOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::FMul) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::FMulOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::FNeg) { FailureOr _llvmir_gen_operand_operand = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_operand)) return failure(); auto op = ::mlir::LLVM::FNegOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_operand); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::FPExt) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); auto op = ::mlir::LLVM::FPExtOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::FPToSI) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::FPToSIOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::FPToUI) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::FPToUIOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::FPTrunc) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); auto op = ::mlir::LLVM::FPTruncOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::FRem) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::FRemOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::FSub) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::FSubOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::Fence) { llvm::FenceInst *fenceInst = cast(inst); moduleImport.mapNoResultOp(inst) = LLVM::FenceOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), convertAtomicOrderingFromLLVM(fenceInst->getOrdering()), getLLVMSyncScope(fenceInst)); return success(); } if (inst->getOpcode() == llvm::Instruction::Freeze) { FailureOr _llvmir_gen_operand_val = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_val)) return failure(); moduleImport.mapValue(inst) = LLVM::FreezeOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_val); return success(); } if (inst->getOpcode() == llvm::Instruction::ICmp) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto *iCmpInst = cast(inst); moduleImport.mapValue(inst) = ::mlir::LLVM::ICmpOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), convertICmpPredicateFromLLVM(iCmpInst->getPredicate()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); return success(); } if (inst->getOpcode() == llvm::Instruction::InsertElement) { FailureOr _llvmir_gen_operand_vector = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_vector)) return failure(); FailureOr _llvmir_gen_operand_value = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_value)) return failure(); FailureOr _llvmir_gen_operand_position = moduleImport.convertValue(llvmOperands[2]); if (failed(_llvmir_gen_operand_position)) return failure(); moduleImport.mapValue(inst) = LLVM::InsertElementOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_vector, *_llvmir_gen_operand_value, *_llvmir_gen_operand_position); return success(); } if (inst->getOpcode() == llvm::Instruction::InsertValue) { FailureOr _llvmir_gen_operand_container = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_container)) return failure(); FailureOr _llvmir_gen_operand_value = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_value)) return failure(); auto *ivInst = cast(inst); moduleImport.mapValue(inst) = LLVM::InsertValueOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_container, *_llvmir_gen_operand_value, getPositionFromIndices(ivInst->getIndices())); return success(); } if (inst->getOpcode() == llvm::Instruction::IntToPtr) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); auto op = ::mlir::LLVM::IntToPtrOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::LShr) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::LShrOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setExactFlag(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::Load) { FailureOr _llvmir_gen_operand_addr = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_addr)) return failure(); auto *loadInst = cast(inst); unsigned alignment = loadInst->getAlign().value(); moduleImport.mapValue(inst) = LLVM::LoadOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_addr, alignment, loadInst->isVolatile(), loadInst->hasMetadata(llvm::LLVMContext::MD_nontemporal), loadInst->hasMetadata(llvm::LLVMContext::MD_invariant_load), loadInst->hasMetadata(llvm::LLVMContext::MD_invariant_group), convertAtomicOrderingFromLLVM(loadInst->getOrdering()), getLLVMSyncScope(loadInst)); return success(); } if (inst->getOpcode() == llvm::Instruction::Mul) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::MulOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setIntegerOverflowFlags(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::Or) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::OrOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setDisjointFlag(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::PtrToAddr) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::PtrToAddrOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::PtrToInt) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::PtrToIntOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::Resume) { FailureOr _llvmir_gen_operand_value = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_value)) return failure(); moduleImport.mapNoResultOp(inst) = LLVM::ResumeOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_value); return success(); } if (inst->getOpcode() == llvm::Instruction::Ret) { FailureOr> mlirOperands = moduleImport.convertValues(llvmOperands); if (failed(mlirOperands)) return failure(); moduleImport.mapNoResultOp(inst) = LLVM::ReturnOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *mlirOperands); return success(); } if (inst->getOpcode() == llvm::Instruction::SDiv) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::SDivOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setExactFlag(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::SExt) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::SExtOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::SIToFP) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::SIToFPOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::SRem) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::SRemOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); return success(); } if (inst->getOpcode() == llvm::Instruction::Select) { FailureOr _llvmir_gen_operand_condition = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_condition)) return failure(); FailureOr _llvmir_gen_operand_trueValue = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_trueValue)) return failure(); FailureOr _llvmir_gen_operand_falseValue = moduleImport.convertValue(llvmOperands[2]); if (failed(_llvmir_gen_operand_falseValue)) return failure(); auto op = LLVM::SelectOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_condition, *_llvmir_gen_operand_trueValue, *_llvmir_gen_operand_falseValue); moduleImport.setFastmathFlagsAttr(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::Shl) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::ShlOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setIntegerOverflowFlags(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::ShuffleVector) { FailureOr _llvmir_gen_operand_v1 = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_v1)) return failure(); FailureOr _llvmir_gen_operand_v2 = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_v2)) return failure(); auto *svInst = cast(inst); SmallVector mask(svInst->getShuffleMask()); moduleImport.mapValue(inst) = LLVM::ShuffleVectorOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_v1, *_llvmir_gen_operand_v2, mask); return success(); } if (inst->getOpcode() == llvm::Instruction::Store) { FailureOr _llvmir_gen_operand_value = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_value)) return failure(); FailureOr _llvmir_gen_operand_addr = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_addr)) return failure(); auto *storeInst = cast(inst); unsigned alignment = storeInst->getAlign().value(); moduleImport.mapNoResultOp(inst) = LLVM::StoreOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_value, *_llvmir_gen_operand_addr, alignment, storeInst->isVolatile(), storeInst->hasMetadata(llvm::LLVMContext::MD_nontemporal), storeInst->hasMetadata(llvm::LLVMContext::MD_invariant_group), convertAtomicOrderingFromLLVM(storeInst->getOrdering()), getLLVMSyncScope(storeInst)); return success(); } if (inst->getOpcode() == llvm::Instruction::Sub) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::SubOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setIntegerOverflowFlags(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::Trunc) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); auto op = ::mlir::LLVM::TruncOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); moduleImport.setIntegerOverflowFlags(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::UDiv) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); auto op = ::mlir::LLVM::UDivOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); moduleImport.setExactFlag(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::UIToFP) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); auto op = ::mlir::LLVM::UIToFPOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); moduleImport.setNonNegFlag(inst, op); moduleImport.mapValue(inst) = op; return success(); } if (inst->getOpcode() == llvm::Instruction::URem) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::URemOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); return success(); } if (inst->getOpcode() == llvm::Instruction::Unreachable) { moduleImport.mapNoResultOp(inst) = LLVM::UnreachableOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc())); return success(); } if (inst->getOpcode() == llvm::Instruction::VAArg) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); moduleImport.mapValue(inst) = mlir::LLVM::VaArgOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); return success(); } if (inst->getOpcode() == llvm::Instruction::Xor) { FailureOr _llvmir_gen_operand_lhs = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_lhs)) return failure(); FailureOr _llvmir_gen_operand_rhs = moduleImport.convertValue(llvmOperands[1]); if (failed(_llvmir_gen_operand_rhs)) return failure(); moduleImport.mapValue(inst) = ::mlir::LLVM::XOrOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), *_llvmir_gen_operand_lhs, *_llvmir_gen_operand_rhs); return success(); } if (inst->getOpcode() == llvm::Instruction::ZExt) { FailureOr _llvmir_gen_operand_arg = moduleImport.convertValue(llvmOperands[0]); if (failed(_llvmir_gen_operand_arg)) return failure(); auto op = ::mlir::LLVM::ZExtOp::create(odsBuilder, moduleImport.translateLoc(inst->getDebugLoc()), moduleImport.convertType(inst->getType()), *_llvmir_gen_operand_arg); moduleImport.setNonNegFlag(inst, op); moduleImport.mapValue(inst) = op; return success(); }