[clang] [clang] Better bitfield access units (PR #65742)

2023-10-13 Thread Nigel Perks via cfe-commits

nigelp-xmos wrote:

XCore: yes the current setting of the new flag, the default false value, is 
right for XCore. Misaligned loads can generate a function call. We do not have 
benchmarks as such, but comparing the code generated for the test files touched 
here, there is an improvement. In particular bitfield-ir.cpp is a big 
improvement.

In bitfield.cpp, two misaligned loads remain. One disappears if I remove the 
struct packed attribute. The other remains: N0::read31(). This is not a 
problem, and is not a degradation, it's a function call intended for the 
purpose; just mentioning for information.

https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0871337 - [XCore] Adapt Clang tests to opaque pointers.

2023-02-16 Thread Nigel Perks via cfe-commits

Author: Nigel Perks
Date: 2023-02-16T16:32:29Z
New Revision: 0871337d97f71cac2dbc9cce33c0ecca3c5e5f9c

URL: 
https://github.com/llvm/llvm-project/commit/0871337d97f71cac2dbc9cce33c0ecca3c5e5f9c
DIFF: 
https://github.com/llvm/llvm-project/commit/0871337d97f71cac2dbc9cce33c0ecca3c5e5f9c.diff

LOG: [XCore] Adapt Clang tests to opaque pointers.

Differential Revision: https://reviews.llvm.org/D144195

Added: 


Modified: 
clang/test/CodeGen/xcore-abi.c
clang/test/CodeGen/xcore-stringtype.c

Removed: 




diff  --git a/clang/test/CodeGen/xcore-abi.c b/clang/test/CodeGen/xcore-abi.c
index 28fdae57de72..4dd0f221533b 100644
--- a/clang/test/CodeGen/xcore-abi.c
+++ b/clang/test/CodeGen/xcore-abi.c
@@ -1,12 +1,12 @@
 // REQUIRES: xcore-registered-target
-// RUN: %clang_cc1 -no-opaque-pointers -triple xcore -verify %s
+// RUN: %clang_cc1 -triple xcore -verify %s
 _Static_assert(sizeof(long long) == 8, "sizeof long long is wrong");
 _Static_assert(_Alignof(long long) == 4, "alignof long long is wrong");
 
 _Static_assert(sizeof(double) == 8, "sizeof double is wrong");
 _Static_assert(_Alignof(double) == 4, "alignof double is wrong");
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple xcore-unknown-unknown 
-fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common 
-emit-llvm -o - %s | FileCheck %s
 
 // CHECK: target triple = "xcore-unknown-unknown"
 
@@ -25,91 +25,77 @@ void testva (int n, ...) {
   // CHECK-LABEL: testva
   va_list ap;
   va_start(ap,n);
-  // CHECK: [[AP:%[a-z0-9]+]] = alloca i8*, align 4
-  // CHECK: [[AP1:%[a-z0-9]+]] = bitcast i8** [[AP]] to i8*
-  // CHECK: call void @llvm.va_start(i8* [[AP1]])
+  // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4
+  // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4
+  // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4
+  // CHECK: call void @llvm.va_start(ptr [[AP]])
 
   char* v1 = va_arg (ap, char*);
   f(v1);
-  // CHECK: [[I:%[a-z0-9]+]] = load i8*, i8** [[AP]]
-  // CHECK: [[P:%[a-z0-9]+]] = bitcast i8* [[I]] to i8**
-  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, i8* [[I]], i32 4
-  // CHECK: store i8* [[IN]], i8** [[AP]]
-  // CHECK: [[V1:%[a-z0-9]+]] = load i8*, i8** [[P]]
-  // CHECK: store i8* [[V1]], i8** [[V:%[a-z0-9]+]], align 4
-  // CHECK: [[V2:%[a-z0-9]+]] = load i8*, i8** [[V]], align 4
-  // CHECK: call void @f(i8* noundef [[V2]])
+  // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
+  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
+  // CHECK: store ptr [[IN]], ptr [[AP]]
+  // CHECK: [[V1:%[a-z0-9]+]] = load ptr, ptr [[I]]
+  // CHECK: store ptr [[V1]], ptr [[V:%[a-z0-9]+]], align 4
+  // CHECK: [[V2:%[a-z0-9]+]] = load ptr, ptr [[V]], align 4
+  // CHECK: call void @f(ptr noundef [[V2]])
 
   char v2 = va_arg (ap, char); // expected-warning{{second argument to 
'va_arg' is of promotable type 'char'}}
   f(&v2);
-  // CHECK: [[I:%[a-z0-9]+]] = load i8*, i8** [[AP]]
-  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, i8* [[I]], i32 4
-  // CHECK: store i8* [[IN]], i8** [[AP]]
-  // CHECK: [[V1:%[a-z0-9]+]] = load i8, i8* [[I]]
-  // CHECK: store i8 [[V1]], i8* [[V:%[a-z0-9]+]], align 1
-  // CHECK: call void @f(i8* noundef [[V]])
+  // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
+  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
+  // CHECK: store ptr [[IN]], ptr [[AP]]
+  // CHECK: [[V1:%[a-z0-9]+]] = load i8, ptr [[I]]
+  // CHECK: store i8 [[V1]], ptr [[V:%[a-z0-9]+]], align 1
+  // CHECK: call void @f(ptr noundef [[V]])
 
   int v3 = va_arg (ap, int);
   f(&v3);
-  // CHECK: [[I:%[a-z0-9]+]] = load i8*, i8** [[AP]]
-  // CHECK: [[P:%[a-z0-9]+]] = bitcast i8* [[I]] to i32*
-  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, i8* [[I]], i32 4
-  // CHECK: store i8* [[IN]], i8** [[AP]]
-  // CHECK: [[V1:%[a-z0-9]+]] = load i32, i32* [[P]]
-  // CHECK: store i32 [[V1]], i32* [[V:%[a-z0-9]+]], align 4
-  // CHECK: [[V2:%[a-z0-9]+]] = bitcast i32* [[V]] to i8*
-  // CHECK: call void @f(i8* noundef [[V2]])
+  // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
+  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
+  // CHECK: store ptr [[IN]], ptr [[AP]]
+  // CHECK: [[V1:%[a-z0-9]+]] = load i32, ptr [[I]]
+  // CHECK: store i32 [[V1]], ptr [[V:%[a-z0-9]+]], align 4
+  // CHECK: call void @f(ptr noundef [[V]])
 
   long long int v4 = va_arg (ap, long long int);
   f(&v4);
-  // CHECK: [[I:%[a-z0-9]+]] = load i8*, i8** [[AP]]
-  // CHECK: [[P:%[a-z0-9]+]] = bitcast i8* [[I]] to i64*
-  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, i8* [[I]], i32 8
-  // CHECK: store i8* [[IN]], i8** [[AP]]
-  // CHECK: [[V1:%[a-z0-9]+]] = load i64, i64* [[P]]
-  // CHECK: store i64 [[V1]], i64* [[V:%[a-z0-9]+]], align 4
-  // CHECK:[[V2:%[a-z0-9]+]] = bitcast i6

[clang] e7b6c0f - [clang][XCore] Define __xcore__ for XCore target.

2021-04-26 Thread Nigel Perks via cfe-commits

Author: Nigel Perks
Date: 2021-04-26T15:06:04+01:00
New Revision: e7b6c0f398ee5975bf9f39e629713ae446e8fe01

URL: 
https://github.com/llvm/llvm-project/commit/e7b6c0f398ee5975bf9f39e629713ae446e8fe01
DIFF: 
https://github.com/llvm/llvm-project/commit/e7b6c0f398ee5975bf9f39e629713ae446e8fe01.diff

LOG: [clang][XCore] Define __xcore__ for XCore target.

The headers shipped with the XMOS XCore compiler expect __xcore__ to be defined.
The __XS1B__ macro, already defined, is for the default subtarget.

No other targets affected.

Added: 


Modified: 
clang/lib/Basic/Targets/XCore.cpp
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/XCore.cpp 
b/clang/lib/Basic/Targets/XCore.cpp
index da614f10e338f..ba64f15f3394a 100644
--- a/clang/lib/Basic/Targets/XCore.cpp
+++ b/clang/lib/Basic/Targets/XCore.cpp
@@ -28,6 +28,7 @@ const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = {
 
 void XCoreTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
+  Builder.defineMacro("__xcore__");
   Builder.defineMacro("__XS1B__");
 }
 

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 0329453c4136b..be60eb6d9cf61 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1468,6 +1468,7 @@
 // XCORE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // XCORE:#define __LITTLE_ENDIAN__ 1
 // XCORE:#define __XS1B__ 1
+// XCORE:#define __xcore__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-unknown-unknown \
 // RUN:   < /dev/null \



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits