Index: lib/Basic/Targets.cpp =================================================================== --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -7992,6 +7992,43 @@ return true; } }; + +// 32-bit RenderScript is armv7 with width and align of 'long' set to 8-bytes +class RenderScript32TargetInfo : public ARMleTargetInfo { +public: + RenderScript32TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) + : ARMleTargetInfo( + llvm::Triple("armv7", Triple.getVendorName(), Triple.getOSName(), + Triple.getEnvironmentName()), + Opts) + { + LongWidth = LongAlign = 64; + } + void getTargetDefines(const LangOptions &Opts, + MacroBuilder &Builder) const override { + Builder.defineMacro("__RENDERSCRIPT__"); + ARMleTargetInfo::getTargetDefines(Opts, Builder); + } +}; + +// 64-bit RenderScript is aarch64 +class RenderScript64TargetInfo : public AArch64leTargetInfo { +public: + RenderScript64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) + : AArch64leTargetInfo( + llvm::Triple("aarch64", Triple.getVendorName(), Triple.getOSName(), + Triple.getEnvironmentName()), + Opts) { } + + void getTargetDefines(const LangOptions &Opts, + MacroBuilder &Builder) const override { + Builder.defineMacro("__RENDERSCRIPT__"); + AArch64leTargetInfo::getTargetDefines(Opts, Builder); + } +}; + } // end anonymous namespace //===----------------------------------------------------------------------===// @@ -8420,6 +8457,11 @@ if (!(Triple == llvm::Triple("wasm64-unknown-unknown"))) return nullptr; return new WebAssemblyOSTargetInfo(Triple, Opts); + + case llvm::Triple::renderscript32: + return new LinuxTargetInfo(Triple, Opts); + case llvm::Triple::renderscript64: + return new LinuxTargetInfo(Triple, Opts); } } Index: test/CodeGen/renderscript.c =================================================================== --- /dev/null +++ test/CodeGen/renderscript.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple=renderscript32-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS32 +// RUN: %clang_cc1 %s -triple=renderscript64-none-linux-android -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-RS64 +// RUN: %clang_cc1 %s -triple=armv7-none-linux-gnueabi -emit-llvm -o - -Werror | FileCheck %s -check-prefix=CHECK-ARM + +// Ensure that the bitcode has the correct triple +// CHECK-RS32: target triple = "armv7-none-linux-gnueabi" +// CHECK-RS64: target triple = "aarch64-none-linux-android" +// CHECK-ARM: target triple = "armv7-none-linux-gnueabi" + +// Ensure that long data type has 8-byte size and alignment in RenderScript +#ifdef __RENDERSCRIPT__ +#define LONG_WIDTH_AND_ALIGN 8 +#else +#define LONG_WIDTH_AND_ALIGN 4 +#endif + +_Static_assert(sizeof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); +_Static_assert(_Alignof(long) == LONG_WIDTH_AND_ALIGN, "sizeof long is wrong"); + +// CHECK-RS32: i64 @test_long(i64 %v) +// CHECK-RS64: i64 @test_long(i64 %v) +// CHECK-ARM: i32 @test_long(i32 %v) +long test_long(long v) { + return v + 1; +}