For Issue dotnet/coreclr#3785 Arm Soft FP support: arguments and return values are...
authorAndrey Kvochko <a.kvochko@samsung.com>
Tue, 5 Apr 2016 15:10:02 +0000 (18:10 +0300)
committerAndrey Kvochko <a.kvochko@samsung.com>
Tue, 5 Apr 2016 15:10:02 +0000 (18:10 +0300)
Commit migrated from https://github.com/dotnet/coreclr/commit/40fc77eb6e799ecb7afdaa912900f3463650781e

16 files changed:
src/coreclr/CMakeLists.txt
src/coreclr/build.sh
src/coreclr/cross/arm-softfp/sources.list [new file with mode: 0644]
src/coreclr/cross/arm-softfp/toolchain.cmake [new file with mode: 0644]
src/coreclr/cross/arm-softfp/tryrun.cmake [new file with mode: 0644]
src/coreclr/cross/build-rootfs.sh
src/coreclr/src/jit/CMakeLists.txt
src/coreclr/src/jit/codegencommon.cpp
src/coreclr/src/jit/codegenlegacy.cpp
src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/compiler.hpp
src/coreclr/src/jit/lclvars.cpp
src/coreclr/src/jit/morph.cpp
src/coreclr/src/jit/regalloc.cpp
src/coreclr/src/jit/registerfp.cpp
src/coreclr/src/pal/tools/gen-buildsys-clang.sh

index d0f3f54..1dabe2c 100644 (file)
@@ -35,9 +35,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
         set(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM 1)
         # Because we don't use CMAKE_C_COMPILER/CMAKE_CXX_COMPILER to use clang
         # we have to set the triple by adding a compiler argument
-        add_compile_options(-target armv7-linux-gnueabihf)
         add_compile_options(-mthumb)
         add_compile_options(-mfpu=vfpv3)
+        if(ARM_SOFTFP)
+            add_compile_options(-mfloat-abi=softfp)
+            add_compile_options(-target armv7-linux-gnueabi)
+        else()
+            add_compile_options(-target armv7-linux-gnueabihf)
+        endif(ARM_SOFTFP)
     elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
         set(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM64 1)
     else()
index a450ef5..af2e624 100755 (executable)
@@ -5,7 +5,7 @@ PYTHON=${PYTHON:-python}
 usage()
 {
     echo "Usage: $0 [BuildArch] [BuildType] [clean] [verbose] [coverage] [cross] [clangx.y] [ninja] [configureonly] [skipconfigure] [skipnative] [skipmscorlib] [skiptests] [cmakeargs]"
-    echo "BuildArch can be: x64, x86, arm, arm64"
+    echo "BuildArch can be: x64, x86, arm, arm-softfp, arm64"
     echo "BuildType can be: debug, checked, release"
     echo "clean - optional argument to force a clean build."
     echo "verbose - optional argument to enable verbose build output."
@@ -443,6 +443,10 @@ while :; do
             __BuildArch=arm
             ;;
 
+        arm-softfp)
+            __BuildArch=arm-softfp
+            ;;
+
         arm64)
             __BuildArch=arm64
             ;;
diff --git a/src/coreclr/cross/arm-softfp/sources.list b/src/coreclr/cross/arm-softfp/sources.list
new file mode 100644 (file)
index 0000000..4d142ac
--- /dev/null
@@ -0,0 +1,3 @@
+# Debian (sid)   # UNSTABLE
+deb http://ftp.debian.org/debian/ sid main contrib non-free
+deb-src http://ftp.debian.org/debian/ sid main contrib non-free
diff --git a/src/coreclr/cross/arm-softfp/toolchain.cmake b/src/coreclr/cross/arm-softfp/toolchain.cmake
new file mode 100644 (file)
index 0000000..9c8ca3e
--- /dev/null
@@ -0,0 +1,28 @@
+set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_VERSION 1)
+set(CMAKE_SYSTEM_PROCESSOR armv7l)
+
+add_compile_options(-target armv7-linux-gnueabi)
+add_compile_options(-mthumb)
+add_compile_options(-mfpu=vfpv3)
+add_compile_options(--sysroot=${CROSS_ROOTFS})
+
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -target arm-linux-gnueabi")
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -B${CROSS_ROOTFS}/usr/lib/arm-linux-gnueabi")
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -L${CROSS_ROOTFS}/lib/arm-linux-gnueabi -L${CROSS_ROOTFS}/usr/lib/arm-linux-gnueabi")
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} --sysroot=${CROSS_ROOTFS}")
+
+set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS}    ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)
+set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)
+
+set(CMAKE_FIND_ROOT_PATH "${CROSS_ROOTFS}")
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+
+set(WITH_LLDB_LIBS "${CROSS_ROOTFS}/usr/lib/arm-linux-gnueabi" CACHE STRING "")
+set(WITH_LLDB_INCLUDES "${CROSS_ROOTFS}/usr/lib/llvm-3.6/include" CACHE STRING "")
diff --git a/src/coreclr/cross/arm-softfp/tryrun.cmake b/src/coreclr/cross/arm-softfp/tryrun.cmake
new file mode 100644 (file)
index 0000000..5994e08
--- /dev/null
@@ -0,0 +1,116 @@
+SET( REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( SSCANF_SUPPORT_ll_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_SCHED_GET_PRIORITY_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_WORKING_GETTIMEOFDAY_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_WORKING_CLOCK_GETTIME_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_CLOCK_MONOTONIC_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_MMAP_DEV_ZERO_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( MMAP_IGNORES_HINT_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( MMAP_DOESNOT_ALLOW_REMAP_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( PTHREAD_CREATE_MODIFIES_ERRNO_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( SEM_INIT_MODIFIES_ERRNO_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_COMPATIBLE_ACOS_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_COMPATIBLE_ASIN_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_COMPATIBLE_POW_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_VALID_NEGATIVE_INF_POW_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_VALID_POSITIVE_INF_POW_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_COMPATIBLE_ATAN2_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_COMPATIBLE_LOG_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_COMPATIBLE_LOG10_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( UNGETC_NOT_RETURN_EOF_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAS_POSIX_SEMAPHORES_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( GETPWUID_R_SETS_ERRNO_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 
+     1
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_CLOCK_THREAD_CPUTIME_EXITCODE
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_SCHED_GETCPU_EXITCODE
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
index 78309f7..6e563d2 100755 (executable)
@@ -3,11 +3,13 @@
 usage()
 {
     echo "Usage: $0 [BuildArch]"
-    echo "BuildArch can be: arm, arm64"
+    echo "BuildArch can be: arm, arm-softfp, arm64"
 
     exit 1
 }
 
+__UbuntuCodeName=trusty
+
 __CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
 __InitialDir=$PWD
 __BuildArch=arm
@@ -38,6 +40,14 @@ for i in "$@"
         __UbuntuPackages="build-essential libunwind8-dev gettext symlinks liblttng-ust-dev libicu-dev"
         __MachineTriple=aarch64-linux-gnu
         ;;
+        arm-softfp)
+        __BuildArch=arm-softfp
+        __UbuntuArch=armel
+        __UbuntuRepo="http://ftp.debian.org/debian/"
+        __UbuntuPackages="build-essential lldb-3.6-dev libunwind8-dev gettext symlinks liblttng-ust-dev libicu-dev"
+        __MachineTriple=arm-linux-gnueabi
+        __UbuntuCodeName=stable
+        ;;
         *)
         __UnprocessedBuildArgs="$__UnprocessedBuildArgs $i"
     esac
@@ -51,9 +61,10 @@ fi
 
 umount $__RootfsDir/*
 rm -rf $__RootfsDir
-qemu-debootstrap --arch $__UbuntuArch trusty $__RootfsDir $__UbuntuRepo
+qemu-debootstrap --arch $__UbuntuArch $__UbuntuCodeName $__RootfsDir $__UbuntuRepo
 cp $__CrossDir/$__BuildArch/sources.list $__RootfsDir/etc/apt/sources.list
 chroot $__RootfsDir apt-get update
 chroot $__RootfsDir apt-get -y install $__UbuntuPackages
 chroot $__RootfsDir symlinks -cr /usr
-umount $__RootfsDir/*
\ No newline at end of file
+umount $__RootfsDir/*
+
index 8990afc..79351e0 100644 (file)
@@ -11,6 +11,10 @@ if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
   add_definitions(-DFEATURE_AVX_SUPPORT) 
 endif (CLR_CMAKE_PLATFORM_ARCH_AMD64)
 
+if (ARM_SOFTFP)
+  add_definitions(-DARM_SOFTFP)
+endif (ARM_SOFTFP)
+
 set( JIT_SOURCES
   alloc.cpp
   assertionprop.cpp
index 4f8f8a9..f4f3679 100644 (file)
@@ -4150,7 +4150,7 @@ void            CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg,
                                  (varDsc->lvType == TYP_STRUCT) ||
                                  (varDsc->lvAddrExposed && compiler->info.compIsVarArgs));
 #else // LEGACY_BACKEND
-                    noway_assert(varDsc->lvType == TYP_STRUCT || (varDsc->lvAddrExposed && compiler->info.compIsVarArgs));
+                    noway_assert(varDsc->lvType == TYP_STRUCT || (varDsc->lvAddrExposed && (compiler->info.compIsVarArgs || compiler->opts.compUseSoftFP)));
 #endif // LEGACY_BACKEND
 #endif // !_TARGET_X86_
                 }            
@@ -7449,7 +7449,7 @@ void                CodeGen::genProfilingLeaveCallback(unsigned helper /*= CORIN
     emitAttr attr = EA_UNKNOWN;
 
     if (compiler->info.compRetType == TYP_VOID ||
-        (!compiler->info.compIsVarArgs && (varTypeIsFloating(compiler->info.compRetType) || compiler->IsHfa(compiler->info.compMethodInfo->args.retTypeClass))))
+        (!compiler->opts.compUseSoftFP && !compiler->info.compIsVarArgs && (varTypeIsFloating(compiler->info.compRetType) || compiler->IsHfa(compiler->info.compMethodInfo->args.retTypeClass))))
     {
         r0Trashed = false;
     }
index 8b9f959..b5cacc3 100644 (file)
@@ -20431,7 +20431,7 @@ regMaskTP           CodeGen::genCodeForCall(GenTreePtr  call,
     if (call->gtType == TYP_FLOAT || call->gtType == TYP_DOUBLE)
     {
 #ifdef _TARGET_ARM_
-        if (call->gtCall.IsVarargs())
+        if (call->gtCall.IsVarargs() || compiler->opts.compUseSoftFP)
         {
             // Result return for vararg methods is in r0, r1, but our callers would
             // expect the return in s0, s1 because of floating type. Do the move now.
index 06830f4..285d473 100644 (file)
@@ -7578,6 +7578,12 @@ public :
         bool               compTailCallLoopOpt;
 #endif
 
+#ifdef ARM_SOFTFP
+        static const bool compUseSoftFP = true;
+#else // !ARM_SOFTFP
+        static const bool compUseSoftFP = false;
+#endif
+
         GCPollType compGCPollType;
     }
         opts;
index cabd6ba..198c8cf 100644 (file)
@@ -2574,7 +2574,7 @@ inline
 var_types Compiler::mangleVarArgsType(var_types type)
 {
 #ifdef _TARGET_ARMARCH_
-    if (info.compIsVarArgs)
+    if (info.compIsVarArgs || opts.compUseSoftFP)
     {
         switch (type) {
         case TYP_FLOAT:
index 14ac29c..6c36098 100644 (file)
@@ -136,7 +136,7 @@ void                Compiler::lvaInitTypeRef()
     {
 #ifdef _TARGET_ARM_
         // TODO-ARM64-NYI: HFA
-        if (!info.compIsVarArgs && IsHfa(info.compMethodInfo->args.retTypeClass))
+        if (!info.compIsVarArgs && !opts.compUseSoftFP && IsHfa(info.compMethodInfo->args.retTypeClass))
         {
             info.compRetNativeType = TYP_STRUCT;
         }
@@ -570,13 +570,13 @@ void                Compiler::lvaInitUserArgs(InitVarDscInfo *      varDscInfo)
 #ifdef _TARGET_ARM_
 
         var_types hfaType = (varTypeIsStruct(argType)) ? GetHfaType(typeHnd) : TYP_UNDEF;
-        bool isHfaArg = !info.compIsVarArgs && varTypeIsFloating(hfaType);
+        bool isHfaArg = !info.compIsVarArgs && !opts.compUseSoftFP && varTypeIsFloating(hfaType);
 
         // On ARM we pass the first 4 words of integer arguments and non-HFA structs in registers.
         // But we pre-spill user arguments in varargs methods and structs.
         // 
         unsigned cAlign;
-        bool  preSpill = info.compIsVarArgs;
+        bool  preSpill = info.compIsVarArgs || opts.compUseSoftFP;
 
         switch (argType)
         {
@@ -912,7 +912,7 @@ void                Compiler::lvaInitUserArgs(InitVarDscInfo *      varDscInfo)
 #else // !FEATURE_UNIX_AMD64_STRUCT_PASSING
         compArgSize += argSize;
 #endif // !FEATURE_UNIX_AMD64_STRUCT_PASSING
-        if (info.compIsVarArgs)
+        if (info.compIsVarArgs || opts.compUseSoftFP)
         {
 #if defined(_TARGET_X86_)
             varDsc->lvStkOffs       = compArgSize;
@@ -4597,7 +4597,7 @@ int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, unsigned argSize
             if (!compIsProfilerHookNeeded())
 #endif
             {
-                bool cond = (info.compIsVarArgs &&
+                bool cond = ((info.compIsVarArgs || opts.compUseSoftFP) &&
                     // Does cur stk arg require double alignment?
                     ((varDsc->lvType == TYP_STRUCT && varDsc->lvStructDoubleAlign) ||
                     (varDsc->lvType == TYP_DOUBLE) ||
index 93f3aca..39eb370 100644 (file)
@@ -2799,8 +2799,9 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
         // this can't be a struct.
         assert(argx->gtType != TYP_STRUCT);
 
+        // FIXME: Issue #4025 Why do we need floating type for 'this' argument
         /* Increment the argument register count and argument index */
-        if (!varTypeIsFloating(argx->gtType))
+        if (!varTypeIsFloating(argx->gtType) || opts.compUseSoftFP)
         {
             intArgRegNum++;
 #if defined(_TARGET_AMD64_) && !defined(UNIX_AMD64_ABI)
@@ -2951,7 +2952,6 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
 #ifdef _TARGET_ARM_
 
         bool passUsingIntRegs;
-
         if (lateArgsComputed)
         {
             passUsingFloatRegs = isValidFloatArgReg(argEntry->regNum);
@@ -2959,7 +2959,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
         }
         else
         {
-            passUsingFloatRegs = !callIsVararg && (isHfaArg || varTypeIsFloating(argx));
+            passUsingFloatRegs = !callIsVararg && (isHfaArg || varTypeIsFloating(argx)) && !opts.compUseSoftFP;
             passUsingIntRegs   =  passUsingFloatRegs ? false : (intArgRegNum < MAX_REG_ARG);
         }
 
index 1675f2c..89f2955 100644 (file)
@@ -595,7 +595,7 @@ void                Compiler::raSetupArgMasks(RegState *regState)
             continue;
 
         // only process args that apply to the current register file
-        if ((argDsc->IsFloatRegType() && !info.compIsVarArgs) != regState->rsIsFloat)
+        if ((argDsc->IsFloatRegType() && !info.compIsVarArgs && !opts.compUseSoftFP) != regState->rsIsFloat)
         {
             continue;
         }
@@ -691,7 +691,7 @@ regNumber     Compiler::raUpdateRegStateForArg(RegState *regState, LclVarDsc *ar
 #ifdef _TARGET_ARM_
     if (argDsc->lvType == TYP_DOUBLE)
     {
-        if (info.compIsVarArgs)
+        if (info.compIsVarArgs || opts.compUseSoftFP)
         {
             assert((inArgReg == REG_R0) || (inArgReg == REG_R2));
             assert(!regState->rsIsFloat);
index 7779cfe..9b7f651 100644 (file)
@@ -229,7 +229,7 @@ void CodeGen::genFloatSimple(GenTree *tree, RegSet::RegisterPreference *pref)
             genCodeForTreeFloat(op1, pref);
 
             inst_RV_TT(ins_FloatConv(tree->TypeGet(), op1->TypeGet()), REG_FLOATRET, op1);
-            if (compiler->info.compIsVarArgs)
+            if (compiler->info.compIsVarArgs || compiler->opts.compUseSoftFP)
             {
                 if (tree->TypeGet() == TYP_FLOAT)
                 {
index 087a4e1..b7945f3 100755 (executable)
@@ -134,6 +134,9 @@ if [[ -n "$CROSSCOMPILE" ]]; then
     cmake_extra_defines="$cmake_extra_defines -C $1/cross/$build_arch/tryrun.cmake"
     cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$1/cross/$build_arch/toolchain.cmake"
 fi
+if [ "$build_arch" == "arm-softfp" ]; then
+    cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1"
+fi
 
 cmake \
   -G "$generator" \