Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile newlib with -DMALLOC_PROVIDED #81

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[submodule "crosstool-NG"]
path = crosstool-NG
url = https://github.com/jcmvbkbc/crosstool-NG
branch = lx106-g++
branch = xtensa-1.22.x
[submodule "lx106-hal"]
path = lx106-hal
url = https://github.com/tommie/lx106-hal
[submodule "esptool"]
path = esptool
url = https://github.com/pfalcon/esptool
url = https://github.com/themadinventor/esptool
253 changes: 253 additions & 0 deletions 1000-mforce-l32.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
https://github.com/jcmvbkbc/gcc-xtensa/commit/6b0c9f92fb8e11c6be098febb4f502f6af37cd35.patch

From 6b0c9f92fb8e11c6be098febb4f502f6af37cd35 Mon Sep 17 00:00:00 2001
From: Max Filippov <[email protected]>
Date: Thu, 11 Jun 2015 17:56:57 +0300
Subject: [PATCH] WIP: xtensa: add -mforce-l32

Signed-off-by: Max Filippov <[email protected]>
---
gcc/config/xtensa/constraints.md | 15 ++++++++++++
gcc/config/xtensa/xtensa.c | 53 +++++++++++++++++++++++++++++++++++++++-
gcc/config/xtensa/xtensa.md | 49 ++++++++++++++++++++-----------------
gcc/config/xtensa/xtensa.opt | 4 +++
4 files changed, 98 insertions(+), 23 deletions(-)

diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md
index 30f4c1f..5fd9337 100644
--- a/gcc/config/xtensa/constraints.md
+++ b/gcc/config/xtensa/constraints.md
@@ -137,3 +137,18 @@
(and (match_code "reg")
(match_test "reload_in_progress
&& REGNO (op) >= FIRST_PSEUDO_REGISTER"))))
+
+(define_constraint "Y"
+ "Memory that is not in a literal pool."
+ (ior (and (and (match_code "mem")
+ (match_test "! constantpool_mem_p (op)"))
+ (match_test "!TARGET_FORCE_L32"))
+ (and (match_code "reg")
+ (match_test "reload_in_progress
+ && REGNO (op) >= FIRST_PSEUDO_REGISTER"))))
+
+(define_constraint "Z"
+ "Memory that is not in a literal pool."
+ (and (and (match_code "mem")
+ (match_test "! constantpool_mem_p (op)"))
+ (match_test "TARGET_FORCE_L32")))
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index d8c5b41..559b181 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -1824,7 +1824,8 @@ xtensa_legitimate_address_p (machine_mode mode, rtx addr, bool strict)
return true;

/* Check for "register + offset" addressing. */
- if (GET_CODE (addr) == PLUS)
+ if (GET_CODE (addr) == PLUS &&
+ (!TARGET_FORCE_L32 || (mode != HImode && mode != QImode)))
{
rtx xplus0 = XEXP (addr, 0);
rtx xplus1 = XEXP (addr, 1);
@@ -2308,6 +2309,8 @@ printx (FILE *file, signed int val)
fprintf (file, "0x%x", val);
}

+static void
+output_address_base (FILE *file, rtx addr);

void
print_operand (FILE *file, rtx x, int letter)
@@ -2317,6 +2320,13 @@ print_operand (FILE *file, rtx x, int letter)

switch (letter)
{
+ case 'B':
+ if (GET_CODE (x) == MEM)
+ output_address_base (file, XEXP (x, 0));
+ else
+ output_operand_lossage ("invalid %%B value");
+ break;
+
case 'D':
if (GET_CODE (x) == REG || GET_CODE (x) == SUBREG)
fprintf (file, "%s", reg_names[xt_true_regnum (x) + 1]);
@@ -2450,6 +2460,47 @@ print_operand (FILE *file, rtx x, int letter)
}
}

+static void
+output_address_base (FILE *file, rtx addr)
+{
+ switch (GET_CODE (addr))
+ {
+ default:
+ fatal_insn ("invalid address", addr);
+ break;
+
+ case REG:
+ fprintf (file, "%s", reg_names [REGNO (addr)]);
+ break;
+
+ case PLUS:
+ {
+ rtx reg = (rtx)0;
+ rtx offset = (rtx)0;
+ rtx arg0 = XEXP (addr, 0);
+ rtx arg1 = XEXP (addr, 1);
+
+ if (GET_CODE (arg0) == REG)
+ {
+ reg = arg0;
+ offset = arg1;
+ }
+ else if (GET_CODE (arg1) == REG)
+ {
+ reg = arg1;
+ offset = arg0;
+ }
+ else
+ fatal_insn ("no register in address", addr);
+
+ if (CONSTANT_P (offset))
+ fprintf (file, "%s", reg_names [REGNO (reg)]);
+ else
+ fatal_insn ("address offset not a constant", addr);
+ }
+ break;
+ }
+}

/* A C compound statement to output to stdio stream STREAM the
assembler syntax for an instruction operand that is a memory
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index a577aa3..f56c45e 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -532,26 +532,28 @@
;; Zero-extend instructions.

(define_insn "zero_extendhisi2"
- [(set (match_operand:SI 0 "register_operand" "=a,a")
- (zero_extend:SI (match_operand:HI 1 "nonimmed_operand" "r,U")))]
+ [(set (match_operand:SI 0 "register_operand" "=a,a,a")
+ (zero_extend:SI (match_operand:HI 1 "nonimmed_operand" "r,Y,Z")))]
""
"@
extui\t%0, %1, 0, 16
- l16ui\t%0, %1"
- [(set_attr "type" "arith,load")
+ l16ui\t%0, %1
+ ssa8l\t%B1 ; srli\t%0, %B1, 2 ; slli\t%0, %0, 2 ; l32i\t%0, %0, 0 ; srl\t%0, %0 ; extui\t%0, %0, 0, 16"
+ [(set_attr "type" "arith,load,load")
(set_attr "mode" "SI")
- (set_attr "length" "3,3")])
+ (set_attr "length" "3,3,18")])

(define_insn "zero_extendqisi2"
- [(set (match_operand:SI 0 "register_operand" "=a,a")
- (zero_extend:SI (match_operand:QI 1 "nonimmed_operand" "r,U")))]
+ [(set (match_operand:SI 0 "register_operand" "=a,a,a")
+ (zero_extend:SI (match_operand:QI 1 "nonimmed_operand" "r,Y,Z")))]
""
"@
extui\t%0, %1, 0, 8
- l8ui\t%0, %1"
- [(set_attr "type" "arith,load")
+ l8ui\t%0, %1
+ ssa8l\t%B1 ; srli\t%0, %B1, 2 ; slli\t%0, %0, 2 ; l32i\t%0, %0, 0 ; srl\t%0, %0 ; extui\t%0, %0, 0, 8"
+ [(set_attr "type" "arith,load,load")
(set_attr "mode" "SI")
- (set_attr "length" "3,3")])
+ (set_attr "length" "3,3,18")])


;; Sign-extend instructions.
@@ -569,15 +571,16 @@
})

(define_insn "extendhisi2_internal"
- [(set (match_operand:SI 0 "register_operand" "=B,a")
- (sign_extend:SI (match_operand:HI 1 "sext_operand" "r,U")))]
+ [(set (match_operand:SI 0 "register_operand" "=B,a,a")
+ (sign_extend:SI (match_operand:HI 1 "sext_operand" "r,r,Y")))]
""
"@
sext\t%0, %1, 15
+ slli\t%0, %1, 16 ; srai\t%0, %0, 16
l16si\t%0, %1"
- [(set_attr "type" "arith,load")
+ [(set_attr "type" "arith,arith,load")
(set_attr "mode" "SI")
- (set_attr "length" "3,3")])
+ (set_attr "length" "3,6,3")])

(define_expand "extendqisi2"
[(set (match_operand:SI 0 "register_operand" "")
@@ -796,8 +799,8 @@
})

(define_insn "movhi_internal"
- [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A")
- (match_operand:HI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))]
+ [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A")
+ (match_operand:HI 1 "move_operand" "M,d,r,I,Y,Z,r,*A,*r"))]
"xtensa_valid_move (HImode, operands)"
"@
movi.n\t%0, %x1
@@ -805,12 +808,13 @@
mov\t%0, %1
movi\t%0, %x1
%v1l16ui\t%0, %1
+ ssa8l\t%B1 ; srli\t%0, %B1, 2 ; slli\t%0, %0, 2 ; %v1l32i\t%0, %0, 0 ; srl\t%0, %0 ; extui\t%0, %0, 0, 16
%v0s16i\t%1, %0
rsr\t%0, ACCLO
wsr\t%1, ACCLO"
- [(set_attr "type" "move,move,move,move,load,store,rsr,wsr")
+ [(set_attr "type" "move,move,move,move,load,load,store,rsr,wsr")
(set_attr "mode" "HI")
- (set_attr "length" "2,2,3,3,3,3,3,3")])
+ (set_attr "length" "2,2,3,3,3,18,3,3,3")])

;; 8-bit Integer moves

@@ -824,8 +828,8 @@
})

(define_insn "movqi_internal"
- [(set (match_operand:QI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A")
- (match_operand:QI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))]
+ [(set (match_operand:QI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A")
+ (match_operand:QI 1 "move_operand" "M,d,r,I,Y,Z,r,*A,*r"))]
"xtensa_valid_move (QImode, operands)"
"@
movi.n\t%0, %x1
@@ -833,12 +837,13 @@
mov\t%0, %1
movi\t%0, %x1
%v1l8ui\t%0, %1
+ ssa8l\t%B1 ; srli\t%0, %B1, 2 ; slli\t%0, %0, 2 ; %v1l32i\t%0, %0, 0 ; srl\t%0, %0 ; extui\t%0, %0, 0, 8
%v0s8i\t%1, %0
rsr\t%0, ACCLO
wsr\t%1, ACCLO"
- [(set_attr "type" "move,move,move,move,load,store,rsr,wsr")
+ [(set_attr "type" "move,move,move,move,load,load,store,rsr,wsr")
(set_attr "mode" "QI")
- (set_attr "length" "2,2,3,3,3,3,3,3")])
+ (set_attr "length" "2,2,3,3,3,18,3,3,3")])

;; Sub-word reloads from the constant pool.

diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt
index 2fd6cee..02020d2 100644
--- a/gcc/config/xtensa/xtensa.opt
+++ b/gcc/config/xtensa/xtensa.opt
@@ -41,3 +41,7 @@ Intersperse literal pools with code in the text section
mserialize-volatile
Target Report Mask(SERIALIZE_VOLATILE)
-mno-serialize-volatile Do not serialize volatile memory references with MEMW instructions
+
+mforce-l32
+Target Report Mask(FORCE_L32)
+Use l32i to access 1- and 2-byte quantities in memory instead of l8ui/l16ui
12 changes: 12 additions & 0 deletions 9000-newlib-flags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- a/newlib/configure.host 2015-11-12 14:04:48.064467034 +0000
+++ b/newlib/configure.host 2015-11-12 14:07:45.645532708 +0000
@@ -285,7 +285,8 @@
xtensa)
libm_machine_dir=xtensa
machine_dir=xtensa
- newlib_cflags="${newlib_cflags} -mlongcalls"
+ newlib_cflags="${newlib_cflags} -mlongcalls -ffunction-sections -mtext-section-literals -Os"
+ newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
;;
z8k)
Loading