mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 11:26:02 +03:00
Default enable attribute cx16 (-mattr=+cx16
).
This enables code generation for cmpxchg16b instruction which is not available on very old 64bit CPUs. The user can change this be choosing a different cpu (`-mcpu=...`) or by explicitly disabling the attribute (`-mattr=-cx16`).
This commit is contained in:
parent
56482f8e30
commit
2cdbe58d86
1 changed files with 18 additions and 0 deletions
|
@ -464,6 +464,24 @@ llvm::TargetMachine* createTargetMachine(
|
||||||
// to default to "generic").
|
// to default to "generic").
|
||||||
cpu = getTargetCPU(cpu, triple);
|
cpu = getTargetCPU(cpu, triple);
|
||||||
|
|
||||||
|
// cmpxchg16b is not available on old 64bit CPUs. Enable code generation
|
||||||
|
// if the user did not make an explicit choice.
|
||||||
|
if (cpu == "x86-64")
|
||||||
|
{
|
||||||
|
#if LDC_LLVM_VER >= 304
|
||||||
|
const char* cx16_plus = "+cx16";
|
||||||
|
const char* cx16_minus = "-cx16";
|
||||||
|
#else
|
||||||
|
const char* cx16_plus = "+cmpxchg16b";
|
||||||
|
const char* cx16_minus = "-cmpxchg16b";
|
||||||
|
#endif
|
||||||
|
bool cx16 = false;
|
||||||
|
for (unsigned i = 0; i < attrs.size(); ++i)
|
||||||
|
if (attrs[i] == cx16_plus || attrs[i] == cx16_minus) cx16 = true;
|
||||||
|
if (!cx16)
|
||||||
|
features.AddFeature(cx16_plus);
|
||||||
|
}
|
||||||
|
|
||||||
if (Logger::enabled())
|
if (Logger::enabled())
|
||||||
{
|
{
|
||||||
Logger::println("Targeting '%s' (CPU '%s' with features '%s')",
|
Logger::println("Targeting '%s' (CPU '%s' with features '%s')",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue