Skip to content

Commit 2525eb2

Browse files
pawosm-armvjayathirtha-nv
authored andcommitted
Flang: __ARM_ARCH and friends defined for AArch64, __x86_64 and others defined for x86_64 only
Signed-off-by: Paul Osmialowski <[email protected]>
1 parent ae2a620 commit 2525eb2

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lib/Driver/ToolChains/Flang.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -566,16 +566,28 @@ void FlangFrontend::ConstructJob(Compilation &C, const JobAction &JA,
566566
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__linux__");
567567
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__NO_MATH_INLINES");
568568
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__LP64__");
569-
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__x86_64");
570-
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__x86_64__");
571569
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__LONG_MAX__=9223372036854775807L");
572570
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__SIZE_TYPE__=unsigned long int");
573571
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__PTRDIFF_TYPE__=long int");
572+
switch (getToolChain().getEffectiveTriple().getArch()) {
573+
case llvm::Triple::aarch64:
574+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__aarch64");
575+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__aarch64__");
576+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__ARM_ARCH=8");
577+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__ARM_ARCH__=8");
578+
break;
579+
case llvm::Triple::x86_64:
580+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__x86_64");
581+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__x86_64__");
582+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__amd_64__amd64__");
583+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__k8");
584+
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__k8__");
585+
break;
586+
default: /* generic 64-bit */
587+
;
588+
}
574589
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__THROW=");
575590
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__extension__=");
576-
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__amd_64__amd64__");
577-
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__k8");
578-
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__k8__");
579591
UpperCmdArgs.push_back("-def"); UpperCmdArgs.push_back("__PGLLVM__");
580592

581593
// Enable preprocessor

0 commit comments

Comments
 (0)