Index: lib/Basic/Targets.cpp =================================================================== --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -1878,7 +1878,11 @@ void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { - Builder.defineMacro("__R600__"); + if (getTriple().getArch() == llvm::Triple::amdgcn) + Builder.defineMacro("__AMDGCN__"); + else + Builder.defineMacro("__R600__"); + if (hasFMAF) Builder.defineMacro("__HAS_FMAF__"); if (hasLDEXPF) Index: test/Preprocessor/predefined-arch-macros.c =================================================================== --- test/Preprocessor/predefined-arch-macros.c +++ test/Preprocessor/predefined-arch-macros.c @@ -1824,3 +1824,17 @@ // RUN: | FileCheck %s -check-prefix=CHECK_SYSTEMZ_ZVECTOR // // CHECK_SYSTEMZ_ZVECTOR: #define __VEC__ 10301 + +// Begin amdgcn tests ---------------- +// +// RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \ +// RUN: -target amdgcn-unknown-unknown \ +// RUN: | FileCheck %s -check-prefix=CHECK_AMDGCN +// CHECK_AMDGCN: #define __AMDGCN__ 1 + +// Begin r600 tests ---------------- +// +// RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \ +// RUN: -target r600-unknown-unknown \ +// RUN: | FileCheck %s -check-prefix=CHECK_R600 +// CHECK_R600: #define __R600__ 1