📄 900-nios2.patch
字号:
diff --git a/config.sub b/config.subindex d2e3557..2297c30 100755--- a/config.sub+++ b/config.sub@@ -276,6 +276,15 @@ case $basic_machine in basic_machine=$basic_machine-unknown os=-none ;;+ # JBG+ nios2 | nios2-* | nios2el | nios2el-*)+ basic_machine=nios2-altera+ os=-none_el+ ;;+ nios2eb | nios2eb-*)+ basic_machine=nios2-altera+ os=-none_eb+ ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; diff --git a/gcc/combine.c b/gcc/combine.cindex 8f43c23..02648b1 100644--- a/gcc/combine.c+++ b/gcc/combine.c@@ -4381,6 +4381,14 @@ combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int last, mode); } +#ifndef __nios2__+/* This screws up Nios II in this test case:++if (x & 1)+ return 2;+else+ return 3;+*/ else if (STORE_FLAG_VALUE == 1 && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT && op1 == const0_rtx@@ -4392,6 +4400,7 @@ combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int last, gen_lowpart_for_combine (mode, op0), const1_rtx); }+#endif else if (STORE_FLAG_VALUE == 1 && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INTdiff --git a/gcc/config.gcc b/gcc/config.gccindex d22f34b..4ecb6e9 100644--- a/gcc/config.gcc+++ b/gcc/config.gcc@@ -1337,6 +1337,17 @@ m32rle-*-linux*) thread_file='posix' fi ;;+# JBG+nios2-*-elf*_eb)+ tm_file="elfos.h nios2/big.h ${tm_file}"+ ;;+nios2-*-elf*)+ tm_file="elfos.h ${tm_file}"+ ;;+nios2-*-uclibc*) # Altera Nios2 running uClinux with uClibc+ tm_file="elfos.h ${tm_file} nios2/nios2-uclibc.h"+ tmake_file=nios2/t-nios2-uclibc+ ;; # m68hc11 and m68hc12 share the same machine description. m68hc11-*-*|m6811-*-*) tm_file="dbxelf.h elfos.h m68hc11/m68hc11.h"diff --git a/gcc/config/nios2/big.h b/gcc/config/nios2/big.hnew file mode 100644index 0000000..b7b1731--- /dev/null+++ b/gcc/config/nios2/big.h@@ -0,0 +1,23 @@+/*+ big.h - Additional definitions for nios2 targets that default to big-endian++ Copyright (C) 2006 Altera++This file is part of GNU CC.++GNU CC is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2, or (at your option)+any later version.++GNU CC is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with GNU CC; see the file COPYING. If not, write to+the Free Software Foundation, 59 Temple Place - Suite 330,+Boston, MA 02111-1307, USA. */++#define TARGET_ENDIAN_DEFAULT BIG_ENDIAN_FLAGdiff --git a/gcc/config/nios2/crti.asm b/gcc/config/nios2/crti.asmnew file mode 100644index 0000000..1fcfeb2--- /dev/null+++ b/gcc/config/nios2/crti.asm@@ -0,0 +1,88 @@+/*+ Copyright (C) 2003 + by Jonah Graham (jgraham@altera.com)++This file is free software; you can redistribute it and/or modify it+under the terms of the GNU General Public License as published by the+Free Software Foundation; either version 2, or (at your option) any+later version.++In addition to the permissions in the GNU General Public License, the+Free Software Foundation gives you unlimited permission to link the+compiled version of this file with other programs, and to distribute+those programs without any restriction coming from the use of this+file. (The General Public License restrictions do apply in other+respects; for example, they cover modification of the file, and+distribution when not linked into another program.)++This file is distributed in the hope that it will be useful, but+WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; see the file COPYING. If not, write to+the Free Software Foundation, 59 Temple Place - Suite 330,+Boston, MA 02111-1307, USA.++ As a special exception, if you link this library with files+ compiled with GCC to produce an executable, this does not cause+ the resulting executable to be covered by the GNU General Public License.+ This exception does not however invalidate any other reasons why+ the executable file might be covered by the GNU General Public License.+++This file just make a stack frame for the contents of the .fini and+.init sections. Users may put any desired instructions in those+sections.+++While technically any code can be put in the init and fini sections+most stuff will not work other than stuff which obeys the call frame+and ABI. All the call-preserved registers are saved, the call clobbered+registers should have been saved by the code calling init and fini.++See crtstuff.c for an example of code that inserts itself in the +init and fini sections. ++See crt0.s for the code that calls init and fini.+*/++ .file "crti.asm"++ .section ".init"+ .align 2+ .global _init+_init:+ addi sp, sp, -48+ stw ra, 44(sp)+ stw r23, 40(sp)+ stw r22, 36(sp)+ stw r21, 32(sp)+ stw r20, 28(sp)+ stw r19, 24(sp)+ stw r18, 20(sp)+ stw r17, 16(sp)+ stw r16, 12(sp)+ stw fp, 8(sp)+ mov fp, sp+ + + .section ".fini"+ .align 2+ .global _fini+_fini:+ addi sp, sp, -48+ stw ra, 44(sp)+ stw r23, 40(sp)+ stw r22, 36(sp)+ stw r21, 32(sp)+ stw r20, 28(sp)+ stw r19, 24(sp)+ stw r18, 20(sp)+ stw r17, 16(sp)+ stw r16, 12(sp)+ stw fp, 8(sp)+ mov fp, sp+ +diff --git a/gcc/config/nios2/crtn.asm b/gcc/config/nios2/crtn.asmnew file mode 100644index 0000000..e337480--- /dev/null+++ b/gcc/config/nios2/crtn.asm@@ -0,0 +1,70 @@+/*+ Copyright (C) 2003 + by Jonah Graham (jgraham@altera.com)++This file is free software; you can redistribute it and/or modify it+under the terms of the GNU General Public License as published by the+Free Software Foundation; either version 2, or (at your option) any+later version.++In addition to the permissions in the GNU General Public License, the+Free Software Foundation gives you unlimited permission to link the+compiled version of this file with other programs, and to distribute+those programs without any restriction coming from the use of this+file. (The General Public License restrictions do apply in other+respects; for example, they cover modification of the file, and+distribution when not linked into another program.)++This file is distributed in the hope that it will be useful, but+WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; see the file COPYING. If not, write to+the Free Software Foundation, 59 Temple Place - Suite 330,+Boston, MA 02111-1307, USA.++ As a special exception, if you link this library with files+ compiled with GCC to produce an executable, this does not cause+ the resulting executable to be covered by the GNU General Public License.+ This exception does not however invalidate any other reasons why+ the executable file might be covered by the GNU General Public License.+++This file just makes sure that the .fini and .init sections do in+fact return. Users may put any desired instructions in those sections.+This file is the last thing linked into any executable.+*/ + .file "crtn.asm"++++ .section ".init"+ ldw ra, 44(sp)+ ldw r23, 40(sp)+ ldw r22, 36(sp)+ ldw r21, 32(sp)+ ldw r20, 28(sp)+ ldw r19, 24(sp)+ ldw r18, 20(sp)+ ldw r17, 16(sp)+ ldw r16, 12(sp)+ ldw fp, 8(sp)+ addi sp, sp, -48+ ret+ + .section ".fini"+ ldw ra, 44(sp)+ ldw r23, 40(sp)+ ldw r22, 36(sp)+ ldw r21, 32(sp)+ ldw r20, 28(sp)+ ldw r19, 24(sp)+ ldw r18, 20(sp)+ ldw r17, 16(sp)+ ldw r16, 12(sp)+ ldw fp, 8(sp)+ addi sp, sp, -48+ ret+ diff --git a/gcc/config/nios2/lib2-divmod-hi.c b/gcc/config/nios2/lib2-divmod-hi.cnew file mode 100644index 0000000..10bd6e4--- /dev/null+++ b/gcc/config/nios2/lib2-divmod-hi.c@@ -0,0 +1,123 @@++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is+ supposedly valid even though this is a "target" file. */+#include "auto-host.h"+++#include "tconfig.h"+#include "tsystem.h"+#include "coretypes.h"+#include "tm.h"+++/* Don't use `fancy_abort' here even if config.h says to use it. */+#ifdef abort+#undef abort+#endif+++#ifdef HAVE_GAS_HIDDEN+#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))+#else+#define ATTRIBUTE_HIDDEN+#endif++#include "libgcc2.h"++extern HItype __modhi3 (HItype, HItype);+extern HItype __divhi3 (HItype, HItype);+extern HItype __umodhi3 (HItype, HItype);+extern HItype __udivhi3 (HItype, HItype);++static UHItype udivmodhi4(UHItype, UHItype, word_type);++static UHItype+udivmodhi4(UHItype num, UHItype den, word_type modwanted)+{+ UHItype bit = 1;+ UHItype res = 0;++ while (den < num && bit && !(den & (1L<<15)))+ {+ den <<=1;+ bit <<=1;+ }+ while (bit)+ {+ if (num >= den)+ {+ num -= den;+ res |= bit;+ }+ bit >>=1;+ den >>=1;+ }+ if (modwanted) return num;+ return res;+}+++HItype+__divhi3 (HItype a, HItype b)+{+ word_type neg = 0;+ HItype res;++ if (a < 0)+ {+ a = -a;+ neg = !neg;+ }++ if (b < 0)+ {+ b = -b;+ neg = !neg;+ }++ res = udivmodhi4 (a, b, 0);++ if (neg)+ res = -res;++ return res;+}+++HItype+__modhi3 (HItype a, HItype b)+{+ word_type neg = 0;+ HItype res;++ if (a < 0)+ {+ a = -a;+ neg = 1;+ }++ if (b < 0)+ b = -b;++ res = udivmodhi4 (a, b, 1);++ if (neg)+ res = -res;++ return res;+}+++HItype+__udivhi3 (HItype a, HItype b)+{+ return udivmodhi4 (a, b, 0);+}+++HItype+__umodhi3 (HItype a, HItype b)+{+ return udivmodhi4 (a, b, 1);+}+diff --git a/gcc/config/nios2/lib2-divmod.c b/gcc/config/nios2/lib2-divmod.cnew file mode 100644index 0000000..00e730d--- /dev/null+++ b/gcc/config/nios2/lib2-divmod.c@@ -0,0 +1,126 @@++/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is+ supposedly valid even though this is a "target" file. */+#include "auto-host.h"+++#include "tconfig.h"+#include "tsystem.h"+#include "coretypes.h"+#include "tm.h"+++/* Don't use `fancy_abort' here even if config.h says to use it. */+#ifdef abort+#undef abort+#endif+++#ifdef HAVE_GAS_HIDDEN+#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))+#else+#define ATTRIBUTE_HIDDEN+#endif++#include "libgcc2.h"++extern SItype __modsi3 (SItype, SItype);+extern SItype __divsi3 (SItype, SItype);+extern SItype __umodsi3 (SItype, SItype);+extern SItype __udivsi3 (SItype, SItype);++static USItype udivmodsi4(USItype, USItype, word_type);++/* 16-bit SI divide and modulo as used in NIOS */+++static USItype+udivmodsi4(USItype num, USItype den, word_type modwanted)+{+ USItype bit = 1;+ USItype res = 0;++ while (den < num && bit && !(den & (1L<<31)))+ {+ den <<=1;+ bit <<=1;+ }+ while (bit)+ {+ if (num >= den)+ {+ num -= den;+ res |= bit;+ }+ bit >>=1;+ den >>=1;+ }+ if (modwanted) return num;+ return res;+}+++SItype+__divsi3 (SItype a, SItype b)+{+ word_type neg = 0;+ SItype res;++ if (a < 0)+ {+ a = -a;+ neg = !neg;+ }++ if (b < 0)+ {+ b = -b;+ neg = !neg;+ }++ res = udivmodsi4 (a, b, 0);++ if (neg)+ res = -res;++ return res;+}+++SItype+__modsi3 (SItype a, SItype b)+{+ word_type neg = 0;+ SItype res;++ if (a < 0)+ {+ a = -a;+ neg = 1;+ }++ if (b < 0)+ b = -b;++ res = udivmodsi4 (a, b, 1);++ if (neg)+ res = -res;++ return res;+}+++SItype+__udivsi3 (SItype a, SItype b)+{+ return udivmodsi4 (a, b, 0);+}+++SItype+__umodsi3 (SItype a, SItype b)+{+ return udivmodsi4 (a, b, 1);+}+diff --git a/gcc/config/nios2/lib2-divtable.c b/gcc/config/nios2/lib2-divtable.cnew file mode 100644
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -