@@ -766,75 +766,17 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
766
766
IS.ParamTypeDefs .push_back (TyEl);
767
767
}
768
768
769
+ // Set default properties to true.
770
+ setDefaultProperties (R);
771
+
769
772
// Parse the intrinsic properties.
770
773
ListInit *PropList = R->getValueAsListInit (" IntrProperties" );
771
774
for (unsigned i = 0 , e = PropList->size (); i != e; ++i) {
772
775
Record *Property = PropList->getElementAsRecord (i);
773
776
assert (Property->isSubClassOf (" IntrinsicProperty" ) &&
774
777
" Expected a property!" );
775
778
776
- if (Property->getName () == " IntrNoMem" )
777
- ModRef = NoMem;
778
- else if (Property->getName () == " IntrReadMem" )
779
- ModRef = ModRefBehavior (ModRef & ~MR_Mod);
780
- else if (Property->getName () == " IntrWriteMem" )
781
- ModRef = ModRefBehavior (ModRef & ~MR_Ref);
782
- else if (Property->getName () == " IntrArgMemOnly" )
783
- ModRef = ModRefBehavior ((ModRef & ~MR_Anywhere) | MR_ArgMem);
784
- else if (Property->getName () == " IntrInaccessibleMemOnly" )
785
- ModRef = ModRefBehavior ((ModRef & ~MR_Anywhere) | MR_InaccessibleMem);
786
- else if (Property->getName () == " IntrInaccessibleMemOrArgMemOnly" )
787
- ModRef = ModRefBehavior ((ModRef & ~MR_Anywhere) | MR_ArgMem |
788
- MR_InaccessibleMem);
789
- else if (Property->getName () == " Commutative" )
790
- isCommutative = true ;
791
- else if (Property->getName () == " Throws" )
792
- canThrow = true ;
793
- else if (Property->getName () == " IntrNoDuplicate" )
794
- isNoDuplicate = true ;
795
- else if (Property->getName () == " IntrConvergent" )
796
- isConvergent = true ;
797
- else if (Property->getName () == " IntrNoReturn" )
798
- isNoReturn = true ;
799
- else if (Property->getName () == " IntrNoSync" )
800
- isNoSync = true ;
801
- else if (Property->getName () == " IntrNoFree" )
802
- isNoFree = true ;
803
- else if (Property->getName () == " IntrWillReturn" )
804
- isWillReturn = true ;
805
- else if (Property->getName () == " IntrCold" )
806
- isCold = true ;
807
- else if (Property->getName () == " IntrSpeculatable" )
808
- isSpeculatable = true ;
809
- else if (Property->getName () == " IntrHasSideEffects" )
810
- hasSideEffects = true ;
811
- else if (Property->isSubClassOf (" NoCapture" )) {
812
- unsigned ArgNo = Property->getValueAsInt (" ArgNo" );
813
- ArgumentAttributes.emplace_back (ArgNo, NoCapture, 0 );
814
- } else if (Property->isSubClassOf (" NoAlias" )) {
815
- unsigned ArgNo = Property->getValueAsInt (" ArgNo" );
816
- ArgumentAttributes.emplace_back (ArgNo, NoAlias, 0 );
817
- } else if (Property->isSubClassOf (" Returned" )) {
818
- unsigned ArgNo = Property->getValueAsInt (" ArgNo" );
819
- ArgumentAttributes.emplace_back (ArgNo, Returned, 0 );
820
- } else if (Property->isSubClassOf (" ReadOnly" )) {
821
- unsigned ArgNo = Property->getValueAsInt (" ArgNo" );
822
- ArgumentAttributes.emplace_back (ArgNo, ReadOnly, 0 );
823
- } else if (Property->isSubClassOf (" WriteOnly" )) {
824
- unsigned ArgNo = Property->getValueAsInt (" ArgNo" );
825
- ArgumentAttributes.emplace_back (ArgNo, WriteOnly, 0 );
826
- } else if (Property->isSubClassOf (" ReadNone" )) {
827
- unsigned ArgNo = Property->getValueAsInt (" ArgNo" );
828
- ArgumentAttributes.emplace_back (ArgNo, ReadNone, 0 );
829
- } else if (Property->isSubClassOf (" ImmArg" )) {
830
- unsigned ArgNo = Property->getValueAsInt (" ArgNo" );
831
- ArgumentAttributes.emplace_back (ArgNo, ImmArg, 0 );
832
- } else if (Property->isSubClassOf (" Align" )) {
833
- unsigned ArgNo = Property->getValueAsInt (" ArgNo" );
834
- uint64_t Align = Property->getValueAsInt (" Align" );
835
- ArgumentAttributes.emplace_back (ArgNo, Alignment, Align);
836
- } else
837
- llvm_unreachable (" Unknown property!" );
779
+ setProperty (Property);
838
780
}
839
781
840
782
// Also record the SDPatternOperator Properties.
@@ -844,6 +786,84 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
844
786
llvm::sort (ArgumentAttributes);
845
787
}
846
788
789
+ void CodeGenIntrinsic::setDefaultProperties (Record *R) {
790
+ // opt-out of using default attributes.
791
+ if (R->getValueAsBit (" DisableDefaultAttributes" ))
792
+ return ;
793
+
794
+ std::vector<Record *> Defs =
795
+ R->getRecords ().getAllDerivedDefinitions (" IntrinsicProperty" );
796
+
797
+ for (Record *Rec : Defs)
798
+ if (Rec->getValueAsBit (" IsDefault" ))
799
+ setProperty (Rec);
800
+ }
801
+
802
+ void CodeGenIntrinsic::setProperty (Record *R) {
803
+ if (R->getName () == " IntrNoMem" )
804
+ ModRef = NoMem;
805
+ else if (R->getName () == " IntrReadMem" )
806
+ ModRef = ModRefBehavior (ModRef & ~MR_Mod);
807
+ else if (R->getName () == " IntrWriteMem" )
808
+ ModRef = ModRefBehavior (ModRef & ~MR_Ref);
809
+ else if (R->getName () == " IntrArgMemOnly" )
810
+ ModRef = ModRefBehavior ((ModRef & ~MR_Anywhere) | MR_ArgMem);
811
+ else if (R->getName () == " IntrInaccessibleMemOnly" )
812
+ ModRef = ModRefBehavior ((ModRef & ~MR_Anywhere) | MR_InaccessibleMem);
813
+ else if (R->getName () == " IntrInaccessibleMemOrArgMemOnly" )
814
+ ModRef = ModRefBehavior ((ModRef & ~MR_Anywhere) | MR_ArgMem |
815
+ MR_InaccessibleMem);
816
+ else if (R->getName () == " Commutative" )
817
+ isCommutative = true ;
818
+ else if (R->getName () == " Throws" )
819
+ canThrow = true ;
820
+ else if (R->getName () == " IntrNoDuplicate" )
821
+ isNoDuplicate = true ;
822
+ else if (R->getName () == " IntrConvergent" )
823
+ isConvergent = true ;
824
+ else if (R->getName () == " IntrNoReturn" )
825
+ isNoReturn = true ;
826
+ else if (R->getName () == " IntrNoSync" )
827
+ isNoSync = true ;
828
+ else if (R->getName () == " IntrNoFree" )
829
+ isNoFree = true ;
830
+ else if (R->getName () == " IntrWillReturn" )
831
+ isWillReturn = true ;
832
+ else if (R->getName () == " IntrCold" )
833
+ isCold = true ;
834
+ else if (R->getName () == " IntrSpeculatable" )
835
+ isSpeculatable = true ;
836
+ else if (R->getName () == " IntrHasSideEffects" )
837
+ hasSideEffects = true ;
838
+ else if (R->isSubClassOf (" NoCapture" )) {
839
+ unsigned ArgNo = R->getValueAsInt (" ArgNo" );
840
+ ArgumentAttributes.emplace_back (ArgNo, NoCapture, 0 );
841
+ } else if (R->isSubClassOf (" NoAlias" )) {
842
+ unsigned ArgNo = R->getValueAsInt (" ArgNo" );
843
+ ArgumentAttributes.emplace_back (ArgNo, NoAlias, 0 );
844
+ } else if (R->isSubClassOf (" Returned" )) {
845
+ unsigned ArgNo = R->getValueAsInt (" ArgNo" );
846
+ ArgumentAttributes.emplace_back (ArgNo, Returned, 0 );
847
+ } else if (R->isSubClassOf (" ReadOnly" )) {
848
+ unsigned ArgNo = R->getValueAsInt (" ArgNo" );
849
+ ArgumentAttributes.emplace_back (ArgNo, ReadOnly, 0 );
850
+ } else if (R->isSubClassOf (" WriteOnly" )) {
851
+ unsigned ArgNo = R->getValueAsInt (" ArgNo" );
852
+ ArgumentAttributes.emplace_back (ArgNo, WriteOnly, 0 );
853
+ } else if (R->isSubClassOf (" ReadNone" )) {
854
+ unsigned ArgNo = R->getValueAsInt (" ArgNo" );
855
+ ArgumentAttributes.emplace_back (ArgNo, ReadNone, 0 );
856
+ } else if (R->isSubClassOf (" ImmArg" )) {
857
+ unsigned ArgNo = R->getValueAsInt (" ArgNo" );
858
+ ArgumentAttributes.emplace_back (ArgNo, ImmArg, 0 );
859
+ } else if (R->isSubClassOf (" Align" )) {
860
+ unsigned ArgNo = R->getValueAsInt (" ArgNo" );
861
+ uint64_t Align = R->getValueAsInt (" Align" );
862
+ ArgumentAttributes.emplace_back (ArgNo, Alignment, Align);
863
+ } else
864
+ llvm_unreachable (" Unknown property!" );
865
+ }
866
+
847
867
bool CodeGenIntrinsic::isParamAPointer (unsigned ParamIdx) const {
848
868
if (ParamIdx >= IS.ParamVTs .size ())
849
869
return false ;
0 commit comments