Add picoChip port.

2008-09-03  Hari Sandanagobalane  <hariharan@picochip.com>

	Add picoChip port.
	* MAINTAINERS: Add picoChip maintainers.
	libgcc/
	* config.host: Add picochip-*-*.
	gcc/
	* doc/extend.texi: Document picoChip builtin functions.
	* doc/invoke.texi: Document picoChip options.
	* doc/contrib.texi: Add picoChip contribution.
	* doc/md.texi: Document picoChip constraints.
	* config.gcc: Add picochip-*-*.
	* config/picochip/: Add new port.

From-SVN: r139932
This commit is contained in:
Hari Sandanagobalane 2008-09-03 12:10:49 +00:00 committed by Paul Brook
parent 44299c9601
commit 358da97e4e
41 changed files with 12560 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2008-09-03 Hari Sandanagobalane <hariharan@picochip.com>
Add picoChip port.
* MAINTAINERS: Add picoChip maintainers.
2008-09-02 Sebastian Pop <sebastian.pop@amd.com>
Tobias Grosser <grosser@fim.uni-passau.de>
Jan Sjodin <jan.sjodin@amd.com>

View File

@ -69,6 +69,8 @@ mmix port Hans-Peter Nilsson hp@bitrange.com
mn10300 port Jeff Law law@redhat.com
mn10300 port Alexandre Oliva aoliva@redhat.com
pdp11 port Paul Koning ni1d@arrl.net
picochip port Hari Sandanagobalane hariharan@picochip.com
picochip port Daniel Towner dant@picochip.com
rs6000 port Geoff Keating geoffk@geoffk.org
rs6000 port David Edelsohn edelsohn@gnu.org
rs6000 vector extns Aldy Hernandez aldyh@redhat.com

View File

@ -0,0 +1,68 @@
;; GCC machine description for picochip
;; Copyright (C) 2008 Free Software Foundation, Inc.
;; Contributed by picoChip Designs Ltd (http://www.picochip.com)
;; Maintained by Daniel Towner (dant@picochip.com) and Hariharan
;; Sandanagobalane (hariharan@picochip.com)
;;
;; This file is part of GCC.
;;
;; GCC 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 3, or (at your option)
;; any later version.
;;
;; GCC 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 GCC; see the file COPYING3. If not, see
;; <http://www.gnu.org/licenses/>.
(define_constraint "I"
"4-bits signed value"
(and (match_code "const_int")
(match_test " ival >= -8 && ival< 8")))
(define_constraint "J"
"4-bits unsigned value"
(and (match_code "const_int")
(match_test "ival>=0 && ival < 16")))
(define_constraint "K"
"8-bits signed value"
(and (match_code "const_int")
(match_test " ival >= -128 && ival < 128")))
(define_constraint "M"
"4-bits magnitude"
(and (match_code "const_int")
(match_test " abs(ival) < 16")))
(define_constraint "N"
"10-bits signed value"
(and (match_code "const_int")
(match_test "ival >= -512 && ival < 512")))
(define_constraint "O"
"16-bits signed value"
(and (match_code "const_int")
(match_test " ival >= -32768 && ival < 32768 ")))
(define_constraint "a"
"See if this is an absolute address in memory"
(and (match_code "mem")
(match_test "picochip_absolute_memory_operand(op,mode) == 1")))
(define_constraint "b"
"See if this is an address in memory, non-strict version"
(match_test "picochip_legitimate_address_p(mode,op,0) == 1"))
(define_register_constraint "k" "FRAME_REGS"
"Frame regs")
(define_register_constraint "f" "PTR_REGS"
"Pointer regs")
(define_register_constraint "t" "TWIN_REGS"
"Twin regs")

View File

@ -0,0 +1,43 @@
;; GCC machine description for picochip
;; Copyright (C) 2008 Free Software Foundation, Inc.
;; Contributed by picoChip Designs Ltd (http://www.picochip.com)
;; Maintained by Daniel Towner (dant@picochip.com) and Hariharan
;; Sandanagobalane (hariharan@picochip.com)
;;
;; This file is part of GCC.
;;
;; GCC 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 3, or (at your option)
;; any later version.
;;
;; GCC 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 GCC; see the file COPYING3. If not, see
;; <http://www.gnu.org/licenses/>.
;; The following DFA description schedules instructions for space. The
;; schedule seeks to avoid stall cycles (e.g., memory load), but the
;; instructions are not VLIW packed (whenever instructions are packed
;; together, an additional byte is used to denote this, which
;; increases the code size).
;; No special handling of the long constants is necessary (as in
;; dfa_speed.md), since VLIW packing is not used.
;; Memory instructions stall for one cycle. All other instructions
;; complete ready for the next cycle.
(define_insn_reservation "nonStallInsn" 1
(and (eq_attr "schedType" "space")
(eq_attr "type" "!mem"))
"slot0+slot1+slot2")
(define_insn_reservation "stallInsn" 2
(and (eq_attr "schedType" "space")
(eq_attr "type" "mem"))
"slot0+slot1+slot2")

View File

@ -0,0 +1,123 @@
;; GCC machine description for picochip
;; Copyright (C) 2008 Free Software Foundation, Inc.
;; Contributed by picoChip Designs Ltd (http://www.picochip.com)
;; Maintained by Daniel Towner (dant@picochip.com) and Hariharan
;; Sandanagobalane (hariharan@picochip.com).
;;
;; This file is part of GCC.
;;
;; GCC 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 3, or (at your option)
;; any later version.
;;
;; GCC 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 GCC; see the file COPYING3. If not, see
;; <http://www.gnu.org/licenses/>.
;; The following DFA description schedules instructions for speed. In
;; addition to the scheduling of instructions to remove stall cycles
;; (e.g., memory load), the scheduler will also pack multiple
;; instructions into a single cycle, using VLIW.
;; Each instruction comes in forms with and without long
;; constants. The long constant is treated as though it were also an
;; instruction. Thus, an instruction which used slot0, will use slot0
;; plus one of the other slots for the constant. This mechanism
;; ensures that it is impossible for 3 instructions to be issued, if
;; one of them has a long constant. This is necessary, because the
;; encoding of 3 instructions, plus a constant, will overrun the
;; 64-bit limit.
; Extended ALU - Slot 0
(define_insn_reservation "picoAluInsn" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "picoAlu") (eq_attr "longConstant" "false")))
"slot0")
(define_insn_reservation "picoAluInsnWithConst" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "picoAlu") (eq_attr "longConstant" "true")))
"(slot0+slot1)|(slot0+slot2)")
; Basic ALU - Slot 0 or 1
(define_insn_reservation "basicAluInsn" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "basicAlu") (eq_attr "longConstant" "false")))
"(slot0|slot1)")
(define_insn_reservation "basicAluInsnWithConst" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "basicAlu") (eq_attr "longConstant" "true")))
"(slot0+slot1) | (slot1+slot2) | (slot0+slot2)")
; ALU which must not set flags - Slot 1
(define_insn_reservation "nonCcAluInsn" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "nonCcAlu") (eq_attr "longConstant" "false")))
"slot1")
(define_insn_reservation "nonCcAluInsnWithConst" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "nonCcAlu") (eq_attr "longConstant" "true")))
"(slot1+slot0) | (slot1+slot2)")
; Memory - Slot 1
(define_insn_reservation "memInsn" 2
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "mem") (eq_attr "longConstant" "false")))
"slot1,nothing")
(define_insn_reservation "memInsnWithConst" 2
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "mem") (eq_attr "longConstant" "true")))
"slot1+(slot0|slot2),nothing")
; Multiply - Slot 2
(define_insn_reservation "mulInsn" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "mul") (eq_attr "longConstant" "false")))
"slot2")
(define_insn_reservation "mulInsnWithConst" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "mul") (eq_attr "longConstant" "true")))
"(slot2+slot0)|(slot2+slot1)")
; MAC - Slot 2
(define_insn_reservation "macInsn" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "mac") (eq_attr "longConstant" "false")))
"slot2")
(define_insn_reservation "macInsnWithConst" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "mac") (eq_attr "longConstant" "true")))
"(slot2+slot0)|(slot2+slot1)")
; Branch - Real branches use slot2, while macro branches use unknown
; resources.
(define_insn_reservation "branchInsn" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "realBranch") (eq_attr "longConstant" "false")))
"slot2")
(define_insn_reservation "branchInsnWithConst" 1
(and (eq_attr "schedType" "speed")
(and (eq_attr "type" "realBranch") (eq_attr "longConstant" "true")))
"(slot2+slot0)|(slot2+slot1)")
(define_insn_reservation "branchInsnMacro" 1
(and (eq_attr "schedType" "speed")
(eq_attr "type" "realBranch"))
"(slot0+slot1+slot2)")
; Call instructions use all slots to prevent inadvertent scheduling
; alongside instructions which set R12.
(define_insn_reservation "callInsn" 1
(and (eq_attr "schedType" "speed") (eq_attr "type" "call"))
"slot0+slot1+slot2")
; Communications - Slot 1
(define_insn_reservation "commsInsn" 1
(and (eq_attr "schedType" "speed") (eq_attr "type" "comms"))
"slot1")

View File

@ -0,0 +1,199 @@
// picoChip ASM file
//
// Support for 64-bit addition.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Hariharan Sandanagobalane (hariharan@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.align 8
.global __adddi3
__adddi3:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &__adddi3 = 12 bytes
// The first operand of add is completely in registers r[2-5]
// The second operand of sub is in stack FP(0-3)
// and result need to be written pointed to by the register r0.
// All we need to do is to load the appropriate values, add them
// appropriately (with add or addc ) and then store the values back.
ldw (FP)0, r1
stl r[7:6], (FP)-1
add.0 r2, r1, r6
ldw (FP)1, r1
addc.0 r3, r1, r7
ldl (FP)1, r[3:2]
stl r[7:6], (r0)0
addc.0 r4, r2, r6
addc.0 r5, r3, r7
stl r[7:6], (r0)1
jr (r12)
=-> ldl (FP)-1, r[7:6]
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __adddi3
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0xe // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#61# 16#64# 16#64# 16#63# 16#69# 16#33# 16#0# // Function name `_adddi3'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile

View File

@ -0,0 +1,197 @@
// picoChip ASM file
// picoChip ASM file
//
// Support for 32-bit arithmetic shift left.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Hariharan Sandanagobalane (hariharan@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.global ___ashlsi3
___ashlsi3:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &___ashlsi3 = 0 bytes
// if (R2 > 15) goto _L2
SUB.0 15,R2,r15
JMPLT _L2
=-> SUB.0 16,R2,R5 // R5 := R5 - R4 (HI)
LSL.0 R1,R2,R1 // R3 := R1 << R2
LSL.0 R0,R2,R4 // R2 := R0 << R2
LSR.0 R0,R5,R5 // R5 := R12 >> R5 NEED TO CHECK - HARI
OR.0 R5,R1,R5 // R3 := R5 IOR R0 (HI)
SUB.0 R2,0,r15
COPYNE R5,R1
JR (R12) // Return to caller
=-> COPY.0 R4,R0
_L2:
LSL.0 R0,R2,R1 // R3 := R0 << R2
JR (R12) // Return to caller
=-> COPY.0 0,R0 // R2 := 0 (short constant)
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __ashlsi3
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#61# 16#73# 16#68# 16#6c# 16#73# 16#69# 16#33# 16#0# // Function name `_ashlsi3'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile

View File

@ -0,0 +1,87 @@
/*
picoChip GCC support for 32-bit shift left.
Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by picoChip Designs Ltd.
Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
and to distribute those combinations 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 a combine
executable.)
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, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
#ifndef PICOCHIP
#error "Intended for compilation for PICOCHIP only."
#endif
typedef int HItype __attribute__ ((mode (HI)));
typedef unsigned int UHItype __attribute__ ((mode (HI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef struct USIstruct {
UHItype low, high;
} USIstruct;
typedef union USIunion {
USItype l;
USIstruct s;
} USIunion;
USItype __ashlsi3(USIunion value, HItype count) {
USIunion result;
int temp;
/* Ignore a zero count until we get into the (count < 16)
clause. This is slightly slower when shifting by zero, but faster
and smaller in all other cases (due to the better scheduling
opportunities available by putting the test near computational
instructions. */
/* if (count == 0) return value.l; */
if (count < 16) {
/* Shift low and high words by the count. */
result.s.low = value.s.low << count;
result.s.high = value.s.high << count;
/* There is now a hole in the lower `count' bits of the high
word. Shift the upper `count' bits of the low word into the
high word. This is only required when the count is non-zero. */
if (count != 0) {
temp = 16 - count;
temp = value.s.low >> temp;
result.s.high |= temp;
}
} else {
/* Shift the lower word of the source into the upper word of the
result, and zero the result's lower word. */
count -= 16;
result.s.high = value.s.low << count;
result.s.low = 0;
}
return result.l;
}

View File

@ -0,0 +1,207 @@
// picoChip ASM file
//
// Support for 32-bit arithmetic shift right.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Hariharan Sandanagobalane (hariharan@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.global ___ashrsi3
___ashrsi3:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &___ashrsi3 = 0 bytes
// if (R2 > 15) goto _L2
SUB.0 15,R2,r15
JMPLT _L2
=-> COPY.0 R1,R3
LSR.0 R1,R2,R1 // R1 := R1 >> R2
// if (R2 == 0) goto _L4
SUB.0 R2,0,r15
JMPEQ _L4
=-> LSR.0 R0,R2,R0 // R2 := R0 >> R2
SUB.0 16,R2,R4 // R4 := R4 - R2 (HI)
ASR.0 R3,15,R5 // R5 = R1 >>{arith} 15
LSL.0 R5,R4,R5 // R5 := R5 << R4
LSL.0 R3,R4,R4 // R4 := R1 << R4
OR.0 R5,R1,R1 // R3 := R5 IOR R3 (HI)
BRA _L4
=-> OR.0 R4,R0,R0 // R2 := R4 IOR R0 (HI)
_L2:
ASR.0 R1,15,R1 // R4 = R1 >>{arith} 15
SUB.0 16,R2,R5 // R5 := R5 - R2 (HI)
LSR.0 R3,R2,R0 // R2 := R1 >> R2
LSL.0 R1,R5,R5 // R5 := R4 << R5
OR.0 R5,R0,R5 // R2 := R5 IOR R2 (HI)
SUB.0 R2,16,r15 // R5 := R5 - R2 (HI)
COPYNE R5,R0
_L4:
JR (R12) // Return to caller
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __ashrsi3
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#61# 16#73# 16#68# 16#72# 16#73# 16#69# 16#33# 16#0# // Function name `_ashrsi3'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,118 @@
/*
picoChip GCC support for 32-bit arithmetic shift right.
Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by picoChip Designs Ltd.
Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
and to distribute those combinations 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 a combine
executable.)
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, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
typedef int HItype __attribute__ ((mode (HI)));
typedef unsigned int UHItype __attribute__ ((mode (HI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef struct USIstruct {
UHItype low, high;
} USIstruct;
typedef union USIunion {
USItype l;
USIstruct s;
} USIunion;
USItype __ashrsi3(USIunion value, HItype count) {
USIunion result;
int temp;
int wordOfSignBits;
/* Ignore a zero count until we get into the (count < 16)
clause. This is slightly slower when shifting by zero, but faster
and smaller in all other cases (due to the better scheduling
opportunities available by putting the test near computational
instructions. */
/* if (count == 0) return value.l; */
if (count < 16) {
/* Shift low and high words by the count. The high word must use
an arithmetic shift. There is no arithmetic shift-right by
variable, so synthesise it. */
int signWord;
int reverseCount;
/* Shift low and high parts by the count. The upper word now has
invalid signed bits. */
result.s.low = value.s.low >> count;
result.s.high = value.s.high >> count;
if (count != 0) {
reverseCount = 16 - count;
/* Given a word of sign bits, shift back left to create the
destination sign bits. */
wordOfSignBits = __builtin_asri(value.s.high, 15);
signWord = wordOfSignBits << reverseCount;
result.s.high |= signWord;
/* There is now a hole in the upper `count' bits of the low
word. Shift the lower `count' bits of the upper word into the
low word. */
temp = value.s.high << reverseCount;
result.s.low |= temp;
}
} else {
int signWord;
/* Shift is greater than one word, so top word will always be set
to sign bits, and bottom word will be shifted from top word. */
result.s.low = value.s.high >> count;
result.s.high = __builtin_asri(value.s.high, 15);
if (count != 16) {
/* Shift the upper word of the source into the lower word of the
result. Arithmetically shift the upper word as well, to retain
the sign. This shift must be synthesised, as no such shift
exists in the instruction set. */
int signWord;
/* Given a complete word of sign-bits, shift this back left to
create the destination sign bits. */
signWord = result.s.high << (16 - count);
// signWord = wordOfSignBits << (16 - count);
/* Insert the sign bits to the result's low word. */
result.s.low |= signWord;
}
}
return result.l;
}

View File

@ -0,0 +1,166 @@
// picoChip ASM file
//.file "clzsi2.asm"
.section .text
.global __clzsi2
__clzsi2:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &__clzsi2 = 0 bytes
// What value should be operated on? If the top word is empty
// then count the bits in the bottom word, and add 16. If the
// top word is not empty, then count the bits in the top word.
// R4 stores the constant 0
sub.0 R1,0,r15 \ copy.1 16,r2
copyeq r0,r1
copyne 0,r2
// R1 now stores value to count, and R2 stores current bit offset.
sbc r1,r0
asr.0 r1,15,r15 \ add.1 r0,1,r0
jr (lr) \ copyne 0,r0
=-> add.0 r0,r2,r0
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __clzsi2
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5F# 16#63# 16#6C# 16#7A# 16#73# 16#69# 16#32# 16#0# // Function name `_clzsi2'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,217 @@
// picoChip ASM file
//.file "ucmpsi2.c"
//
// Support for 32-bit signed compare.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
//
// Compiled from the following, and then hand optimised.
//
// int __cmpsi2 (USItype x, USItype y)
// {
//
// SIunion lx; lx.l = x;
// SIunion ly; ly.l = y;
//
// if (lx.s.high < ly.s.high)
// return 0;
// else if (lx.s.high > ly.s.high)
// return 2;
// if (lx.s.low < ly.s.low)
// return 0;
// else if (lx.s.low > ly.s.low)
// return 2;
// return 1;
// }
.section .text
.align 8
.global ___cmpsi2
___cmpsi2:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &___cmpsi2 = 0 bytes
SUB.0 R1,R3,r15
BLT _L1
=-> SUB.0 R3,R1,r15 \ COPY.1 0,R5
BLT _L1
=-> SUB.0 R0,R2,r15 \ COPY.1 2,R5
BLO _L1
=-> SUB.0 R2,R0,r15 \ COPY.1 0,R5
BLO _L1
=-> COPY.0 2,R5
COPY.0 1,R5
_L1:
JR (R12)
=-> COPY.0 R5,R0
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __cmpsi2
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#5f# 16#63# 16#6d# 16#70# 16#73# 16#69# 16#32# 16#0# // Function name `__cmpsi2'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,268 @@
// picoChip ASM file
//
// Support for 16-bit unsigned division/modulus.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.global __divmod15
__divmod15:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &__divmod15 = 0 bytes
__divmod15:
// The picoChip instruction set has a divstep instruction which
// is used to perform one iteration of a binary division algorithm.
// The instruction allows 16-bit signed division to be implemented.
// It does not directly allow 16-bit unsigned division to be
// implemented. Thus, this function pulls out the common division
// iteration for 15-bits unsigned, and then special wrappers
// provide the logic to change this into a 16-bit signed or
// unsigned division, as appropriate. This allows the two
// versions of division to share a common implementation, reducing
// code size when the two are used together. It also reduces
// the maintenance overhead.
// Input:
// r0 - dividend
// r1 - divisor
// Output:
// r0 - quotient
// r1 - remainder
// R5 is unused
// Check for special cases. The emphasis is on detecting these as
// quickly as possible, so that the main division can be started. If
// the user requests division by one, division by self, and so on
// then they will just have to accept that this won't be particularly
// quick (relatively), whereas a real division (e.g., dividing a
// large value by a small value) will run as fast as possible
// (i.e., special case detection should not slow down the common case)
//
// Special cases to consider:
//
// Division by zero.
// Division of zero.
// Inputs are equal
// Divisor is bigger than dividend
// Division by power of two (can be shifted instead).
// Division by 1 (special case of power of two division)
//
// Division/modulus by zero is undefined (ISO C:6.5.5), so
// don't bother handling this special case.
//
// The special cases of division by a power of 2 are ignored, since
// they cause the general case to slow down. Omitting these
// special cases also reduces code size considerably.
// Handle divisor >= dividend separately. Note that this also handles
// the case where the dividend is zero. Note that the flags must be
// preserved, since they are also used at the branch destination.
sub.0 r1,r0,r15
sbc r0,r2 \ bge divisorGeDividend
=-> sbc r1,r4
// Compute the shift count. The amount by which the divisor
// must be shifted left to be aligned with the dividend.
sub.0 r4,r2,r3
// Align the divisor to the dividend. Execute a divstep (since at
// least one will always be executed). Skip the remaining loop
// if the shift count is zero.
lsl.0 r1,r3,r1 \ beq skipLoop
=-> divstep r0,r1 \ add.1 r3,1,r2
// Execute the divstep loop until temp is 0. This assumes that the
// loop count is at least one.
sub.0 r3,1,r4
divLoop:
divstep r0,r1 \ bne divLoop
=-> sub.0 r4,1,r4
skipLoop:
// The top bits of the result are the remainder. The bottom
// bits are the quotient.
lsr.0 r0,r2,r1 \ sub.1 16,r2,r4
jr (lr ) \ lsl.0 r0,r4,r0
=-> lsr.0 r0,r4,r0
// Special case.
divisorGeDividend:
// The divisor is greater than or equal to the dividend. The flags
// indicate which of these alternatives it is. The COPYNE can be used
// to set the result appropriately, without introducing any more
// branches.
copy.0 r0,r1 \ copy.1 0,r0
jr (lr) \ copyeq r0,r1
=-> copyeq 1,r0
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __divmod15
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#64# 16#69# 16#76# 16#6d# 16#6f# 16#64# 16#31# 16#35# 16#0# // Function name `_divmod15'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,251 @@
// picoChip ASM file
//
// Support for 16-bit signed division/modulus.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.align 8
.global __divmodhi4
__divmodhi4:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &__divmodhi4 = 4 bytes
// 16-bit signed division. Most of the special cases are dealt
// with by the 15-bit signed division library (e.g., division by
// zero, division by 1, and so on). This wrapper simply inverts
// any negative inputs, calls the 15-bit library, and flips any
// results as necessary. The
// only special cases to be handled here are where either the
// divisor or the dividend are the maximum negative values.
// Encode r5 with a bit pattern which indicates whether the
// outputs of the division must be negated. The MSB will be set
// to the sign of the dividend (which controls the remainder's
// sign), while the LSB will store the XOR of the two signs,
// which indicates the quotient's sign. R5 is not modified by the
// 15-bit divmod routine.
sub.0 r1,16#8000#,r15 \ asr.1 r0,15,r4
beq divisorIsLargestNegative \ lsr.0 r1,15,r3
=-> sub.0 r0,16#8000#,r15 \ xor.1 r3,r4,r5
// Handle least negative dividend with a special case. Note that the
// absolute value of the divisor is also computed here.
add.0 [asr r1,15],r1,r3 \ beq dividendIsLargestNegative
=-> xor.0 [asr r1,15],r3,r1 \ stw lr,(fp)-1
// Compute the absolute value of the dividend, and call the main
// divide routine.
add.0 r4,r0,r2 \ jl (&__divmod15) // fn_call &__divmod15
=-> xor.0 r4,r2,r0
handleNegatedResults:
// Speculatively store the negation of the results.
sub.0 0,r0,r2 \ sub.1 0,r1,r3
// Does the quotient need negating? The LSB indicates this.
and.0 r5,1,r15 \ ldw (fp)-1,lr
copyne r2,r0
asr.0 r5,15,r15 \ jr (lr)
=-> copyne r3,r1
dividendIsLargestNegative:
// Divide the constant -32768. Use the Hacker's Delight
// algorithm (i.e., ((dividend / 2) / divisor) * 2) gives
// approximate answer). This code is a special case, so no
// great effort is made to make it fast, only to make it
// small.
lsr.0 r0,1,r0 \ jl (&__divmod15) // fn_call &__divmod15
=-> stw r1,(fp)-2
// Load the original divisor, and compute the new quotient and
// remainder.
lsl.0 r0,1,r0 \ ldw (fp)-2,r3
lsl.0 r1,1,r1 // Fill stall slot
// The error in the quotient is 0 or 1. The error can be determined
// by comparing the remainder to the original divisor. If the
// remainder is bigger, then an error of 1 has been introduced,
// which must be fixed.
sub.0 r1,r3,r15
blo noCompensationForError
=-> nop
add.0 r0,1,r0 \ sub.1 r1,r3,r1
noCompensationForError:
bra handleNegatedResults
=-> nop
divisorIsLargestNegative:
// The flags indicate whether the dividend is also the maximum negative
copy.0 r0,r1 \ copy.1 0,r0
copyeq r0,r1 \ jr (lr)
=-> copyeq 1,r0
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __divmodhi4
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x4 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#64# 16#69# 16#76# 16#6d# 16#6f# 16#64# 16#68# 16#69# 16#34# 16#0# // Function name `_divmodhi4'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile

View File

@ -0,0 +1,239 @@
// picoChip ASM file
//
// Support for 32-bit signed division/modulus.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
//
.section .text
.align 8
.global __divmodsi4
__divmodsi4:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &__divmodsi4 = 8 bytes
// Note: optimising for size is preferred over optimising for speed.
// Note: the frame is setup throughout the following instructions,
// and is complete at the point the udivmodsi4 function is called.
// Note that R9 is encoded with a pattern which indicates
// whether the remainder and quotient should be negated on
// completion. The MSB is set to the sign of the dividend
// (i.e., the sign of the remainder), while the LSB encodes
// the XOR of the two input's signs (i.e., the sign of the
// quotient.
// If dividend is negative, invert the dividend and flag.
ASR.0 r1,15,r4
BEQ dividendNotNegative
=-> STL R[9:8],(FP)-2
// Dividend is negative - negate dividend.
SUB.0 0,R0,R0
SUBB.0 0,R1,R1
dividendNotNegative:
// If divisor is negative, invert the divisor.
AND.0 [lsr r3,15],1,r5
SUB.0 R3,0, r15
BGE divisorNotNegative
=-> XOR.0 r4,r5,r9
// Divisor is negative - negate divisor.
SUB.0 0,R2,R2
SUBB.0 0,R3,R3
divisorNotNegative:
STL R[13:12],(FP)-1 \ JL (&__udivmodsi4)
=-> SUB.0 FP,8,FP // udivmodsi expects the frame to be valid still.
// The LSB of R9 indicates whether the quotient should be negated.
AND.0 r9,1,r15
BEQ skipQuotientNegation
=-> LDL (FP)1,R[13:12] // Convenient point to restore link/fp
SUB.0 0,R4,R4
SUBB.0 0,R5,R5
skipQuotientNegation:
// The MSB of R9 indicates whether the remainder should be negated.
ASR.0 R9,15,r15
BEQ epilogue
SUB.0 0,R6,R6
SUBB.0 0,R7,R7
epilogue:
JR (R12)
=-> LDL (FP)-2,R[9:8]
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __divmodsi4
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x8 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#64# 16#69# 16#76# 16#6d# 16#6f# 16#64# 16#73# 16#69# 16#34# 16#0# // Function name `_divmodsi4'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,6 @@
// picoChip ASM file
// Fake libgcc asm file. This contains nothing, but is used to prevent gcc
// getting upset about the lack of a libgcc.S file when LIB1ASMFUNCS is defined
// to switch off the compilation of parts of libgcc.

View File

@ -0,0 +1,187 @@
// picoChip ASM file
//
// Support for 32-bit arithmetic shift right.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Hariharan Sandanagobalane (hariharan@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.global _longjmp
_longjmp:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &_longjmp = 0 bytes
LDL (R0)0, R[3:2]
LDL (R0)1, R[5:4]
LDL (R0)2, R[7:6]
LDL (R0)3, R[9:8]
LDL (R0)4, R[11:10]
LDL (R0)5, R[13:12]
LDW (R0)12, R14
LDW (R0)13, R1
JR (R12)
=-> COPY.0 1,R0
// picoChip Function Epilogue : longjmp
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#6c# 16#6f# 16#6e# 16#67# 16#6a# 16#6d# 16#70# 16#0# // Function name `longjmp'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,195 @@
// picoChip ASM file
//
// Support for 32-bit logical shift right.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Hariharan Sandanagobalane (hariharan@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.global ___lshrsi3
___lshrsi3:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &___lshrsi3 = 4 bytes
// if (R2 > 15) goto _L2
SUB.0 15,R2,r15
JMPLT _L2
=-> SUB.0 16,R2,R5 // R5 := R5 - R2 (HI)
LSR.0 R0,R2,R0 // R4 := R0 >> R2
LSR.0 R1,R2,R3 // R3 := R1 >> R2
// if (R2 == 0) goto _L4
LSL.0 R1,R5,R5 // R5 := R1 << R5
OR.0 R5,R0,R4 // R2 := R5 IOR R2 (HI)
SUB.0 R2,0,r15
COPYNE R4,R0 // R0 := R2
JR (R12) // Return to caller
=-> COPY.0 R3,R1 // R1 := R3
_L2:
LSR.0 R1,R2,R0 // R2 := R1 >> R2
JR (R12) // Return to caller
=-> COPY.0 0,R1 // R3 := 0 (short constant)
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __lshrsi3
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x4 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#5f# 16#6c# 16#73# 16#68# 16#72# 16#72# 16#73# 16#69# 16#33# 16#0# // Function name `__lshrsi3'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile

View File

@ -0,0 +1,81 @@
/*
picoChip GCC support for 32-bit logical shift right.
Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by picoChip Designs Ltd.
Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
and to distribute those combinations 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 a combine
executable.)
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, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
typedef int HItype __attribute__ ((mode (HI)));
typedef unsigned int UHItype __attribute__ ((mode (HI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef struct USIstruct {
UHItype low, high;
} USIstruct;
typedef union USIunion {
USItype l;
USIstruct s;
} USIunion;
USItype __lshrsi3(USIunion value, HItype count) {
USIunion result;
int temp;
/* Ignore a zero count until we get into the (count < 16)
clause. This is slightly slower when shifting by zero, but faster
and smaller in all other cases (due to the better scheduling
opportunities available by putting the test near computational
instructions. */
if (count < 16) {
/* Shift low and high words by the count. */
result.s.low = value.s.low >> count;
result.s.high = value.s.high >> count;
/* There is now a hole in the upper `count' bits of the low
word. Shift the lower `count' bits of the upper word into the
low word. This only works when count isn't zero. */
if (count != 0) {
temp = value.s.high << (16 - count);
result.s.low |= temp;
}
} else {
/* Shift the upper word of the source into the lower word of the
result, and zero the result's upper word. Note that we actually
ned to shift by (count - 16), but as we are only using the
bottom 4 bits, this is equivalent to shifting by count. */
result.s.low = value.s.high >> count;
result.s.high = 0;
}
return result.l;
}

View File

@ -0,0 +1,184 @@
// picoChip ASM file
//.file "ucmpsi2.c"
//
// Support for parity checks.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.align 8
.global ___parityhi2
___parityhi2:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &___parityhi2 = 0 bytes
XOR.0 [LSR R0,8],R0,R0
XOR.0 [LSR R0,4],R0,R0
XOR.0 [LSR R0,2],R0,R0
JR (R12) \ XOR.0 [LSR R0,1],R0,R0
=-> AND.0 R0,1,R0
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __parityhi2
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#5f# 16#70# 16#61# 16#72# 16#69# 16#74# 16#79# 16#68# 16#69# 16#32# 16#0# // Function name `__parityhi2'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,206 @@
// picoChip ASM file
//.file "popcounthi2.S"
//
// Support for 16-bit population count.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
// The following code (taken from a newsgroup posting) was compiled, and then
// hand assembled (a similar version is given in the Hacker's Delight
// book, chapter 5).
//
// int
// popcount (int value)
// {
// value = ((value & 0xAAAA) >> 1) + (value & 0x5555);
// value = ((value & 0xCCCC) >> 2) + (value & 0x3333);
// value = ((value & 0xF0F0) >> 4) + (value & 0x0F0F);
// return ((value & 0xFF00) >> 8) + (value & 0x00FF);
// }
//
// This assembly function is approx. 20x faster than a naive loop
// implementation of the population count, but about 30% bigger
// (45 bytes v. 34 bytes).
.align 8
.global ___popcounthi2
___popcounthi2:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &___popcounthi2 = 0 bytes
AND.0 [LSR R0,1],21845,R0 \ AND.1 R0,21845,R5
ADD.0 R0,R5,R0
AND.0 [LSR R0,2],13107,R0 \ AND.1 R0,13107,R5
ADD.0 R0,R5,R0 \ COPY.1 1807,R2
AND.0 [LSR R0,4],R2,R0 \ AND.1 R0,3855,R5
ADD.0 R0,R5,R0
JR (R12) \ AND.0 R0, 255, R5
=-> ADD.0 [LSR R0,8],R5,R0
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : ___popcounthi2
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#5f# 16#70# 16#6f# 16#70# 16#63# 16#6f# 16#75# 16#6e# 16#74# 16#68# 16#69# 16#32# 16#0# // Function name `__popcounthi2'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,187 @@
// picoChip ASM file
//
// Support for 32-bit arithmetic shift right.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Hariharan Sandanagobalane (hariharan@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.global _setjmp
_setjmp:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &_setjmp = 0 bytes
STL R[3:2],(R0)0
STL R[5:4],(R0)1
STL R[7:6],(R0)2
STL R[9:8],(R0)3
STL R[11:10],(R0)4
STL R[13:12],(R0)5
STW R14,(R0)12
STW R1,(R0)13
JR (R12)
=-> COPY.0 0,R0
// picoChip Function Epilogue : setjmp
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#73# 16#65# 16#74# 16#6a# 16#6d# 16#70# 16#0# // Function name `setjmp'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,196 @@
// picoChip ASM file
//
// Support for 64-bit subtraction.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Hariharan Sandanagobalane (hariharan@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA..global __divmodhi4
.section .text
.align 8
.global __subdi3
__subdi3:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &__subdi3 = 4 bytes
// The first operand of sub is completely in registers r[2-5]
// The second operand of sub is in stack FP(0-3)
// and result need to be written pointed to by the register r0.
// All we need to do is to load the appropriate values, sub them
// appropriately (with sub or subb) and then store the values back.
ldw (FP)0, r1
stl r[7:6], (FP)-1
sub.0 r2, r1, r6
ldw (FP)1, r1
subb.0 r3, r1, r7
ldl (FP)1, r[3:2]
stl r[7:6], (r0)0
subb.0 r4, r2, r6
subb.0 r5, r3, r7
stl r[7:6], (r0)1
jr (r12)
=-> ldl (FP)2, r[7:6]
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __subdi3
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x4 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#73# 16#75# 16#62# 16#64# 16#69# 16#33# 16#0# // Function name `_subdi3'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile

View File

@ -0,0 +1,214 @@
// picoChip ASM file
//.file "ucmpsi2.c"
//
// Support for 32-bit unsigned compare.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
//
// Compiled from the following, and then hand optimised.
//
// int __ucmpsi2 (USItype x, USItype y)
// {
//
// USIunion lx; lx.l = x;
// USIunion ly; ly.l = y;
//
// if (lx.s.high < ly.s.high)
// return 0;
// else if (lx.s.high > ly.s.high)
// return 2;
// if (lx.s.low < ly.s.low)
// return 0;
// else if (lx.s.low > ly.s.low)
// return 2;
// return 1;
// }
.section .text
.align 8
.global ___ucmpsi2
___ucmpsi2:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &___ucmpsi2 = 0 bytes
SUB.0 R1,R3,r15
BLO _L1
=-> SUB.0 R3,R1,r15 \ COPY.1 0,R5
BLO _L1
=-> SUB.0 R0,R2,r15 \ COPY.1 2,R5
BLO _L1
=-> SUB.0 R2,R0,r15 \ COPY.1 0,R5
BLO _L1
=-> COPY.0 2,R5
COPY.0 1,R5
_L1:
JR (R12)
=-> COPY.0 R5,R0 // R0 := R5
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : __ucmpsi2
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#5f# 16#75# 16#63# 16#6d# 16#70# 16#73# 16#69# 16#32# 16#0# // Function name `__ucmpsi2'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,243 @@
// picoChip ASM file
//
// Support for 16-bit unsigned division/modulus.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.global __udivmodhi4
__udivmodhi4:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &__udivmodhi4 = 6 bytes
// 16-bit unsigned division. The divstep function is only capable of
// handling 15-bit division (plus a sign to give 16-bits). It is not
// capable of handling unsigned division directly. Instead, take
// advantage of the special property that
// ((divisor / 2) / dividend) * 2 will be almost good enough. The
// error in the result is only 0 or 1, and this can be easily
// tested and corrected. A full description of the algorithm can
// be found in `Hacker's Delight', by Henry Warren, page 146.
// Input:
// r0 - dividend
// r1 - divisor
// Output:
// r0 - quotient
// r1 - remainder
// Note that the lr, and original inputs are speculatively saved. They
// will only be restored if the 15-bit division function is called.
sub.0 r1,0,r15 \ stl r[0:1],(fp)-1
bge divisorIs15bit
=-> sub.0 r0,r1,r2 \ stw lr,(fp)-3
// The divisor is >= 2^15.
bhs quotientIs1
// The dividend < divisor. The quotient is thus 0, and the
// remainder is the dividend.
copy.0 r0,r1 \ jr (lr)
=-> copy.0 0,r0
quotientIs1:
// The dividend >= divisor. The quotient is thus 1, and the
// remainder can be computed directly by subtraction (i.e., the
// result of the comparison already performed to branch here).
jr (lr) \ copy.0 r2,r1
=-> copy.0 1,r0
divisorIs15bit:
// The divisor is < 2^15.
// Divide the original dividend by 2, and call the 15-bit division.
// Note that the original dividend is stored in r5, which is
// known to be unused by the called function, so that
// a memory stall isn't introduced immediately after the
// function returns, to reload this value from memory.
jl (&__divmod15) \ copy.0 r0,r5 // fn_call &__divmod15
=-> lsr.0 r0,1,r0
// Compute the new quotient and remainder by multiplying them by 2.
// The remainder will be 1 out, if the original dividend was odd.
and.0 r5,1,r5 \ ldl (fp)-1,r[2:3]
add.0 [lsl r1,1],r5,r1 \ lsl.1 r0,1,r0
// The error in the quotient is 0 or 1. The error can be determined
// by comparing the remainder to the original divisor. If the
// remainder is bigger, then an error of 1 has been introduced.
sub.0 r1,r3,r15 \ ldw (fp)-3,lr
blo noCompensation
=-> nop
add.0 r0,1,r0 \ sub.1 r1,r3,r1
noCompensation:
jr (lr)
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : udivmodhi4
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x6 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#75# 16#64# 16#69# 16#76# 16#6d# 16#6f# 16#64# 16#68# 16#69# 16#34# 16#0# // Function name `_udivmodhi4'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,323 @@
// picoChip ASM file
//
// Support for 32-bit unsigned division/modulus.
//
// Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
// Contributed by picoChip Designs Ltd.
// Maintained by Daniel Towner (daniel.towner@picochip.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 into combinations with other programs,
// and to distribute those combinations 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 a combine
// executable.)
//
// 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, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
.section .text
.align 8
.global __udivmodsi4
__udivmodsi4:
_picoMark_FUNCTION_BEGIN=
// picoChip Function Prologue : &__udivmodsi4 = 24 bytes
// Schedule the register saves alongside the special cases, so that
// if the special cases fail, the registers will have already
// been stored onto the stack.
SUB.0 R3,R1,r15 \ STL R[13:12],(FP)-1
BHS skipCommonCase \ STL R[9:8],(FP)-4
=-> SUB.0 R2,1,r15 \ STL R[11:10],(FP)-3
_L2:
// Flags set above, and in _L2 caller.
BNE restOfCode
=-> SUB.0 R3,0,r15
BNE restOfCode
=-> COPY.0 R0,R4 \ COPY.1 R1,R5
JR (R12) // Return to caller
=-> COPY.0 0,R6 \ COPY.1 0,R7
// Never reach here
skipCommonCase:
SUB.0 R3,R1,r15
BNE _L3 // (Reversed branch)
=-> SUB.0 R2,R0,r15 // Must be set in delay slot, so ready by _L9
_L9:
BLO _L2 // (Reversed branch)
=-> SUB.0 R2,1,r15
_L3:
SUB.0 R2,R0,r15
BEQ _L10 // (Reversed branch)
=-> SUB.0 R1,R3,r15 // Set flags for branch at _L10
_L4:
// greater than
COPY.0 0,R4 \ COPY.1 0,R5 \ JR (R12) // Return to caller
=-> COPY.0 R0,R6 \ COPY.1 R1,R7
// Doesn't reach here.
_L10:
// Flags set in _L10 call delay slot.
BNE _L4
=-> COPY.0 1,R4 \ COPY.1 0,R5
JR (R12) // Return to caller
=-> COPY.0 0,R6 \ COPY.1 0,R7
restOfCode:
// Prologue
// Register saves scheduled alongside special cases above.
ADD.0 FP,-20,FP \ STW R14,(FP)-4
// The following can be scheduled together.
// dividend in R[9:8] (from R[1:0])
// divisor in R[7:6] (from R[3:2])
// R14 := clzsi2 (dividend)
// R0 := clzsi2 (divisor)
JL (&__clzsi2) \ COPY.0 R0,R8 \ COPY.1 R1,R9
=-> COPY.0 R2,R6 \ COPY.1 R3,R7
COPY.0 R0,R14 \ JL (&__clzsi2)
=-> COPY.0 R6,R0 \ COPY.1 R7,R1
// R14 := R0 - R14
SUB.0 R0,R14,R14
ADD.0 R14,1,R0 // R0 := R14 + 1 (HI)
// R[11:10] = R[7,6] << R14
SUB.0 15,R14,r15
LSL.0 R6,R14,R11 \ BLT setupDivstepLoop
=-> SUB.0 0,R14,R4 \ COPY.1 0,R10
// Zero shift is a special case. Shifting by zero within a 16-bit
// source object is fine, but don't execute the OR of the right-shift
// into the final result.
LSL.0 R7,R14,R11 \ BEQ setupDivstepLoop
=-> LSL.0 R6,R14,R10
LSR.0 R6,R4,R4
OR.0 R11,R4,R11
setupDivstepLoop:
// R[5:4] := R[9:8] (SI)
COPY.0 R8,R4 \ COPY.1 R9,R5
COPY.0 0,R6 \ COPY.1 R0,R8
// Store original value of loopCount for use after the loop.
// The Subtraction is handled in the tail of the loop iteration
// after this point.
SUB.0 R4,R10,R0 \ COPY.1 R8,R14
// workingResult in R4,5,6
// temps in r0,1,2 and r7
// alignedDivisor in R10,11
// loopCount in r8
// r3, r9 scratch, used for renaming.
loopStart:
// R0 := R4 - zeroExtend (R10) - only need 33-bits (i.e., 48-bits)
SUBB.0 R5,R11,R1 \ LSR.1 R0,15,R3
SUBB.0 R6,0,R2 \ LSR.1 R1,15,R6
// if (carry) goto shiftOnly
SUB.0 R8,1,R8 \ BNE shiftOnly
=-> LSR.0 R4,15,R7 \ LSL.1 R1,1,R9
OR.0 [LSL R0,1],1,R4 \ BNE loopStart
=-> SUB.0 R4,R10,R0 \ OR.1 R9,R3,R5
BRA loopEnd
shiftOnly:
OR.0 [LSL R5,1],R7,R5 \ BNE loopStart \ LSR.1 R5,15,R6
=-> SUB.0 [LSL R4,1],R10,R0 \LSL.1 R4,1,R4
// End of loop
loopEnd:
// Schedule the computation of the upper word after shifting
// alongside the decision over whether to branch, and the register
// restores.
// R10 is filled with a useful constant.
SUB.0 15,r14,r15 \ LDL (FP)4,R[13:12]
SUB.1 0,R14,R1 // Don't set flags!
LSL.0 R6,R1,R3 \ LDL (FP)-4,R[9:8]
BLT remainderHasMoreThan16Bits \ LSR.0 R5,R14,R7 \ COPY.1 -1,R10
=-> LSL.0 R5,R1,R2 \ OR.1 R7,R3,R3
LSR.0 R4,R14,R3 \ COPY.1 R3,R7
BRA epilogue \ LSR.0 -1,R1,R0 \ COPY.1 0,R5
=-> OR.0 R3,R2,R6 \ AND.1 R0,R4,R4
remainderHasMoreThan16Bits:
LSL.0 R10,R14,R1 \ COPY.1 R3,R6
XOR.0 R10,R1,R1 \ COPY.1 0,R7
AND.0 R1,R5,R5
epilogue:
JR (R12) \ LDW (FP)-4,R14
=-> LDL (FP)-3,R[11:10]
_picoMark_FUNCTION_END=
// picoChip Function Epilogue : udivmodsi4
//============================================================================
// All DWARF information between this marker, and the END OF DWARF
// marker should be included in the source file. Search for
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
// provide the relevent information. Add markers called
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
// function in question.
//============================================================================
//============================================================================
// Frame information.
//============================================================================
.section .debug_frame
_picoMark_DebugFrame=
// Common CIE header.
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
_picoMark_CieBegin=
.unalignedInitLong 0xffffffff
.initByte 0x1 // CIE Version
.ascii 16#0# // CIE Augmentation
.uleb128 0x1 // CIE Code Alignment Factor
.sleb128 2 // CIE Data Alignment Factor
.initByte 0xc // CIE RA Column
.initByte 0xc // DW_CFA_def_cfa
.uleb128 0xd
.uleb128 0x0
.align 2
_picoMark_CieEnd=
// FDE
_picoMark_LSFDE0I900821033007563=
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
_picoMark_FdeBegin=
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
.unalignedInitWord _picoMark_FUNCTION_BEGIN // FDE initial location
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x18 // <-- FUNCTION_STACK_SIZE_GOES_HERE
.initByte 0x4 // DW_CFA_advance_loc4
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
.initByte 0xe // DW_CFA_def_cfa_offset
.uleb128 0x0
.align 2
_picoMark_FdeEnd=
//============================================================================
// Abbrevation information.
//============================================================================
.section .debug_abbrev
_picoMark_ABBREVIATIONS=
.section .debug_abbrev
.uleb128 0x1 // (abbrev code)
.uleb128 0x11 // (TAG: DW_TAG_compile_unit)
.initByte 0x1 // DW_children_yes
.uleb128 0x10 // (DW_AT_stmt_list)
.uleb128 0x6 // (DW_FORM_data4)
.uleb128 0x12 // (DW_AT_high_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x11 // (DW_AT_low_pc)
.uleb128 0x1 // (DW_FORM_addr)
.uleb128 0x25 // (DW_AT_producer)
.uleb128 0x8 // (DW_FORM_string)
.uleb128 0x13 // (DW_AT_language)
.uleb128 0x5 // (DW_FORM_data2)
.uleb128 0x3 // (DW_AT_name)
.uleb128 0x8 // (DW_FORM_string)
.initByte 0x0
.initByte 0x0
.uleb128 0x2 ;# (abbrev code)
.uleb128 0x2e ;# (TAG: DW_TAG_subprogram)
.initByte 0x0 ;# DW_children_no
.uleb128 0x3 ;# (DW_AT_name)
.uleb128 0x8 ;# (DW_FORM_string)
.uleb128 0x11 ;# (DW_AT_low_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.uleb128 0x12 ;# (DW_AT_high_pc)
.uleb128 0x1 ;# (DW_FORM_addr)
.initByte 0x0
.initByte 0x0
.initByte 0x0
//============================================================================
// Line information. DwarfLib requires this to be present, but it can
// be empty.
//============================================================================
.section .debug_line
_picoMark_LINES=
//============================================================================
// Debug Information
//============================================================================
.section .debug_info
//Fixed header.
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
_picoMark_DEBUG_INFO_BEGIN=
.unalignedInitWord 0x2
.unalignedInitLong _picoMark_ABBREVIATIONS
.initByte 0x2
// Compile unit information.
.uleb128 0x1 // (DIE 0xb) DW_TAG_compile_unit)
.unalignedInitLong _picoMark_LINES
.unalignedInitWord _picoMark_FUNCTION_END
.unalignedInitWord _picoMark_FUNCTION_BEGIN
// Producer is `picoChip'
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
.unalignedInitWord 0xcafe // ASM language
.ascii 16#0# // Name. DwarfLib expects this to be present.
.uleb128 0x2 ;# (DIE DW_TAG_subprogram)
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
// digit is specified using the format 16#XX#
.ascii 16#5f# 16#75# 16#64# 16#69# 16#76# 16#6d# 16#6f# 16#64# 16#73# 16#69# 16#34# 16#0# // Function name `_udivmodsi4'
.unalignedInitWord _picoMark_FUNCTION_BEGIN // DW_AT_low_pc
.unalignedInitWord _picoMark_FUNCTION_END // DW_AT_high_pc
.initByte 0x0 // end of compile unit children.
_picoMark_DEBUG_INFO_END=
//============================================================================
// END OF DWARF
//============================================================================
.section .endFile
// End of picoChip ASM file

