[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-03 Thread Ben Shi via cfe-commits

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


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-03 Thread Jianjian Guan via cfe-commits

https://github.com/jacquesguan approved this pull request.

LGTM

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


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-01 Thread Lu Weining via cfe-commits

SixWeining wrote:

LGTM. I have checked with 
https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html. 'G' stands for 
"A floating point constant 0.0". But I'd like to wait others' opinion.

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


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-01 Thread Ben Shi via cfe-commits

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


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-01 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/76561

>From 75164dccb2697ad5468700a9f23a0bc7d8ab49e8 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Fri, 29 Dec 2023 17:58:21 +0800
Subject: [PATCH] [clang][AVR] Restrict range of assembly constraint 'G'

According to https://www.nongnu.org/avr-libc/user-manual/inline_asm.html,
"G" only represents floating point constant '0.0'. And avr-gcc also
rejects other non-zero FP values.
---
 clang/lib/Basic/Targets/AVR.h | 4 +++-
 clang/test/CodeGen/avr/avr-inline-asm-constraints.c   | 4 ++--
 .../test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index 854a51d78c393b..9376c46cd98ca1 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -146,7 +146,9 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
 case 'R': // Integer constant (Range: -6 to 5)
   Info.setRequiresImmediate(-6, 5);
   return true;
-case 'G': // Floating point constant
+case 'G': // Floating point constant 0.0
+  Info.setRequiresImmediate(0);
+  return true;
 case 'Q': // A memory address based on Y or Z pointer with displacement.
   return true;
 }
diff --git a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
index 96774861feb228..3a956de8db48f0 100644
--- a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
@@ -109,8 +109,8 @@ void R() {
 }
 
 void G() {
-  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 50)
-  asm("subi r30, %0" :: "G"(50));
+  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 0)
+  asm("subi r30, %0" :: "G"(0));
 }
 
 void Q() {
diff --git a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
index ceea59229f736a..29f0b69285fa88 100644
--- a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
@@ -5,4 +5,5 @@ const unsigned char val = 0;
 int foo(void) {
   __asm__ volatile("foo %0, 1" : : "fo" (val)); // expected-error {{invalid 
input constraint 'fo' in asm}}
   __asm__ volatile("foo %0, 1" : : "Nd" (val)); // expected-error {{invalid 
input constraint 'Nd' in asm}}
+  __asm__ volatile("subi r30, %0" : : "G" (1)); // expected-error {{value '1' 
out of range for constraint 'G'}}
 }

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


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-01 Thread Ben Shi via cfe-commits

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


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-01 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/76561

>From 66a786a0353d8ae88006e585861fcb2035797032 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Fri, 29 Dec 2023 17:58:21 +0800
Subject: [PATCH] [clang][AVR] Restrict range of assembly constraint 'G'

According to https://www.nongnu.org/avr-libc/user-manual/inline_asm.html,
"G" only represent float constant "0.0". And avr-gcc also rejects
other non-zero values.
---
 clang/lib/Basic/Targets/AVR.h | 4 +++-
 clang/test/CodeGen/avr/avr-inline-asm-constraints.c   | 4 ++--
 .../test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index 854a51d78c393b..9376c46cd98ca1 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -146,7 +146,9 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
 case 'R': // Integer constant (Range: -6 to 5)
   Info.setRequiresImmediate(-6, 5);
   return true;
-case 'G': // Floating point constant
+case 'G': // Floating point constant 0.0
+  Info.setRequiresImmediate(0);
+  return true;
 case 'Q': // A memory address based on Y or Z pointer with displacement.
   return true;
 }
diff --git a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
index 96774861feb228..3a956de8db48f0 100644
--- a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
@@ -109,8 +109,8 @@ void R() {
 }
 
 void G() {
-  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 50)
-  asm("subi r30, %0" :: "G"(50));
+  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 0)
+  asm("subi r30, %0" :: "G"(0));
 }
 
 void Q() {
diff --git a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
index ceea59229f736a..29f0b69285fa88 100644
--- a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
@@ -5,4 +5,5 @@ const unsigned char val = 0;
 int foo(void) {
   __asm__ volatile("foo %0, 1" : : "fo" (val)); // expected-error {{invalid 
input constraint 'fo' in asm}}
   __asm__ volatile("foo %0, 1" : : "Nd" (val)); // expected-error {{invalid 
