@@ -81,18 +81,19 @@ void cudaq::opt::populateCCTypeConversions(LLVMTypeConverter *converter) {
8181 return LLVM::LLVMStructType::getLiteral (type.getContext (), members,
8282 type.getPacked ());
8383 });
84- converter->addConversion ([](quake::MeasureType type) -> Type {
85- auto ctx = type.getContext ();
86- auto i32Ty = IntegerType::get (ctx, 32 );
87- auto i64Ty = IntegerType::get (ctx, 64 );
88- return LLVM::LLVMStructType::getLiteral (ctx, {i32Ty, i64Ty});
89- });
9084}
9185
9286std::size_t cudaq::opt::getDataSize (llvm::DataLayout &dataLayout, Type ty) {
9387 LLVMTypeConverter converter (ty.getContext ());
9488 cudaq::opt::populateCCTypeConversions (&converter);
9589 auto llvmDialectTy = converter.convertType (ty);
90+ // `measure_result` -> struct conversion for size calculation
91+ converter.addConversion ([](quake::MeasureType type) -> Type {
92+ auto ctx = type.getContext ();
93+ auto i32Ty = IntegerType::get (ctx, 32 );
94+ auto i64Ty = IntegerType::get (ctx, 64 );
95+ return LLVM::LLVMStructType::getLiteral (ctx, {i32Ty, i64Ty});
96+ });
9697 llvm::LLVMContext context;
9798 LLVM::TypeToLLVMIRTranslator translator (context);
9899 auto llvmTy = translator.translateType (llvmDialectTy);
@@ -103,6 +104,13 @@ std::size_t cudaq::opt::getDataOffset(llvm::DataLayout &dataLayout, Type ty,
103104 std::size_t off) {
104105 LLVMTypeConverter converter (ty.getContext ());
105106 cudaq::opt::populateCCTypeConversions (&converter);
107+ // `measure_result` -> struct conversion for size calculation
108+ converter.addConversion ([](quake::MeasureType type) -> Type {
109+ auto ctx = type.getContext ();
110+ auto i32Ty = IntegerType::get (ctx, 32 );
111+ auto i64Ty = IntegerType::get (ctx, 64 );
112+ return LLVM::LLVMStructType::getLiteral (ctx, {i32Ty, i64Ty});
113+ });
106114 auto llvmDialectTy = converter.convertType (ty);
107115 llvm::LLVMContext context;
108116 LLVM::TypeToLLVMIRTranslator translator (context);
0 commit comments