View File

@ -0,0 +1,140 @@
/* Prototypes for exported functions defined in picochip.c
Copyright (C) 2000, 2001, 2008 Free Software Foundation, Inc.
Contributed by picoChip Designs Ltd. (http://www.picochip.com)
Maintained by Daniel Towner (daniel.towner@picochip.com) and
Hariharan Sandanagobalane (hariharan@picochip.com).
This file is part of GCC.
GCC 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 3, or (at your option)
any later version.
GCC 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 GCC; see the file COPYING3. If not, see
<http://www.gnu.org/licenses/>. */
#include "target.h"
extern void picochip_function_prologue (FILE *, HOST_WIDE_INT);
extern void picochip_function_epilogue (FILE *, HOST_WIDE_INT);
extern enum reg_class picochip_reg_class_from_letter (unsigned);
extern int picochip_legitimate_address_p (int, struct rtx_def *, unsigned);
extern int picochip_const_ok_for_letter_p (unsigned HOST_WIDE_INT value, unsigned c);
#ifdef RTX_CODE /* inside TREE_CODE */
extern int picochip_reg_mode_ok_for_base_p (int mode, rtx x, unsigned strict);
extern void picochip_print_operand (FILE * file, rtx op, int letter);
extern void picochip_print_operand_address (FILE * file, rtx operand);
extern const char *picochip_output_cbranch (rtx operands[]);
extern const char *picochip_output_branch (rtx operands[], rtx insn);
extern const char *picochip_output_compare (rtx operands[]);
extern const char *picochip_output_jump (rtx insn);
extern const char *picochip_output_put_array (int alternative,
rtx operands[]);
extern const char *picochip_output_get_array (int alternative,
rtx operands[]);
extern const char *picochip_output_testport_array (int alternative,
rtx operands[]);
extern rtx gen_SImode_mem(rtx opnd1,rtx opnd2);
extern bool ok_to_peephole_stw(rtx opnd0, rtx opnd1, rtx opnd2, rtx opnd3);
extern bool ok_to_peephole_ldw(rtx opnd0, rtx opnd1, rtx opnd2, rtx opnd3);
extern rtx gen_min_reg(rtx opnd1,rtx opnd2);
extern rtx picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
int named);
extern rtx picochip_incoming_function_arg (CUMULATIVE_ARGS, int, tree, int);
extern CUMULATIVE_ARGS picochip_arg_advance (CUMULATIVE_ARGS cum, int mode,
tree type, int named);
extern int picochip_regno_nregs (int regno, int mode);
extern int picochip_class_max_nregs (int class, int mode);
extern void picochip_order_regs_for_local_alloc (void);
extern int picochip_word_aligned_memory_reference (rtx operand);
extern int picochip_alignable_memory_operand (rtx operand, enum machine_mode mode);
extern int picochip_absolute_memory_operand (rtx op, enum machine_mode mode);
extern rtx picochip_function_value (const_tree valtype, const_tree func, bool outgoing);
extern int picochip_symbol_offset (rtx operand);
extern int picochip_get_function_arg_boundary (enum machine_mode mode);
extern enum reg_class picochip_secondary_reload(bool in_p,
rtx x,
enum reg_class cla,
enum machine_mode mode,
secondary_reload_info *sri);
extern void picochip_get_hi_aligned_mem (rtx ref, rtx * paligned_mem, rtx * pbitnum);
extern rtx picochip_get_low_const (rtx value);
extern rtx picochip_get_high_const (rtx value);
extern void picochip_expand_prologue (void);
extern void picochip_expand_epilogue (int is_sibling_call);
extern void picochip_final_prescan_insn (rtx insn, rtx * operand, int num_operands);
extern const char *picochip_asm_output_opcode (FILE * f, const char *ptr);
extern void picochip_override_options (void);
extern int picochip_check_conditional_copy (rtx * operands);
extern rtx picochip_return_addr_rtx(int count, rtx frameaddr);
extern rtx picochip_struct_value_rtx(tree fntype ATTRIBUTE_UNUSED,
int incoming ATTRIBUTE_UNUSED);
#endif /* RTX_CODE inside TREE_CODE */
void picochip_output_ascii (FILE * file, const char *str, int length);
extern int picochip_hard_regno_mode_ok (int regno, enum machine_mode mode);
extern void picochip_generate_internal_label (char *str, const char *prefix,
long num);
extern bool picochip_return_in_memory(const_tree type,
const_tree fntype ATTRIBUTE_UNUSED);
extern int initial_elimination_offset (int from, int to);
extern void picochip_output_aligned_common (FILE * stream, const char *name,
unsigned size, unsigned align);
extern void picochip_output_global (FILE * stream, const char *name);
extern void picochip_output_aligned_local (FILE * stream, const char *name,
unsigned size, unsigned alignment);
extern void picochip_output_label (FILE * stream, const char name[]);
extern void picochip_output_labelref (FILE * stream, const char name[]);
extern void picochip_weaken_label (FILE * stream, const char name[]);
extern void picochip_output_internal_label (FILE * stream, const char *prefix,
unsigned long num);
extern void warn_of_byte_access (void);
/* True if VLIW scheduling is enabled (i.e., second scheduling pass). */
extern int picochip_flag_schedule_insns2;
extern void picochip_asm_output_anchor (rtx symbol);
/* Instruction set capability flags. These are initialised to the
appropriate values by picochip_override_options, once the user has
selected a CPU type. */
extern bool picochip_has_mul_unit;
extern bool picochip_has_mac_unit;

4421
config/picochip/picochip.c Normal file

File diff suppressed because it is too large Load Diff

749
config/picochip/picochip.h Normal file
View File

