@@ -325,6 +325,7 @@ void CIRGenFunction::emitStoreOfScalar(mlir::Value value, Address addr,
325325 const auto vecTy = cast<cir::VectorType>(elementType);
326326
327327 // TODO(CIR): Use `ABIInfo::getOptimalVectorMemoryType` once it upstreamed
328+ assert (!cir::MissingFeatures::cirgenABIInfo ());
328329 if (vecTy.getSize () == 3 && !getLangOpts ().PreserveVec3Type )
329330 cgm.errorNYI (addr.getPointer ().getLoc (),
330331 " emitStoreOfScalar Vec3 & PreserveVec3Type disabled" );
@@ -345,7 +346,7 @@ void CIRGenFunction::emitStoreOfScalar(mlir::Value value, Address addr,
345346 }
346347
347348 assert (currSrcLoc && " must pass in source location" );
348- builder.createStore (*currSrcLoc, value, addr /* , isVolatile*/ );
349+ builder.createStore (*currSrcLoc, value, addr, isVolatile);
349350
350351 if (isNontemporal) {
351352 cgm.errorNYI (addr.getPointer ().getLoc (), " emitStoreOfScalar nontemporal" );
@@ -543,23 +544,52 @@ void CIRGenFunction::emitStoreOfScalar(mlir::Value value, LValue lvalue,
543544 lvalue.getType (), isInit, /* isNontemporal=*/ false );
544545}
545546
546- mlir::Value CIRGenFunction::emitLoadOfScalar (LValue lvalue,
547- SourceLocation loc) {
547+ mlir::Value CIRGenFunction::emitLoadOfScalar (Address addr, bool isVolatile,
548+ QualType ty, SourceLocation loc,
549+ LValueBaseInfo baseInfo) {
548550 assert (!cir::MissingFeatures::opLoadStoreThreadLocal ());
549- assert (!cir::MissingFeatures::opLoadEmitScalarRangeCheck ());
550- assert (!cir::MissingFeatures::opLoadBooleanRepresentation ());
551-
552- Address addr = lvalue.getAddress ();
553551 mlir::Type eltTy = addr.getElementType ();
554552
553+ if (const auto *clangVecTy = ty->getAs <clang::VectorType>()) {
554+ if (clangVecTy->isExtVectorBoolType ()) {
555+ cgm.errorNYI (loc, " emitLoadOfScalar: ExtVectorBoolType" );
556+ return nullptr ;
557+ }
558+
559+ const auto vecTy = cast<cir::VectorType>(eltTy);
560+
561+ // Handle vectors of size 3 like size 4 for better performance.
562+ assert (!cir::MissingFeatures::cirgenABIInfo ());
563+ if (vecTy.getSize () == 3 && !getLangOpts ().PreserveVec3Type )
564+ cgm.errorNYI (addr.getPointer ().getLoc (),
565+ " emitLoadOfScalar Vec3 & PreserveVec3Type disabled" );
566+ }
567+
568+ assert (!cir::MissingFeatures::opLoadStoreTbaa ());
569+ LValue atomicLValue = LValue::makeAddr (addr, ty, baseInfo);
570+ if (ty->isAtomicType () || isLValueSuitableForInlineAtomic (atomicLValue))
571+ cgm.errorNYI (" emitLoadOfScalar: load atomic" );
572+
555573 if (mlir::isa<cir::VoidType>(eltTy))
556574 cgm.errorNYI (loc, " emitLoadOfScalar: void type" );
557575
558- mlir::Value loadOp = builder.createLoad (getLoc (loc), addr);
576+ assert (!cir::MissingFeatures::opLoadEmitScalarRangeCheck ());
577+
578+ mlir::Value loadOp = builder.createLoad (getLoc (loc), addr, isVolatile);
579+ if (!ty->isBooleanType () && ty->hasBooleanRepresentation ())
580+ cgm.errorNYI (" emitLoadOfScalar: boolean type with boolean representation" );
559581
560582 return loadOp;
561583}
562584
585+ mlir::Value CIRGenFunction::emitLoadOfScalar (LValue lvalue,
586+ SourceLocation loc) {
587+ assert (!cir::MissingFeatures::opLoadStoreNontemporal ());
588+ assert (!cir::MissingFeatures::opLoadStoreTbaa ());
589+ return emitLoadOfScalar (lvalue.getAddress (), lvalue.isVolatile (),
590+ lvalue.getType (), loc, lvalue.getBaseInfo ());
591+ }
592+
563593// / Given an expression that represents a value lvalue, this
564594// / method emits the address of the lvalue, then loads the result as an rvalue,
565595// / returning the rvalue.
0 commit comments