input constraint 'Nd' in asm}}
+  __asm__ volatile("subi r30, %0" : : "G" (1)); // expected-error {{value '1' 
out of range for constraint 'G'}}
 }

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


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2023-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ben Shi (benshi001)


Changes

According to https://www.nongnu.org/avr-libc/user-manual/inline_asm.html, "G" 
only represent a float constraint "0.0". And avr-gcc also rejects other 
non-zero values.

---
Full diff: https://github.com/llvm/llvm-project/pull/76561.diff


3 Files Affected:

- (modified) clang/lib/Basic/Targets/AVR.h (+3-1) 
- (modified) clang/test/CodeGen/avr/avr-inline-asm-constraints.c (+2-2) 
- (modified) clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c 
(+1) 


``diff
diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index 854a51d78c393b..9376c46cd98ca1 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -146,7 +146,9 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
 case 'R': // Integer constant (Range: -6 to 5)
   Info.setRequiresImmediate(-6, 5);
   return true;
-case 'G': // Floating point constant
+case 'G': // Floating point constant 0.0
+  Info.setRequiresImmediate(0);
+  return true;
 case 'Q': // A memory address based on Y or Z pointer with displacement.
   return true;
 }
diff --git a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
index 96774861feb228..3a956de8db48f0 100644
--- a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
@@ -109,8 +109,8 @@ void R() {
 }
 
 void G() {
-  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 50)
-  asm("subi r30, %0" :: "G"(50));
+  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 0)
+  asm("subi r30, %0" :: "G"(0));
 }
 
 void Q() {
diff --git a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
index ceea59229f736a..29f0b69285fa88 100644
--- a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
@@ -5,4 +5,5 @@ const unsigned char val = 0;
 int foo(void) {
   __asm__ volatile("foo %0, 1" : : "fo" (val)); // expected-error {{invalid 
input constraint 'fo' in asm}}
   __asm__ volatile("foo %0, 1" : : "Nd" (val)); // expected-error {{invalid 
input constraint 'Nd' in asm}}
+  __asm__ volatile("subi r30, %0" : : "G" (1)); // expected-error {{value '1' 
out of range for constraint 'G'}}
 }

``




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


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2023-12-29 Thread Ben Shi via cfe-commits

https://github.com/benshi001 created 
https://github.com/llvm/llvm-project/pull/76561

According to https://www.nongnu.org/avr-libc/user-manual/inline_asm.html, "G" 
only represent a float constraint "0.0". And avr-gcc also rejects other 
non-zero values.

>From 0a29621f6c6808668ada014313083f45a601f33b Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Fri, 29 Dec 2023 17:58:21 +0800
Subject: [PATCH] [clang][AVR] Restrict range of assembly constraint 'G'

According to https://www.nongnu.org/avr-libc/user-manual/inline_asm.html,
"G" only represent a float constraint "0.0". And avr-gcc also rejects
other non-zero values.
---
 clang/lib/Basic/Targets/AVR.h | 4 +++-
 clang/test/CodeGen/avr/avr-inline-asm-constraints.c   | 4 ++--
 .../test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index 854a51d78c393b..9376c46cd98ca1 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -146,7 +146,9 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
 case 'R': // Integer constant (Range: -6 to 5)
   Info.setRequiresImmediate(-6, 5);
   return true;
-case 'G': // Floating point constant
+case 'G': // Floating point constant 0.0
+  Info.setRequiresImmediate(0);
+  return true;
 case 'Q': // A memory address based on Y or Z pointer with displacement.
   return true;
 }
diff --git a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
index 96774861feb228..3a956de8db48f0 100644
--- a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
@@ -109,8 +109,8 @@ void R() {
 }
 
 void G() {
-  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 50)
-  asm("subi r30, %0" :: "G"(50));
+  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 0)
+  asm("subi r30, %0" :: "G"(0));
 }
 
 void Q() {
diff --git a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
index ceea59229f736a..29f0b69285fa88 100644
--- a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
@@ -5,4 +5,5 @@ const unsigned char val = 0;
 int foo(void) {
   __asm__ volatile("foo %0, 1" : : "fo" (val)); // expected-error {{invalid 
input constraint 'fo' in asm}}
   __asm__ volatile("foo %0, 1" : : "Nd" (val)); // expected-error {{invalid 
input constraint 'Nd' in asm}}
+  __asm__ volatile("subi r30, %0" : : "G" (1)); // expected-error {{value '1' 
out of range for constraint 'G'}}
 }

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