@ -0,0 +1,749 @@
/* Definitions of target machine for GNU compiler for picoChip
Copyright (C) 2001, 2008 Free Software Foundation, Inc.
Contributed by picoChip Designs Ltd. (http://www.picochip.com)
Maintained by Daniel Towner (daniel.towner@picochip.com) and
Hariharan Sandanagobalane (hariharan@picochip.com).
This file is part of GCC.
GCC 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 3, or (at your option)
any later version.
GCC 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 GCC; see the file COPYING3. If not, see
<http://www.gnu.org/licenses/>. */
/* Which type of DFA scheduling to use - schedule for speed (VLIW), or
schedule for space. When scheduling for space, attempt to schedule
into stall cycles, but don't pack instructions. */
enum picochip_dfa_type
{
DFA_TYPE_NONE,
DFA_TYPE_SPACE,
DFA_TYPE_SPEED
};
extern enum picochip_dfa_type picochip_schedule_type;
/* Controlling the Compilation Driver */
/* Pass through the save-temps command option. */
#define LINK_SPEC " %{save-temps:--save-temps}"
/* This is an embedded processor, and only supports a cut-down version of
* the standard C library. */
#define LIB_SPEC "-lpicoC"
/* The start file is automatically provided by the linker. */
#define STARTFILE_SPEC ""
/* Run-time Target Specification */
/* Define some additional pre-processor macros. */
#define TARGET_CPU_CPP_BUILTINS() \
do \
{ \
builtin_define ("NO_TRAMPOLINES"); \
builtin_define ("PICOCHIP"); \
builtin_define ("__PICOCHIP__"); \
} \
while (0)
/* Translate requests for particular AEs into their respective ISA
options. Note that byte access is enabled by default. */
#define TARGET_OPTION_TRANSLATE_TABLE \
{ "-mae=ANY", "-mmul-type=none -mno-byte-access" }, \
{ "-mae=ANY2", "-mmul-type=none -mno-byte-access" }, \
{ "-mae=ANY3", "-mmul-type=none" }, \
{ "-mae=STAN", "-mmul-type=none -mno-byte-access" }, \
{ "-mae=STAN2", "-mmul-type=mac -mno-byte-access" }, \
{ "-mae=STAN3", "-mmul-type=mac " }, \
{ "-mae=MAC", "-mmul-type=mac -mno-byte-access" }, \
{ "-mae=MUL", "-mmul-type=mul" }, \
{ "-mae=MEM", "-mmul-type=mul" }, \
{ "-mae=MEM2", "-mmul-type=mul" }, \
{ "-mae=CTRL", "-mmul-type=mul" }, \
{ "-mae=CTRL2", "-mmul-type=mul" }
/* Specify the default options, so that the multilib build doesn't
need to provide special cases for the defaults. */
#define MULTILIB_DEFAULTS \
{ "mmul-type=mul", "mbyte-access"}
#define TARGET_HAS_BYTE_ACCESS (picochip_has_byte_access)
#define TARGET_HAS_MUL_UNIT (picochip_has_mul_unit)
#define TARGET_HAS_MAC_UNIT (picochip_has_mac_unit)
#define TARGET_HAS_MULTIPLY (picochip_has_mac_unit || picochip_has_mul_unit)
/* Allow some options to be overriden. In particular, the 2nd
scheduling pass option is switched off, and a machine dependent
reorganisation ensures that it is run later on, after the second
jump optimisation. */
#define OVERRIDE_OPTIONS picochip_override_options()
#define CAN_DEBUG_WITHOUT_FP 1
#define TARGET_VERSION fprintf(stderr, "(picoChip)");
/* Storage Layout */
/* picoChip processors are 16-bit machines, little endian. */
#define BITS_BIG_ENDIAN 0
#define BYTES_BIG_ENDIAN 0
#define WORDS_BIG_ENDIAN 0
#define BITS_PER_UNIT 8
#define BITS_PER_WORD 16
#define UNITS_PER_WORD (BITS_PER_WORD / BITS_PER_UNIT)
#define POINTER_SIZE BITS_PER_WORD
/* Promote those modes that are smaller than an int, to int mode. */
#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
((GET_MODE_CLASS (MODE) == MODE_INT \
&& GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
? (MODE) = HImode : 0)
/* All parameters are at least this aligned. Parameters are passed
one-per-register. */
#define PARM_BOUNDARY BITS_PER_WORD
/* The main stack pointer is guaranteed to be aligned to the most
strict data alignment. */
#define STACK_BOUNDARY 32
/* Function entry point is byte aligned. */
#define FUNCTION_BOUNDARY 8
/* This is the biggest alignment that can be allowed on this machine.
Since the STANs have only 256 byte memory, it doesnt make sense
to have alignments greater than 32 bytes. Hence the value */
#define MAX_OFILE_ALIGNMENT 32*8
/* The strictest data object alignment, which repesents a register pair. */
#define BIGGEST_ALIGNMENT 32
/* The hardware doesn't allow unaligned memory access. */
#define STRICT_ALIGNMENT 1
/* We want the 'unix' style bitfield packing algorithm. */
#define PCC_BITFIELD_TYPE_MATTERS 1
/* Support up to 64-bit integers. */
#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode)
/* We don't support floating point, but give it a sensible definition. */
#define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
/* Layout of Source Language Data Types. */
#define INT_TYPE_SIZE BITS_PER_WORD
/* The normal sizes for C scalar data. */
#define CHAR_TYPE_SIZE 8
#define SHORT_TYPE_SIZE 16
#define LONG_TYPE_SIZE 32
#define LONG_LONG_TYPE_SIZE 64
/* We don't support the following data types, but still give them
sensible values. */
#define FLOAT_TYPE_SIZE 32
#define DOUBLE_TYPE_SIZE 32
#define LONG_DOUBLE_TYPE_SIZE 32
/* Plain `char' is a signed type, since the hardware sign-extends
bytes when loading them from memory into a register. */
#define DEFAULT_SIGNED_CHAR 1
/* Note that the names of the types used in the following macros must
be precisely the same as those defined internally in gcc. For
example, `unsigned short' wouldn't work as a type string, since gcc
doesn't define any type with this exact string. The correct string
to use is `short unsigned int'. */
#define SIZE_TYPE "unsigned int"
#define PTRDIFF_TYPE "int"
#define WCHAR_TYPE "short unsigned int"
#define WCHAR_TYPE_SIZE 16
#define WINT_TYPE "unsigned int"
/* Register Usage */
/* Picochip has 16 16-bit registers, a condition code register and an
(inaccessible) instruction pointer. One of these registers (r15) is
special, and is either used to load a constant anywhere a register
can normally be used, or is used to specify a dummy destination
(e.g., when setting condition flags). We also define some pseudo
registers to represent condition codes, the frame pointer and the
argument pointer. The latter two are eliminated wherever possible.
Pairs of general registers may be combined to form 32-bit registers.
The picoChip registers are as follows:
0..1 - function return value
0..5 - first 6 function parameters
6..11 - General purpose
12 - link register
13 - stack pointer
14 - specialized pointer
15 - long constant or /dev/null
(16) acc0
(17) pseudo condition code
(18) pseudo frame pointer
(19) pseudo arg pointer
Registers 0..6, 12, 13, 14, 15 are caller save
Registers 0..12, 14 are available to the register allocator.
In addition, the DSP variant of the ISA allows extra accumulator
registers to be accessed. These are special purpose registers,
which are not currently used by the compiler.
*/
/* Basic Characteristics of Registers */
/* We have 16 hard registers plus 3 pseudo hard registers and an accumulator. */
#define FIRST_PSEUDO_REGISTER 20
/* The first non-hard register. Only used internally by the picoChip port. */
#define FIRST_NONHARD_REGISTER 18
/* Cannot use SP, CST, CC, FP, AP */
#define FIXED_REGISTERS {0,0,0,0,0,0,0,0, 0,0,0,0,0,1,0,1, 1,1,1,1}
/* Those that are clobbered by a function call (includes pseudo-regs) */
#define CALL_USED_REGISTERS {1,1,1,1,1,1,0,0, 0,0,0,0,1,1,0,1, 1,1,1,1}
#define CALL_REALLY_USED_REGISTERS {1,1,1,1,1,1,0,0, 0,0,0,0,1,1,0,0, 0,1,0,0}
/* Define the number of the picoChip link and condition psuedo registers. */
#define LINK_REGNUM 12
#define CC_REGNUM 17
#define ACC_REGNUM 16
/* Order of Allocation of Registers */
/* The registers are allocated starting with the caller-clobbered
registers, in reverse order. The registers are then listed in an
order which means that they are efficiently saved in pairs (i.e.,
one 32-bit store can be used instead of two 16-bit stores to save
the registers into the stack). The exception to this is the use of
r14 (AP) register, which also appears early on. This is because the
AP register can be used to encode memory operations more
efficiently than other registers. Some code can be made more
compact as a result. */
/* My current feeling is that r14 should go to the end and maybe even r12.
It seems like the overhead of store/load that will occur since we cant
pair anything up with r14 will be higher than the advantage of smaller
encoding.
Also r12 is put towards the end for leaf functions. Since leaf functions
do not have any calls, the prologue/epilogue for them wouldnt save up/
restore its value. So, it doesnt make sense for us to use it in the middle,
if we can avoid it. */
#define REG_ALLOC_ORDER {5,4,3,2,1,0,12,6,7,8,9,10,11,14,16,0,0,0,0,0}
#define LEAF_REG_ALLOC_ORDER {5,4,3,2,1,0,6,7,8,9,10,11,14,12,16,0,0,0,0,0}
/* We can dynamically change the REG_ALLOC_ORDER using the following hook.
It would be desirable to change it for leaf functions so we can put
r12 at the end of this list.*/
#define ORDER_REGS_FOR_LOCAL_ALLOC picochip_order_regs_for_local_alloc ()
/* How Values Fit in Registers */
/* Number of consecutive hard regs needed starting at reg REGNO
to hold something of mode MODE. */
#define HARD_REGNO_NREGS(REGNO, MODE) picochip_regno_nregs((REGNO), (MODE))
/* Is it ok to place MODE in REGNO? Require that the register number
be aligned. */
#define HARD_REGNO_MODE_OK(REGNO, MODE) picochip_hard_regno_mode_ok(REGNO, MODE)
#define MODES_TIEABLE_P(MODE1,MODE2) 1
/* Don't copy the cc register ('cos you can't put it back). */
#define AVOID_CCMODE_COPIES 1
/* Register Classes */
enum reg_class
{
NO_REGS, /* no registers in set */
FRAME_REGS, /* registers with a long offset */
PTR_REGS, /* registers without an offset */
CONST_REGS, /* registers for long constants */
NULL_REGS, /* registers which ignore writes */
CC_REGS, /* condition code registers */
ACC_REGS, /* Accumulator registers */
TWIN_REGS, /* registers which can be paired */
GR_REGS, /* general purpose registers */
ALL_REGS, /* all registers */
LIM_REG_CLASSES, /* max value + 1 */
/* Some aliases */
GENERAL_REGS = GR_REGS
};
#define N_REG_CLASSES (int) LIM_REG_CLASSES
/* The following macro defines cover classes for Integrated Register
Allocator. Cover classes is a set of non-intersected register
classes covering all hard registers used for register allocation
purpose. Any move between two registers of a cover class should be
cheaper than load or store of the registers. The macro value is
array of register classes with LIM_REG_CLASSES used as the end
marker. */
#define IRA_COVER_CLASSES \
{ \
GR_REGS, LIM_REG_CLASSES \
}
/* The names of the register classes */
#define REG_CLASS_NAMES \
{ \
"NO_REGS", \
"FRAME_REGS", \
"PTR_REGS", \
"CONST_REGS", \
"NULL_REGS", \
"CC_REGS", \
"ACC_REGS", \
"TWIN_REGS", \
"GR_REGS", \
"ALL_REGS" \
}
/* Each reg class is an array of 32-bit integers. Each array must be
long enough to store one bit for every pseudo register. Thus in the
following code, each array only stores one 32-bit value. */
#define REG_CLASS_CONTENTS \
{ \
{0x00000000}, /* no registers */ \
{0x00002000}, /* frame */ \
{0x00004000}, /* pointer */ \
{0x00008000}, /* const */ \
{0x00008000}, /* null */ \
{0x00020000}, /* cc */ \
{0x00010000}, /* acc0 */ \
{0x00000FFF}, /* twin */ \
{0x000CFFFF}, /* general registers - includes pseudo-arg */ \
{0x000FFFFF} /* all registers - includes pseudo-arg */ \
}
/* The earliest register class containing the given register. */
extern const enum reg_class picochip_regno_reg_class[FIRST_PSEUDO_REGISTER];
#define REGNO_REG_CLASS(REGNO) picochip_regno_reg_class[REGNO]
/* Any register can be a base pointer. */
#define BASE_REG_CLASS GR_REGS
/* Any register can be an index. */
#define INDEX_REG_CLASS GR_REGS
#define REGNO_OK_FOR_BASE_P(REGNO) \
(REGNO_REG_CLASS (REGNO) != CC_REGS && REGNO_REG_CLASS (REGNO) != ACC_REGS)
#define REGNO_OK_FOR_INDEX_P(REGNO) 0
#define PREFERRED_RELOAD_CLASS(X, CLASS) CLASS
#define CLASS_MAX_NREGS(CLASS, MODE) picochip_class_max_nregs(CLASS, MODE)
/* Stack Layout and Calling Conventions */
#define STACK_GROWS_DOWNWARD 1
/* The frame pointer points to the outgoing argument area, so the
locals are above that. */
#define STARTING_FRAME_OFFSET 0
#define FIRST_PARM_OFFSET(FNDECL) 0
/* Specify where the return address lives before entry to the
prologue. This is required to enable DWARF debug information to be
generated. */
#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LINK_REGNUM)
#define RETURN_ADDR_RTX(count,frameaddr) picochip_return_addr_rtx(count,frameaddr)
#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LINK_REGNUM)
/* Registers that Address the Stack Frame */
#define STACK_POINTER_REGNUM 13
#define FRAME_POINTER_REGNUM 18
#define ARG_POINTER_REGNUM 19
/* Static chain is used to pass the local variables of the enclosing function.
The static chain is passed in memory. The first long-word location
beneath the stack pointer is used. In the presence of pretend
arguments, which are written into that location, this mechanism
complicates matters. */
/* Location seen by the caller. */
#define STATIC_CHAIN \
gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx, -2 * UNITS_PER_WORD))
/* Location seen by the callee. */
#define STATIC_CHAIN_INCOMING \
gen_rtx_MEM (Pmode, plus_constant (arg_pointer_rtx, 0))
/* Eliminating Frame Pointer and Arg Pointer. The frame and argument
pointers are eliminated wherever possible, by replacing them with
offsets from the stack pointer. */
/* We want to get rid of the frame pointer. */
#define FRAME_POINTER_REQUIRED 0
#define ELIMINABLE_REGS \
{{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
#define CAN_ELIMINATE(FROM, TO) 1
#define INITIAL_ELIMINATION_OFFSET(FROM,TO,OFFSET) \
OFFSET = initial_elimination_offset(FROM, TO);
#define ACCUMULATE_OUTGOING_ARGS 1
#define PUSH_ARGS 0
/* Functions don't pop their args. */
#define RETURN_POPS_ARGS(FNDECL, FNTYPE, STACK) 0
/* Passing Arguments in Registers */
/* Store the offset of the next argument. */
#define CUMULATIVE_ARGS unsigned
/* Decide how function arguments are handled. */
#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
picochip_function_arg (CUM, MODE, TYPE, NAMED)
/* Incoming arguments are always the same as normal arguments, except
for a function which uses variadic arguments, in which case all
arguments are effectively passed on the stack. */
#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
picochip_incoming_function_arg(CUM, MODE, TYPE, NAMED)
#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
((CUM) = 0)
#define FUNCTION_ARG_ADVANCE(CUM,MODE,TYPE,NAMED) \
(CUM) = picochip_arg_advance (CUM, MODE, TYPE, NAMED)
/* Originally this used TYPE_ALIGN to determine the
alignment. Unfortunately, this fails in some cases, because the
type is unknown (e.g., libcall's). Instead, use GET_MODE_ALIGNMENT
since the mode is always present. */
#define FUNCTION_ARG_BOUNDARY(MODE,TYPE) \
picochip_get_function_arg_boundary(MODE)
/* The first 6 registers can hold parameters. */
#define FUNCTION_ARG_REGNO_P(REGNO) ((REGNO) < 6)
/* How Scalar Function Values are Returned
Do we need this?? */
#define FUNCTION_VALUE(VALTYPE,FUNC) picochip_function_value(VALTYPE, FUNC, 0)
#define LIBCALL_VALUE(MODE) (gen_rtx_REG (MODE, 0))
/* Results are in register zero. If an SImode register is returned,
reg0 will suffice to mean R[0:1]. */
#define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == 0)
/* Don't automatically pass struct's in memory - use the
* RETURN_IN_MEMORY macro to determine when structs are returned in
* memory, and when in registers. */
#define DEFAULT_PCC_STRUCT_RETURN 0
/* Function Entry and Exit */
/* The epilogue doesn't clobber anything. */
#define EPILOGUE_USES(REGNO) 0
/* Generating Code for Profiling. No profiling implemented */
#define FUNCTION_PROFILER(FILE,LABELNO)
/* Trampolines for Nested Functions */
/* No trampolines. */
#define TRAMPOLINE_SIZE 0
#define INITIALIZE_TRAMPOLINE(ADDR,FNADDR,CHAIN)
/* Addressing Modes */
#define CONSTANT_ADDRESS_P(X) CONSTANT_P(X)
#define MAX_REGS_PER_ADDRESS 1
#ifdef REG_OK_STRICT
#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
if (picochip_legitimate_address_p (MODE, X, 1)) goto LABEL;
#else /* REG_OK_STRICT */
#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
if (picochip_legitimate_address_p (MODE, X, 0)) goto LABEL;
#endif /* !REG_OK_STRICT */
/* extern struct rtx_def *picochip_legitimize_address */
/* PARAMS ((struct rtx_def *, struct rtx_def *, int)); */
#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN);
/* Legitimize reload address tries machine dependent means of
reloading addresses. There seems to be a strange error in gcc,
which necessitates this macro. Consider:
set (reg A) (symbol_ref)
set (reg B) (plus (reg A) (const_int))
A symbol_ref is a valid constant, so the symbol_ref is propagated
into the second instruction to generate the instruction:
set (reg B) (plus (symbol_ref) (const_int))
This is an invalid address, and find_reloads_address correctly
determines this. However, that function doesn't generate a valid
replacement for the now invalid address, and the invalid address is
output into the assembly language. To fix the problem without
changing gcc itself, the following macro tests when such an invalid
address has been computed, and wraps it up inside a constant rtx. A
constant rtx can be correctly reloaded by the function, and hence
correct code is generated. */
#define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
if (picochip_symbol_offset(X)) { X = gen_rtx_CONST(MODE, X); }
/* There are no mode dependent addresses. */
#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) do {} while (0)
/* Nonzero if the constant rtx X is a legitimate general operand. X
satisfies CONSTANT_P. */
#define LEGITIMATE_CONSTANT_P(X) 1
/* Condition Code Status */
#define CC_STATUS_MDEP unsigned
#define CC_STATUS_MDEP_INIT (cc_status.mdep = 0)
/* Describing Relative Costs of Operations */
/* Bytes are no faster than words. */
#define SLOW_BYTE_ACCESS 1
/* The assembler is often able to optimise function call branches, so
don't try to CSE them in the compiler. This was the thinking before.
But now, we realise that the benefits from CSE would mostly outweigh
the disadvantages. */
#define NO_FUNCTION_CSE
/* Dividing the Output into Sections */
#define TEXT_SECTION_ASM_OP ".section .text\n"
#define DATA_SECTION_ASM_OP ".section .data\n"
#define BSS_SECTION_ASM_OP ".section .bss\n"
/* picoChip is Harvard (separate data/instruction memories), so
read-only data must go into the data section. */
#define READONLY_DATA_SECTION_ASM_OP ".section .data\n"
/* Defining the Output Assembler Language */
/* The Overall Framework of an Assembler File */
#define ASM_FILE_COMMENT "// "
#define ASM_APP_ON "// High-level ASM start\n"
#define ASM_APP_OFF "// High-level ASM end\n"
#define ASM_OUTPUT_IDENT(STREAM,STRING) fprintf(STREAM, ".ident %s\n", STRING)
/* Output of Data */
#define ASM_OUTPUT_ASCII(FILE, PTR, LEN) picochip_output_ascii(FILE, PTR, LEN);
/* Output of Uninitialized Variables */
#define ASM_OUTPUT_ALIGNED_COMMON(FILE,NAME,SIZE,ALIGN) \
picochip_output_aligned_common(FILE, NAME, SIZE, ALIGN)
#define ASM_OUTPUT_ALIGNED_LOCAL(FILE,NAME,SIZE,ALIGN) \
picochip_output_aligned_local(FILE, NAME, SIZE, ALIGN)
/* Output and Generation of Labels */
#define ASM_OUTPUT_LABEL(STREAM,NAME) \
do { picochip_output_label(STREAM, NAME); } while (0);
#define ASM_OUTPUT_LABELREF(STREAM, NAME) \
{ picochip_output_labelref(STREAM, NAME); }
/* Format must match that of picochip_output_label. */
#define ASM_GENERATE_INTERNAL_LABEL(STRING,PREFIX,NUM) \
picochip_generate_internal_label(STRING,PREFIX,(long)NUM)
#define ASM_WEAKEN_LABEL(STREAM,NAME) picochip_weaken_label(STREAM,NAME);
/* Store in OUTPUT a string (made with alloca) containing an
assembler-name for a local static variable named NAME. LABELNO is
an integer which is different for each call. The assembler can't
use periods to generate the name, so we use a ___ separator
instead. */
#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 15), \
sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
/* Macros Controlling Initialization Routines */
/* By defining this, the main function won't try to call `__main'. */
#define HAS_INIT_SECTION
/* Output of Assembler Instructions */
#define REGISTER_NAMES \
{"R0", "R1", "R2", "R3", \
"R4", "R5", "R6", "R7", \
"R8", "R9", "R10", "R11", \
"R12", "FP", "R14", "R15", \
"acc0", "pseudoCC", "pseudoFP", "pseudoAP"}
#define ADDITIONAL_REGISTER_NAMES \
{ \
{ "R0", 0}, \
{ "R1", 1}, \
{ "R2", 2}, \
{ "R3", 3}, \
{ "R4", 4}, \
{ "R5", 5}, \
{ "R6", 6}, \
{ "R7", 7}, \
{ "R8", 8}, \
{ "R9", 9}, \
{ "R10", 10}, \
{ "R11", 11}, \
{ "R12", 12}, \
{ "FP", 13}, \
{ "R14", 14}, \
{ "R15", 15}, \
{ "acc0", 16}, \
{ "sp", 12}, /* ABI stack pointer */ \
{ "ln", 13}, /* arch link register */ \
{ "ptr", 14}, /* arch constant pointer */ \
{ "rc", 15}, /* arch constant register */ \
{ "rz", 15}, /* arch zero */ \
}
/* Final prescan insn is called just before an instruction is
output. In our case, we use this to detect the VLIW slot to which
the instruction has been assigned, preparatory to generating the
VLIW output in ASM_OUTPUT_OPCODE. */
#define FINAL_PRESCAN_INSN(insn, operand, nop) \
picochip_final_prescan_insn (insn, operand,nop)
#define ASM_OUTPUT_OPCODE(FILE,PTR) \
{ PTR = picochip_asm_output_opcode(FILE, PTR); }
#define PRINT_OPERAND(STREAM,X,CODE) \
picochip_print_operand(STREAM, X, CODE)
#define PRINT_OPERAND_PUNCT_VALID_P(code) \
(((code) == '|') || ((code) == '#') || ((code) == '>'))
#define PRINT_OPERAND_ADDRESS(STREAM,X) \
picochip_print_operand_address(STREAM,X)
/* Output of Dispatch Tables */
/* Initialise a data memory location to an absolute code label. Used
for building switch statement jump tables. Note - the format of the
label must match that of the function picochip_output_label. */
#define ASM_OUTPUT_ADDR_VEC_ELT(stream, value) \
fprintf (stream, ".initWord _L%d\n", value);
/* Assembler Commands for Alignment */
#define ASM_OUTPUT_SKIP(STREAM,BYTES) \
fprintf(STREAM, ".skip %u\n", BYTES);
#define ASM_OUTPUT_ALIGN(STREAM,POWER) \
fprintf(STREAM, ".align %u\n", 1 << POWER);
/* The elaborator doesn't output zero bytes in the text section. */
#define ASM_NO_SKIP_IN_TEXT 1
/* Controlling Debugging Information Format */
/* Macros Affecting All Debugging Formats */
#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
#define DWARF2_DEBUGGING_INFO
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
#define DWARF2_FRAME_INFO 1
/* Generate .file/.loc directives, so that the assembler generates the
line table. */
#define DWARF2_ASM_LINE_DEBUG_INFO 1
/* Miscellaneous Parameters */
#define CASE_VECTOR_MODE HImode
#define WORD_REGISTER_OPERATIONS
#define LOAD_EXTEND_OP(MODE) ((MODE) == QImode ? SIGN_EXTEND : ZERO_EXTEND)
#define MOVE_MAX 4
#define SHIFT_COUNT_TRUNCATED 1
#define Pmode HImode
#define FUNCTION_MODE QImode
#define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
#define ASM_LONG ":TODO:.word\t"
/* Define builtins for selected special-purpose instructions. */
enum picochip_builtins
{
PICOCHIP_BUILTIN_SBC,
PICOCHIP_BUILTIN_PUT,
PICOCHIP_BUILTIN_GET,
PICOCHIP_BUILTIN_TESTPORT,
PICOCHIP_BUILTIN_COPYSW,
PICOCHIP_BUILTIN_ADDS,
PICOCHIP_BUILTIN_SUBS,
PICOCHIP_BUILTIN_BREV,
PICOCHIP_BUILTIN_BYTESWAP,
PICOCHIP_BUILTIN_GET_ARRAY,
PICOCHIP_BUILTIN_PUT_ARRAY,
PICOCHIP_BUILTIN_TESTPORT_ARRAY,
PICOCHIP_BUILTIN_ASRI,
PICOCHIP_BUILTIN_PROFILE,
PICOCHIP_BUILTIN_HALT
};
#define NO_DOT_IN_LABEL 1
/* The assembler does support LEB128, despite the auto-configure test
not detecting this. */
#define HAVE_AS_LEB128 1
/* The End */

2699
config/picochip/picochip.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
; Options for the picoChip port of the compiler.
; Copyright (C) 2008 Free Software Foundation, Inc.
;
; This file is part of GCC.
;
; GCC 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 3, or (at your option) any later
; version.
;
; GCC 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 GCC; see the file COPYING3. If not, see
; <http://www.gnu.org/licenses/>.
mae=
Target RejectNegative Joined Var(picochip_ae_type_string)
Specify which type of AE to target. This option sets the mul-type
and byte-access.
mmul-type=
Target RejectNegative Undocumented Joined Var(picochip_mul_type_string)
Specify which type of multiplication to use. Can be mem, mac or none.
mbyte-access
Target Undocumented Var(picochip_has_byte_access,1) Init(1)
Specify whether the byte access instructions should be used. Enabled by default.
mdebug
Target RejectNegative Undocumented Mask(DEBUG)
Enable debug output to be generated.
msymbol-as-address
Target Mask(SYMBOL_AS_ADDRESS)
Allow a symbol value to be used as an immediate value in an
instruction.
minefficient-warnings
Target Mask(INEFFICIENT_WARNINGS)
Generate warnings when inefficient code is known to be generated.
minefficient
Target Mask(INEFFICIENT_WARNINGS) MaskExists Undocumented

View File

@ -0,0 +1,72 @@
;; GCC machine description for picochip
;; Copyright (C) 2008 Free Software Foundation, Inc.
;; Contributed by picoChip Designs Ltd (http://www.picochip.com)
;; Maintained by Daniel Towner (dant@picochip.com) and Hariharan
;; Sandanagobalane (hariharan@picochip.com)
;;
;; This file is part of GCC.
;;
;; GCC 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 3, or (at your option)
;; any later version.
;;
;; GCC 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 GCC; see the file COPYING3. If not, see
;; <http://www.gnu.org/licenses/>.
(define_predicate "picochip_register_or_immediate_operand"
(ior (match_operand 0 "register_operand")
(match_operand 0 "immediate_operand")))
(define_predicate "power_of_2_imm_operand"
(match_code "const_int")
{
if (GET_CODE (op) == CONST_INT)
{
if (exact_log2 (INTVAL (op)) <= 16 && exact_log2 (INTVAL (op)) > 0)
return 1;
}
return 0;
})
;; Limit the comparison operators to a selected subset.
(define_predicate "picochip_supported_comparison_operator"
(and (match_operand 0 "comparison_operator")
(match_code "ne,eq,ge,geu,lt,ltu")))
(define_predicate "picochip_peephole_comparison_operator"
(and (match_operand 0 "comparison_operator")
(match_code "ne,eq")))
;; Allow selected arithmetic operators to apply a shift to their first
;; operands
(define_predicate "picochip_first_op_shift_operator"
(match_code "and,plus,minus,ior,xor"))
;; The same as the previous predicate, but only allowing those
;; operators which can accept an immediate.
(define_predicate "picochip_first_op_shift_operator_imm"
(match_code "plus,minus"))
;; Predicate on a J type integer.
(define_predicate "picochip_J_operand"
(match_operand 0 "immediate_operand")
{
return (CONST_INT == GET_CODE(op) &&
picochip_const_ok_for_letter_p (INTVAL(op), 'J'));
})
;; Is the operand suitable for use in a compare?
(define_predicate "picochip_comparison_operand"
(ior (match_operand 0 "register_operand")
(and (match_operand 0 "immediate_operand")
(match_test "picochip_const_ok_for_letter_p(INTVAL(op), 'O')"))))

View File

@ -0,0 +1,62 @@
# Compile the extra library functions.
LIB2FUNCS_EXTRA = \
$(srcdir)/config/picochip/libgccExtras/ashrsi3.asm \
$(srcdir)/config/picochip/libgccExtras/ashlsi3.asm \
$(srcdir)/config/picochip/libgccExtras/divmodhi4.asm \
$(srcdir)/config/picochip/libgccExtras/udivmodhi4.asm \
$(srcdir)/config/picochip/libgccExtras/divmodsi4.asm \
$(srcdir)/config/picochip/libgccExtras/udivmodsi4.asm \
$(srcdir)/config/picochip/libgccExtras/divmod15.asm \
$(srcdir)/config/picochip/libgccExtras/ucmpsi2.asm \
$(srcdir)/config/picochip/libgccExtras/cmpsi2.asm \
$(srcdir)/config/picochip/libgccExtras/clzsi2.asm \
$(srcdir)/config/picochip/libgccExtras/adddi3.asm \
$(srcdir)/config/picochip/libgccExtras/subdi3.asm \
$(srcdir)/config/picochip/libgccExtras/lshrsi3.asm \
$(srcdir)/config/picochip/libgccExtras/parityhi2.asm \
$(srcdir)/config/picochip/libgccExtras/popcounthi2.asm
# Prevent some of the more complicated libgcc functions from being
# compiled. This is because they are generally too big to fit into an
# AE anyway, so there is no point in having them. Also, some don't
# compile properly so we'll ignore them for the moment.
LIB1ASMFUNCS = _mulsc3 _divsc3
LIB1ASMSRC = picochip/libgccExtras/fake_libgcc.asm
# Turn off the building of exception handling libraries.
LIB2ADDEH =
LIB2ADDEHDEP =
# Turn off ranlib on target libraries.
RANLIB_FOR_TARGET = cat
# Special libgcc setup. Make single/double floating point the same,
# and use our own include files.
TARGET_LIBGCC2_CFLAGS = -DDF=SF -I../../includes/
# Switch off all debugging for the embedded libraries.
# (embedded processors need small libraries by default).
# NOTE: If the debug level is increased, turn off instruction scheduling.
LIBGCC2_DEBUG_CFLAGS = -g0
# Build all combinations of library for different multiply units, and
# presence/absence of byte access.
MULTILIB_OPTIONS = mmul-type=none/mmul-type=mac/mmul-type=mul mno-byte-access/mbyte-access
# Using a mul unit (currently) implies that byte access is available.
MULTILIB_EXCEPTIONS = mmul-type=mul/mno-byte-access
# We want fine grained libraries, so use the new code
# to build the floating point emulation libraries.
FPBIT = fp-bit.c
# Software floating point support. Floating point is not properly
# supported, but is existence can be useful for some types of testing.
fp-bit.c: $(srcdir)/config/fp-bit.c
echo '#define FLOAT' > fp-bit.c
echo '#define FLOAT_ONLY' >> fp-bit.c
echo '#define SMALL_MACHINE' >> fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c

View File

@ -1,3 +1,13 @@
2008-09-03 Hari Sandanagobalane <hariharan@picochip.com>
Add picoChip port.
* doc/extend.texi: Document picoChip builtin functions.
* doc/invoke.texi: Document picoChip options.
* doc/contrib.texi: Add picoChip contribution.
* doc/md.texi: Document picoChip constraints.
* config.gcc: Add picochip-*-*.
* config/picochip/: Add new port.
2008-09-03 Richard Guenther <rguenther@suse.de>
PR tree-optimization/37328

View File

@ -329,6 +329,9 @@ mips*-*-*)
need_64bit_hwint=yes
extra_headers="loongson.h"
;;
picochip-*-*)
cpu_type=picochip
;;
powerpc*-*-*)
cpu_type=rs6000
extra_headers="ppc-asm.h altivec.h spe.h ppu_intrinsics.h paired.h spu2vmx.h vec_types.h si2vmx.h"
@ -1707,6 +1710,9 @@ pdp11-*-bsd)
;;
pdp11-*-*)
;;
picochip-*)
# Nothing special
;;
# port not yet contributed
#powerpc-*-openbsd*)
# tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-fprules-fpbit "

View File

@ -917,6 +917,10 @@ Teemu Torma for thread safe exception handling support.
Leonard Tower wrote parts of the parser, RTL generator, and RTL
definitions, and of the VAX machine description.
@item
Daniel Towner and Hariharan Sandanagobalane contributed and
maintain the picoChip port.
@item
Tom Tromey for internationalization support and for his many Java
contributions and libgcj maintainership.

View File

@ -6985,6 +6985,7 @@ instructions, but allow the compiler to schedule those calls.
* MIPS DSP Built-in Functions::
* MIPS Paired-Single Support::
* MIPS Loongson Built-in Functions::
* picoChip Built-in Functions::
* PowerPC AltiVec Built-in Functions::
* SPARC VIS Built-in Functions::
* SPU Built-in Functions::
@ -9403,6 +9404,42 @@ else
@end smallexample
@end table
@node picoChip Built-in Functions
@subsection picoChip Built-in Functions
GCC provides an interface to selected machine instructions from the
picoChip instruction set.
@table @code
@item int __builtin_sbc (int @var{value})
Sign bit count. Return the number of consecutive bits in @var{value}
which have the same value as the sign-bit. The result is the number of
leading sign bits minus one, giving the number of redundant sign bits in
@var{value}.
@item int __builtin_byteswap (int @var{value})
Byte swap. Return the result of swapping the upper and lower bytes of
@var{value}.
@item int __builtin_brev (int @var{value})
Bit reversal. Return the result of reversing the bits in
@var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
and so on.
@item int __builtin_adds (int @var{x}, int @var{y})
Saturating addition. Return the result of adding @var{x} and @var{y},
storing the value 32767 if the result overflows.
@item int __builtin_subs (int @var{x}, int @var{y})
Saturating subtraction. Return the result of subtracting @var{y} from
@var{x}, storing the value -32768 if the result overflows.
@item void __builtin_halt (void)
Halt. The processor will stop execution. This built-in is useful for
implementing assertions.
@end table
@node PowerPC AltiVec Built-in Functions
@subsection PowerPC AltiVec Built-in Functions

View File

@ -691,6 +691,10 @@ Objective-C and Objective-C++ Dialects}.
-mbranch-expensive -mbranch-cheap @gol
-msplit -mno-split -munix-asm -mdec-asm}
@emph{picoChip Options}
@gccoptlist{-mae=@var{ae_type} -mvliw-lookahead=@var{N}
-msymbol-as-address -mno-inefficient-warnings}
@emph{PowerPC Options}
See RS/6000 and PowerPC Options.
@ -8603,6 +8607,7 @@ platform.
* MMIX Options::
* MN10300 Options::
* PDP-11 Options::
* picoChip Options::
* PowerPC Options::
* RS/6000 and PowerPC Options::
* S/390 and zSeries Options::
@ -13095,6 +13100,54 @@ Use DEC assembler syntax. This is the default when configured for any
PDP-11 target other than @samp{pdp11-*-bsd}.
@end table
@node picoChip Options
@subsection picoChip Options
@cindex picoChip options
These @samp{-m} options are defined for picoChip implementations:
@table @gcctabopt
@item -mae=@var{ae_type}
@opindex mcpu
Set the instruction set, register set, and instruction scheduling
parameters for array element type @var{ae_type}. Supported values
for @var{ae_type} are @samp{ANY}, @samp{MUL}, and @samp{MAC}.
@option{-mae=ANY} selects a completely generic AE type. Code
generated with this option will run on any of the other AE types. The
code will not be as efficient as it would be if compiled for a specific
AE type, and some types of operation (e.g., multiplication) will not
work properly on all types of AE.
@option{-mae=MUL} selects a MUL AE type. This is the most useful AE type
for compiled code, and is the default.
@option{-mae=MAC} selects a DSP-style MAC AE. Code compiled with this
option may suffer from poor performance of byte (char) manipulation,
since the DSP AE does not provide hardware support for byte load/stores.
@item -msymbol-as-address
Enable the compiler to directly use a symbol name as an address in a
load/store instruction, without first loading it into a
register. Typically, the use of this option will generate larger
programs, which run faster than when the option isn't used. However, the
results vary from program to program, so it is left as a user option,
rather than being permanently enabled.
@item -mno-inefficient-warnings
Disables warnings about the generation of inefficient code. These
warnings can be generated, for example, when compiling code which
performs byte-level memory operations on the MAC AE type. The MAC AE has
no hardware support for byte-level memory operations, so all byte
load/stores must be synthesised from word load/store operations. This is
inefficient and a warning will be generated indicating to the programmer
that they should rewrite the code to avoid byte operations, or to target
an AE type which has the necessary hardware support. This option enables
the warning to be turned off.
@end table
@node PowerPC Options
@subsection PowerPC Options
@cindex PowerPC options

View File

@ -1855,6 +1855,46 @@ A memory operand for floating-point loads and stores
A register indirect memory operand
@end table
@item picoChip family---@file{picochip.h}
@table @code
@item k
Stack register.
@item f
Pointer register. A register which can be used to access memory without
supplying an offset. Any other register can be used to access memory,
but will need a constant offset. In the case of the offset being zero,
it is more efficient to use a pointer register, since this reduces code
size.
@item t
A twin register. A register which may be paired with an adjacent
register to create a 32-bit register.
@item a
Any absolute memory address (e.g., symbolic constant, symbolic
constant + offset).
@item I
4-bit signed integer.
@item J
4-bit unsigned integer.
@item K
8-bit signed integer.
@item M
Any constant whose absolute value is no greater than 4-bits.
@item N
10-bit signed integer
@item O
16-bit signed integer.
@end table
@item PowerPC and IBM RS6000---@file{config/rs6000/rs6000.h}
@table @code
@item b

View File

@ -1,3 +1,8 @@
2008-09-03 Hari Sandanagobalane <hariharan@picochip.com>
Add picoChip port.
* config.host: Add picochip-*-*.
2008-08-06 Bob Wilson <bob.wilson@acm.org>
* config.host: Match more processor names for Xtensa.

View File

@ -428,6 +428,8 @@ pdp11-*-bsd)
;;
pdp11-*-*)
;;
picochip-*-*)
;;
powerpc64-*-linux*)
tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ldbl128"
;;