Hi dsanders, petarj,

Types larger than register size should not be extended. This affect alignment 
for 128 bit integer types. On mips64 32 bit unsigned int type should not be 
zero extended, so it is passed directly.

http://reviews.llvm.org/D9198

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-int128-alignment.c
  test/CodeGen/mips-unsigned-extend.c
  test/CodeGen/mips-vector-arg.c
  test/CodeGen/mips64-padding-arg.c
  test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lib/CodeGen/TargetInfo.cpp
===================================================================
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -5641,7 +5641,8 @@
     Ty = EnumTy->getDecl()->getIntegerType();
 
   // All integral types are promoted to the GPR width.
-  if (Ty->isIntegralOrEnumerationType())
+  if (Ty->isIntegralOrEnumerationType() && TySize < getTarget().getRegisterWidth() &&
+      !(Ty->isUnsignedIntegerType() && TySize == 32))
     return ABIArgInfo::getExtend();
 
   return ABIArgInfo::getDirect(
Index: test/CodeGen/atomics-inlining.c
===================================================================
--- test/CodeGen/atomics-inlining.c
+++ test/CodeGen/atomics-inlining.c
@@ -76,8 +76,8 @@
 // MIPS32: store atomic i32 {{.*}}, i32* @i1 seq_cst
 // MIPS32: call i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
 // MIPS32: call void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
-// MIPS32: call void @__atomic_load(i32 zeroext 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
-// MIPS32: call void @__atomic_store(i32 zeroext 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
+// MIPS32: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
+// MIPS32: call void @__atomic_store(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
 
 // MIPS64-LABEL: define void @test1
 // MIPS64: = load atomic i8, i8* @c1 seq_cst
@@ -88,6 +88,6 @@
 // MIPS64: store atomic i32 {{.*}}, i32* @i1 seq_cst
 // MIPS64: = load atomic i64, i64* @ll1 seq_cst
 // MIPS64: store atomic i64 {{.*}}, i64* @ll1 seq_cst
-// MIPS64: call void @__atomic_load(i64 zeroext 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0)
-// MIPS64: call void @__atomic_store(i64 zeroext 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
+// MIPS64: call void @__atomic_load(i64 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0)
+// MIPS64: call void @__atomic_store(i64 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
 }
Index: test/CodeGen/mips-int128-alignment.c
===================================================================
--- test/CodeGen/mips-int128-alignment.c
+++ test/CodeGen/mips-int128-alignment.c
@@ -0,0 +1,14 @@
+// RUN: %clang -target mips64-unknown-linux -O0 -mabi=n64 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=N64
+// RUN: %clang -target mips64-unknown-linux -O0 -mabi=n32 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=N32
+
+void foo(unsigned int a, __int128_t b) {
+}
+
+void foo1() {
+        unsigned int a;
+        __int128_t b;
+        foo(a,b);
+}
+
+//N64: call void @foo(i32 %0, i64 undef, i128 %1)
+//N32: call void @foo(i32 %0, i64 undef, i128 %1)
Index: test/CodeGen/mips-unsigned-extend.c
===================================================================
--- test/CodeGen/mips-unsigned-extend.c
+++ test/CodeGen/mips-unsigned-extend.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target mips64-unknown-linux -O0 -mabi=n64 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=N64
+// RUN: %clang -target mips64-unknown-linux -O0 -mabi=n32 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=N32
+// RUN: %clang -target mips-unknown-linux -O0 -mabi=o32 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=O32 
+
+void foo(unsigned a) {
+}
+
+void foo1() {
+        unsigned f = 0xffffffe0;
+        foo(f);
+}
+
+// N64: call void @foo(i32 %0)
+// N32: call void @foo(i32 %0)
+// O32: call void @foo(i32 %0) 
\ No newline at end of file
Index: test/CodeGen/mips-vector-arg.c
===================================================================
--- test/CodeGen/mips-vector-arg.c
+++ test/CodeGen/mips-vector-arg.c
@@ -8,17 +8,17 @@
 typedef float  v4sf __attribute__ ((__vector_size__ (16)));
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
-// O32: define void @test_v4sf(i32 inreg %a1.coerce0, i32 inreg %a1.coerce1, i32 inreg %a1.coerce2, i32 inreg %a1.coerce3, i32 signext %a2, i32, i32 inreg %a3.coerce0, i32 inreg %a3.coerce1, i32 inreg %a3.coerce2, i32 inreg %a3.coerce3) [[NUW:#[0-9]+]]
-// O32: declare i32 @test_v4sf_2(i32 inreg, i32 inreg, i32 inreg, i32 inreg, i32 signext, i32, i32 inreg, i32 inreg, i32 inreg, i32 inreg)
+// O32: define void @test_v4sf(i32 inreg %a1.coerce0, i32 inreg %a1.coerce1, i32 inreg %a1.coerce2, i32 inreg %a1.coerce3, i32 %a2, i32, i32 inreg %a3.coerce0, i32 inreg %a3.coerce1, i32 inreg %a3.coerce2, i32 inreg %a3.coerce3) [[NUW:#[0-9]+]]
+// O32: declare i32 @test_v4sf_2(i32 inreg, i32 inreg, i32 inreg, i32 inreg, i32, i32, i32 inreg, i32 inreg, i32 inreg, i32 inreg)
 // N64: define void @test_v4sf(i64 inreg %a1.coerce0, i64 inreg %a1.coerce1, i32 signext %a2, i64, i64 inreg %a3.coerce0, i64 inreg %a3.coerce1) [[NUW:#[0-9]+]]
 // N64: declare i32 @test_v4sf_2(i64 inreg, i64 inreg, i32 signext, i64, i64 inreg, i64 inreg)
 extern test_v4sf_2(v4sf, int, v4sf);
 void test_v4sf(v4sf a1, int a2, v4sf a3) {
   test_v4sf_2(a3, a2, a1);
 }
 
