33    if (knownTranslations.count(type))
 
   34      return knownTranslations.lookup(type);
 
   37    llvm::Type *translated =
 
   39            .Case([
this](LLVM::LLVMVoidType) {
 
   40              return llvm::Type::getVoidTy(context);
 
   43                [
this](Float16Type) { 
return llvm::Type::getHalfTy(context); })
 
   44            .Case([
this](BFloat16Type) {
 
   45              return llvm::Type::getBFloatTy(context);
 
   48                [
this](Float32Type) { 
return llvm::Type::getFloatTy(context); })
 
   49            .Case([
this](Float64Type) {
 
   50              return llvm::Type::getDoubleTy(context);
 
   52            .Case([
this](Float80Type) {
 
   53              return llvm::Type::getX86_FP80Ty(context);
 
   55            .Case([
this](Float128Type) {
 
   56              return llvm::Type::getFP128Ty(context);
 
   58            .Case([
this](LLVM::LLVMPPCFP128Type) {
 
   59              return llvm::Type::getPPC_FP128Ty(context);
 
   61            .Case([
this](LLVM::LLVMTokenType) {
 
   62              return llvm::Type::getTokenTy(context);
 
   64            .Case([
this](LLVM::LLVMLabelType) {
 
   65              return llvm::Type::getLabelTy(context);
 
   67            .Case([
this](LLVM::LLVMMetadataType) {
 
   68              return llvm::Type::getMetadataTy(context);
 
   70            .Case([
this](LLVM::LLVMX86AMXType) {
 
   71              return llvm::Type::getX86_AMXTy(context);
 
   73            .Case<LLVM::LLVMArrayType, IntegerType, LLVM::LLVMFunctionType,
 
   74                  LLVM::LLVMPointerType, LLVM::LLVMStructType, VectorType,
 
   75                  LLVM::LLVMTargetExtType, PtrLikeTypeInterface>(
 
   76                [
this](
auto type) { 
return this->translate(type); })
 
   77            .DefaultUnreachable(
"unknown LLVM dialect type");
 
   80    knownTranslations.try_emplace(type, translated);
 
 
   86  llvm::Type *translate(LLVM::LLVMArrayType type) {
 
   87    return llvm::ArrayType::get(
translateType(type.getElementType()),
 
   88                                type.getNumElements());
 
   92  llvm::Type *translate(LLVM::LLVMFunctionType type) {
 
   94    translateTypes(type.getParams(), paramTypes);
 
   95    return llvm::FunctionType::get(
translateType(type.getReturnType()),
 
   96                                   paramTypes, type.isVarArg());
 
  100  llvm::Type *translate(IntegerType type) {
 
  101    return llvm::IntegerType::get(context, type.getWidth());
 
  105  llvm::Type *translate(LLVM::LLVMPointerType type) {
 
  106    return llvm::PointerType::get(context, type.getAddressSpace());
 
  112  llvm::Type *translate(LLVM::LLVMStructType type) {
 
  113    SmallVector<llvm::Type *, 8> subtypes;
 
  114    if (!type.isIdentified()) {
 
  115      translateTypes(type.getBody(), subtypes);
 
  116      return llvm::StructType::get(context, subtypes, type.isPacked());
 
  119    llvm::StructType *structType =
 
  120        llvm::StructType::create(context, type.getName());
 
  123    knownTranslations.try_emplace(type, structType);
 
  127    translateTypes(type.getBody(), subtypes);
 
  128    structType->setBody(subtypes, type.isPacked());
 
  133  llvm::Type *translate(VectorType type) {
 
  135           "expected compatible with LLVM vector type");
 
  136    if (type.isScalable())
 
  137      return llvm::ScalableVectorType::get(
translateType(type.getElementType()),
 
  138                                           type.getNumElements());
 
  139    return llvm::FixedVectorType::get(
translateType(type.getElementType()),
 
  140                                      type.getNumElements());
 
  144  llvm::Type *translate(LLVM::LLVMTargetExtType type) {
 
  145    SmallVector<llvm::Type *> typeParams;
 
  146    translateTypes(type.getTypeParams(), typeParams);
 
  147    return llvm::TargetExtType::get(context, type.getExtTypeName(), typeParams,
 
  148                                    type.getIntParams());
 
  152  llvm::Type *translate(PtrLikeTypeInterface type) {
 
  154        dyn_cast<LLVM::LLVMAddrSpaceAttrInterface>(type.getMemorySpace());
 
  155    assert(memSpace && 
"expected pointer with an LLVM address space");
 
  156    assert(!type.hasPtrMetadata() && 
"expected pointer without metadata");
 
  157    return llvm::PointerType::get(context, memSpace.getAddressSpace());
 
  161  void translateTypes(ArrayRef<Type> types,
 
  162                      SmallVectorImpl<llvm::Type *> &
result) {
 
  164    for (
auto type : types)
 
  169  llvm::LLVMContext &context;
 
  175  llvm::DenseMap<Type, llvm::Type *> knownTranslations;