@@ -173,9 +173,9 @@ static Address emitPointerWithAlignment(const Expr *expr,
173
173
llvm_unreachable (" NYI" );
174
174
}
175
175
176
- auto ElemTy = cgf.convertTypeForMem (expr->getType ()->getPointeeType ());
176
+ auto eltTy = cgf.convertTypeForMem (expr->getType ()->getPointeeType ());
177
177
addr = cgf.getBuilder ().createElementBitCast (
178
- cgf.getLoc (expr->getSourceRange ()), addr, ElemTy );
178
+ cgf.getLoc (expr->getSourceRange ()), addr, eltTy );
179
179
if (CE->getCastKind () == CK_AddressSpaceConversion) {
180
180
assert (!cir::MissingFeatures::addressSpace ());
181
181
llvm_unreachable (" NYI" );
@@ -616,6 +616,25 @@ void CIRGenFunction::emitStoreOfScalar(mlir::Value value, Address addr,
616
616
LValueBaseInfo baseInfo,
617
617
TBAAAccessInfo tbaaInfo, bool isInit,
618
618
bool isNontemporal) {
619
+ assert (!cir::MissingFeatures::threadLocal () && " NYI" );
620
+
621
+ auto eltTy = addr.getElementType ();
622
+ if (const auto *clangVecTy = ty->getAs <clang::VectorType>()) {
623
+ // Boolean vectors use `iN` as storage type.
624
+ if (clangVecTy->isExtVectorBoolType ()) {
625
+ llvm_unreachable (" isExtVectorBoolType NYI" );
626
+ }
627
+
628
+ // Handle vectors of size 3 like size 4 for better performance.
629
+ const auto vTy = cast<cir::VectorType>(eltTy);
630
+ auto newVecTy =
631
+ CGM.getABIInfo ().getOptimalVectorMemoryType (vTy, getLangOpts ());
632
+
633
+ if (vTy != newVecTy) {
634
+ llvm_unreachable (" NYI" );
635
+ }
636
+ }
637
+
619
638
value = emitToMemory (value, ty);
620
639
621
640
LValue atomicLValue =
@@ -626,26 +645,6 @@ void CIRGenFunction::emitStoreOfScalar(mlir::Value value, Address addr,
626
645
return ;
627
646
}
628
647
629
- mlir::Type SrcTy = value.getType ();
630
- if (const auto *ClangVecTy = ty->getAs <clang::VectorType>()) {
631
- // TODO(CIR): this has fallen out of date with codegen
632
- llvm_unreachable (" NYI: Special treatment of 3-element vector store" );
633
- // auto VecTy = dyn_cast<cir::VectorType>(SrcTy);
634
- // if (!CGM.getCodeGenOpts().PreserveVec3Type &&
635
- // ClangVecTy->getNumElements() == 3) {
636
- // // Handle vec3 special.
637
- // if (VecTy && VecTy.getSize() == 3) {
638
- // // Our source is a vec3, do a shuffle vector to make it a vec4.
639
- // value = builder.createVecShuffle(value.getLoc(), value,
640
- // ArrayRef<int64_t>{0, 1, 2, -1});
641
- // SrcTy = cir::VectorType::get(VecTy.getContext(), VecTy.getEltType(), 4);
642
- // }
643
- // if (addr.getElementType() != SrcTy) {
644
- // addr = addr.withElementType(SrcTy);
645
- // }
646
- // }
647
- }
648
-
649
648
// Update the alloca with more info on initialization.
650
649
assert (addr.getPointer () && " expected pointer to exist" );
651
650
auto SrcAlloca =
@@ -2917,40 +2916,36 @@ mlir::Value CIRGenFunction::emitLoadOfScalar(Address addr, bool isVolatile,
2917
2916
LValueBaseInfo baseInfo,
2918
2917
TBAAAccessInfo tbaaInfo,
2919
2918
bool isNontemporal) {
2920
- // TODO(CIR): this has fallen out of sync with codegen
2921
- // Atomic operations have to be done on integral types
2922
- LValue atomicLValue =
2923
- LValue::makeAddr (addr, ty, getContext (), baseInfo, tbaaInfo);
2924
- if (ty->isAtomicType () || LValueIsSuitableForInlineAtomic (atomicLValue)) {
2925
- llvm_unreachable (" NYI" );
2926
- }
2919
+ assert (!cir::MissingFeatures::threadLocal () && " NYI" );
2920
+ auto eltTy = addr.getElementType ();
2927
2921
2928
- auto ElemTy = addr.getElementType ();
2922
+ if (const auto *clangVecTy = ty->getAs <clang::VectorType>()) {
2923
+ // Boolean vectors use `iN` as storage type.
2924
+ if (clangVecTy->isExtVectorBoolType ()) {
2925
+ llvm_unreachable (" NYI" );
2926
+ }
2929
2927
2930
- if (const auto *ClangVecTy = ty->getAs <clang::VectorType>()) {
2931
2928
// Handle vectors of size 3 like size 4 for better performance.
2932
- const auto VTy = cast<cir::VectorType>(ElemTy);
2929
+ const auto vTy = cast<cir::VectorType>(eltTy);
2930
+ auto newVecTy =
2931
+ CGM.getABIInfo ().getOptimalVectorMemoryType (vTy, getLangOpts ());
2933
2932
2934
- // TODO(CIR): this has fallen out of sync with codegen
2935
- llvm_unreachable (" NYI: Special treatment of 3-element vector store" );
2936
- // if (!CGM.getCodeGenOpts().PreserveVec3Type &&
2937
- // ClangVecTy->getNumElements() == 3) {
2938
- // auto loc = addr.getPointer().getLoc();
2939
- // auto vec4Ty = cir::VectorType::get(VTy.getContext(), VTy.getEltType(), 4);
2940
- // Address Cast = addr.withElementType(vec4Ty);
2941
- // // Now load value.
2942
- // mlir::Value V = builder.createLoad(loc, Cast);
2933
+ if (vTy != newVecTy) {
2934
+ llvm_unreachable (" NYI" );
2935
+ }
2936
+ }
2943
2937
2944
- // // Shuffle vector to get vec3.
2945
- // V = builder.createVecShuffle(loc, V, ArrayRef<int64_t>{0, 1, 2} );
2946
- // return emitFromMemory(V, ty);
2947
- // }
2938
+ LValue atomicLValue =
2939
+ LValue::makeAddr (addr, ty, getContext (), baseInfo, tbaaInfo );
2940
+ if (ty-> isAtomicType () || LValueIsSuitableForInlineAtomic (atomicLValue)) {
2941
+ llvm_unreachable ( " NYI " );
2948
2942
}
2949
2943
2944
+ // TODO(cir): modernize this with addr.withElementType(convertTypeForLoadStore
2950
2945
auto Ptr = addr.getPointer ();
2951
- if (mlir::isa<cir::VoidType>(ElemTy )) {
2952
- ElemTy = cir::IntType::get (&getMLIRContext (), 8 , true );
2953
- auto ElemPtrTy = cir::PointerType::get (&getMLIRContext (), ElemTy );
2946
+ if (mlir::isa<cir::VoidType>(eltTy )) {
2947
+ eltTy = cir::IntType::get (&getMLIRContext (), 8 , true );
2948
+ auto ElemPtrTy = cir::PointerType::get (&getMLIRContext (), eltTy );
2954
2949
Ptr = builder.create <cir::CastOp>(loc, ElemPtrTy, cir::CastKind::bitcast,
2955
2950
Ptr );
2956
2951
}
@@ -2962,7 +2957,6 @@ mlir::Value CIRGenFunction::emitLoadOfScalar(Address addr, bool isVolatile,
2962
2957
CGM.decorateOperationWithTBAA (loadOp, tbaaInfo);
2963
2958
2964
2959
assert (!cir::MissingFeatures::emitScalarRangeCheck () && " NYI" );
2965
-
2966
2960
return emitFromMemory (loadOp, ty);
2967
2961
}
2968
2962
0 commit comments