benshi001 created this revision.
benshi001 added reviewers: aykevl, dylanmckay.
Herald added a subscriber: Jim.
Herald added a project: All.
benshi001 requested review of this revision.
Herald added subscribers: cfe-commits, jacquesguan.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139908

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/avr/avr-builtins.c


Index: clang/test/CodeGen/avr/avr-builtins.c
===================================================================
--- clang/test/CodeGen/avr/avr-builtins.c
+++ clang/test/CodeGen/avr/avr-builtins.c
@@ -8,7 +8,7 @@
     return __builtin_bitreverse8(data);
 }
 
-// CHECK: define{{.*}} zeroext i8 @bitrev8
+// CHECK: define{{.*}} i8 @bitrev8
 // CHECK: i8 @llvm.bitreverse.i8(i8
 
 unsigned int bitrev16(unsigned int data) {
@@ -35,7 +35,7 @@
     return __builtin_rotateleft8(x, y);
 }
 
-// CHECK: define{{.*}} zeroext i8 @rotleft8
+// CHECK: define{{.*}} i8 @rotleft8
 // CHECK: i8 @llvm.fshl.i8(i8
 
 unsigned int rotleft16(unsigned int x, unsigned int y) {
@@ -62,7 +62,7 @@
     return __builtin_rotateright8(x, y);
 }
 
-// CHECK: define{{.*}} zeroext i8 @rotright8
+// CHECK: define{{.*}} i8 @rotright8
 // CHECK: i8 @llvm.fshr.i8(i8
 
 unsigned int rotright16(unsigned int x, unsigned int y) {
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8435,6 +8435,10 @@
       LargeRet = true;
       return getNaturalAlignIndirect(Ty);
     }
+    // An i8 return value should not be extended to i16, since AVR has 8-bit
+    // registers.
+    if (Ty->isIntegralOrEnumerationType() && getContext().getTypeSize(Ty) <= 8)
+      return ABIArgInfo::getDirect();
     // Otherwise we follow the default way which is compatible.
     return DefaultABIInfo::classifyReturnType(Ty);
   }


Index: clang/test/CodeGen/avr/avr-builtins.c
===================================================================
--- clang/test/CodeGen/avr/avr-builtins.c
+++ clang/test/CodeGen/avr/avr-builtins.c
@@ -8,7 +8,7 @@
     return __builtin_bitreverse8(data);
 }
 
-// CHECK: define{{.*}} zeroext i8 @bitrev8
+// CHECK: define{{.*}} i8 @bitrev8
 // CHECK: i8 @llvm.bitreverse.i8(i8
 
 unsigned int bitrev16(unsigned int data) {
@@ -35,7 +35,7 @@
     return __builtin_rotateleft8(x, y);
 }
 
-// CHECK: define{{.*}} zeroext i8 @rotleft8
+// CHECK: define{{.*}} i8 @rotleft8
 // CHECK: i8 @llvm.fshl.i8(i8
 
 unsigned int rotleft16(unsigned int x, unsigned int y) {
@@ -62,7 +62,7 @@
     return __builtin_rotateright8(x, y);
 }
 
-// CHECK: define{{.*}} zeroext i8 @rotright8
+// CHECK: define{{.*}} i8 @rotright8
 // CHECK: i8 @llvm.fshr.i8(i8
 
 unsigned int rotright16(unsigned int x, unsigned int y) {
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8435,6 +8435,10 @@
       LargeRet = true;
       return getNaturalAlignIndirect(Ty);
     }
+    // An i8 return value should not be extended to i16, since AVR has 8-bit
+    // registers.
+    if (Ty->isIntegralOrEnumerationType() && getContext().getTypeSize(Ty) <= 8)
+      return ABIArgInfo::getDirect();
     // Otherwise we follow the default way which is compatible.
     return DefaultABIInfo::classifyReturnType(Ty);
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to