llvm::StringMap<bool> Features;
Target->getDefaultFeatures(Features);
- // Fist the last of each option;
- llvm::StringMap<unsigned> LastOpt;
- for (unsigned I = 0, N = Opts->FeaturesAsWritten.size();
- I < N; ++I) {
- const char *Name = Opts->FeaturesAsWritten[I].c_str() + 1;
- LastOpt[Name] = I;
- }
-
// Apply the user specified deltas.
for (unsigned I = 0, N = Opts->FeaturesAsWritten.size();
I < N; ++I) {
const char *Name = Opts->FeaturesAsWritten[I].c_str();
-
- // If this option was overridden, ignore it.
- llvm::StringMap<unsigned>::iterator LastI = LastOpt.find(Name + 1);
- assert(LastI != LastOpt.end());
- unsigned Last = LastI->second;
- if (Last != I)
- continue;
-
// Apply the feature via the target.
bool Enabled = Name[0] == '+';
Target->setFeatureEnabled(Features, Name + 1, Enabled);
getX86TargetFeatures(Args, Features);
break;
}
- for (std::vector<const char *>::iterator I = Features.begin(),
- E = Features.end();
- I != E; ++I) {
+
+ // Find the last of each feature.
+ llvm::StringMap<unsigned> LastOpt;
+ for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+ const char *Name = Features[I];
+ assert(Name[0] == '-' || Name[0] == '+');
+ LastOpt[Name + 1] = I;
+ }
+
+ for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+ // If this feature was overridden, ignore it.
+ const char *Name = Features[I];
+ llvm::StringMap<unsigned>::iterator LastI = LastOpt.find(Name + 1);
+ assert(LastI != LastOpt.end());
+ unsigned Last = LastI->second;
+ if (Last != I)
+ continue;
+
CmdArgs.push_back("-target-feature");
- CmdArgs.push_back(*I);
+ CmdArgs.push_back(Name);
}
}
// RUN: %clang -target i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse 2>&1 | FileCheck %s
-// CHECK: "pentium4" "-target-feature" "+sse" "-target-feature" "+sse4" "-target-feature" "-sse" "-target-feature" "-mmx" "-target-feature" "+sse"
+// CHECK: "pentium4" "-target-feature" "+sse4" "-target-feature" "-mmx" "-target-feature" "+sse"
+// Note that we filter out all but the last -m(no)sse.