-// O32: define void @test_v4i32(i32 inreg %a1.coerce0, i32 inreg %a1.coerce1, i32 inreg %a1.coerce2, i32 inreg %a1.coerce3, i32 signext %a2, i32, i32 inreg %a3.coerce0, i32 inreg %a3.coerce1, i32 inreg %a3.coerce2, i32 inreg %a3.coerce3) [[NUW]]
-// O32: declare i32 @test_v4i32_2(i32 inreg, i32 inreg, i32 inreg, i32 inreg, i32 signext, i32, i32 inreg, i32 inreg, i32 inreg, i32 inreg)
+// O32: define void @test_v4i32(i32 inreg %a1.coerce0, i32 inreg %a1.coerce1, i32 inreg %a1.coerce2, i32 inreg %a1.coerce3, i32 %a2, i32, i32 inreg %a3.coerce0, i32 inreg %a3.coerce1, i32 inreg %a3.coerce2, i32 inreg %a3.coerce3) [[NUW]]
+// O32: declare i32 @test_v4i32_2(i32 inreg, i32 inreg, i32 inreg, i32 inreg, i32, i32, i32 inreg, i32 inreg, i32 inreg, i32 inreg)
 // N64: define void @test_v4i32(i64 inreg %a1.coerce0, i64 inreg %a1.coerce1, i32 signext %a2, i64, i64 inreg %a3.coerce0, i64 inreg %a3.coerce1) [[NUW]]
 // N64: declare i32 @test_v4i32_2(i64 inreg, i64 inreg, i32 signext, i64, i64 inreg, i64 inreg)
 extern test_v4i32_2(v4i32, int, v4i32);
Index: test/CodeGen/mips64-padding-arg.c
===================================================================
--- test/CodeGen/mips64-padding-arg.c
+++ test/CodeGen/mips64-padding-arg.c
@@ -55,7 +55,7 @@
 }
 
 // O32-LABEL: define void @foo9()
-// O32: declare void @foo10(i32 signext, i32
+// O32: declare void @foo10(i32, i32
 
 typedef struct __attribute__((aligned(16))) {
   int a;
Index: test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
===================================================================
--- test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
+++ test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
@@ -10,27 +10,27 @@
   return rv;
 }
 // O32-LABEL: define i32* @_Z10alloc_longv()
-// O32: call noalias i8* @_Znwj(i32 zeroext 4)
+// O32: call noalias i8* @_Znwj(i32 4)
 
 // N32-LABEL: define i32* @_Z10alloc_longv()
-// N32: call noalias i8* @_Znwj(i32 zeroext 4)
+// N32: call noalias i8* @_Znwj(i32 4)
 
 // N64-LABEL: define i64* @_Z10alloc_longv()
-// N64: call noalias i8* @_Znwm(i64 zeroext 8)
+// N64: call noalias i8* @_Znwm(i64 8)
 
 long *alloc_long_array() {
   long *rv = new long[2];
   return rv;
 }
 
 // O32-LABEL: define i32* @_Z16alloc_long_arrayv()
-// O32: call noalias i8* @_Znaj(i32 zeroext 8)
+// O32: call noalias i8* @_Znaj(i32 8)
 
 // N32-LABEL: define i32* @_Z16alloc_long_arrayv()
-// N32: call noalias i8* @_Znaj(i32 zeroext 8)
+// N32: call noalias i8* @_Znaj(i32 8)
 
 // N64-LABEL: define i64* @_Z16alloc_long_arrayv()
-// N64: call noalias i8* @_Znam(i64 zeroext 16)
+// N64: call noalias i8* @_Znam(i64 16)
 
 #include <stddef.h>
 
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to