@@ -49,6 +49,7 @@ using namespace mlir;
49
49
#include " clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc"
50
50
#include " clang/CIR/Interfaces/ASTAttrInterfaces.h"
51
51
#include " clang/CIR/Interfaces/CIROpInterfaces.h"
52
+ #include < clang/CIR/MissingFeatures.h>
52
53
53
54
// ===----------------------------------------------------------------------===//
54
55
// CIR Dialect
@@ -470,28 +471,28 @@ LogicalResult mlir::cir::CastOp::verify() {
470
471
}
471
472
472
473
switch (getKind ()) {
473
- case cir::CastKind::int_to_bool: {
474
+ case mlir:: cir::CastKind::int_to_bool: {
474
475
if (!mlir::isa<mlir::cir::BoolType>(resType))
475
476
return emitOpError () << " requires !cir.bool type for result" ;
476
477
if (!mlir::isa<mlir::cir::IntType>(srcType))
477
478
return emitOpError () << " requires !cir.int type for source" ;
478
479
return success ();
479
480
}
480
- case cir::CastKind::ptr_to_bool: {
481
+ case mlir:: cir::CastKind::ptr_to_bool: {
481
482
if (!mlir::isa<mlir::cir::BoolType>(resType))
482
483
return emitOpError () << " requires !cir.bool type for result" ;
483
484
if (!mlir::isa<mlir::cir::PointerType>(srcType))
484
485
return emitOpError () << " requires !cir.ptr type for source" ;
485
486
return success ();
486
487
}
487
- case cir::CastKind::integral: {
488
+ case mlir:: cir::CastKind::integral: {
488
489
if (!mlir::isa<mlir::cir::IntType>(resType))
489
490
return emitOpError () << " requires !cir.int type for result" ;
490
491
if (!mlir::isa<mlir::cir::IntType>(srcType))
491
492
return emitOpError () << " requires !cir.int type for source" ;
492
493
return success ();
493
494
}
494
- case cir::CastKind::array_to_ptrdecay: {
495
+ case mlir:: cir::CastKind::array_to_ptrdecay: {
495
496
auto arrayPtrTy = mlir::dyn_cast<mlir::cir::PointerType>(srcType);
496
497
auto flatPtrTy = mlir::dyn_cast<mlir::cir::PointerType>(resType);
497
498
if (!arrayPtrTy || !flatPtrTy)
@@ -512,7 +513,7 @@ LogicalResult mlir::cir::CastOp::verify() {
512
513
<< " requires same type for array element and pointee result" ;
513
514
return success ();
514
515
}
515
- case cir::CastKind::bitcast: {
516
+ case mlir:: cir::CastKind::bitcast: {
516
517
// Allow bitcast of structs for calling conventions.
517
518
if (isa<StructType>(srcType) || isa<StructType>(resType))
518
519
return success ();
@@ -537,62 +538,62 @@ LogicalResult mlir::cir::CastOp::verify() {
537
538
<< " requires !cir.ptr or !cir.vector type for source and result" ;
538
539
return success ();
539
540
}
540
- case cir::CastKind::floating: {
541
+ case mlir:: cir::CastKind::floating: {
541
542
if (!mlir::isa<mlir::cir::CIRFPTypeInterface>(srcType) ||
542
543
!mlir::isa<mlir::cir::CIRFPTypeInterface>(resType))
543
544
return emitOpError () << " requires !cir.float type for source and result" ;
544
545
return success ();
545
546
}
546
- case cir::CastKind::float_to_int: {
547
+ case mlir:: cir::CastKind::float_to_int: {
547
548
if (!mlir::isa<mlir::cir::CIRFPTypeInterface>(srcType))
548
549
return emitOpError () << " requires !cir.float type for source" ;
549
550
if (!mlir::dyn_cast<mlir::cir::IntType>(resType))
550
551
return emitOpError () << " requires !cir.int type for result" ;
551
552
return success ();
552
553
}
553
- case cir::CastKind::int_to_ptr: {
554
+ case mlir:: cir::CastKind::int_to_ptr: {
554
555
if (!mlir::dyn_cast<mlir::cir::IntType>(srcType))
555
556
return emitOpError () << " requires !cir.int type for source" ;
556
557
if (!mlir::dyn_cast<mlir::cir::PointerType>(resType))
557
558
return emitOpError () << " requires !cir.ptr type for result" ;
558
559
return success ();
559
560
}
560
- case cir::CastKind::ptr_to_int: {
561
+ case mlir:: cir::CastKind::ptr_to_int: {
561
562
if (!mlir::dyn_cast<mlir::cir::PointerType>(srcType))
562
563
return emitOpError () << " requires !cir.ptr type for source" ;
563
564
if (!mlir::dyn_cast<mlir::cir::IntType>(resType))
564
565
return emitOpError () << " requires !cir.int type for result" ;
565
566
return success ();
566
567
}
567
- case cir::CastKind::float_to_bool: {
568
+ case mlir:: cir::CastKind::float_to_bool: {
568
569
if (!mlir::isa<mlir::cir::CIRFPTypeInterface>(srcType))
569
570
return emitOpError () << " requires !cir.float type for source" ;
570
571
if (!mlir::isa<mlir::cir::BoolType>(resType))
571
572
return emitOpError () << " requires !cir.bool type for result" ;
572
573
return success ();
573
574
}
574
- case cir::CastKind::bool_to_int: {
575
+ case mlir:: cir::CastKind::bool_to_int: {
575
576
if (!mlir::isa<mlir::cir::BoolType>(srcType))
576
577
return emitOpError () << " requires !cir.bool type for source" ;
577
578
if (!mlir::isa<mlir::cir::IntType>(resType))
578
579
return emitOpError () << " requires !cir.int type for result" ;
579
580
return success ();
580
581
}
581
- case cir::CastKind::int_to_float: {
582
+ case mlir:: cir::CastKind::int_to_float: {
582
583
if (!mlir::isa<mlir::cir::IntType>(srcType))
583
584
return emitOpError () << " requires !cir.int type for source" ;
584
585
if (!mlir::isa<mlir::cir::CIRFPTypeInterface>(resType))
585
586
return emitOpError () << " requires !cir.float type for result" ;
586
587
return success ();
587
588
}
588
- case cir::CastKind::bool_to_float: {
589
+ case mlir:: cir::CastKind::bool_to_float: {
589
590
if (!mlir::isa<mlir::cir::BoolType>(srcType))
590
591
return emitOpError () << " requires !cir.bool type for source" ;
591
592
if (!mlir::isa<mlir::cir::CIRFPTypeInterface>(resType))
592
593
return emitOpError () << " requires !cir.float type for result" ;
593
594
return success ();
594
595
}
595
- case cir::CastKind::address_space: {
596
+ case mlir:: cir::CastKind::address_space: {
596
597
auto srcPtrTy = mlir::dyn_cast<mlir::cir::PointerType>(srcType);
597
598
auto resPtrTy = mlir::dyn_cast<mlir::cir::PointerType>(resType);
598
599
if (!srcPtrTy || !resPtrTy)
@@ -601,7 +602,7 @@ LogicalResult mlir::cir::CastOp::verify() {
601
602
return emitOpError () << " requires two types differ in addrspace only" ;
602
603
return success ();
603
604
}
604
- case cir::CastKind::float_to_complex: {
605
+ case mlir:: cir::CastKind::float_to_complex: {
605
606
if (!mlir::isa<mlir::cir::CIRFPTypeInterface>(srcType))
606
607
return emitOpError () << " requires !cir.float type for source" ;
607
608
auto resComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(resType);
@@ -611,7 +612,7 @@ LogicalResult mlir::cir::CastOp::verify() {
611
612
return emitOpError () << " requires source type match result element type" ;
612
613
return success ();
613
614
}
614
- case cir::CastKind::int_to_complex: {
615
+ case mlir:: cir::CastKind::int_to_complex: {
615
616
if (!mlir::isa<mlir::cir::IntType>(srcType))
616
617
return emitOpError () << " requires !cir.int type for source" ;
617
618
auto resComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(resType);
@@ -621,7 +622,7 @@ LogicalResult mlir::cir::CastOp::verify() {
621
622
return emitOpError () << " requires source type match result element type" ;
622
623
return success ();
623
624
}
624
- case cir::CastKind::float_complex_to_real: {
625
+ case mlir:: cir::CastKind::float_complex_to_real: {
625
626
auto srcComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(srcType);
626
627
if (!srcComplexTy)
627
628
return emitOpError () << " requires !cir.complex type for source" ;
@@ -631,7 +632,7 @@ LogicalResult mlir::cir::CastOp::verify() {
631
632
return emitOpError () << " requires source element type match result type" ;
632
633
return success ();
633
634
}
634
- case cir::CastKind::int_complex_to_real: {
635
+ case mlir:: cir::CastKind::int_complex_to_real: {
635
636
auto srcComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(srcType);
636
637
if (!srcComplexTy)
637
638
return emitOpError () << " requires !cir.complex type for source" ;
@@ -641,7 +642,7 @@ LogicalResult mlir::cir::CastOp::verify() {
641
642
return emitOpError () << " requires source element type match result type" ;
642
643
return success ();
643
644
}
644
- case cir::CastKind::float_complex_to_bool: {
645
+ case mlir:: cir::CastKind::float_complex_to_bool: {
645
646
auto srcComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(srcType);
646
647
if (!srcComplexTy ||
647
648
!mlir::isa<mlir::cir::CIRFPTypeInterface>(srcComplexTy.getElementTy ()))
@@ -651,7 +652,7 @@ LogicalResult mlir::cir::CastOp::verify() {
651
652
return emitOpError () << " requires !cir.bool type for result" ;
652
653
return success ();
653
654
}
654
- case cir::CastKind::int_complex_to_bool: {
655
+ case mlir:: cir::CastKind::int_complex_to_bool: {
655
656
auto srcComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(srcType);
656
657
if (!srcComplexTy ||
657
658
!mlir::isa<mlir::cir::IntType>(srcComplexTy.getElementTy ()))
@@ -661,7 +662,7 @@ LogicalResult mlir::cir::CastOp::verify() {
661
662
return emitOpError () << " requires !cir.bool type for result" ;
662
663
return success ();
663
664
}
664
- case cir::CastKind::float_complex: {
665
+ case mlir:: cir::CastKind::float_complex: {
665
666
auto srcComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(srcType);
666
667
if (!srcComplexTy ||
667
668
!mlir::isa<mlir::cir::CIRFPTypeInterface>(srcComplexTy.getElementTy ()))
@@ -674,7 +675,7 @@ LogicalResult mlir::cir::CastOp::verify() {
674
675
<< " requires !cir.complex<!cir.float> type for result" ;
675
676
return success ();
676
677
}
677
- case cir::CastKind::float_complex_to_int_complex: {
678
+ case mlir:: cir::CastKind::float_complex_to_int_complex: {
678
679
auto srcComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(srcType);
679
680
if (!srcComplexTy ||
680
681
!mlir::isa<mlir::cir::CIRFPTypeInterface>(srcComplexTy.getElementTy ()))
@@ -686,7 +687,7 @@ LogicalResult mlir::cir::CastOp::verify() {
686
687
return emitOpError () << " requires !cir.complex<!cir.int> type for result" ;
687
688
return success ();
688
689
}
689
- case cir::CastKind::int_complex: {
690
+ case mlir:: cir::CastKind::int_complex: {
690
691
auto srcComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(srcType);
691
692
if (!srcComplexTy ||
692
693
!mlir::isa<mlir::cir::IntType>(srcComplexTy.getElementTy ()))
@@ -697,7 +698,7 @@ LogicalResult mlir::cir::CastOp::verify() {
697
698
return emitOpError () << " requires !cir.complex<!cir.int> type for result" ;
698
699
return success ();
699
700
}
700
- case cir::CastKind::int_complex_to_float_complex: {
701
+ case mlir:: cir::CastKind::int_complex_to_float_complex: {
701
702
auto srcComplexTy = mlir::dyn_cast<mlir::cir::ComplexType>(srcType);
702
703
if (!srcComplexTy ||
703
704
!mlir::isa<mlir::cir::IntType>(srcComplexTy.getElementTy ()))
@@ -920,6 +921,16 @@ LogicalResult mlir::cir::ComplexImagPtrOp::verify() {
920
921
return success ();
921
922
}
922
923
924
+ // ===----------------------------------------------------------------------===//
925
+ // LoadOp
926
+ // ===----------------------------------------------------------------------===//
927
+
928
+ void mlir::cir::LoadOp::setAtomic (mlir::cir::MemOrder order) {
929
+ setMemOrder (order);
930
+ if (::cir::MissingFeatures::syncScopeID ())
931
+ llvm_unreachable (" NYI" );
932
+ }
933
+
923
934
// ===----------------------------------------------------------------------===//
924
935
// VecCreateOp
925
936
// ===----------------------------------------------------------------------===//
@@ -1030,11 +1041,11 @@ mlir::LogicalResult mlir::cir::ReturnOp::verify() {
1030
1041
// Returns can be present in multiple different scopes, get the
1031
1042
// wrapping function and start from there.
1032
1043
auto *fnOp = getOperation ()->getParentOp ();
1033
- while (!isa<cir::FuncOp>(fnOp))
1044
+ while (!isa<mlir:: cir::FuncOp>(fnOp))
1034
1045
fnOp = fnOp->getParentOp ();
1035
1046
1036
1047
// Make sure return types match function return type.
1037
- if (checkReturnAndFunction (*this , cast<cir::FuncOp>(fnOp)).failed ())
1048
+ if (checkReturnAndFunction (*this , cast<mlir:: cir::FuncOp>(fnOp)).failed ())
1038
1049
return failure ();
1039
1050
1040
1051
return success ();
@@ -2095,8 +2106,8 @@ LogicalResult mlir::cir::GlobalOp::verify() {
2095
2106
2096
2107
void mlir::cir::GlobalOp::build (
2097
2108
OpBuilder &odsBuilder, OperationState &odsState, StringRef sym_name,
2098
- Type sym_type, bool isConstant, cir::GlobalLinkageKind linkage,
2099
- cir::AddressSpaceAttr addrSpace,
2109
+ Type sym_type, bool isConstant, mlir:: cir::GlobalLinkageKind linkage,
2110
+ mlir:: cir::AddressSpaceAttr addrSpace,
2100
2111
function_ref<void (OpBuilder &, Location)> ctorBuilder,
2101
2112
function_ref<void(OpBuilder &, Location)> dtorBuilder) {
2102
2113
odsState.addAttribute (getSymNameAttrName (odsState.name ),
@@ -2108,7 +2119,7 @@ void mlir::cir::GlobalOp::build(
2108
2119
odsBuilder.getUnitAttr ());
2109
2120
2110
2121
::mlir::cir::GlobalLinkageKindAttr linkageAttr =
2111
- cir::GlobalLinkageKindAttr::get (odsBuilder.getContext (), linkage);
2122
+ mlir:: cir::GlobalLinkageKindAttr::get (odsBuilder.getContext (), linkage);
2112
2123
odsState.addAttribute (getLinkageAttrName (odsState.name ), linkageAttr);
2113
2124
2114
2125
if (addrSpace)
@@ -2681,7 +2692,7 @@ void mlir::cir::FuncOp::print(OpAsmPrinter &p) {
2681
2692
// getNumArguments hook not failing.
2682
2693
LogicalResult mlir::cir::FuncOp::verifyType () {
2683
2694
auto type = getFunctionType ();
2684
- if (!isa<cir::FuncType>(type))
2695
+ if (!isa<mlir:: cir::FuncType>(type))
2685
2696
return emitOpError (" requires '" + getFunctionTypeAttrName ().str () +
2686
2697
" ' attribute of function type" );
2687
2698
if (!getNoProto () && type.isVarArg () && type.getNumInputs () == 0 )
@@ -2704,19 +2715,20 @@ LogicalResult mlir::cir::FuncOp::verify() {
2704
2715
if (getLinkage () == cir::GlobalLinkageKind::CommonLinkage)
2705
2716
return emitOpError () << " functions cannot have '"
2706
2717
<< stringifyGlobalLinkageKind (
2707
- cir::GlobalLinkageKind::CommonLinkage)
2718
+ mlir:: cir::GlobalLinkageKind::CommonLinkage)
2708
2719
<< " ' linkage" ;
2709
2720
2710
2721
if (isExternal ()) {
2711
- if (getLinkage () != cir::GlobalLinkageKind::ExternalLinkage &&
2712
- getLinkage () != cir::GlobalLinkageKind::ExternalWeakLinkage)
2713
- return emitOpError () << " external functions must have '"
2714
- << stringifyGlobalLinkageKind (
2715
- cir::GlobalLinkageKind::ExternalLinkage)
2716
- << " ' or '"
2717
- << stringifyGlobalLinkageKind (
2718
- cir::GlobalLinkageKind::ExternalWeakLinkage)
2719
- << " ' linkage" ;
2722
+ if (getLinkage () != mlir::cir::GlobalLinkageKind::ExternalLinkage &&
2723
+ getLinkage () != mlir::cir::GlobalLinkageKind::ExternalWeakLinkage)
2724
+ return emitOpError ()
2725
+ << " external functions must have '"
2726
+ << stringifyGlobalLinkageKind (
2727
+ mlir::cir::GlobalLinkageKind::ExternalLinkage)
2728
+ << " ' or '"
2729
+ << stringifyGlobalLinkageKind (
2730
+ mlir::cir::GlobalLinkageKind::ExternalWeakLinkage)
2731
+ << " ' linkage" ;
2720
2732
return success ();
2721
2733
}
2722
2734
@@ -3212,11 +3224,11 @@ mlir::cir::TryCallOp::getSuccessorOperands(unsigned index) {
3212
3224
3213
3225
LogicalResult mlir::cir::UnaryOp::verify () {
3214
3226
switch (getKind ()) {
3215
- case cir::UnaryOpKind::Inc:
3216
- case cir::UnaryOpKind::Dec:
3217
- case cir::UnaryOpKind::Plus:
3218
- case cir::UnaryOpKind::Minus:
3219
- case cir::UnaryOpKind::Not:
3227
+ case mlir:: cir::UnaryOpKind::Inc:
3228
+ case mlir:: cir::UnaryOpKind::Dec:
3229
+ case mlir:: cir::UnaryOpKind::Plus:
3230
+ case mlir:: cir::UnaryOpKind::Minus:
3231
+ case mlir:: cir::UnaryOpKind::Not:
3220
3232
// Nothing to verify.
3221
3233
return success ();
3222
3234
}
@@ -3233,8 +3245,9 @@ void mlir::cir::AwaitOp::build(
3233
3245
function_ref<void (OpBuilder &, Location)> readyBuilder,
3234
3246
function_ref<void(OpBuilder &, Location)> suspendBuilder,
3235
3247
function_ref<void(OpBuilder &, Location)> resumeBuilder) {
3236
- result.addAttribute (getKindAttrName (result.name ),
3237
- cir::AwaitKindAttr::get (builder.getContext (), kind));
3248
+ result.addAttribute (
3249
+ getKindAttrName (result.name ),
3250
+ mlir::cir::AwaitKindAttr::get (builder.getContext (), kind));
3238
3251
{
3239
3252
OpBuilder::InsertionGuard guard (builder);
3240
3253
Region *readyRegion = result.addRegion ();
@@ -3346,7 +3359,7 @@ LogicalResult mlir::cir::ConstArrayAttr::verify(
3346
3359
3347
3360
if (auto strAttr = mlir::dyn_cast<mlir::StringAttr>(attr)) {
3348
3361
mlir::cir::ArrayType at = mlir::cast<mlir::cir::ArrayType>(type);
3349
- auto intTy = mlir::dyn_cast<cir::IntType>(at.getEltType ());
3362
+ auto intTy = mlir::dyn_cast<mlir:: cir::IntType>(at.getEltType ());
3350
3363
3351
3364
// TODO: add CIR type for char.
3352
3365
if (!intTy || intTy.getWidth () != 8 ) {
@@ -3463,8 +3476,9 @@ LogicalResult mlir::cir::ConstVectorAttr::verify(
3463
3476
::mlir::Type type, mlir::ArrayAttr arrayAttr) {
3464
3477
3465
3478
if (!mlir::isa<mlir::cir::VectorType>(type)) {
3466
- return emitError ()
3467
- << " type of cir::ConstVectorAttr is not a cir::VectorType: " << type;
3479
+ return emitError () << " type of mlir::cir::ConstVectorAttr is not a "
3480
+ " mlir::cir::VectorType: "
3481
+ << type;
3468
3482
}
3469
3483
auto vecType = mlir::cast<mlir::cir::VectorType>(type);
3470
3484
@@ -3654,8 +3668,8 @@ LogicalResult mlir::cir::CopyOp::verify() {
3654
3668
// ===----------------------------------------------------------------------===//
3655
3669
3656
3670
LogicalResult mlir::cir::MemCpyOp::verify () {
3657
- auto voidPtr =
3658
- cir::PointerType::get ( getContext (), cir::VoidType::get (getContext ()));
3671
+ auto voidPtr = mlir::cir::PointerType::get (
3672
+ getContext (), mlir:: cir::VoidType::get (getContext ()));
3659
3673
3660
3674
if (!getLenTy ().isUnsigned ())
3661
3675
return emitError () << " memcpy length must be an unsigned integer" ;
0 commit comments