@@ -1757,6 +1757,53 @@ def MSVtorDisp : InheritableAttr {
1757
1757
let Documentation = [Undocumented];
1758
1758
}
1759
1759
1760
- def Unaligned : IgnoredAttr {
1761
- let Spellings = [Keyword<"__unaligned">];
1762
- }
1760
+ def Unaligned : IgnoredAttr {
1761
+ let Spellings = [Keyword<"__unaligned">];
1762
+ }
1763
+
1764
+ def LoopHint : Attr {
1765
+ /// vectorize: vectorizes loop operations if 'value != 0'.
1766
+ /// vectorize_width: vectorize loop operations with width 'value'.
1767
+ /// interleave: interleave multiple loop iterations if 'value != 0'.
1768
+ /// interleave_count: interleaves 'value' loop interations.
1769
+
1770
+ /// FIXME: Add Pragma spelling to tablegen and
1771
+ /// use it here.
1772
+ let Spellings = [Keyword<"loop">];
1773
+
1774
+ /// State of the loop optimization specified by the spelling.
1775
+ let Args = [EnumArgument<"Option", "OptionType",
1776
+ ["vectorize", "vectorize_width", "interleave", "interleave_count"],
1777
+ ["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount"]>,
1778
+ DefaultIntArgument<"Value", 1>];
1779
+
1780
+ let AdditionalMembers = [{
1781
+ static StringRef getOptionName(int Option) {
1782
+ switch(Option) {
1783
+ case Vectorize: return "vectorize";
1784
+ case VectorizeWidth: return "vectorize_width";
1785
+ case Interleave: return "interleave";
1786
+ case InterleaveCount: return "interleave_count";
1787
+ }
1788
+ llvm_unreachable("Unhandled LoopHint option.");
1789
+ }
1790
+
1791
+ static StringRef getValueName(int Value) {
1792
+ if (Value)
1793
+ return "enable";
1794
+ return "disable";
1795
+ }
1796
+
1797
+ // FIXME: Modify pretty printer to print this pragma.
1798
+ void print(raw_ostream &OS, const PrintingPolicy &Policy) const {
1799
+ OS << "#pragma clang loop " << getOptionName(option) << "(";
1800
+ if (option == VectorizeWidth || option == InterleaveCount)
1801
+ OS << value;
1802
+ else
1803
+ OS << getValueName(value);
1804
+ OS << ")\n";
1805
+ }
1806
+ }];
1807
+
1808
+ let Documentation = [Undocumented];
1809
+ }
0 commit comments