@@ -95,69 +95,42 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
9595 CPUFastVectorUnaligned = true ;
9696 }
9797
98- // Handle features corresponding to "-ffixed-X" options
99- if (Args.hasArg (options::OPT_ffixed_x1))
100- Features.push_back (" +reserve-x1" );
101- if (Args.hasArg (options::OPT_ffixed_x2))
102- Features.push_back (" +reserve-x2" );
103- if (Args.hasArg (options::OPT_ffixed_x3))
104- Features.push_back (" +reserve-x3" );
105- if (Args.hasArg (options::OPT_ffixed_x4))
106- Features.push_back (" +reserve-x4" );
107- if (Args.hasArg (options::OPT_ffixed_x5))
108- Features.push_back (" +reserve-x5" );
109- if (Args.hasArg (options::OPT_ffixed_x6))
110- Features.push_back (" +reserve-x6" );
111- if (Args.hasArg (options::OPT_ffixed_x7))
112- Features.push_back (" +reserve-x7" );
113- if (Args.hasArg (options::OPT_ffixed_x8))
114- Features.push_back (" +reserve-x8" );
115- if (Args.hasArg (options::OPT_ffixed_x9))
116- Features.push_back (" +reserve-x9" );
117- if (Args.hasArg (options::OPT_ffixed_x10))
118- Features.push_back (" +reserve-x10" );
119- if (Args.hasArg (options::OPT_ffixed_x11))
120- Features.push_back (" +reserve-x11" );
121- if (Args.hasArg (options::OPT_ffixed_x12))
122- Features.push_back (" +reserve-x12" );
123- if (Args.hasArg (options::OPT_ffixed_x13))
124- Features.push_back (" +reserve-x13" );
125- if (Args.hasArg (options::OPT_ffixed_x14))
126- Features.push_back (" +reserve-x14" );
127- if (Args.hasArg (options::OPT_ffixed_x15))
128- Features.push_back (" +reserve-x15" );
129- if (Args.hasArg (options::OPT_ffixed_x16))
130- Features.push_back (" +reserve-x16" );
131- if (Args.hasArg (options::OPT_ffixed_x17))
132- Features.push_back (" +reserve-x17" );
133- if (Args.hasArg (options::OPT_ffixed_x18))
134- Features.push_back (" +reserve-x18" );
135- if (Args.hasArg (options::OPT_ffixed_x19))
136- Features.push_back (" +reserve-x19" );
137- if (Args.hasArg (options::OPT_ffixed_x20))
138- Features.push_back (" +reserve-x20" );
139- if (Args.hasArg (options::OPT_ffixed_x21))
140- Features.push_back (" +reserve-x21" );
141- if (Args.hasArg (options::OPT_ffixed_x22))
142- Features.push_back (" +reserve-x22" );
143- if (Args.hasArg (options::OPT_ffixed_x23))
144- Features.push_back (" +reserve-x23" );
145- if (Args.hasArg (options::OPT_ffixed_x24))
146- Features.push_back (" +reserve-x24" );
147- if (Args.hasArg (options::OPT_ffixed_x25))
148- Features.push_back (" +reserve-x25" );
149- if (Args.hasArg (options::OPT_ffixed_x26))
150- Features.push_back (" +reserve-x26" );
151- if (Args.hasArg (options::OPT_ffixed_x27))
152- Features.push_back (" +reserve-x27" );
153- if (Args.hasArg (options::OPT_ffixed_x28))
154- Features.push_back (" +reserve-x28" );
155- if (Args.hasArg (options::OPT_ffixed_x29))
156- Features.push_back (" +reserve-x29" );
157- if (Args.hasArg (options::OPT_ffixed_x30))
158- Features.push_back (" +reserve-x30" );
159- if (Args.hasArg (options::OPT_ffixed_x31))
160- Features.push_back (" +reserve-x31" );
98+ // Handle features corresponding to "-ffixed-X" options
99+ #define RESERVE_REG (REG ) \
100+ if (Args.hasArg (options::OPT_ffixed_##REG)) \
101+ Features.push_back (" +reserve-" #REG);
102+ RESERVE_REG (x1)
103+ RESERVE_REG (x2)
104+ RESERVE_REG (x3)
105+ RESERVE_REG (x4)
106+ RESERVE_REG (x5)
107+ RESERVE_REG (x6)
108+ RESERVE_REG (x7)
109+ RESERVE_REG (x8)
110+ RESERVE_REG (x9)
111+ RESERVE_REG (x10)
112+ RESERVE_REG (x11)
113+ RESERVE_REG (x12)
114+ RESERVE_REG (x13)
115+ RESERVE_REG (x14)
116+ RESERVE_REG (x15)
117+ RESERVE_REG (x16)
118+ RESERVE_REG (x17)
119+ RESERVE_REG (x18)
120+ RESERVE_REG (x19)
121+ RESERVE_REG (x20)
122+ RESERVE_REG (x21)
123+ RESERVE_REG (x22)
124+ RESERVE_REG (x23)
125+ RESERVE_REG (x24)
126+ RESERVE_REG (x25)
127+ RESERVE_REG (x26)
128+ RESERVE_REG (x27)
129+ RESERVE_REG (x28)
130+ RESERVE_REG (x29)
131+ RESERVE_REG (x30)
132+ RESERVE_REG (x31)
133+ #undef RESERVE_REG
161134
162135 // -mrelax is default, unless -mno-relax is specified.
163136 if (Args.hasFlag (options::OPT_mrelax, options::OPT_mno_relax, true )) {
0 commit comments