Skip to content

Commit 1dcd2d9

Browse files
committed
[clang][AVR] Improve compitability of inline assembly with avr-gcc
Allow the value 64 to be round up to 0 for constraint 'I'.
1 parent c5e07fb commit 1dcd2d9

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

clang/lib/Basic/Targets/AVR.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public TargetInfo {
124124
Info.setAllowsRegister();
125125
return true;
126126
case 'I': // 6-bit positive integer constant
127-
Info.setRequiresImmediate(0, 63);
127+
Info.setRequiresImmediate(0, 64);
128128
return true;
129129
case 'J': // 6-bit negative integer constant
130130
Info.setRequiresImmediate(-63, 0);

clang/test/CodeGen/avr/avr-inline-asm-constraints.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ void z() {
7171
void I() {
7272
// CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "I"(i16 50)
7373
asm("subi r30, %0" :: "I"(50));
74+
// CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "I"(i16 64)
75+
asm("subi r30, %0" :: "I"(64));
7476
}
7577

7678
void J() {

clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ int foo(void) {
66
__asm__ volatile("foo %0, 1" : : "fo" (val)); // expected-error {{invalid input constraint 'fo' in asm}}
77
__asm__ volatile("foo %0, 1" : : "Nd" (val)); // expected-error {{invalid input constraint 'Nd' in asm}}
88
__asm__ volatile("subi r30, %0" : : "G" (1)); // expected-error {{value '1' out of range for constraint 'G'}}
9+
__asm__ volatile("out %0, r20" : : "I" (65)); // expected-error {{value '65' out of range for constraint 'I'}}
910
}

0 commit comments

Comments
 (0)