Hi t.p.northover,
A subtarget feature for CRC32 instructions was recently added in the ARM64
backend, this patch hooks it up to the currently existing -mcrc/-mnocrc options
such that it is usable as an optional extension from clang.
http://reviews.llvm.org/D3591
Files:
lib/Basic/Targets.cpp
lib/Driver/Tools.cpp
test/Preprocessor/aarch64-target-features.c
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3399,6 +3399,7 @@
};
unsigned FPU;
+ unsigned CRC;
unsigned Crypto;
static const Builtin::Info BuiltinInfo[];
@@ -3475,6 +3476,9 @@
Builder.defineMacro("__ARM_NEON_FP", "7");
}
+ if (CRC)
+ Builder.defineMacro("__ARM_FEATURE_CRC32");
+
if (Crypto) {
Builder.defineMacro("__ARM_FEATURE_CRYPTO");
}
@@ -3498,10 +3502,13 @@
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
FPU = FPUMode;
+ CRC = 0;
Crypto = 0;
for (unsigned i = 0, e = Features.size(); i != e; ++i) {
if (Features[i] == "+neon")
FPU = NeonMode;
+ if (Features[i] == "+crc")
+ CRC = 1;
if (Features[i] == "+crypto")
Crypto = 1;
}
@@ -4492,6 +4499,7 @@
};
unsigned FPU;
+ unsigned CRC;
unsigned Crypto;
static const Builtin::Info BuiltinInfo[];
@@ -4589,6 +4597,9 @@
Builder.defineMacro("__ARM_NEON_FP", "7");
}
+ if (CRC)
+ Builder.defineMacro("__ARM_FEATURE_CRC32");
+
if (Crypto)
Builder.defineMacro("__ARM_FEATURE_CRYPTO");
}
@@ -4608,10 +4619,13 @@
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
FPU = FPUMode;
+ CRC = 0;
Crypto = 0;
for (unsigned i = 0, e = Features.size(); i != e; ++i) {
if (Features[i] == "+neon")
FPU = NeonMode;
+ if (Features[i] == "+crc")
+ CRC = 1;
if (Features[i] == "+crypto")
Crypto = 1;
}
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1540,6 +1540,15 @@
Features.push_back("-crypto");
Features.push_back("-neon");
}
+
+ // En/disable crc
+ if (Arg *A = Args.getLastArg(options::OPT_mcrc,
+ options::OPT_mnocrc)) {
+ if (A->getOption().matches(options::OPT_mcrc))
+ Features.push_back("+crc");
+ else
+ Features.push_back("-crc");
+ }
}
static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple,
Index: test/Preprocessor/aarch64-target-features.c
===================================================================
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -10,6 +10,7 @@
// CHECK: __ARM_ARCH_PROFILE 'A'
// CHECK-NOT: __ARM_FEATURE_BIG_ENDIAN
// CHECK: __ARM_FEATURE_CLZ 1
+// CHECK-NOT: __ARM_FEATURE_CRC32 1
// CHECK-NOT: __ARM_FEATURE_CRYPTO 1
// CHECK: __ARM_FEATURE_DIV 1
// CHECK: __ARM_FEATURE_FMA 1
@@ -27,6 +28,10 @@
// RUN: %clang -target aarch64-none-linux-gnu -mfpu=crypto-neon-fp-armv8 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRYPTO %s
// CHECK-CRYPTO: __ARM_FEATURE_CRYPTO 1
+// RUN: %clang -target aarch64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// CHECK-CRC32: __ARM_FEATURE_CRC32 1
+
// RUN: %clang -target aarch64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
// CHECK-FASTMATH: __ARM_FP_FAST 1
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits