[PATCH] D21334: Add TargetInfo for 32-bit and 64-bit RenderScript
Pirama Arumuga Nainar via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 1 12:14:35 PDT 2016
pirama updated this revision to Diff 62520.
pirama added a comment.
Reformatted with clang-format for just the parts I added. I ignored
clang-format-suggested changes in code unrelated to this patch.
Is there a policy or practise on periodically fixing format-related issues? If
not, I can format this file in an one-off basis in a separate patch.
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,42 @@
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 +8456,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.62520.patch
Type: text/x-patch
Size: 3473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160701/46935ae3/attachment-0001.bin>
More information about the cfe-commits
mailing list