[PATCH] D21334: Add TargetInfo for 32-bit and 64-bit RenderScript
Pirama Arumuga Nainar via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 14 13:22:52 PDT 2016
pirama updated this revision to Diff 60735.
pirama added a comment.
- revise test
http://reviews.llvm.org/D21334
Files:
lib/Basic/Targets.cpp
test/CodeGen/renderscript.c
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;
+}
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<WebAssembly64TargetInfo>(Triple, Opts);
+
+ case llvm::Triple::renderscript32:
+ return new LinuxTargetInfo<RenderScript32TargetInfo>(Triple, Opts);
+ case llvm::Triple::renderscript64:
+ return new LinuxTargetInfo<RenderScript64TargetInfo>(Triple, Opts);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21334.60735.patch
Type: text/x-patch
Size: 3358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160614/6f55ffe7/attachment-0001.bin>
More information about the cfe-commits
mailing list