├── .gitignore ├── .travis.yml ├── LICENSE ├── README.rst ├── arm ├── .gitignore ├── README.rst ├── arm-sim.py ├── asm_test.py ├── asm_tests │ ├── adc-00.S │ ├── adc-01.S │ ├── adc-02.S │ ├── adc-03.S │ ├── add-00.S │ ├── add-01.S │ ├── add-02.S │ ├── arm-macros.h │ ├── build.py │ ├── cmp-00.S │ ├── cmp-01.S │ ├── cmp-02.S │ ├── cmp-03.S │ ├── cmp-04.S │ ├── cmp-05.S │ ├── cmp-06.S │ ├── cmp-07.S │ ├── cmp-08.S │ ├── cmp-09.S │ ├── cmp-10.S │ ├── cmp-11.S │ ├── cmp-12.S │ ├── cmp-13.S │ ├── cmp-14.S │ ├── eor-00.S │ ├── eor-01.S │ ├── eor-02.S │ ├── eor-03.S │ ├── eor-04.S │ ├── eor-05.S │ ├── ldm-00.S │ ├── ldm-01.S │ ├── ldm-02.S │ ├── ldm-03.S │ ├── ldr-00.S │ ├── ldr-01.S │ ├── ldr-02.S │ ├── ldr-03.S │ ├── ldrb-00.S │ ├── ldrbcs-00.S │ ├── ldrbcs-01.S │ ├── ldrbeq-00.S │ ├── ldrbne-00.S │ ├── ldrh-00.S │ ├── ldrhi-00.S │ ├── ldrls-00.S │ ├── ldrne-00.S │ ├── mla-00.S │ ├── mov-00.S │ ├── mov-01.S │ ├── mov-02.S │ ├── mov-03.S │ ├── mov-04.S │ ├── mov-05.S │ ├── mov-06.S │ ├── mov-07.S │ ├── movcc-00.S │ ├── movcc-01.S │ ├── movcs-00.S │ ├── movcs-01.S │ ├── moveq-00.S │ ├── moveq-01.S │ ├── movgt-00.S │ ├── movgt-01.S │ ├── movhi-00.S │ ├── movls-00.S │ ├── movls-01.S │ ├── movne-00.S │ ├── movne-01.S │ ├── mul-00.S │ ├── mul-01.S │ ├── mvn-00.S │ ├── mvn-01.S │ ├── mvneq-00.S │ ├── mvnne-00.S │ ├── orr-00.S │ ├── orr-01.S │ ├── orr-02.S │ ├── orreq-00.S │ ├── orreq-01.S │ ├── orrgt-00.S │ ├── orrgt-01.S │ ├── orrhi-00.S │ ├── orrhi-01.S │ ├── orrne-00.S │ ├── orrne-01.S │ ├── rsb-00.S │ ├── rsb-01.S │ ├── rsb-02.S │ ├── rsbeq-00.S │ ├── rsble-00.S │ ├── rsble-01.S │ ├── rsbne-00.S │ ├── smull-00.S │ ├── smull-01.S │ ├── smull-02.S │ ├── smull-03.S │ ├── smull-04.S │ ├── stm-00.S │ ├── stm-01.S │ ├── str-00.S │ ├── strb-00.S │ ├── strb-01.S │ ├── strbcc-00.S │ ├── strbcs-00.S │ ├── strbne-00.S │ ├── strcc-00.S │ ├── streq-00.S │ ├── strhi-00.S │ ├── strls-00.S │ ├── strne-00.S │ ├── sub-00.S │ ├── sub-01.S │ ├── sub-02.S │ ├── subeq-00.S │ ├── subeq-01.S │ ├── sublt-00.S │ ├── sublt-01.S │ ├── teq-00.S │ ├── teq-01.S │ ├── teq-02.S │ ├── tst-00.S │ ├── tst-01.S │ ├── tst-02.S │ ├── tst-03.S │ ├── tst-04.S │ ├── tstne-00.S │ ├── tstne-01.S │ ├── umlal-00.S │ ├── umlal-01.S │ ├── umlal-02.S │ ├── umlal-03.S │ ├── umull-00.S │ ├── umull-01.S │ └── umull-02.S ├── bootstrap.py ├── instruction.py ├── isa.py ├── machine.py ├── syscalls.py ├── ubmark_test.py └── utils.py ├── benchmarks.rst ├── docs ├── RPython.rst ├── pydgin_logo.png ├── pydgin_logo.svg └── related_work.rst ├── parc ├── .gitignore ├── README.rst ├── asm_test.py ├── asm_tests │ ├── .gitignore │ ├── Makefile.in │ ├── README.rst │ ├── aclocal.m4 │ ├── config.h.in │ ├── configure │ ├── configure.ac │ ├── mt │ │ ├── mt-addiu.S │ │ ├── mt-addu.S │ │ ├── mt-amo-add.S │ │ ├── mt-amo-and.S │ │ ├── mt-amo-min.S │ │ ├── mt-amo-or.S │ │ ├── mt-amo-xchg.S │ │ ├── mt-and.S │ │ ├── mt-andi.S │ │ ├── mt-beq.S │ │ ├── mt-bgez.S │ │ ├── mt-bgtz.S │ │ ├── mt-blez.S │ │ ├── mt-bltz.S │ │ ├── mt-bne.S │ │ ├── mt-div.S │ │ ├── mt-divu.S │ │ ├── mt-j.S │ │ ├── mt-jal.S │ │ ├── mt-jalr.S │ │ ├── mt-jr.S │ │ ├── mt-lb.S │ │ ├── mt-lbu.S │ │ ├── mt-lh.S │ │ ├── mt-lhu.S │ │ ├── mt-lui.S │ │ ├── mt-lw.S │ │ ├── mt-macros.h │ │ ├── mt-movn.S │ │ ├── mt-movz.S │ │ ├── mt-mul.S │ │ ├── mt-nor.S │ │ ├── mt-or.S │ │ ├── mt-ori.S │ │ ├── mt-rem.S │ │ ├── mt-remu.S │ │ ├── mt-simple.S │ │ ├── mt-sll.S │ │ ├── mt-sllv.S │ │ ├── mt-slt.S │ │ ├── mt-slti.S │ │ ├── mt-sltiu.S │ │ ├── mt-sltu.S │ │ ├── mt-sra.S │ │ ├── mt-srav.S │ │ ├── mt-srl.S │ │ ├── mt-srlv.S │ │ ├── mt-subu.S │ │ ├── mt-xor.S │ │ ├── mt-xori.S │ │ └── mt.mk │ ├── parcv1 │ │ ├── parc-macros.h │ │ ├── parcv1-addiu.S │ │ ├── parcv1-addu.S │ │ ├── parcv1-bne.S │ │ ├── parcv1-jal.S │ │ ├── parcv1-jr.S │ │ ├── parcv1-lui.S │ │ ├── parcv1-lw.S │ │ ├── parcv1-ori.S │ │ ├── parcv1-sw.S │ │ └── parcv1.mk │ ├── parcv2 │ │ ├── parc-macros.h │ │ ├── parcv2-and.S │ │ ├── parcv2-andi.S │ │ ├── parcv2-beq.S │ │ ├── parcv2-bgez.S │ │ ├── parcv2-bgtz.S │ │ ├── parcv2-blez.S │ │ ├── parcv2-bltz.S │ │ ├── parcv2-div.S │ │ ├── parcv2-divu.S │ │ ├── parcv2-j.S │ │ ├── parcv2-jalr.S │ │ ├── parcv2-lb.S │ │ ├── parcv2-lbu.S │ │ ├── parcv2-lh.S │ │ ├── parcv2-lhu.S │ │ ├── parcv2-mfc0.S │ │ ├── parcv2-mul.S │ │ ├── parcv2-nor.S │ │ ├── parcv2-or.S │ │ ├── parcv2-rem.S │ │ ├── parcv2-remu.S │ │ ├── parcv2-sb.S │ │ ├── parcv2-sh.S │ │ ├── parcv2-sll.S │ │ ├── parcv2-sllv.S │ │ ├── parcv2-slt.S │ │ ├── parcv2-slti.S │ │ ├── parcv2-sltiu.S │ │ ├── parcv2-sltu.S │ │ ├── parcv2-sra.S │ │ ├── parcv2-srav.S │ │ ├── parcv2-srl.S │ │ ├── parcv2-srlv.S │ │ ├── parcv2-subu.S │ │ ├── parcv2-xor.S │ │ ├── parcv2-xori.S │ │ └── parcv2.mk │ ├── parcv3 │ │ ├── parc-macros.h │ │ ├── parcv3-add-s.S │ │ ├── parcv3-amo-add.S │ │ ├── parcv3-amo-and.S │ │ ├── parcv3-amo-min.S │ │ ├── parcv3-amo-or.S │ │ ├── parcv3-amo-xchg.S │ │ ├── parcv3-c-eq-s.S │ │ ├── parcv3-c-le-s.S │ │ ├── parcv3-c-lt-s.S │ │ ├── parcv3-cvt-s-w.S │ │ ├── parcv3-cvt-w-s.S │ │ ├── parcv3-div-s.S │ │ ├── parcv3-fstat.S │ │ ├── parcv3-gcd.S │ │ ├── parcv3-movn.S │ │ ├── parcv3-movz.S │ │ ├── parcv3-mul-s.S │ │ ├── parcv3-scan.S │ │ ├── parcv3-sub-s.S │ │ ├── parcv3-syscall.S │ │ ├── parcv3-vecincr.S │ │ ├── parcv3-write.S │ │ └── parcv3.mk │ └── scripts │ │ ├── config.guess │ │ ├── config.sub │ │ ├── install.sh │ │ ├── mk-install-dirs.sh │ │ ├── objdump2vmh-cache.py │ │ ├── objdump2vmh.py │ │ ├── test.ld │ │ └── vcs-version.sh ├── bootstrap.py ├── instruction.py ├── isa.py ├── machine.py ├── parc-sim.py ├── syscalls.py ├── ubmark_test.py └── utils.py ├── pydgin ├── SparseMemoryImage.py ├── __init__.py ├── debug.py ├── elf.py ├── jit.py ├── machine.py ├── misc.py ├── sim.py ├── storage.py ├── syscalls.py └── utils.py ├── riscv ├── .gitignore ├── asm_test.py ├── bootstrap.py ├── csr.py ├── helpers.py ├── instruction.py ├── isa.py ├── isa_RV32A.py ├── isa_RV32D.py ├── isa_RV32F.py ├── isa_RV32I.py ├── isa_RV32M.py ├── isa_RV64A.py ├── isa_RV64D.py ├── isa_RV64F.py ├── isa_RV64I.py ├── isa_RV64M.py ├── machine.py ├── riscv-sim.py ├── syscalls.py ├── ubmark_test.py └── utils.py ├── scripts ├── .gitignore ├── build-softfloat.py ├── build.py ├── get-test-list.py ├── parc_inject_bootstrap.py ├── rm_pycache.py └── vcs-version.sh ├── softfloat ├── __init__.py └── softfloat-c │ ├── 8086 │ ├── OLD-specialize.c │ ├── OLD-specialize.h │ ├── platform.h │ ├── s_commonNaNToF32UI.c │ ├── s_commonNaNToF64UI.c │ ├── s_f32UIToCommonNaN.c │ ├── s_f64UIToCommonNaN.c │ ├── s_isSigNaNF32UI.c │ ├── s_isSigNaNF64UI.c │ ├── s_propagateNaNF32UI.c │ ├── s_propagateNaNF64UI.c │ ├── softfloat_raiseFlags.c │ ├── softfloat_types.h │ └── specialize.h │ ├── f32_add.c │ ├── f32_classify.c │ ├── f32_div.c │ ├── f32_eq.c │ ├── f32_eq_signaling.c │ ├── f32_isSignalingNaN.c │ ├── f32_le.c │ ├── f32_le_quiet.c │ ├── f32_lt.c │ ├── f32_lt_quiet.c │ ├── f32_mul.c │ ├── f32_mulAdd.c │ ├── f32_rem.c │ ├── f32_roundToInt.c │ ├── f32_sqrt.c │ ├── f32_sub.c │ ├── f32_to_f64.c │ ├── f32_to_i32.c │ ├── f32_to_i32_r_minMag.c │ ├── f32_to_i64.c │ ├── f32_to_i64_r_minMag.c │ ├── f32_to_ui32.c │ ├── f32_to_ui32_r_minMag.c │ ├── f32_to_ui64.c │ ├── f32_to_ui64_r_minMag.c │ ├── f64_add.c │ ├── f64_classify.c │ ├── f64_div.c │ ├── f64_eq.c │ ├── f64_eq_signaling.c │ ├── f64_isSignalingNaN.c │ ├── f64_le.c │ ├── f64_le_quiet.c │ ├── f64_lt.c │ ├── f64_lt_quiet.c │ ├── f64_mul.c │ ├── f64_mulAdd.c │ ├── f64_rem.c │ ├── f64_roundToInt.c │ ├── f64_sqrt.c │ ├── f64_sub.c │ ├── f64_to_f32.c │ ├── f64_to_i32.c │ ├── f64_to_i32_r_minMag.c │ ├── f64_to_i64.c │ ├── f64_to_i64_r_minMag.c │ ├── f64_to_ui32.c │ ├── f64_to_ui32_r_minMag.c │ ├── f64_to_ui64.c │ ├── f64_to_ui64_r_minMag.c │ ├── i32_to_f32.c │ ├── i32_to_f64.c │ ├── i64_to_f32.c │ ├── i64_to_f64.c │ ├── internals.h │ ├── platform.h │ ├── primitives.h │ ├── s_add128.c │ ├── s_add192.c │ ├── s_addMagsF32.c │ ├── s_addMagsF64.c │ ├── s_commonNaNToF32UI.c │ ├── s_commonNaNToF64UI.c │ ├── s_countLeadingZeros32.c │ ├── s_countLeadingZeros64.c │ ├── s_countLeadingZeros8.c │ ├── s_eq128.c │ ├── s_estimateDiv128To64.c │ ├── s_estimateSqrt32.c │ ├── s_f32UIToCommonNaN.c │ ├── s_f64UIToCommonNaN.c │ ├── s_isSigNaNF32UI.c │ ├── s_isSigNaNF64UI.c │ ├── s_le128.c │ ├── s_lt128.c │ ├── s_mul128By64To192.c │ ├── s_mul128To256.c │ ├── s_mul64To128.c │ ├── s_mulAddF32.c │ ├── s_mulAddF64.c │ ├── s_normRoundPackToF32.c │ ├── s_normRoundPackToF64.c │ ├── s_normSubnormalF32Sig.c │ ├── s_normSubnormalF64Sig.c │ ├── s_propagateNaNF32UI.c │ ├── s_propagateNaNF64UI.c │ ├── s_roundPackToF32.c │ ├── s_roundPackToF64.c │ ├── s_roundPackToI32.c │ ├── s_roundPackToI64.c │ ├── s_roundPackToUI32.c │ ├── s_roundPackToUI64.c │ ├── s_shift128ExtraRightJam.c │ ├── s_shift128RightJam.c │ ├── s_shift32RightJam.c │ ├── s_shift64ExtraRightJam.c │ ├── s_shift64RightJam.c │ ├── s_shortShift128ExtraRightJam.c │ ├── s_shortShift128Left.c │ ├── s_shortShift128Right.c │ ├── s_shortShift192Left.c │ ├── s_shortShift32Right1Jam.c │ ├── s_shortShift64ExtraRightJam.c │ ├── s_shortShift64RightJam.c │ ├── s_sub128.c │ ├── s_sub192.c │ ├── s_subMagsF32.c │ ├── s_subMagsF64.c │ ├── softfloat.h │ ├── softfloat_raiseFlags.c │ ├── softfloat_state.c │ ├── softfloat_types.h │ ├── specialize.h │ ├── ui32_to_f32.c │ ├── ui32_to_f64.c │ ├── ui64_to_f32.c │ └── ui64_to_f64.c ├── syscall-tests ├── Makefile ├── args-test.c ├── fcntl-test.c ├── malloc-test.c ├── open-close-test.c ├── read-test.c ├── stat-test.c └── uname-test.c └── ubmark-nosyscalls ├── Makefile.in ├── aclocal.m4 ├── config.h.in ├── configure ├── configure.ac ├── convert ├── scripts ├── config.guess ├── config.sub ├── install.sh ├── mk-install-dirs.sh ├── objdump2vmh.py ├── ubmark.ld └── vcs-version.sh └── ubmark ├── ubmark-bin-search.c ├── ubmark-bin-search.dat ├── ubmark-cmplx-mult.c ├── ubmark-cmplx-mult.dat ├── ubmark-masked-filter.c ├── ubmark-masked-filter.dat ├── ubmark-mvmult-cp2.c ├── ubmark-mvmult.c ├── ubmark-mvmult.dat ├── ubmark-vvadd.c ├── ubmark-vvadd.dat ├── ubmark.ac ├── ubmark.h └── ubmark.mk.in /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *-c 3 | *.swp 4 | build/ 5 | softfloat/_abi.py 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2015, Cornell University 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or 5 | without modification, are permitted provided that the following 6 | conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of Cornell University nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 28 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /arm/.gitignore: -------------------------------------------------------------------------------- 1 | pydgin-arm-* 2 | -------------------------------------------------------------------------------- /arm/asm_tests/adc-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #1 5 | mov r3, #1 6 | mov r4, #0 7 | adc r4, r2, r3 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/adc-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #1 5 | mov r3, #1 6 | 7 | # Set the carry bit 8 | mov r0, #0xa000000b 9 | movs r0, r0, RRX 10 | 11 | adc r4, r2, r3 12 | 13 | TEST_END 14 | -------------------------------------------------------------------------------- /arm/asm_tests/adc-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0x00100000 5 | mov r3, #0x00100000 6 | mov r5, #1 7 | adcs r1, r1, r3, asr r5 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/adc-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0x00100000 5 | mov r3, #0x00100000 6 | mov r5, #1 7 | 8 | # Set the carry bit 9 | mov r0, #0xa000000b 10 | movs r0, r0, RRX 11 | 12 | adcs r1, r1, r3, asr r5 13 | 14 | TEST_END 15 | -------------------------------------------------------------------------------- /arm/asm_tests/add-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | adds r1, r0, r0 5 | 6 | TEST_END 7 | -------------------------------------------------------------------------------- /arm/asm_tests/add-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #0x7fffffff 5 | adds r1, r2, #1 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/add-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0 5 | mov r3, #0x00100000 6 | mov lr, #0x0000001f 7 | adds r1, r1, r3, lsl lr 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/arm-macros.h: -------------------------------------------------------------------------------- 1 | .macro TEST_BEGIN 2 | 3 | # gcc needs this to create a valid elf 4 | .global main 5 | main: 6 | 7 | .endm 8 | 9 | .macro TEST_END 10 | 11 | # Terminate the program by calling the exit syscall (1) 12 | mov r7, #1 13 | swi 0x00000000 14 | 15 | # the pydgin elf loader needs this to find the breakpoint 16 | .bss 17 | xxx: .word 0 18 | 19 | .endm 20 | 21 | -------------------------------------------------------------------------------- /arm/asm_tests/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import subprocess 5 | 6 | assembler = "arm-unknown-linux-uclibcgnueabi-gcc -nostdlib" 7 | 8 | # try creating a build dir 9 | 10 | cmd = "mkdir -p build" 11 | print cmd 12 | subprocess.check_call( cmd, shell=True ) 13 | 14 | # build the binaries 15 | 16 | for asm_file in filter( lambda s : s.endswith( ".S" ), os.listdir( "." ) ): 17 | 18 | elf_file = asm_file[:-2] 19 | 20 | cmd = "{assembler} {asm_file} -o build/{elf_file}".format( **locals() ) 21 | print cmd 22 | subprocess.check_call( cmd, shell=True ) 23 | 24 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0xFFFFFFFF 5 | cmp r4, #0 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #immediate rotation 5 | mov r4, #0x3f0 6 | cmp r4, #0x3f, 0x1c 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift left by immediate 5 | mov r4, #0x3f0 6 | mov r3, #0x7e 7 | cmp r4, r3, LSL #0x3 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift left by register, Rs[7:0] == 0 5 | mov r4, #0x3f0 6 | mov r3, #0x3f0 7 | mov r2, #0x1f000000 8 | cmp r4, r3, LSL r2 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-04.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift left by register, Rs[7:0] < 32 5 | mov r4, #0x3f0 6 | mov r3, #0x3f 7 | mov r2, #0x00000204 8 | cmp r4, r3, LSL r2 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-05.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift left by register, Rs[7:0] >= 32 (shifter_operand = 0) 5 | mov r4, #0x0 6 | mov r3, #0x3f0 7 | mov r2, #0xff 8 | cmp r4, r3, LSL r2 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-06.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift right by immediate 0 5 | mov r3, #0x3f0 6 | mov r4, #0x3f0 7 | cmp r4, r3, LSR #0x0 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-07.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift right by immediate > 0 5 | mov r3, #0x3f0000 6 | mov r4, #0x3f0 7 | cmp r4, r3, LSR #0xC 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-08.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift right by register, Rs[7:0] == 0 5 | mov r3, #0x3f0000 6 | mov r4, #0x3f0000 7 | mov r5, #0x200 8 | cmp r4, r3, LSR r5 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-09.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift right by register, Rs[7:0] < 32 5 | mov r3, #0x3f 6 | mov r4, #0x3f0000 7 | mov r5, #0x210 8 | cmp r3, r4, LSR r5 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-10.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #logical shift right by register, Rs[7:0] >= 32 (shifter_operand == 0) 5 | mov r3, #0x0 6 | mov r4, #0x3f0000 7 | mov r5, #0x220 8 | cmp r3, r3, LSR r5 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-11.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #arithmetic shift right by immediate 5 | mov r3, #0xf0000000 6 | mov r4, #0x9C000000 7 | cmp r3, r3, ASR #3 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-12.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #arithmetic shift right by immediate 5 | mov r3, #0xf0000000 6 | mov r4, #0x9C000000 7 | mov r5, #3 8 | cmp r3, r3, ASR r5 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-13.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #rotate right by immediate 5 | mov r3, #0x1000000f 6 | mov r4, #0xf1000000 7 | cmp r3, r3, ROR #4 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/cmp-14.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #rotate right by register 5 | mov r3, #0x1000000f 6 | mov r4, #0xf1000000 7 | mov r5, #0x4 8 | cmp r3, r3, ROR r5 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/eor-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #3 5 | eor r5, r4, #0 6 | eor r6, r4, #3 7 | eor r7, r4, #2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/eor-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #3 5 | eors r5, r4, #0 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/eor-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #3 5 | eors r5, r4, #3 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/eor-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #3 5 | eors r5, r4, r4, ROR #1 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/eor-04.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #3 5 | mov r3, #0x1B 6 | eors r5, r4, r4, ROR #3 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/eor-05.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | eors r4, r4, #0xcb00000 5 | 6 | TEST_END 7 | 8 | 9 | -------------------------------------------------------------------------------- /arm/asm_tests/ldm-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | /*LDM in default is LDMIA.*/ 5 | tdata_0: .word 0x00000001 6 | tdata_1: .word 0x00000002 7 | 8 | ldr r4, =tdata_0 9 | ldm r4, {r5, r6} 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/ldm-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | /*LDMDA:Decrement address After each transfer*/ 5 | tdata_0: .word 0x00000001 6 | tdata_1: .word 0x00000002 7 | 8 | ldr r4, =tdata_1 9 | ldmda r4!, {r5, r6} 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/ldm-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | /*LDMIB:Increment address Before each transfer (ARM only).*/ 5 | tdata_0: .word 0x00000001 6 | tdata_1: .word 0x00000002 7 | tdata_2: .word 0x00000003 8 | 9 | ldr r4, =tdata_0 10 | ldmib r4, {r5, r6} 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/ldm-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | /*LDMDA:Decrement address After each transfer*/ 5 | tdata_0: .word 0x00000001 6 | tdata_1: .word 0x00000002 7 | tdata_2: .word 0x00000003 8 | 9 | ldr r4, =tdata_2 10 | ldmdb r4!, {r5, r6} 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/ldr-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000FF 5 | 6 | ldr r4, =tdata_0 7 | ldr r5, [r4] 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/ldr-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | tdata_1: .word 0x00000ff0 6 | 7 | ldr r4, =tdata_1 8 | ldr r5, [r4, #-4] 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/ldr-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | tdata_1: .word 0x00000ff0 6 | tdata_2: .word 0x0000ff00 7 | 8 | ldr r4, =tdata_0 9 | mov r6, #8 10 | ldr r5, [r4, r6] 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/ldr-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r8, =tdata_0 7 | mov r4, #0 8 | mov r5, #0 9 | mov r6, #0 10 | mov r9, #12 11 | add r9, r9, pc 12 | str r9, [r8] 13 | ldr pc, [r8] 14 | mov r4, pc 15 | mov r5, pc 16 | mov r6, pc 17 | 18 | TEST_END 19 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrb-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x0F0F0F0F 5 | 6 | ldr r4, =tdata_0 7 | ldrb r5, [r4] 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrbcs-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x0F0F0F0F 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #0 9 | ldrcsb r5, [r4, #0] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrbcs-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x0F0F0F0F 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #2 9 | ldrcsb r5, [r4, #0] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrbeq-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x0F0F0F0F 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #1 9 | ldreqb r5, [r4, #0] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrbne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x0F0F0F0F 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #0 9 | ldrneb r5, [r4, #0] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrh-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x00010101 5 | 6 | ldr r4, =tdata_0 7 | ldrh r5, [r4] 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrhi-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #0 9 | ldrhi r5, [r4, #0] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrls-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #1 9 | ldrls r5, [r4, #0] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/ldrne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #0 9 | ldrne r5, [r4, #0] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/mla-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | /* MLA{S}{cond} Rd, Rn, Rm, Ra 5 | * 6 | * The MLA instruction multiplies the values from Rn and Rm, 7 | * adds the value from Ra, and places the least significant 8 | * 32 bits of the result in Rd. 9 | */ 10 | 11 | mov r1, #0x00001000 12 | mov r2, #0x00010000 13 | mov r5, #0x80000000 14 | mlas r9, r1, r2, r5 15 | 16 | TEST_END 17 | -------------------------------------------------------------------------------- /arm/asm_tests/mov-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0 5 | 6 | TEST_END 7 | -------------------------------------------------------------------------------- /arm/asm_tests/mov-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #1 5 | movs r4, r2 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/mov-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, pc 5 | 6 | TEST_END 7 | -------------------------------------------------------------------------------- /arm/asm_tests/mov-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0 5 | mov r5, #0 6 | mov r6, #0 7 | mov pc, pc 8 | mov r4, pc 9 | mov r5, pc 10 | mov r6, pc 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/mov-04.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #1 5 | mov r5, #8 6 | movs r4, r5, LSR #2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/mov-05.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #1 5 | mov r5, #8 6 | movs r4, r5, LSL #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/mov-06.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #Rotate right with extend, carry = 0 5 | mov r3, #0xa000000b 6 | movs r3, r3, RRX 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/mov-07.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | #Rotate right with extend, carry = 1 5 | mov r4, #0xFFFFFFFF 6 | cmp r4, #0 7 | mov r3, #0xa000000b 8 | movs r3, r3, RRX 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/movcc-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | movccs r4, #1 5 | 6 | TEST_END 7 | -------------------------------------------------------------------------------- /arm/asm_tests/movcc-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #0 5 | cmp r5, #0 6 | movccs r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/movcs-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #0 5 | cmp r5, #0 6 | movcs r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/movcs-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | movcss r4, #1 5 | 6 | TEST_END 7 | -------------------------------------------------------------------------------- /arm/asm_tests/moveq-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | moveqs r4, #1 5 | 6 | TEST_END 7 | -------------------------------------------------------------------------------- /arm/asm_tests/moveq-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #0 5 | cmp r5, #0 6 | moveq r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/movgt-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | movgts r4, #1 5 | 6 | TEST_END 7 | -------------------------------------------------------------------------------- /arm/asm_tests/movgt-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #0 5 | cmp r5, #1 6 | moveqs r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/movhi-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #1 5 | cmp r5, #0 6 | movhis r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/movls-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #1 5 | cmp r5, #0 6 | movlss r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/movls-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #0 5 | cmp r5, #0 6 | movls r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/movne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #1 5 | cmp r5, #0 6 | movnes r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/movne-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r5, #1 5 | cmp r5, #1 6 | movnes r4, #1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/mul-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xf0000000 5 | mov r2, #2 6 | muls r3, r1, r2 // V and C bits won't be affected in any case 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/mul-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xf0000000 5 | mov r2, #0 6 | muls r3, r1, r2 // V and C bits won't be affected in any case 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/mvn-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #7 5 | mvns r1, r2 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/mvn-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mvns r1, #0xffffffff 5 | 6 | TEST_END 7 | -------------------------------------------------------------------------------- /arm/asm_tests/mvneq-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #7 5 | cmp r2, #7 6 | mvneq r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/mvnne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #7 5 | cmp r2, #6 6 | mvnne r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/orr-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xFFFFFFF8 5 | mov r2, #7 6 | orrs r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/orr-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0x7 5 | orrs r1, #0x000000F8 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/orr-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0 5 | mov r5, #0 6 | mov r6, #0 7 | orr pc, pc, #0 8 | mov r4, pc 9 | mov r5, pc 10 | mov r6, pc 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/orreq-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xFFFFFFF8 5 | mov r2, #7 6 | cmp r2, #6 7 | orreqs r1, r2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/orreq-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xFFFFFFF8 5 | mov r2, #7 6 | cmp r2, #7 7 | orreqs r1, r2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/orrgt-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #0x80000000 6 | orrgts r1, r3 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/orrgt-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #0x80000000 6 | mov r3, #0x70000000 7 | subs r1, r1, r2 8 | orrgts r1, r3 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/orrhi-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xFFFFFFF8 5 | mov r2, #7 6 | cmp r2, #6 7 | orrhis r1, r2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/orrhi-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xFFFFFFF8 5 | mov r2, #7 6 | cmp r2, #7 7 | orrhis r1, r2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/orrne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xFFFFFFF8 5 | mov r2, #7 6 | cmp r2, #7 7 | orrnes r1, r2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/orrne-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xFFFFFFF8 5 | mov r2, #7 6 | cmp r2, #8 7 | orrnes r1, r2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/rsb-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #8 6 | rsbs r1, r2, r1 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/rsb-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | rsbs r1, r1, #1 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/rsb-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r6, #0x28 5 | mov r7, #0x00 6 | rsbne r6, r7, r6 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/rsbeq-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #8 6 | cmp r2, #8 7 | rsbeq r1, r2, r1 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/rsble-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #8 6 | cmp r2, #8 7 | rsble r1, r2, r1 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/rsble-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #8 6 | cmp r2, #9 7 | rsble r1, r2, r1 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/rsbne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #8 6 | cmp r2, #7 7 | rsbne r1, r2, r1 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/smull-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #0x83000000 5 | orr r2, r2, #0x004e0000 6 | orr r2, r2, #0x00000b00 7 | orr r2, r2, #0x0000005f 8 | mov lr, #0x00007e00 9 | orr lr, lr, #0x00000056 10 | smull r1, r3, r2, lr 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/smull-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0 5 | mov r2, #0xffffffff 6 | smulls r3, r4, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/smull-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0x7fffffff 5 | mov r2, #0xffffffff 6 | smulls r3, r4, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/smull-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0x80000000 5 | mov r2, #0x80000000 6 | smulls r3, r4, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/smull-04.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0x7fffffff 5 | mov r2, #0x80000000 6 | smulls r3, r4, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/stm-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | mov r6, #2 9 | stm r4, {r5, r6} 10 | ldm r4, {r8, r9} 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/stm-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | mov r6, #2 9 | stmib r4, {r5, r6} 10 | ldm r4, {r8, r9, r10} 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/str-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | str r5, [r4] 9 | ldr r6, [r4] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/strb-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #0x10000000 8 | strb r5, [r4] 9 | ldr r6, [r4] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/strb-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #0x1f 8 | strb r5, [r4] 9 | ldr r6, [r4] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/strbcc-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x10000000 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #0xff 8 | strccb r5, [r4] 9 | ldr r6, [r4] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/strbcs-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x10000000 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #0xff 8 | cmp r5, #0xff 9 | strcsb r5, [r4] 10 | ldr r6, [r4] 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/strbne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x10000000 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #0xff 8 | cmp r5, #0xfe 9 | strneb r5, [r4] 10 | ldr r6, [r4] 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/strcc-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | str r5, [r4] 9 | ldr r6, [r4] 10 | 11 | TEST_END 12 | -------------------------------------------------------------------------------- /arm/asm_tests/streq-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #1 9 | str r5, [r4] 10 | ldr r6, [r4] 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/strhi-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #0 9 | str r5, [r4] 10 | ldr r6, [r4] 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/strls-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #1 9 | str r5, [r4] 10 | ldr r6, [r4] 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/strne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | tdata_0: .word 0x000000ff 5 | 6 | ldr r4, =tdata_0 7 | mov r5, #1 8 | cmp r5, #0 9 | str r5, [r4] 10 | ldr r6, [r4] 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/sub-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #8 6 | subs r1, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/sub-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | subs r1, r1, #1 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/sub-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0 5 | mov r5, #0 6 | mov r6, #0 7 | sub pc, pc, #-4 8 | mov r4, pc 9 | mov r5, pc 10 | mov r6, pc 11 | 12 | TEST_END 13 | -------------------------------------------------------------------------------- /arm/asm_tests/subeq-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #8 6 | cmp r2, #7 7 | subeqs r1, r1, r2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/subeq-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | mov r2, #8 6 | cmp r2, #8 7 | subeqs r1, r1, r2 8 | 9 | TEST_END 10 | -------------------------------------------------------------------------------- /arm/asm_tests/sublt-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | movs r2, #8 6 | sublts r1, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/sublt-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #1 5 | movs r2, #0x80000000 6 | sublts r1, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/teq-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #3 5 | teq r4, #3 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/teq-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #1 5 | teqs r4, #0 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/teq-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0x80000000 5 | teqs r4, #0 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/tst-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0 5 | tst r4, #0 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/tst-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #1 5 | tst r4, #0 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/tst-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0x80000000 5 | tst r4, #0x80000000 6 | 7 | TEST_END 8 | -------------------------------------------------------------------------------- /arm/asm_tests/tst-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #0x7f000000 5 | orr r2, #0x00e80000 6 | orr r2, #0x00008600 7 | orr r2, #0x000000c1 8 | tst r2, #3 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/tst-04.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r2, #0xbf000000 5 | orr r2, #0x00e80000 6 | orr r2, #0x0000b800 7 | orr r2, #0x00000060 8 | tst r2, #3 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/tstne-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0x80000000 5 | cmp r4, #0 6 | tstne r4, #0x80000000 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/tstne-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r4, #0x80000000 5 | cmp r4, #0x80000000 6 | tstne r4, #0x80000000 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/umlal-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #2 5 | mov r2, #0x80000000 6 | mov r3, #0 7 | mov r4, #0xffffffff 8 | umlals r3, r4, r1, r2 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/umlal-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xc0000000 5 | mov r2, #0xffffffff 6 | mov r3, #0x40000000 7 | mov r4, #0x40000001 8 | umlals r3, r4, r1, r2 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/umlal-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xc0000000 5 | mov r2, #0xffffffff 6 | mov r3, #0 7 | mov r4, #0x40000000 8 | umlals r3, r4, r1, r2 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/umlal-03.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xc0000000 5 | mov r2, #0xffffffff 6 | mov r3, #0xc0000000 7 | mov r4, #0x40000001 8 | umlals r3, r4, r1, r2 9 | 10 | TEST_END 11 | -------------------------------------------------------------------------------- /arm/asm_tests/umull-00.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0 5 | mov r2, #0xffffffff 6 | umulls r3, r4, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/umull-01.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0x80000000 5 | mov r2, #2 6 | umulls r3, r4, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /arm/asm_tests/umull-02.S: -------------------------------------------------------------------------------- 1 | #include "arm-macros.h" 2 | TEST_BEGIN 3 | 4 | mov r1, #0xc0000000 5 | mov r2, #0xffffffff 6 | umulls r3, r4, r1, r2 7 | 8 | TEST_END 9 | -------------------------------------------------------------------------------- /benchmarks.rst: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | RPython ISA Paper 3 | ================================================================================ 4 | 5 | -------------------------------------------------------------------------------- 6 | Outline 7 | -------------------------------------------------------------------------------- 8 | 9 | -------------------------------------------------------------------------------- 10 | Preliminary Results 11 | -------------------------------------------------------------------------------- 12 | 13 | :: 14 | 15 | maven-isa pisa-sim 16 | --------- ---------------------------------- 17 | cpython pypy c-nojit c-jit 18 | 19 | 20 | ubmark-vvadd 5059 1234 cycles 21 | .053 .855 .005 .006 seconds 22 | 95452 1443 246800 205666 cycles/sec 23 | 1x .02x 2.58x 2.15x speedup 24 | 25 | ubmark-vvadd 266508 239279 cycles 26 | x500 .133 3.799 1.633 .009 .058 seconds 27 | 2003819 62984 146527 26586555 4125500 cycles/sec 28 | 1x .03x .07x 13.26x 2.06x speedup 29 | 30 | 31 | -------------------------------------------------------------------------------- /docs/pydgin_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornell-brg/pydgin/30f8efa914f26dbee622ebd14d4345840a69c10c/docs/pydgin_logo.png -------------------------------------------------------------------------------- /parc/.gitignore: -------------------------------------------------------------------------------- 1 | pydgin-parc-* 2 | -------------------------------------------------------------------------------- /parc/asm_tests/.gitignore: -------------------------------------------------------------------------------- 1 | autom4te.cache/ 2 | build/ 3 | build-*/ 4 | -------------------------------------------------------------------------------- /parc/asm_tests/README.rst: -------------------------------------------------------------------------------- 1 | ========================================================================== 2 | PARC Assembly Tests 3 | ========================================================================== 4 | 5 | This requires ``pydgin-parc-xcc`` (``maven-sys-xcc``) cross-compiler 6 | installed. First, build the tests:: 7 | 8 | % mkdir build 9 | % cd build 10 | % ../configure --host=maven 11 | % make 12 | 13 | Now, you can run the tests. Failures and errors (if any) would be reported 14 | at the very end:: 15 | 16 | % make check 17 | ... 18 | ------------------------------------------------------------------------ 19 | Test summary (failures and errors) 20 | ------------------------------------------------------------------------ 21 | parcv2-div.out: [ FAILED ] ./parcv2-div (line 28) 22 | ... 23 | 24 | This runs the interpreted pydgin by default. To test with translated 25 | pydgin, you can specify the translated pydgin binary with ``RUN`` flag to 26 | ``make``:: 27 | 28 | % make check RUN=../../pydgin-parc-jit 29 | 30 | -------------------------------------------------------------------------------- /parc/asm_tests/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define if we should include subproject utst */ 4 | #undef HAVE_UTST 5 | 6 | /* Define to the address where bug reports for this package should be sent. */ 7 | #undef PACKAGE_BUGREPORT 8 | 9 | /* Define to the full name of this package. */ 10 | #undef PACKAGE_NAME 11 | 12 | /* Define to the full name and version of this package. */ 13 | #undef PACKAGE_STRING 14 | 15 | /* Define to the one symbol short name of this package. */ 16 | #undef PACKAGE_TARNAME 17 | 18 | /* Define to the home page for this package. */ 19 | #undef PACKAGE_URL 20 | 21 | /* Define to the version of this package. */ 22 | #undef PACKAGE_VERSION 23 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-andi.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-andi 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Logical tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_IMM_OP( andi, 0xff00ff00, 0x0f0f, 0x00000f00 ) 14 | TEST_IMM_OP( andi, 0x0ff00ff0, 0xf0f0, 0x000000f0 ) 15 | TEST_IMM_OP( andi, 0x00ff00ff, 0x0f0f, 0x0000000f ) 16 | TEST_IMM_OP( andi, 0xf00ff00f, 0xf0f0, 0x0000f000 ) 17 | 18 | //-------------------------------------------------------------------- 19 | // Source/Destination tests 20 | //-------------------------------------------------------------------- 21 | 22 | TEST_IMM_SRC0_EQ_DEST( andi, 0xff00ff00, 0xf0f0, 0x0000f000 ) 23 | 24 | //-------------------------------------------------------------------- 25 | // Bypassing tests 26 | //-------------------------------------------------------------------- 27 | 28 | TEST_IMM_DEST_BYP( 0, andi, 0x0ff00ff0, 0x0f0f, 0x00000f00 ) 29 | TEST_IMM_DEST_BYP( 1, andi, 0x00ff00ff, 0xf0f0, 0x000000f0 ) 30 | TEST_IMM_DEST_BYP( 2, andi, 0xf00ff00f, 0x0f0f, 0x0000000f ) 31 | TEST_IMM_DEST_BYP( 3, andi, 0xf0f0f0f0, 0xff00, 0x0000f000 ) 32 | TEST_IMM_DEST_BYP( 4, andi, 0x0f0f0f0f, 0x00ff, 0x0000000f ) 33 | 34 | TEST_IMM_SRC0_BYP( 0, andi, 0x0ff00ff0, 0x0f0f, 0x00000f00 ) 35 | TEST_IMM_SRC0_BYP( 1, andi, 0x00ff00ff, 0xf0f0, 0x000000f0 ) 36 | TEST_IMM_SRC0_BYP( 2, andi, 0xf00ff00f, 0x0f0f, 0x0000000f ) 37 | TEST_IMM_SRC0_BYP( 3, andi, 0xf0f0f0f0, 0xff00, 0x0000f000 ) 38 | TEST_IMM_SRC0_BYP( 4, andi, 0x0f0f0f0f, 0x00ff, 0x0000000f ) 39 | 40 | TEST_MT_END 41 | 42 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-beq.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-beq 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Branch tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_BR2_OP_TAKEN( beq, 0, 0 ) 14 | TEST_BR2_OP_TAKEN( beq, 1, 1 ) 15 | TEST_BR2_OP_TAKEN( beq, -1, -1 ) 16 | 17 | TEST_BR2_OP_NOTTAKEN( beq, 0, 1 ) 18 | TEST_BR2_OP_NOTTAKEN( beq, 1, 0 ) 19 | TEST_BR2_OP_NOTTAKEN( beq, -1, 1 ) 20 | TEST_BR2_OP_NOTTAKEN( beq, 1, -1 ) 21 | 22 | //-------------------------------------------------------------------- 23 | // Bypassing tests 24 | //-------------------------------------------------------------------- 25 | 26 | TEST_BR2_SRC01_BYP( 0, 0, beq, 0, -1 ) 27 | TEST_BR2_SRC01_BYP( 0, 1, beq, 0, -1 ) 28 | TEST_BR2_SRC01_BYP( 0, 2, beq, 0, -1 ) 29 | TEST_BR2_SRC01_BYP( 0, 3, beq, 0, -1 ) 30 | TEST_BR2_SRC01_BYP( 0, 4, beq, 0, -1 ) 31 | 32 | TEST_BR2_SRC01_BYP( 1, 0, beq, 0, -1 ) 33 | TEST_BR2_SRC01_BYP( 1, 1, beq, 0, -1 ) 34 | TEST_BR2_SRC01_BYP( 2, 0, beq, 0, -1 ) 35 | 36 | TEST_BR2_SRC01_BYP( 0, 0, beq, 0, -1 ) 37 | TEST_BR2_SRC01_BYP( 0, 1, beq, 0, -1 ) 38 | TEST_BR2_SRC01_BYP( 0, 2, beq, 0, -1 ) 39 | TEST_BR2_SRC01_BYP( 0, 3, beq, 0, -1 ) 40 | TEST_BR2_SRC01_BYP( 0, 4, beq, 0, -1 ) 41 | 42 | TEST_BR2_SRC01_BYP( 1, 0, beq, 0, -1 ) 43 | TEST_BR2_SRC01_BYP( 1, 1, beq, 0, -1 ) 44 | TEST_BR2_SRC01_BYP( 2, 0, beq, 0, -1 ) 45 | 46 | TEST_MT_END 47 | 48 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-bgez.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-bgez 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Branch tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_BR1_OP_TAKEN( bgez, 0 ) 14 | TEST_BR1_OP_TAKEN( bgez, 1 ) 15 | 16 | TEST_BR1_OP_NOTTAKEN( bgez, -1 ) 17 | TEST_BR1_OP_NOTTAKEN( bgez, -10 ) 18 | 19 | //-------------------------------------------------------------------- 20 | // Bypassing tests 21 | //-------------------------------------------------------------------- 22 | 23 | TEST_BR1_SRC0_BYP( 0, bgez, -1 ) 24 | TEST_BR1_SRC0_BYP( 1, bgez, -1 ) 25 | TEST_BR1_SRC0_BYP( 2, bgez, -1 ) 26 | TEST_BR1_SRC0_BYP( 3, bgez, -1 ) 27 | TEST_BR1_SRC0_BYP( 4, bgez, -1 ) 28 | 29 | TEST_MT_END 30 | 31 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-bgtz.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-bgtz 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Branch tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_BR1_OP_TAKEN( bgtz, 1 ) 14 | TEST_BR1_OP_TAKEN( bgtz, 10 ) 15 | 16 | TEST_BR1_OP_NOTTAKEN( bgtz, 0 ) 17 | TEST_BR1_OP_NOTTAKEN( bgtz, -1 ) 18 | 19 | //-------------------------------------------------------------------- 20 | // Bypassing tests 21 | //-------------------------------------------------------------------- 22 | 23 | TEST_BR1_SRC0_BYP( 0, bgtz, -1 ) 24 | TEST_BR1_SRC0_BYP( 1, bgtz, -1 ) 25 | TEST_BR1_SRC0_BYP( 2, bgtz, -1 ) 26 | TEST_BR1_SRC0_BYP( 3, bgtz, -1 ) 27 | TEST_BR1_SRC0_BYP( 4, bgtz, -1 ) 28 | 29 | TEST_MT_END 30 | 31 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-blez.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-blez 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Branch tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_BR1_OP_TAKEN( blez, 0 ) 14 | TEST_BR1_OP_TAKEN( blez, -1 ) 15 | 16 | TEST_BR1_OP_NOTTAKEN( blez, 1 ) 17 | TEST_BR1_OP_NOTTAKEN( blez, 10 ) 18 | 19 | //-------------------------------------------------------------------- 20 | // Bypassing tests 21 | //-------------------------------------------------------------------- 22 | 23 | TEST_BR1_SRC0_BYP( 0, blez, 1 ) 24 | TEST_BR1_SRC0_BYP( 1, blez, 1 ) 25 | TEST_BR1_SRC0_BYP( 2, blez, 1 ) 26 | TEST_BR1_SRC0_BYP( 3, blez, 1 ) 27 | TEST_BR1_SRC0_BYP( 4, blez, 1 ) 28 | 29 | TEST_MT_END 30 | 31 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-bltz.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-bltz 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Branch tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_BR1_OP_TAKEN( bltz, -1 ) 14 | TEST_BR1_OP_TAKEN( bltz, -10 ) 15 | 16 | TEST_BR1_OP_NOTTAKEN( bltz, 0 ) 17 | TEST_BR1_OP_NOTTAKEN( bltz, 1 ) 18 | 19 | //-------------------------------------------------------------------- 20 | // Bypassing tests 21 | //-------------------------------------------------------------------- 22 | 23 | TEST_BR1_SRC0_BYP( 0, bltz, 1 ) 24 | TEST_BR1_SRC0_BYP( 1, bltz, 1 ) 25 | TEST_BR1_SRC0_BYP( 2, bltz, 1 ) 26 | TEST_BR1_SRC0_BYP( 3, bltz, 1 ) 27 | TEST_BR1_SRC0_BYP( 4, bltz, 1 ) 28 | 29 | TEST_MT_END 30 | 31 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-bne.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-bne 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Branch tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_BR2_OP_TAKEN( bne, 0, 1 ) 14 | TEST_BR2_OP_TAKEN( bne, 1, 0 ) 15 | TEST_BR2_OP_TAKEN( bne, -1, 1 ) 16 | TEST_BR2_OP_TAKEN( bne, 1, -1 ) 17 | 18 | TEST_BR2_OP_NOTTAKEN( bne, 0, 0 ) 19 | TEST_BR2_OP_NOTTAKEN( bne, 1, 1 ) 20 | TEST_BR2_OP_NOTTAKEN( bne, -1, -1 ) 21 | 22 | //-------------------------------------------------------------------- 23 | // Bypassing tests 24 | //-------------------------------------------------------------------- 25 | 26 | TEST_BR2_SRC01_BYP( 0, 0, bne, 0, 0 ) 27 | TEST_BR2_SRC01_BYP( 0, 1, bne, 0, 0 ) 28 | TEST_BR2_SRC01_BYP( 0, 2, bne, 0, 0 ) 29 | TEST_BR2_SRC01_BYP( 0, 3, bne, 0, 0 ) 30 | TEST_BR2_SRC01_BYP( 0, 4, bne, 0, 0 ) 31 | 32 | TEST_BR2_SRC01_BYP( 1, 0, bne, 0, 0 ) 33 | TEST_BR2_SRC01_BYP( 1, 1, bne, 0, 0 ) 34 | TEST_BR2_SRC01_BYP( 2, 0, bne, 0, 0 ) 35 | 36 | TEST_BR2_SRC01_BYP( 0, 0, bne, 0, 0 ) 37 | TEST_BR2_SRC01_BYP( 0, 1, bne, 0, 0 ) 38 | TEST_BR2_SRC01_BYP( 0, 2, bne, 0, 0 ) 39 | TEST_BR2_SRC01_BYP( 0, 3, bne, 0, 0 ) 40 | TEST_BR2_SRC01_BYP( 0, 4, bne, 0, 0 ) 41 | 42 | TEST_BR2_SRC01_BYP( 1, 0, bne, 0, 0 ) 43 | TEST_BR2_SRC01_BYP( 1, 1, bne, 0, 0 ) 44 | TEST_BR2_SRC01_BYP( 2, 0, bne, 0, 0 ) 45 | 46 | TEST_MT_END 47 | 48 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-j.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-j 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | j 1f 10 | TEST_CHECK_FAIL 11 | 1: 12 | 13 | TEST_MT_END 14 | 15 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-jal.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-jal 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | jal 1f 10 | linkaddr_0: 11 | TEST_CHECK_FAIL 12 | 1: 13 | 14 | la $2, linkaddr_0 15 | TEST_CHECK_EQ( $31, $2 ) 16 | 17 | TEST_MT_END 18 | 19 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-jalr.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-jalr 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Basic test 11 | //-------------------------------------------------------------------- 12 | 13 | li $31, 0xdeadbeef 14 | la $3, 1f 15 | 16 | jalr $4, $3 17 | linkaddr_0: 18 | TEST_CHECK_FAIL 19 | 1: 20 | 21 | la $2, linkaddr_0 22 | TEST_CHECK_EQ( $4, $2 ) 23 | 24 | // Make sure $31 not overwritten 25 | TEST_CHECK_EQ( $31, 0xdeadbeef ) 26 | 27 | //-------------------------------------------------------------------- 28 | // Check $0 link destination 29 | //-------------------------------------------------------------------- 30 | 31 | li $31, 0xdeadbeef 32 | la $3, 1f 33 | 34 | jalr $0, $3 35 | TEST_CHECK_FAIL 36 | 1: 37 | 38 | // Make sure $31 not overwritten 39 | TEST_CHECK_EQ( $31, 0xdeadbeef ) 40 | 41 | //-------------------------------------------------------------------- 42 | // Bypassing tests 43 | //-------------------------------------------------------------------- 44 | 45 | TEST_JR_SRC0_BYP( 0, jalr ) 46 | TEST_JR_SRC0_BYP( 1, jalr ) 47 | TEST_JR_SRC0_BYP( 2, jalr ) 48 | TEST_JR_SRC0_BYP( 3, jalr ) 49 | TEST_JR_SRC0_BYP( 4, jalr ) 50 | 51 | TEST_MT_END 52 | 53 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-jr.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-jr 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Basic test 11 | //-------------------------------------------------------------------- 12 | 13 | la $3, 1f 14 | jr $3 15 | TEST_CHECK_FAIL 16 | 1: 17 | 18 | //-------------------------------------------------------------------- 19 | // Bypassing tests 20 | //-------------------------------------------------------------------- 21 | 22 | TEST_JR_SRC0_BYP( 0, jr ) 23 | TEST_JR_SRC0_BYP( 1, jr ) 24 | TEST_JR_SRC0_BYP( 2, jr ) 25 | TEST_JR_SRC0_BYP( 3, jr ) 26 | TEST_JR_SRC0_BYP( 4, jr ) 27 | 28 | TEST_MT_END 29 | 30 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-lui.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-lui 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Basic tests 11 | //-------------------------------------------------------------------- 12 | 13 | lui $2, 0x0000 14 | TEST_CHECK_EQ( $2, 0x00000000 ) 15 | 16 | lui $2, 0xffff 17 | TEST_CHECK_EQ( $2, 0xffff0000 ) 18 | 19 | lui $2, 0x7fff 20 | TEST_CHECK_EQ( $2, 0x7fff0000 ) 21 | 22 | lui $2, 0x8000 23 | TEST_CHECK_EQ( $2, 0x80000000 ) 24 | 25 | //-------------------------------------------------------------------- 26 | // Bypassing tests 27 | //-------------------------------------------------------------------- 28 | 29 | lui $2, 0xdead 30 | addiu $7, $2, 0 31 | TEST_CHECK_EQ( $7, 0xdead0000 ) 32 | 33 | lui $2, 0xeadd 34 | TEST_INSERT_NOPS( 1 ) 35 | addiu $7, $2, 0 36 | TEST_CHECK_EQ( $7, 0xeadd0000 ) 37 | 38 | lui $2, 0xadde 39 | TEST_INSERT_NOPS( 2 ) 40 | addiu $7, $2, 0 41 | TEST_CHECK_EQ( $7, 0xadde0000 ) 42 | 43 | lui $2, 0xddea 44 | TEST_INSERT_NOPS( 3 ) 45 | addiu $7, $2, 0 46 | TEST_CHECK_EQ( $7, 0xddea0000 ) 47 | 48 | lui $2, 0xdead 49 | TEST_INSERT_NOPS( 4 ) 50 | addiu $7, $2, 0 51 | TEST_CHECK_EQ( $7, 0xdead0000 ) 52 | 53 | TEST_MT_END 54 | 55 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-ori.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-ori 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Logical tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_IMM_OP( ori, 0xff00ff00, 0x0f0f, 0xff00ff0f ) 14 | TEST_IMM_OP( ori, 0x0ff00ff0, 0xf0f0, 0x0ff0fff0 ) 15 | TEST_IMM_OP( ori, 0x00ff00ff, 0x0f0f, 0x00ff0fff ) 16 | TEST_IMM_OP( ori, 0xf00ff00f, 0xf0f0, 0xf00ff0ff ) 17 | 18 | //-------------------------------------------------------------------- 19 | // Source/Destination tests 20 | //-------------------------------------------------------------------- 21 | 22 | TEST_IMM_SRC0_EQ_DEST( ori, 0xff00ff00, 0xf0f0, 0xff00fff0 ) 23 | 24 | //-------------------------------------------------------------------- 25 | // Bypassing tests 26 | //-------------------------------------------------------------------- 27 | 28 | TEST_IMM_DEST_BYP( 0, ori, 0x0ff00ff0, 0xf0f0, 0x0ff0fff0 ) 29 | TEST_IMM_DEST_BYP( 1, ori, 0x00ff00ff, 0x0f0f, 0x00ff0fff ) 30 | TEST_IMM_DEST_BYP( 2, ori, 0xf00ff00f, 0xf0f0, 0xf00ff0ff ) 31 | TEST_IMM_DEST_BYP( 3, ori, 0xf0f0f0f0, 0xff00, 0xf0f0fff0 ) 32 | TEST_IMM_DEST_BYP( 4, ori, 0x0f0f0f0f, 0x00ff, 0x0f0f0fff ) 33 | 34 | TEST_IMM_SRC0_BYP( 0, ori, 0x0ff00ff0, 0xf0f0, 0x0ff0fff0 ) 35 | TEST_IMM_SRC0_BYP( 1, ori, 0x00ff00ff, 0x0f0f, 0x00ff0fff ) 36 | TEST_IMM_SRC0_BYP( 2, ori, 0xf00ff00f, 0xf0f0, 0xf00ff0ff ) 37 | TEST_IMM_SRC0_BYP( 3, ori, 0xf0f0f0f0, 0xff00, 0xf0f0fff0 ) 38 | TEST_IMM_SRC0_BYP( 4, ori, 0x0f0f0f0f, 0x00ff, 0x0f0f0fff ) 39 | 40 | TEST_MT_END 41 | 42 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-simple.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-simple.S 3 | //======================================================================== 4 | // We want to make sure our basic test macros are working. 5 | 6 | #include "mt-macros.h" 7 | 8 | TEST_MT_BEGIN 9 | 10 | //-------------------------------------------------------------------- 11 | // 1 + 1 = 2 12 | //-------------------------------------------------------------------- 13 | // You can try forcing a failure by changing the expected value in 14 | // the following two TEST_CHECK_EQ macros. Try making one, the 15 | // other, and both fail and observe which line number is reported as 16 | // failing. 17 | 18 | li $2, 1 19 | addiu $3, $2, 1 20 | 21 | mfc0 $10, $c0_coreid 22 | bne $10, $0, notcore0 23 | 24 | TEST_CHECK_EQ( $3, 2 ) 25 | 26 | j converge 27 | 28 | notcore0: 29 | 30 | TEST_CHECK_EQ( $3, 2 ) 31 | 32 | converge: 33 | 34 | //-------------------------------------------------------------------- 35 | // 1 + 2 = 3 36 | //-------------------------------------------------------------------- 37 | 38 | li $2, 1 39 | addiu $3, $2, 2 40 | TEST_CHECK_EQ( $3, 3 ) 41 | 42 | TEST_MT_END 43 | 44 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt-xori.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // mt-xori 3 | //======================================================================== 4 | 5 | #include "mt-macros.h" 6 | 7 | TEST_MT_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Logical tests 11 | //-------------------------------------------------------------------- 12 | 13 | TEST_IMM_OP( xori, 0xff00ff00, 0x0f0f, 0xff00f00f ) 14 | TEST_IMM_OP( xori, 0x0ff00ff0, 0xf0f0, 0x0ff0ff00 ) 15 | TEST_IMM_OP( xori, 0x00ff00ff, 0x0f0f, 0x00ff0ff0 ) 16 | TEST_IMM_OP( xori, 0xf00ff00f, 0xf0f0, 0xf00f00ff ) 17 | 18 | //-------------------------------------------------------------------- 19 | // Source/Destination tests 20 | //-------------------------------------------------------------------- 21 | 22 | TEST_IMM_SRC0_EQ_DEST( xori, 0xff00ff00, 0x0f0f, 0xff00f00f ) 23 | 24 | //-------------------------------------------------------------------- 25 | // Bypassing tests 26 | //-------------------------------------------------------------------- 27 | 28 | TEST_IMM_DEST_BYP( 0, xori, 0x0ff00ff0, 0xf0f0, 0x0ff0ff00 ) 29 | TEST_IMM_DEST_BYP( 1, xori, 0x00ff00ff, 0x0f0f, 0x00ff0ff0 ) 30 | TEST_IMM_DEST_BYP( 2, xori, 0xf00ff00f, 0xf0f0, 0xf00f00ff ) 31 | TEST_IMM_DEST_BYP( 3, xori, 0xf0f0f0f0, 0xff00, 0xf0f00ff0 ) 32 | TEST_IMM_DEST_BYP( 4, xori, 0x0f0f0f0f, 0x00ff, 0x0f0f0ff0 ) 33 | 34 | TEST_IMM_SRC0_BYP( 0, xori, 0x0ff00ff0, 0xf0f0, 0x0ff0ff00 ) 35 | TEST_IMM_SRC0_BYP( 1, xori, 0x00ff00ff, 0x0f0f, 0x00ff0ff0 ) 36 | TEST_IMM_SRC0_BYP( 2, xori, 0xf00ff00f, 0xf0f0, 0xf00f00ff ) 37 | TEST_IMM_SRC0_BYP( 3, xori, 0xf0f0f0f0, 0xff00, 0xf0f00ff0 ) 38 | TEST_IMM_SRC0_BYP( 4, xori, 0x0f0f0f0f, 0x00ff, 0x0f0f0ff0 ) 39 | 40 | TEST_MT_END 41 | 42 | -------------------------------------------------------------------------------- /parc/asm_tests/mt/mt.mk: -------------------------------------------------------------------------------- 1 | #========================================================================= 2 | # mt.mk 3 | #========================================================================= 4 | 5 | # Very simple tests 6 | mt_srcs += \ 7 | mt-simple.S \ 8 | 9 | # Immediate instructions 10 | mt_srcs += \ 11 | mt-addiu.S \ 12 | mt-andi.S \ 13 | mt-ori.S \ 14 | mt-xori.S \ 15 | mt-lui.S \ 16 | 17 | # Basic arithmetic and logic instructions 18 | mt_srcs += \ 19 | mt-addu.S \ 20 | mt-subu.S \ 21 | mt-and.S \ 22 | mt-or.S \ 23 | mt-nor.S \ 24 | mt-xor.S \ 25 | 26 | # Shift instructions 27 | mt_srcs += \ 28 | mt-sll.S \ 29 | mt-sra.S \ 30 | mt-srl.S \ 31 | mt-sllv.S \ 32 | mt-srav.S \ 33 | mt-srlv.S \ 34 | 35 | # Comparison instructions 36 | mt_srcs += \ 37 | mt-slt.S \ 38 | mt-sltu.S \ 39 | mt-slti.S \ 40 | mt-sltiu.S \ 41 | 42 | # Branch instructions 43 | mt_srcs += \ 44 | mt-beq.S \ 45 | mt-bne.S \ 46 | mt-bgez.S \ 47 | mt-bgtz.S \ 48 | mt-blez.S \ 49 | mt-bltz.S \ 50 | 51 | # Jump instructions 52 | mt_srcs += \ 53 | mt-j.S \ 54 | mt-jr.S \ 55 | mt-jal.S \ 56 | mt-jalr.S \ 57 | 58 | # Load instructions 59 | mt_srcs += \ 60 | mt-lw.S \ 61 | mt-lhu.S \ 62 | mt-lbu.S \ 63 | mt-lh.S \ 64 | mt-lb.S \ 65 | 66 | # Conditional move instructions 67 | #mt_srcs += \ 68 | # mt-movz.S \ 69 | # mt-movn.S \ 70 | 71 | # Multiply and divide instructions 72 | mt_srcs += \ 73 | mt-mul.S \ 74 | mt-div.S \ 75 | mt-divu.S \ 76 | mt-rem.S \ 77 | mt-remu.S \ 78 | 79 | # Atomic ops 80 | mt_srcs += \ 81 | mt-amo-or.S \ 82 | mt-amo-and.S \ 83 | mt-amo-add.S \ 84 | mt-amo-xchg.S \ 85 | mt-amo-min.S \ 86 | 87 | 88 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv1/parcv1-jal.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv1-jal.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Basic test 11 | //----------------------------------------------------------------- 12 | 13 | test: 14 | li $29, __LINE__ 15 | li $31, 0 16 | 17 | linkaddr: 18 | jal target 19 | nop 20 | nop 21 | 22 | j _fail 23 | 24 | target: 25 | la $2, linkaddr 26 | addiu $2, $2, 4 27 | bne $2, $31, _fail 28 | 29 | 30 | // Test that there is no branch delay slot 31 | 32 | li $2, 1 33 | jal 1f 34 | addiu $2, 1 35 | addiu $2, 1 36 | addiu $2, 1 37 | addiu $2, 1 38 | 1: addiu $2, 1 39 | addiu $2, 1 40 | TEST_CHECK_EQ( $2, 3 ) 41 | 42 | TEST_PARC_END 43 | 44 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv1/parcv1-jr.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv1-jr.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Basic test 11 | //----------------------------------------------------------------- 12 | 13 | test: 14 | li $29, __LINE__ 15 | li $31, 0 16 | la $3, target 17 | 18 | linkaddr: 19 | jr $3 20 | nop 21 | nop 22 | 23 | j _fail 24 | 25 | target: 26 | 27 | //----------------------------------------------------------------- 28 | // Bypassing tests 29 | //----------------------------------------------------------------- 30 | 31 | TEST_JR_SRC0_BYP( 0, jr ) 32 | TEST_JR_SRC0_BYP( 1, jr ) 33 | TEST_JR_SRC0_BYP( 2, jr ) 34 | 35 | // Test that there is no branch delay slot 36 | 37 | li $2, 1 38 | la $3, 1f 39 | jr $3 40 | addiu $2, 1 41 | addiu $2, 1 42 | addiu $2, 1 43 | addiu $2, 1 44 | 1: addiu $2, 1 45 | addiu $2, 1 46 | TEST_CHECK_EQ( $2, 3 ) 47 | 48 | TEST_PARC_END 49 | 50 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv1/parcv1-lui.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv1-lui.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Basic tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_LUI_OP( lui, 0x0000, 0x00000000 ) 14 | TEST_LUI_OP( lui, 0xffff, 0xffff0000 ) 15 | TEST_LUI_OP( lui, 0x7fff, 0x7fff0000 ) 16 | TEST_LUI_OP( lui, 0x8000, 0x80000000 ) 17 | 18 | //---------------------------------------------------------------- 19 | // Bypassing tests 20 | //---------------------------------------------------------------- 21 | 22 | TEST_LUI_DEST_BYP( 0, lui, 0xffff, 0xffff0000 ) 23 | TEST_LUI_DEST_BYP( 1, lui, 0x7fff, 0x7fff0000 ) 24 | TEST_LUI_DEST_BYP( 2, lui, 0x8000, 0x80000000 ) 25 | 26 | TEST_PARC_END 27 | 28 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv1/parcv1-ori.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv1-ori.S 3 | //========================================================================= 4 | 5 | 6 | #include "parc-macros.h" 7 | 8 | TEST_PARC_BEGIN 9 | 10 | //------------------------------------------------------------- 11 | // Logical tests 12 | //------------------------------------------------------------- 13 | 14 | TEST_IMM_OP( ori, 0xff00ff00, 0x0f0f, 0xff00ff0f ) 15 | TEST_IMM_OP( ori, 0x0ff00ff0, 0xf0f0, 0x0ff0fff0 ) 16 | TEST_IMM_OP( ori, 0x00ff00ff, 0x0f0f, 0x00ff0fff ) 17 | TEST_IMM_OP( ori, 0xf00ff00f, 0xf0f0, 0xf00ff0ff ) 18 | 19 | //------------------------------------------------------------- 20 | // Source/Destination tests 21 | //------------------------------------------------------------- 22 | 23 | TEST_IMM_SRC0_EQ_DEST( ori, 0xff00ff00, 0xf0f0, 0xff00fff0 ) 24 | 25 | //------------------------------------------------------------- 26 | // Bypassing tests 27 | //------------------------------------------------------------- 28 | 29 | TEST_IMM_DEST_BYP( 0, ori, 0x0ff00ff0, 0xf0f0, 0x0ff0fff0 ); 30 | TEST_IMM_DEST_BYP( 1, ori, 0x00ff00ff, 0x0f0f, 0x00ff0fff ); 31 | TEST_IMM_DEST_BYP( 2, ori, 0xf00ff00f, 0xf0f0, 0xf00ff0ff ); 32 | 33 | TEST_IMM_SRC0_BYP( 0, ori, 0x0ff00ff0, 0xf0f0, 0x0ff0fff0 ); 34 | TEST_IMM_SRC0_BYP( 1, ori, 0x00ff00ff, 0x0f0f, 0x00ff0fff ); 35 | TEST_IMM_SRC0_BYP( 2, ori, 0xf00ff00f, 0xf0f0, 0xf00ff0ff ); 36 | 37 | TEST_PARC_END 38 | 39 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv1/parcv1.mk: -------------------------------------------------------------------------------- 1 | #========================================================================= 2 | # parcv1.mk 3 | #========================================================================= 4 | 5 | parcv1_srcs += \ 6 | parcv1-addiu.S \ 7 | parcv1-ori.S \ 8 | parcv1-lui.S \ 9 | parcv1-bne.S \ 10 | parcv1-addu.S \ 11 | parcv1-lw.S \ 12 | parcv1-sw.S \ 13 | parcv1-jal.S \ 14 | parcv1-jr.S \ 15 | 16 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2-andi.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv2-andi.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Logical tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_IMM_OP( andi, 0xff00ff00, 0x0f0f, 0x00000f00 ) 14 | TEST_IMM_OP( andi, 0x0ff00ff0, 0xf0f0, 0x000000f0 ) 15 | TEST_IMM_OP( andi, 0x00ff00ff, 0x0f0f, 0x0000000f ) 16 | TEST_IMM_OP( andi, 0xf00ff00f, 0xf0f0, 0x0000f000 ) 17 | 18 | //----------------------------------------------------------------- 19 | // Source/Destination tests 20 | //----------------------------------------------------------------- 21 | 22 | TEST_IMM_SRC0_EQ_DEST( andi, 0xff00ff00, 0xf0f0, 0x0000f000 ) 23 | 24 | //----------------------------------------------------------------- 25 | // Bypassing tests 26 | //----------------------------------------------------------------- 27 | 28 | TEST_IMM_DEST_BYP( 0, andi, 0x0ff00ff0, 0x0f0f, 0x00000f00 ) 29 | TEST_IMM_DEST_BYP( 1, andi, 0x00ff00ff, 0xf0f0, 0x000000f0 ) 30 | TEST_IMM_DEST_BYP( 2, andi, 0xf00ff00f, 0x0f0f, 0x0000000f ) 31 | 32 | TEST_IMM_SRC0_BYP( 0, andi, 0x0ff00ff0, 0x0f0f, 0x00000f00 ) 33 | TEST_IMM_SRC0_BYP( 1, andi, 0x00ff00ff, 0xf0f0, 0x000000f0 ) 34 | TEST_IMM_SRC0_BYP( 2, andi, 0xf00ff00f, 0x0f0f, 0x0000000f ) 35 | 36 | TEST_PARC_END 37 | 38 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2-bgez.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv2-bgez.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Branch tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_BR1_OP_TAKEN( bgez, 0 ) 14 | TEST_BR1_OP_TAKEN( bgez, 1 ) 15 | 16 | TEST_BR1_OP_NOTTAKEN( bgez, -1 ) 17 | TEST_BR1_OP_NOTTAKEN( bgez, -10 ) 18 | 19 | //----------------------------------------------------------------- 20 | // Bypassing tests 21 | //----------------------------------------------------------------- 22 | 23 | TEST_BR1_SRC0_BYP( 0, bgez, -1 ) 24 | TEST_BR1_SRC0_BYP( 1, bgez, -1 ) 25 | TEST_BR1_SRC0_BYP( 2, bgez, -1 ) 26 | 27 | //----------------------------------------------------------------- 28 | // Test that there is no branch delay slot 29 | //----------------------------------------------------------------- 30 | 31 | li $2, 1 32 | bgez $0, 1f 33 | addiu $2, 1 34 | addiu $2, 1 35 | addiu $2, 1 36 | addiu $2, 1 37 | 1: addiu $2, 1 38 | addiu $2, 1 39 | TEST_CHECK_EQ( $2, 3 ) 40 | 41 | TEST_PARC_END 42 | 43 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2-bgtz.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv2-bgtz.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Branch tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_BR1_OP_TAKEN( bgtz, 1 ); 14 | TEST_BR1_OP_TAKEN( bgtz, 10 ); 15 | 16 | TEST_BR1_OP_NOTTAKEN( bgtz, 0 ); 17 | TEST_BR1_OP_NOTTAKEN( bgtz, -1 ); 18 | 19 | //----------------------------------------------------------------- 20 | // Bypassing tests 21 | //----------------------------------------------------------------- 22 | 23 | TEST_BR1_SRC0_BYP( 0, bgtz, -1 ); 24 | TEST_BR1_SRC0_BYP( 1, bgtz, -1 ); 25 | TEST_BR1_SRC0_BYP( 2, bgtz, -1 ); 26 | 27 | //----------------------------------------------------------------- 28 | // Test that there is no branch delay slot 29 | //----------------------------------------------------------------- 30 | 31 | li $2, 1 32 | bgtz $2, 1f 33 | addiu $2, 1 34 | addiu $2, 1 35 | addiu $2, 1 36 | addiu $2, 1 37 | 1: addiu $2, 1 38 | addiu $2, 1 39 | TEST_CHECK_EQ( $2, 3 ) 40 | 41 | TEST_PARC_END 42 | 43 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2-blez.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv2-blez.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Branch tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_BR1_OP_TAKEN( blez, 0 ) 14 | TEST_BR1_OP_TAKEN( blez, -1 ) 15 | 16 | TEST_BR1_OP_NOTTAKEN( blez, 1 ) 17 | TEST_BR1_OP_NOTTAKEN( blez, 10 ) 18 | 19 | //----------------------------------------------------------------- 20 | // Bypassing tests 21 | //----------------------------------------------------------------- 22 | 23 | TEST_BR1_SRC0_BYP( 0, blez, 1 ) 24 | TEST_BR1_SRC0_BYP( 1, blez, 1 ) 25 | TEST_BR1_SRC0_BYP( 2, blez, 1 ) 26 | 27 | //----------------------------------------------------------------- 28 | // Test that there is no branch delay slot 29 | //----------------------------------------------------------------- 30 | 31 | li $2, 1 32 | blez $0, 1f 33 | addiu $2, 1 34 | addiu $2, 1 35 | addiu $2, 1 36 | addiu $2, 1 37 | 1: addiu $2, 1 38 | addiu $2, 1 39 | TEST_CHECK_EQ( $2, 3 ) 40 | 41 | TEST_PARC_END 42 | 43 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2-bltz.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv2-bltz.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Branch tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_BR1_OP_TAKEN( bltz, -1 ) 14 | TEST_BR1_OP_TAKEN( bltz, -10 ) 15 | 16 | TEST_BR1_OP_NOTTAKEN( bltz, 0 ) 17 | TEST_BR1_OP_NOTTAKEN( bltz, 1 ) 18 | 19 | //----------------------------------------------------------------- 20 | // Bypassing tests 21 | //----------------------------------------------------------------- 22 | 23 | TEST_BR1_SRC0_BYP( 0, bltz, 1 ) 24 | TEST_BR1_SRC0_BYP( 1, bltz, 1 ) 25 | TEST_BR1_SRC0_BYP( 2, bltz, 1 ) 26 | 27 | //----------------------------------------------------------------- 28 | // Test that there is no branch delay slot 29 | //----------------------------------------------------------------- 30 | 31 | li $2, 1 32 | li $3, -1 33 | bltz $3, 1f 34 | addiu $2, 1 35 | addiu $2, 1 36 | addiu $2, 1 37 | addiu $2, 1 38 | 1: addiu $2, 1 39 | addiu $2, 1 40 | TEST_CHECK_EQ( $2, 3 ) 41 | 42 | TEST_PARC_END 43 | 44 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2-j.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv2-j.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Basic test 11 | //----------------------------------------------------------------- 12 | 13 | li $29, __LINE__ 14 | j test_0 15 | j _fail 16 | test_0: 17 | 18 | //----------------------------------------------------------------- 19 | // Test that there is no branch delay slot 20 | //----------------------------------------------------------------- 21 | 22 | li $2, 1 23 | j 1f 24 | addiu $2, 1 25 | addiu $2, 1 26 | addiu $2, 1 27 | addiu $2, 1 28 | 1: addiu $2, 1 29 | addiu $2, 1 30 | TEST_CHECK_EQ( $2, 3 ) 31 | 32 | //----------------------------------------------------------------- 33 | // Test a jump to PC+4 34 | //----------------------------------------------------------------- 35 | 36 | li $29, __LINE__ 37 | j test_1 38 | test_1: 39 | addiu $2, 1 40 | TEST_CHECK_EQ( $2, 4 ) 41 | 42 | TEST_PARC_END 43 | 44 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2-mfc0.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // parcv2-mfc0.S 3 | //======================================================================== 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //-------------------------------------------------------------------- 10 | // Basic test 11 | //-------------------------------------------------------------------- 12 | 13 | li $2, 7 14 | mfc0 $2, $c0_coreid 15 | TEST_CHECK_EQ( $2, 0x0 ) 16 | 17 | //-------------------------------------------------------------------- 18 | // Bypassing tests 19 | //-------------------------------------------------------------------- 20 | 21 | li $2, 7 22 | mfc0 $2, $c0_coreid 23 | addiu $2, 0 24 | TEST_CHECK_EQ( $2, 0x0 ) 25 | 26 | li $2, 7 27 | mfc0 $2, $c0_coreid 28 | TEST_INSERT_NOPS( 1 ) 29 | addiu $2, 0 30 | TEST_CHECK_EQ( $2, 0x0 ) 31 | 32 | li $2, 7 33 | mfc0 $2, $c0_coreid 34 | TEST_INSERT_NOPS( 2 ) 35 | addiu $2, 0 36 | TEST_CHECK_EQ( $2, 0x0 ) 37 | 38 | li $2, 7 39 | mfc0 $2, $c0_coreid 40 | TEST_INSERT_NOPS( 3 ) 41 | addiu $2, 0 42 | TEST_CHECK_EQ( $2, 0x0 ) 43 | 44 | li $2, 7 45 | mfc0 $2, $c0_coreid 46 | TEST_INSERT_NOPS( 4 ) 47 | addiu $2, 0 48 | TEST_CHECK_EQ( $2, 0x0 ) 49 | 50 | TEST_PARC_END 51 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2-xori.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv2-xori.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Logical tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_IMM_OP( xori, 0xff00ff00, 0x0f0f, 0xff00f00f ) 14 | TEST_IMM_OP( xori, 0x0ff00ff0, 0xf0f0, 0x0ff0ff00 ) 15 | TEST_IMM_OP( xori, 0x00ff00ff, 0x0f0f, 0x00ff0ff0 ) 16 | TEST_IMM_OP( xori, 0xf00ff00f, 0xf0f0, 0xf00f00ff ) 17 | 18 | //----------------------------------------------------------------- 19 | // Source/Destination tests 20 | //----------------------------------------------------------------- 21 | 22 | TEST_IMM_SRC0_EQ_DEST( xori, 0xff00ff00, 0x0f0f, 0xff00f00f ) 23 | 24 | //----------------------------------------------------------------- 25 | // Bypassing tests 26 | //----------------------------------------------------------------- 27 | 28 | TEST_IMM_DEST_BYP( 0, xori, 0x0ff00ff0, 0xf0f0, 0x0ff0ff00 ) 29 | TEST_IMM_DEST_BYP( 1, xori, 0x00ff00ff, 0x0f0f, 0x00ff0ff0 ) 30 | TEST_IMM_DEST_BYP( 2, xori, 0xf00ff00f, 0xf0f0, 0xf00f00ff ) 31 | 32 | TEST_IMM_SRC0_BYP( 0, xori, 0x0ff00ff0, 0xf0f0, 0x0ff0ff00 ) 33 | TEST_IMM_SRC0_BYP( 1, xori, 0x00ff00ff, 0x0f0f, 0x00ff0ff0 ) 34 | TEST_IMM_SRC0_BYP( 2, xori, 0xf00ff00f, 0xf0f0, 0xf00f00ff ) 35 | 36 | TEST_PARC_END 37 | 38 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv2/parcv2.mk: -------------------------------------------------------------------------------- 1 | #========================================================================= 2 | # parcv2.mk 3 | #========================================================================= 4 | 5 | parcv2_srcs += \ 6 | parcv2-andi.S \ 7 | parcv2-xori.S \ 8 | parcv2-slti.S \ 9 | parcv2-sltiu.S \ 10 | parcv2-sll.S \ 11 | parcv2-srl.S \ 12 | parcv2-sra.S \ 13 | parcv2-subu.S \ 14 | parcv2-and.S \ 15 | parcv2-or.S \ 16 | parcv2-xor.S \ 17 | parcv2-nor.S \ 18 | parcv2-slt.S \ 19 | parcv2-sltu.S \ 20 | parcv2-sllv.S \ 21 | parcv2-srlv.S \ 22 | parcv2-srav.S \ 23 | parcv2-lh.S \ 24 | parcv2-lhu.S \ 25 | parcv2-lb.S \ 26 | parcv2-lbu.S \ 27 | parcv2-sh.S \ 28 | parcv2-sb.S \ 29 | parcv2-beq.S \ 30 | parcv2-blez.S \ 31 | parcv2-bgez.S \ 32 | parcv2-bltz.S \ 33 | parcv2-bgtz.S \ 34 | parcv2-j.S \ 35 | parcv2-jalr.S \ 36 | parcv2-mul.S \ 37 | parcv2-div.S \ 38 | parcv2-divu.S \ 39 | parcv2-rem.S \ 40 | parcv2-remu.S \ 41 | parcv2-mfc0.S \ 42 | 43 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-cvt-s-w.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv3-cvt-s-w.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Basic tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_RR_OP1( cvt.s.w, 0x4372a3d5, 0x4e86e548 ) 14 | TEST_RR_OP1( cvt.s.w, 0x7474211a, 0x4ee8e842 ) 15 | TEST_RR_OP1( cvt.s.w, 0x712ce9e3, 0x4ee259d4 ) 16 | TEST_RR_OP1( cvt.s.w, 0x6148c087, 0x4ec29181 ) 17 | TEST_RR_OP1( cvt.s.w, 0x1020a2a3, 0x4d810515 ) 18 | TEST_RR_OP1( cvt.s.w, 0x35a8f903, 0x4e56a3e4 ) 19 | TEST_RR_OP1( cvt.s.w, 0x3024509c, 0x4e409142 ) 20 | TEST_RR_OP1( cvt.s.w, 0x34af471f, 0x4e52bd1c ) 21 | TEST_RR_OP1( cvt.s.w, 0x35aec62b, 0x4e56bb19 ) 22 | TEST_RR_OP1( cvt.s.w, 0x2ecd0cab, 0x4e3b3433 ) 23 | TEST_RR_OP1( cvt.s.w, 0x4938474c, 0x4e92708f ) 24 | TEST_RR_OP1( cvt.s.w, 0x6953f15b, 0x4ed2a7e3 ) 25 | TEST_RR_OP1( cvt.s.w, 0x76dde468, 0x4eedbbc9 ) 26 | TEST_RR_OP1( cvt.s.w, 0x02e0e165, 0x4c383859 ) 27 | TEST_RR_OP1( cvt.s.w, 0x3f84ea01, 0x4e7e13a8 ) 28 | TEST_RR_OP1( cvt.s.w, 0x129701ad, 0x4d94b80d ) 29 | 30 | TEST_PARC_END 31 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-cvt-w-s.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv3-cvt-w-s.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Basic tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_RR_OP1( cvt.w.s, 0xceb81b59, 0xa3f25380 ) 14 | TEST_RR_OP1( cvt.w.s, 0x4edbd694, 0x6deb4a00 ) 15 | TEST_RR_OP1( cvt.w.s, 0xcbdcaba4, 0xfe46a8b8 ) 16 | TEST_RR_OP1( cvt.w.s, 0xcef782c3, 0x843e9e80 ) 17 | TEST_RR_OP1( cvt.w.s, 0x4e49a70e, 0x3269c380 ) 18 | TEST_RR_OP1( cvt.w.s, 0x4ec737ee, 0x639bf700 ) 19 | TEST_RR_OP1( cvt.w.s, 0xceeb438e, 0x8a5e3900 ) 20 | TEST_RR_OP1( cvt.w.s, 0x4d702eb0, 0x0f02eb00 ) 21 | TEST_RR_OP1( cvt.w.s, 0x4ed09953, 0x684ca980 ) 22 | TEST_RR_OP1( cvt.w.s, 0xcdd2e959, 0xe5a2d4e0 ) 23 | TEST_RR_OP1( cvt.w.s, 0xce576337, 0xca273240 ) 24 | TEST_RR_OP1( cvt.w.s, 0xce34724e, 0xd2e36c80 ) 25 | TEST_RR_OP1( cvt.w.s, 0xcef29d11, 0x86b17780 ) 26 | TEST_RR_OP1( cvt.w.s, 0xcea9b70b, 0xab247a80 ) 27 | TEST_RR_OP1( cvt.w.s, 0x4ef26b78, 0x7935bc00 ) 28 | TEST_RR_OP1( cvt.w.s, 0xcc30dba0, 0xfd3c9180 ) 29 | 30 | TEST_PARC_END 31 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-gcd.S: -------------------------------------------------------------------------------- 1 | //========================================================================= 2 | // parcv3-gcd.S 3 | //========================================================================= 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | //----------------------------------------------------------------- 10 | // Arithmetic tests 11 | //----------------------------------------------------------------- 12 | 13 | TEST_RR_OP( subu.xi, 100, 24, 4 ) 14 | TEST_RR_OP( subu.xi, 15, 5, 5 ) 15 | TEST_RR_OP( subu.xi, 5, 15, 5 ) 16 | TEST_RR_OP( subu.xi, 7, 13, 1 ) 17 | 18 | //----------------------------------------------------------------- 19 | // Source/Destination tests 20 | //----------------------------------------------------------------- 21 | 22 | TEST_RR_SRC0_EQ_DEST( subu.xi, 100, 24, 4 ) 23 | TEST_RR_SRC1_EQ_DEST( subu.xi, 75, 45, 15 ) 24 | 25 | //----------------------------------------------------------------- 26 | // Bypassing tests 27 | //----------------------------------------------------------------- 28 | 29 | TEST_RR_DEST_BYP( 0, subu.xi, 100, 24, 4 ) 30 | TEST_RR_DEST_BYP( 1, subu.xi, 100, 24, 4 ) 31 | TEST_RR_DEST_BYP( 2, subu.xi, 100, 24, 4 ) 32 | 33 | TEST_PARC_END 34 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-movn.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // parcv3-movn.S 3 | //======================================================================== 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | li $2, 0 10 | li $3, 0xdeadbeef 11 | li $4, 0xffffffff 12 | movn $4, $3, $2 13 | TEST_CHECK_EQ( $4, 0xffffffff ) 14 | 15 | li $2, 1 16 | movn $4, $3, $2 17 | TEST_CHECK_EQ( $4, 0xdeadbeef ) 18 | 19 | TEST_PARC_END 20 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-movz.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // parcv3-movz.S 3 | //======================================================================== 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | li $2, 1 10 | li $3, 0xdeadbeef 11 | li $4, 0xffffffff 12 | movz $4, $3, $2 13 | TEST_CHECK_EQ( $4, 0xffffffff ) 14 | 15 | li $2, 0 16 | movz $4, $3, $2 17 | TEST_CHECK_EQ( $4, 0xdeadbeef ) 18 | 19 | TEST_PARC_END 20 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-scan.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // tloops-scan.S 3 | //======================================================================== 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | // Test a simple loop with only integer operations 10 | 11 | // add dummy instructions to fit in cache line and not induce a primary 12 | // miss 13 | li $2, 0 14 | li $3, 0 15 | li $4, 5 16 | li $2, 0 17 | li $2, 0 18 | li $3, 0 19 | li $3, 0 20 | la $5, tdata_4 21 | 22 | // lw instruction feeds a instruction in for loop body 23 | lw $5, 0($5) 24 | j l 25 | 1: lw $6, 0($5) 26 | addu $3, $3, $2 27 | //addiu $3, $3, 2 28 | //addiu $2, $2, 1 29 | //mul $6, $6, $2 30 | l: for.u $2, $4, 1b 31 | j _pass 32 | TEST_PARC_END 33 | 34 | //------------------------------------------------------------------------ 35 | // Test data 36 | //------------------------------------------------------------------------ 37 | 38 | .data 39 | .align 4 40 | 41 | tdata_0: .word 0x00000001 42 | tdata_1: .word 0x00000001 43 | tdata_2: .word 0x00000001 44 | tdata_3: .word 0x00000001 45 | tdata_4: .word 0x00000001 46 | 47 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-syscall.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // parcv3-syscall.S 3 | //======================================================================== 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_XCPT_BEGIN 8 | 9 | //---------------------------------------------------------------- 10 | // Configure exception handler 11 | //---------------------------------------------------------------- 12 | 13 | li $k0, 1 14 | eret 15 | 16 | TEST_XCPT_END 17 | 18 | TEST_PARC_BEGIN 19 | 20 | //---------------------------------------------------------------- 21 | // Basic test 22 | //---------------------------------------------------------------- 23 | 24 | li $k0, 0 25 | syscall 26 | TEST_CHECK_EQ( $k0, 1 ) 27 | 28 | TEST_PARC_END 29 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-vecincr.S: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // parcv3-vecincr.S 3 | //======================================================================== 4 | 5 | #include "parc-macros.h" 6 | 7 | TEST_PARC_BEGIN 8 | 9 | li $8, 8 // length 10 | la $9, tdata_0 // start_addr 11 | subu.xi $10, $9, $8 // call vecincr 12 | 13 | TEST_CHECK_EQ( $8, $10 ) // check if all elements were visited 14 | 15 | la $11, tdata_8 16 | 1: 17 | lw $12, 0($9) // load value 18 | lw $13, 0($11) // load ref 19 | TEST_CHECK_EQ( $12, $13 ) 20 | addiu $9, $9, 4 21 | addiu $11, $11, 4 22 | addiu $8, $8, -1 23 | bnez $8, 1b 24 | j _pass 25 | 26 | TEST_PARC_END 27 | 28 | //------------------------------------------------------------------------ 29 | // Test data 30 | //------------------------------------------------------------------------ 31 | 32 | .data 33 | .align 4 34 | 35 | tdata_0: .word 0x00000001 36 | tdata_1: .word 0x00000002 37 | tdata_2: .word 0x00000003 38 | tdata_3: .word 0x00000004 39 | tdata_4: .word 0x00000005 40 | tdata_5: .word 0x00000006 41 | tdata_6: .word 0x00000007 42 | tdata_7: .word 0x00000008 43 | 44 | tdata_8: .word 0x00000002 45 | tdata_9: .word 0x00000003 46 | tdata_10: .word 0x00000004 47 | tdata_11: .word 0x00000005 48 | tdata_12: .word 0x00000006 49 | tdata_13: .word 0x00000007 50 | tdata_14: .word 0x00000008 51 | tdata_15: .word 0x00000009 52 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3-write.S: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // parcv3-write.S 3 | //------------------------------------------------------------------------ 4 | // Test the write syscall by printing out "Hello, World!". 5 | 6 | #include "parc-macros.h" 7 | 8 | TEST_PARC_BEGIN 9 | 10 | //---------------------------------------------------------------- 11 | // Basic test 12 | //---------------------------------------------------------------- 13 | 14 | li $v0, 3 15 | li $a0, 1 16 | la $a1, tdata0 17 | li $a2, 14 18 | syscall 19 | li $v0, 1 20 | syscall 21 | 22 | TEST_PARC_END 23 | 24 | //---------------------------------------------------------------- 25 | // Test data 26 | //---------------------------------------------------------------- 27 | 28 | .data 29 | .align 4 30 | 31 | tdata0: .word 0x6c6c6548 32 | tdata1: .word 0x57202c6f 33 | tdata2: .word 0x646c726f 34 | tdata3: .word 0x00000a21 35 | 36 | -------------------------------------------------------------------------------- /parc/asm_tests/parcv3/parcv3.mk: -------------------------------------------------------------------------------- 1 | #========================================================================= 2 | # parcv3.mk 3 | #========================================================================= 4 | 5 | parcv3_srcs += \ 6 | parcv3-syscall.S \ 7 | parcv3-amo-add.S \ 8 | parcv3-amo-and.S \ 9 | parcv3-amo-or.S \ 10 | parcv3-amo-xchg.S \ 11 | parcv3-amo-min.S \ 12 | parcv3-movn.S \ 13 | parcv3-movz.S \ 14 | parcv3-add-s.S \ 15 | parcv3-sub-s.S \ 16 | parcv3-mul-s.S \ 17 | parcv3-div-s.S \ 18 | parcv3-c-eq-s.S \ 19 | parcv3-c-lt-s.S \ 20 | parcv3-c-le-s.S \ 21 | parcv3-cvt-w-s.S \ 22 | parcv3-cvt-s-w.S \ 23 | 24 | # parcv3-gcd.S \ 25 | # parcv3-vecincr.S \ 26 | # parcv3-scan.S \ 27 | # parcv3-write.S \ 28 | # parcv3-fstat.S \ 29 | # 30 | -------------------------------------------------------------------------------- /parc/asm_tests/scripts/mk-install-dirs.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | # $Id: mkinstalldirs,v 1.1 2003/09/09 22:24:03 mhampton Exp $ 8 | 9 | errstatus=0 10 | 11 | for file 12 | do 13 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 | shift 15 | 16 | pathcomp= 17 | for d 18 | do 19 | pathcomp="$pathcomp$d" 20 | case "$pathcomp" in 21 | -* ) pathcomp=./$pathcomp ;; 22 | esac 23 | 24 | if test ! -d "$pathcomp"; then 25 | echo "mkdir $pathcomp" 1>&2 26 | 27 | mkdir "$pathcomp" || lasterr=$? 28 | 29 | if test ! -d "$pathcomp"; then 30 | errstatus=$lasterr 31 | fi 32 | fi 33 | 34 | pathcomp="$pathcomp/" 35 | done 36 | done 37 | 38 | exit $errstatus 39 | 40 | # mkinstalldirs ends here 41 | -------------------------------------------------------------------------------- /parc/asm_tests/scripts/test.ld: -------------------------------------------------------------------------------- 1 | /*======================================================================*/ 2 | /* Proxy kernel linker script */ 3 | /*======================================================================*/ 4 | /* This is the linker script used when building the proxy kernel. */ 5 | 6 | /*----------------------------------------------------------------------*/ 7 | /* Setup */ 8 | /*----------------------------------------------------------------------*/ 9 | 10 | /* The OUTPUT_ARCH command specifies the machine architecture where the 11 | argument is one of the names used in the BFD library. More 12 | specifically one of the entires in bfd/cpu-mips.c */ 13 | 14 | OUTPUT_ARCH( "mips:maven" ) 15 | 16 | /* The ENTRY command specifies the entry point (ie. first instruction 17 | to execute). The symbol _test should be defined in each test. */ 18 | 19 | ENTRY( _test ) 20 | 21 | /*----------------------------------------------------------------------*/ 22 | /* Sections */ 23 | /*----------------------------------------------------------------------*/ 24 | 25 | SECTIONS 26 | { 27 | 28 | /* xcpthandler: exception handle */ 29 | . = 0x00800000; 30 | .xcpthandler : 31 | { 32 | *(.xcpthandler) 33 | } 34 | 35 | /* text: test code section */ 36 | . = 0x00808000; 37 | .text : 38 | { 39 | *(.text) 40 | } 41 | 42 | /* data: Initialized data segment */ 43 | .data : 44 | { 45 | *(.data) 46 | } 47 | 48 | /* End of uninitalized data segement */ 49 | _end = .; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /parc/instruction.py: -------------------------------------------------------------------------------- 1 | #======================================================================= 2 | # instruction.py 3 | #======================================================================= 4 | 5 | from pydgin.utils import r_uint 6 | 7 | class Instruction( object ): 8 | def __init__( self, bits, str ): 9 | self.bits = r_uint( bits ) 10 | self.str = str 11 | 12 | @property 13 | def rd( self ): 14 | return (self.bits >> 11) & 0x1F 15 | 16 | @property 17 | def rt( self ): 18 | return (self.bits >> 16) & 0x1F 19 | 20 | @property 21 | def rs( self ): 22 | return (self.bits >> 21) & 0x1F 23 | 24 | @property 25 | def fd( self ): 26 | return (self.bits >> 6) & 0x1F 27 | 28 | @property 29 | def ft( self ): 30 | return (self.bits >> 16) & 0x1F 31 | 32 | @property 33 | def fs( self ): 34 | return (self.bits >> 11) & 0x1F 35 | 36 | @property 37 | def imm( self ): 38 | return self.bits & 0xFFFF 39 | 40 | @property 41 | def jtarg( self ): 42 | return self.bits & 0x3FFFFFF 43 | 44 | @property 45 | def shamt( self ): 46 | return (self.bits >> 6) & 0x1F 47 | 48 | -------------------------------------------------------------------------------- /parc/machine.py: -------------------------------------------------------------------------------- 1 | #======================================================================= 2 | # machine.py 3 | #======================================================================= 4 | 5 | from pydgin.machine import Machine 6 | from pydgin.storage import RegisterFile 7 | from pydgin.utils import r_uint 8 | 9 | #----------------------------------------------------------------------- 10 | # State 11 | #----------------------------------------------------------------------- 12 | class State( Machine ): 13 | _virtualizable_ = ['pc', 'num_insts'] 14 | def __init__( self, memory, debug, reset_addr=0x400): 15 | Machine.__init__(self, memory, RegisterFile(), debug, reset_addr=reset_addr ) 16 | 17 | # parc special 18 | self.src_ptr = 0 19 | self.sink_ptr = 0 20 | 21 | # indicate if this is running a self-checking test 22 | self.testbin = False 23 | 24 | # executable name 25 | self.exe_name = "" 26 | 27 | # syscall stuff... TODO: should this be here? 28 | self.breakpoint = r_uint( 0 ) 29 | 30 | def fetch_pc( self ): 31 | return self.pc 32 | -------------------------------------------------------------------------------- /parc/utils.py: -------------------------------------------------------------------------------- 1 | #======================================================================= 2 | # utils.py 3 | #======================================================================= 4 | # PARC-specific bitwise operation utilities. 5 | 6 | #----------------------------------------------------------------------- 7 | # trim_5 8 | #----------------------------------------------------------------------- 9 | # Trim arithmetic to 5-bit values. 10 | def trim_5( value ): 11 | return value & 0b11111 12 | 13 | -------------------------------------------------------------------------------- /pydgin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cornell-brg/pydgin/30f8efa914f26dbee622ebd14d4345840a69c10c/pydgin/__init__.py -------------------------------------------------------------------------------- /pydgin/jit.py: -------------------------------------------------------------------------------- 1 | #========================================================================= 2 | # jit.py 3 | #========================================================================= 4 | # Thin wrapper for RPython jitting API. Mostly for turning jit-related 5 | # calls into no-ops when not translated and when RPython not in path. 6 | 7 | try: 8 | import rpython.rlib.jit as jit 9 | 10 | JitDriver = jit.JitDriver 11 | unroll_safe = jit.unroll_safe 12 | elidable = jit.elidable 13 | set_param = jit.set_param 14 | set_user_param = jit.set_user_param 15 | hint = jit.hint 16 | 17 | except ImportError: 18 | # rpython not in path, use dummy functions 19 | 20 | class JitDriver( object ): 21 | def __init__( self, **kwargs ): 22 | pass 23 | def jit_merge_point( self, **kwargs ): 24 | pass 25 | def can_enter_jit( self, **kwargs ): 26 | pass 27 | 28 | def dummy_decorator( func ): 29 | return func 30 | 31 | unroll_safe = dummy_decorator 32 | elidable = dummy_decorator 33 | 34 | def set_param( driver, name, value ): 35 | pass 36 | 37 | def set_user_param( driver, text ): 38 | pass 39 | 40 | def hint( x, **kwargs ): 41 | return x 42 | -------------------------------------------------------------------------------- /pydgin/machine.py: -------------------------------------------------------------------------------- 1 | #======================================================================= 2 | # machine.py 3 | #======================================================================= 4 | 5 | #----------------------------------------------------------------------- 6 | # Machine 7 | #----------------------------------------------------------------------- 8 | class Machine( object ): 9 | def __init__( self, memory, register_file, debug, reset_addr=0x400 ): 10 | 11 | self.rf = register_file 12 | self.mem = memory 13 | self.pc = reset_addr 14 | 15 | self .debug = debug 16 | self.rf .debug = debug 17 | self.mem.debug = debug 18 | 19 | # common registers 20 | self.status = 0 21 | self.stats_en = 0 22 | self.num_insts = 0 23 | self.stat_num_insts = 0 24 | 25 | # we need a dedicated running flag because status could be 0 on a 26 | # syscall_exit 27 | self.running = True 28 | 29 | def fetch_pc( self ): 30 | return self.pc 31 | -------------------------------------------------------------------------------- /riscv/.gitignore: -------------------------------------------------------------------------------- 1 | pydgin-riscv-* 2 | -------------------------------------------------------------------------------- /riscv/helpers.py: -------------------------------------------------------------------------------- 1 | from utils import trim_64 2 | 3 | def BRANCH_TARGET( s, inst ): 4 | return trim_64( s.pc + inst.sb_imm ) 5 | 6 | def JUMP_TARGET( s, inst ): 7 | return trim_64( s.pc + inst.uj_imm ) 8 | 9 | def SHAMT( s, inst ): 10 | return inst.i_imm & 0x3F 11 | 12 | class TRAP_ILLEGAL_INSTRUCTION( Exception ): 13 | pass 14 | -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | builds/ 2 | -------------------------------------------------------------------------------- /scripts/get-test-list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #========================================================================= 3 | # get-test-list.py 4 | #========================================================================= 5 | # Generates a list of tests in a directory 6 | 7 | usage = """Usage: 8 | ./get-test-list.py dir [extension] 9 | Prints the list of tests in a python-friendly fashion in dir. Extension 10 | can be specified to determine which files are tests (which will be 11 | stripped). By default, the extension is ".d".""" 12 | 13 | import os 14 | import sys 15 | 16 | if len( sys.argv ) < 2: 17 | print usage 18 | sys.exit(1) 19 | 20 | dir = sys.argv[1] 21 | ext = sys.argv[2] if len( sys.argv ) >= 3 else ".d" 22 | ext_len = len( ext ) 23 | 24 | ext_files = filter( lambda f : f.endswith( ext ), os.listdir( dir ) ) 25 | test_files = sorted( map( lambda f : f[:-ext_len], ext_files ) ) 26 | 27 | print "tests = [\n ", 28 | print ",\n ".join( map( '"{}"'.format, test_files ) ) 29 | print "]" 30 | 31 | -------------------------------------------------------------------------------- /scripts/rm_pycache.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | #======================================================================== 3 | # rm_pycache.py 4 | #======================================================================== 5 | # Utility script to remove all .pyc files and __pycache__ directories. 6 | 7 | from __future__ import print_function 8 | 9 | import os 10 | 11 | def main(): 12 | 13 | for root, dirs, files in os.walk('.'): 14 | pycaches = [os.path.join(root, x) for x in dirs if x == '__pycache__'] 15 | for i in pycaches: 16 | print( 'rm: {}'.format(i) ) 17 | os.system( 'rm -r {}'.format(i) ) 18 | 19 | for root, dirs, files in os.walk('.'): 20 | pycs = [os.path.join(root, x) for x in files if x.endswith('.pyc')] 21 | for i in pycs: 22 | print( 'rm: {}'.format(i) ) 23 | os.remove( i ) 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/8086/s_commonNaNToF32UI.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "specialize.h" 5 | 6 | /*---------------------------------------------------------------------------- 7 | | Returns the result of converting the canonical NaN `a' to the single- 8 | | precision floating-point format. 9 | *----------------------------------------------------------------------------*/ 10 | 11 | uint_fast32_t softfloat_commonNaNToF32UI( struct commonNaN a ) 12 | { 13 | 14 | return (uint_fast32_t) a.sign<<31 | 0x7FC00000 | a.v64>>41; 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/8086/s_commonNaNToF64UI.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "specialize.h" 5 | 6 | /*---------------------------------------------------------------------------- 7 | | Returns the result of converting the canonical NaN `a' to the double- 8 | | precision floating-point format. 9 | *----------------------------------------------------------------------------*/ 10 | 11 | uint_fast64_t softfloat_commonNaNToF64UI( struct commonNaN a ) 12 | { 13 | 14 | return 15 | (uint_fast64_t) a.sign<<63 | UINT64_C( 0x7FF8000000000000 ) 16 | | a.v64>>12; 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/8086/s_f32UIToCommonNaN.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "specialize.h" 5 | #include "softfloat.h" 6 | 7 | /*---------------------------------------------------------------------------- 8 | | Returns the result of converting the single-precision floating-point NaN 9 | | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid 10 | | exception is raised. 11 | *----------------------------------------------------------------------------*/ 12 | struct commonNaN softfloat_f32UIToCommonNaN( uint_fast32_t uiA ) 13 | { 14 | struct commonNaN z; 15 | 16 | if ( softfloat_isSigNaNF32UI( uiA ) ) { 17 | softfloat_raiseFlags( softfloat_flag_invalid ); 18 | } 19 | z.sign = uiA>>31; 20 | z.v64 = (uint_fast64_t) uiA<<41; 21 | z.v0 = 0; 22 | return z; 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/8086/s_f64UIToCommonNaN.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "specialize.h" 5 | #include "softfloat.h" 6 | 7 | /*---------------------------------------------------------------------------- 8 | | Returns the result of converting the double-precision floating-point NaN 9 | | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid 10 | | exception is raised. 11 | *----------------------------------------------------------------------------*/ 12 | struct commonNaN softfloat_f64UIToCommonNaN( uint_fast64_t uiA ) 13 | { 14 | struct commonNaN z; 15 | 16 | if ( softfloat_isSigNaNF64UI( uiA ) ) { 17 | softfloat_raiseFlags( softfloat_flag_invalid ); 18 | } 19 | z.sign = uiA>>63; 20 | z.v64 = uiA<<12; 21 | z.v0 = 0; 22 | return z; 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/8086/s_isSigNaNF32UI.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "specialize.h" 6 | 7 | bool softfloat_isSigNaNF32UI( uint_fast32_t ui ) 8 | { 9 | 10 | return ( ( ui>>22 & 0x1FF ) == 0x1FE ) && ( ui & 0x003FFFFF ); 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/8086/s_isSigNaNF64UI.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "specialize.h" 6 | 7 | bool softfloat_isSigNaNF64UI( uint_fast64_t ui ) 8 | { 9 | 10 | return 11 | ( ( ui>>51 & 0xFFF ) == 0xFFE ) 12 | && ( ui & UINT64_C( 0x0007FFFFFFFFFFFF ) ); 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/8086/softfloat_types.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef softfloat_types_h 3 | #define softfloat_types_h 4 | 5 | /*** COMMENTS. ***/ 6 | 7 | #include 8 | #include 9 | 10 | typedef struct { uint32_t v; } float32_t; 11 | typedef struct { uint64_t v; } float64_t; 12 | typedef struct { uint64_t v; uint16_t x; } floatx80_t; 13 | typedef struct { uint64_t v[ 2 ]; } float128_t; 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_add.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float32_t f32_add( float32_t a, float32_t b ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | bool signA; 13 | union ui32_f32 uB; 14 | uint_fast32_t uiB; 15 | bool signB; 16 | float32_t ( *magsRoutine )( uint_fast32_t, uint_fast32_t, bool ); 17 | 18 | uA.f = a; 19 | uiA = uA.ui; 20 | signA = signF32UI( uiA ); 21 | uB.f = b; 22 | uiB = uB.ui; 23 | signB = signF32UI( uiB ); 24 | magsRoutine = 25 | ( signA == signB ) ? softfloat_addMagsF32 : softfloat_subMagsF32; 26 | return magsRoutine( uiA, uiB, signA ); 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_classify.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | uint_fast16_t f32_classify( float32_t a ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | 14 | uA.f = a; 15 | uiA = uA.ui; 16 | 17 | uint_fast16_t infOrNaN = expF32UI( uiA ) == 0xFF; 18 | uint_fast16_t subnormalOrZero = expF32UI( uiA ) == 0; 19 | bool sign = signF32UI( uiA ); 20 | 21 | return 22 | ( sign && infOrNaN && fracF32UI( uiA ) == 0 ) << 0 | 23 | ( sign && !infOrNaN && !subnormalOrZero ) << 1 | 24 | ( sign && subnormalOrZero && fracF32UI( uiA ) ) << 2 | 25 | ( sign && subnormalOrZero && fracF32UI( uiA ) == 0 ) << 3 | 26 | ( !sign && infOrNaN && fracF32UI( uiA ) == 0 ) << 7 | 27 | ( !sign && !infOrNaN && !subnormalOrZero ) << 6 | 28 | ( !sign && subnormalOrZero && fracF32UI( uiA ) ) << 5 | 29 | ( !sign && subnormalOrZero && fracF32UI( uiA ) == 0 ) << 4 | 30 | ( isNaNF32UI( uiA ) && softfloat_isSigNaNF32UI( uiA )) << 8 | 31 | ( isNaNF32UI( uiA ) && !softfloat_isSigNaNF32UI( uiA )) << 9; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_eq.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | bool f32_eq( float32_t a, float32_t b ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | union ui32_f32 uB; 14 | uint_fast32_t uiB; 15 | 16 | uA.f = a; 17 | uiA = uA.ui; 18 | uB.f = b; 19 | uiB = uB.ui; 20 | if ( 21 | ( ( expF32UI( uiA ) == 0xFF ) && fracF32UI( uiA ) ) 22 | || ( ( expF32UI( uiB ) == 0xFF ) && fracF32UI( uiB ) ) 23 | ) { 24 | if ( 25 | softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB ) 26 | ) { 27 | softfloat_raiseFlags( softfloat_flag_invalid ); 28 | } 29 | return false; 30 | } 31 | return ( uiA == uiB ) || ! (uint32_t) ( ( uiA | uiB )<<1 ); 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_eq_signaling.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | bool f32_eq_signaling( float32_t a, float32_t b ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | union ui32_f32 uB; 13 | uint_fast32_t uiB; 14 | 15 | uA.f = a; 16 | uiA = uA.ui; 17 | uB.f = b; 18 | uiB = uB.ui; 19 | if ( 20 | ( ( expF32UI( uiA ) == 0xFF ) && fracF32UI( uiA ) ) 21 | || ( ( expF32UI( uiB ) == 0xFF ) && fracF32UI( uiB ) ) 22 | ) { 23 | softfloat_raiseFlags( softfloat_flag_invalid ); 24 | return false; 25 | } 26 | return ( uiA == uiB ) || ! (uint32_t) ( ( uiA | uiB )<<1 ); 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_isSignalingNaN.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "internals.h" 5 | #include "specialize.h" 6 | #include "softfloat.h" 7 | 8 | bool f32_isSignalingNaN( float32_t a ) 9 | { 10 | union ui32_f32 uA; 11 | 12 | uA.f = a; 13 | return softfloat_isSigNaNF32UI( uA.ui ); 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_le.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | bool f32_le( float32_t a, float32_t b ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | union ui32_f32 uB; 13 | uint_fast32_t uiB; 14 | bool signA, signB; 15 | 16 | uA.f = a; 17 | uiA = uA.ui; 18 | uB.f = b; 19 | uiB = uB.ui; 20 | if ( 21 | ( ( expF32UI( uiA ) == 0xFF ) && fracF32UI( uiA ) ) 22 | || ( ( expF32UI( uiB ) == 0xFF ) && fracF32UI( uiB ) ) 23 | ) { 24 | softfloat_raiseFlags( softfloat_flag_invalid ); 25 | return false; 26 | } 27 | signA = signF32UI( uiA ); 28 | signB = signF32UI( uiB ); 29 | return 30 | ( signA != signB ) ? signA || ! (uint32_t) ( ( uiA | uiB )<<1 ) 31 | : ( uiA == uiB ) || ( signA ^ ( uiA < uiB ) ); 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_le_quiet.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | bool f32_le_quiet( float32_t a, float32_t b ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | union ui32_f32 uB; 14 | uint_fast32_t uiB; 15 | bool signA, signB; 16 | 17 | uA.f = a; 18 | uiA = uA.ui; 19 | uB.f = b; 20 | uiB = uB.ui; 21 | if ( 22 | ( ( expF32UI( uiA ) == 0xFF ) && fracF32UI( uiA ) ) 23 | || ( ( expF32UI( uiB ) == 0xFF ) && fracF32UI( uiB ) ) 24 | ) { 25 | if ( 26 | softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB ) 27 | ) { 28 | softfloat_raiseFlags( softfloat_flag_invalid ); 29 | } 30 | return false; 31 | } 32 | signA = signF32UI( uiA ); 33 | signB = signF32UI( uiB ); 34 | return 35 | ( signA != signB ) ? signA || ! (uint32_t) ( ( uiA | uiB )<<1 ) 36 | : ( uiA == uiB ) || ( signA ^ ( uiA < uiB ) ); 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_lt.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | bool f32_lt( float32_t a, float32_t b ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | union ui32_f32 uB; 13 | uint_fast32_t uiB; 14 | bool signA, signB; 15 | 16 | uA.f = a; 17 | uiA = uA.ui; 18 | uB.f = b; 19 | uiB = uB.ui; 20 | if ( 21 | ( ( expF32UI( uiA ) == 0xFF ) && fracF32UI( uiA ) ) 22 | || ( ( expF32UI( uiB ) == 0xFF ) && fracF32UI( uiB ) ) 23 | ) { 24 | softfloat_raiseFlags( softfloat_flag_invalid ); 25 | return false; 26 | } 27 | signA = signF32UI( uiA ); 28 | signB = signF32UI( uiB ); 29 | return 30 | ( signA != signB ) ? signA && ( (uint32_t) ( ( uiA | uiB )<<1 ) != 0 ) 31 | : ( uiA != uiB ) && ( signA ^ ( uiA < uiB ) ); 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_lt_quiet.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | bool f32_lt_quiet( float32_t a, float32_t b ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | union ui32_f32 uB; 14 | uint_fast32_t uiB; 15 | bool signA, signB; 16 | 17 | uA.f = a; 18 | uiA = uA.ui; 19 | uB.f = b; 20 | uiB = uB.ui; 21 | if ( 22 | ( ( expF32UI( uiA ) == 0xFF ) && fracF32UI( uiA ) ) 23 | || ( ( expF32UI( uiB ) == 0xFF ) && fracF32UI( uiB ) ) 24 | ) { 25 | if ( 26 | softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB ) 27 | ) { 28 | softfloat_raiseFlags( softfloat_flag_invalid ); 29 | } 30 | return false; 31 | } 32 | signA = signF32UI( uiA ); 33 | signB = signF32UI( uiB ); 34 | return 35 | ( signA != signB ) ? signA && ( (uint32_t) ( ( uiA | uiB )<<1 ) != 0 ) 36 | : ( uiA != uiB ) && ( signA ^ ( uiA < uiB ) ); 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_mulAdd.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "internals.h" 5 | #include "softfloat.h" 6 | 7 | float32_t f32_mulAdd( float32_t a, float32_t b, float32_t c ) 8 | { 9 | union ui32_f32 uA; 10 | uint_fast32_t uiA; 11 | union ui32_f32 uB; 12 | uint_fast32_t uiB; 13 | union ui32_f32 uC; 14 | uint_fast32_t uiC; 15 | 16 | uA.f = a; 17 | uiA = uA.ui; 18 | uB.f = b; 19 | uiB = uB.ui; 20 | uC.f = c; 21 | uiC = uC.ui; 22 | return softfloat_mulAddF32( 0, uiA, uiB, uiC ); 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_sub.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float32_t f32_sub( float32_t a, float32_t b ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | bool signA; 13 | union ui32_f32 uB; 14 | uint_fast32_t uiB; 15 | bool signB; 16 | float32_t ( *magsRoutine )( uint_fast32_t, uint_fast32_t, bool ); 17 | 18 | uA.f = a; 19 | uiA = uA.ui; 20 | signA = signF32UI( uiA ); 21 | uB.f = b; 22 | uiB = uB.ui; 23 | signB = signF32UI( uiB ); 24 | magsRoutine = 25 | ( signA == signB ) ? softfloat_subMagsF32 : softfloat_addMagsF32; 26 | return magsRoutine( uiA, uiB ^ 0x80000000, signA ); 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_to_f64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | float64_t f32_to_f64( float32_t a ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast32_t sig; 16 | uint_fast64_t uiZ; 17 | struct exp16_sig32 normExpSig; 18 | union ui64_f64 uZ; 19 | 20 | uA.f = a; 21 | uiA = uA.ui; 22 | sign = signF32UI( uiA ); 23 | exp = expF32UI( uiA ); 24 | sig = fracF32UI( uiA ); 25 | if ( exp == 0xFF ) { 26 | uiZ = 27 | sig ? softfloat_commonNaNToF64UI( 28 | softfloat_f32UIToCommonNaN( uiA ) ) 29 | : packToF64UI( sign, 0x7FF, 0 ); 30 | goto uiZ; 31 | } 32 | if ( ! exp ) { 33 | if ( ! sig ) { 34 | uiZ = packToF64UI( sign, 0, 0 ); 35 | goto uiZ; 36 | } 37 | normExpSig = softfloat_normSubnormalF32Sig( sig ); 38 | exp = normExpSig.exp - 1; 39 | sig = normExpSig.sig; 40 | } 41 | uiZ = packToF64UI( sign, exp + 0x380, (uint_fast64_t) sig<<29 ); 42 | uiZ: 43 | uZ.ui = uiZ; 44 | return uZ.f; 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_to_i32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | int_fast32_t f32_to_i32( float32_t a, int_fast8_t roundingMode, bool exact ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast32_t sig; 16 | uint_fast64_t sig64; 17 | int_fast16_t shiftCount; 18 | 19 | uA.f = a; 20 | uiA = uA.ui; 21 | sign = signF32UI( uiA ); 22 | exp = expF32UI( uiA ); 23 | sig = fracF32UI( uiA ); 24 | if ( exp ) sig |= 0x00800000; 25 | sig64 = (uint_fast64_t) sig<<32; 26 | shiftCount = 0xAF - exp; 27 | if ( 0 < shiftCount ) { 28 | sig64 = softfloat_shift64RightJam( sig64, shiftCount ); 29 | } 30 | return softfloat_roundPackToI32( sign, sig64, roundingMode, exact ); 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_to_i32_r_minMag.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | int_fast32_t f32_to_i32_r_minMag( float32_t a, bool exact ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | int_fast16_t exp; 13 | uint_fast32_t sig; 14 | bool sign; 15 | int_fast16_t shiftCount; 16 | int_fast32_t absZ; 17 | 18 | uA.f = a; 19 | uiA = uA.ui; 20 | exp = expF32UI( uiA ); 21 | sig = fracF32UI( uiA ); 22 | if ( exp < 0x7F ) { 23 | if ( exact && ( exp | sig ) ) { 24 | softfloat_exceptionFlags |= softfloat_flag_inexact; 25 | } 26 | return 0; 27 | } 28 | sign = signF32UI( uiA ); 29 | shiftCount = 0x9E - exp; 30 | if ( shiftCount <= 0 ) { 31 | if ( uiA != packToF32UI( 1, 0x9E, 0 ) ) { 32 | softfloat_raiseFlags( softfloat_flag_invalid ); 33 | if ( ! sign || ( ( exp == 0xFF ) && sig ) ) return 0x7FFFFFFF; 34 | } 35 | return -0x7FFFFFFF - 1; 36 | } 37 | sig = ( sig | 0x00800000 )<<8; 38 | absZ = sig>>shiftCount; 39 | if ( exact && (uint32_t) ( sig<<( ( - shiftCount ) & 31 ) ) ) { 40 | softfloat_exceptionFlags |= softfloat_flag_inexact; 41 | } 42 | return sign ? - absZ : absZ; 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_to_i64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | int_fast64_t f32_to_i64( float32_t a, int_fast8_t roundingMode, bool exact ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast32_t sig; 16 | int_fast16_t shiftCount; 17 | uint_fast64_t sig64, extra; 18 | struct uint64_extra sig64Extra; 19 | 20 | uA.f = a; 21 | uiA = uA.ui; 22 | sign = signF32UI( uiA ); 23 | exp = expF32UI( uiA ); 24 | sig = fracF32UI( uiA ); 25 | shiftCount = 0xBE - exp; 26 | if ( shiftCount < 0 ) { 27 | softfloat_raiseFlags( softfloat_flag_invalid ); 28 | if ( ! sign ) { 29 | return INT64_C( 0x7FFFFFFFFFFFFFFF ); 30 | } 31 | return - INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1; 32 | } 33 | if ( exp ) sig |= 0x00800000; 34 | sig64 = (uint_fast64_t) sig<<40; 35 | extra = 0; 36 | if ( shiftCount ) { 37 | sig64Extra = softfloat_shift64ExtraRightJam( sig64, 0, shiftCount ); 38 | sig64 = sig64Extra.v; 39 | extra = sig64Extra.extra; 40 | } 41 | return softfloat_roundPackToI64( sign, sig64, extra, roundingMode, exact ); 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_to_i64_r_minMag.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | int_fast64_t f32_to_i64_r_minMag( float32_t a, bool exact ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | int_fast16_t exp; 13 | uint_fast32_t sig; 14 | bool sign; 15 | int_fast16_t shiftCount; 16 | uint_fast64_t sig64; 17 | int_fast64_t absZ; 18 | 19 | uA.f = a; 20 | uiA = uA.ui; 21 | exp = expF32UI( uiA ); 22 | sig = fracF32UI( uiA ); 23 | if ( exp < 0x7F ) { 24 | if ( exact && ( exp | sig ) ) { 25 | softfloat_exceptionFlags |= softfloat_flag_inexact; 26 | } 27 | return 0; 28 | } 29 | sign = signF32UI( uiA ); 30 | shiftCount = 0xBE - exp; 31 | if ( shiftCount <= 0 ) { 32 | if ( uiA != packToF32UI( 1, 0xBE, 0 ) ) { 33 | softfloat_raiseFlags( softfloat_flag_invalid ); 34 | if ( ! sign || ( ( exp == 0xFF ) && sig ) ) { 35 | return INT64_C( 0x7FFFFFFFFFFFFFFF ); 36 | } 37 | } 38 | return - INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1; 39 | } 40 | sig |= 0x00800000; 41 | sig64 = (uint_fast64_t) sig<<40; 42 | absZ = sig64>>shiftCount; 43 | shiftCount = 40 - shiftCount; 44 | if ( 45 | exact && ( shiftCount < 0 ) && (uint32_t) ( sig<<( shiftCount & 31 ) ) 46 | ) { 47 | softfloat_exceptionFlags |= softfloat_flag_inexact; 48 | } 49 | return sign ? - absZ : absZ; 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_to_ui32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | uint_fast32_t f32_to_ui32( float32_t a, int_fast8_t roundingMode, bool exact ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast32_t sig; 16 | uint_fast64_t sig64; 17 | int_fast16_t shiftCount; 18 | 19 | uA.f = a; 20 | uiA = uA.ui; 21 | sign = signF32UI( uiA ); 22 | exp = expF32UI( uiA ); 23 | sig = fracF32UI( uiA ); 24 | if ( exp ) sig |= 0x00800000; 25 | sig64 = (uint_fast64_t) sig<<32; 26 | shiftCount = 0xAF - exp; 27 | if ( 0 < shiftCount ) { 28 | sig64 = softfloat_shift64RightJam( sig64, shiftCount ); 29 | } 30 | return softfloat_roundPackToUI32( sign, sig64, roundingMode, exact ); 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_to_ui32_r_minMag.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | uint_fast32_t f32_to_ui32_r_minMag( float32_t a, bool exact ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | int_fast16_t exp; 13 | uint_fast32_t sig; 14 | int_fast16_t shiftCount; 15 | uint_fast32_t z; 16 | 17 | uA.f = a; 18 | uiA = uA.ui; 19 | exp = expF32UI( uiA ); 20 | sig = fracF32UI( uiA ); 21 | if ( exp < 0x7F ) { 22 | if ( exact && ( exp | sig ) ) { 23 | softfloat_exceptionFlags |= softfloat_flag_inexact; 24 | } 25 | return 0; 26 | } 27 | if ( signF32UI( uiA ) ) goto invalid; 28 | shiftCount = 0x9E - exp; 29 | if ( shiftCount < 0 ) goto invalid; 30 | sig = ( sig | 0x00800000 )<<8; 31 | z = sig>>shiftCount; 32 | if ( exact && ( sig & ( ( (uint_fast32_t) 1< 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | uint_fast64_t f32_to_ui64( float32_t a, int_fast8_t roundingMode, bool exact ) 10 | { 11 | union ui32_f32 uA; 12 | uint_fast32_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast32_t sig; 16 | int_fast16_t shiftCount; 17 | uint_fast64_t sig64, extra; 18 | struct uint64_extra sig64Extra; 19 | 20 | uA.f = a; 21 | uiA = uA.ui; 22 | sign = signF32UI( uiA ); 23 | exp = expF32UI( uiA ); 24 | sig = fracF32UI( uiA ); 25 | shiftCount = 0xBE - exp; 26 | if ( shiftCount < 0 ) { 27 | softfloat_raiseFlags( softfloat_flag_invalid ); 28 | return UINT64_C( 0xFFFFFFFFFFFFFFFF ); 29 | } 30 | if ( exp ) sig |= 0x00800000; 31 | sig64 = (uint_fast64_t) sig<<40; 32 | extra = 0; 33 | if ( shiftCount ) { 34 | sig64Extra = softfloat_shift64ExtraRightJam( sig64, 0, shiftCount ); 35 | sig64 = sig64Extra.v; 36 | extra = sig64Extra.extra; 37 | } 38 | return 39 | softfloat_roundPackToUI64( sign, sig64, extra, roundingMode, exact ); 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f32_to_ui64_r_minMag.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | uint_fast64_t f32_to_ui64_r_minMag( float32_t a, bool exact ) 9 | { 10 | union ui32_f32 uA; 11 | uint_fast32_t uiA; 12 | int_fast16_t exp; 13 | uint_fast32_t sig; 14 | int_fast16_t shiftCount; 15 | uint_fast64_t sig64, z; 16 | 17 | uA.f = a; 18 | uiA = uA.ui; 19 | exp = expF32UI( uiA ); 20 | sig = fracF32UI( uiA ); 21 | if ( exp < 0x7F ) { 22 | if ( exact && ( exp | sig ) ) { 23 | softfloat_exceptionFlags |= softfloat_flag_inexact; 24 | } 25 | return 0; 26 | } 27 | if ( signF32UI( uiA ) ) goto invalid; 28 | shiftCount = 0xBE - exp; 29 | if ( shiftCount < 0 ) goto invalid; 30 | sig |= 0x00800000; 31 | sig64 = (uint_fast64_t) sig<<40; 32 | z = sig64>>shiftCount; 33 | shiftCount = 40 - shiftCount; 34 | if ( 35 | exact && ( shiftCount < 0 ) && (uint32_t) ( sig<<( shiftCount & 31 ) ) 36 | ) { 37 | softfloat_exceptionFlags |= softfloat_flag_inexact; 38 | } 39 | return z; 40 | invalid: 41 | softfloat_raiseFlags( softfloat_flag_invalid ); 42 | return UINT64_C( 0xFFFFFFFFFFFFFFFF ); 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_add.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float64_t f64_add( float64_t a, float64_t b ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | bool signA; 13 | union ui64_f64 uB; 14 | uint_fast64_t uiB; 15 | bool signB; 16 | float64_t ( *magsRoutine )( uint_fast64_t, uint_fast64_t, bool ); 17 | 18 | uA.f = a; 19 | uiA = uA.ui; 20 | signA = signF64UI( uiA ); 21 | uB.f = b; 22 | uiB = uB.ui; 23 | signB = signF64UI( uiB ); 24 | magsRoutine = 25 | ( signA == signB ) ? softfloat_addMagsF64 : softfloat_subMagsF64; 26 | return magsRoutine( uiA, uiB, signA ); 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_classify.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | uint_fast16_t f64_classify( float64_t a ) 10 | { 11 | union ui64_f64 uA; 12 | uint_fast64_t uiA; 13 | 14 | uA.f = a; 15 | uiA = uA.ui; 16 | 17 | uint_fast16_t infOrNaN = expF64UI( uiA ) == 0x7FF; 18 | uint_fast16_t subnormalOrZero = expF64UI( uiA ) == 0; 19 | bool sign = signF64UI( uiA ); 20 | 21 | return 22 | ( sign && infOrNaN && fracF64UI( uiA ) == 0 ) << 0 | 23 | ( sign && !infOrNaN && !subnormalOrZero ) << 1 | 24 | ( sign && subnormalOrZero && fracF64UI( uiA ) ) << 2 | 25 | ( sign && subnormalOrZero && fracF64UI( uiA ) == 0 ) << 3 | 26 | ( !sign && infOrNaN && fracF64UI( uiA ) == 0 ) << 7 | 27 | ( !sign && !infOrNaN && !subnormalOrZero ) << 6 | 28 | ( !sign && subnormalOrZero && fracF64UI( uiA ) ) << 5 | 29 | ( !sign && subnormalOrZero && fracF64UI( uiA ) == 0 ) << 4 | 30 | ( isNaNF64UI( uiA ) && softfloat_isSigNaNF64UI( uiA )) << 8 | 31 | ( isNaNF64UI( uiA ) && !softfloat_isSigNaNF64UI( uiA )) << 9; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_eq.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | bool f64_eq( float64_t a, float64_t b ) 10 | { 11 | union ui64_f64 uA; 12 | uint_fast64_t uiA; 13 | union ui64_f64 uB; 14 | uint_fast64_t uiB; 15 | 16 | uA.f = a; 17 | uiA = uA.ui; 18 | uB.f = b; 19 | uiB = uB.ui; 20 | if ( 21 | ( ( expF64UI( uiA ) == 0x7FF ) && fracF64UI( uiA ) ) 22 | || ( ( expF64UI( uiB ) == 0x7FF ) && fracF64UI( uiB ) ) 23 | ) { 24 | if ( 25 | softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB ) 26 | ) { 27 | softfloat_raiseFlags( softfloat_flag_invalid ); 28 | } 29 | return false; 30 | } 31 | return 32 | ( uiA == uiB ) || ! ( ( uiA | uiB ) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ); 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_eq_signaling.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | bool f64_eq_signaling( float64_t a, float64_t b ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | union ui64_f64 uB; 13 | uint_fast64_t uiB; 14 | 15 | uA.f = a; 16 | uiA = uA.ui; 17 | uB.f = b; 18 | uiB = uB.ui; 19 | if ( 20 | ( ( expF64UI( uiA ) == 0x7FF ) && fracF64UI( uiA ) ) 21 | || ( ( expF64UI( uiB ) == 0x7FF ) && fracF64UI( uiB ) ) 22 | ) { 23 | softfloat_raiseFlags( softfloat_flag_invalid ); 24 | return false; 25 | } 26 | return 27 | ( uiA == uiB ) || ! ( ( uiA | uiB ) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ); 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_isSignalingNaN.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "internals.h" 5 | #include "specialize.h" 6 | #include "softfloat.h" 7 | 8 | bool f64_isSignalingNaN( float64_t a ) 9 | { 10 | union ui64_f64 uA; 11 | 12 | uA.f = a; 13 | return softfloat_isSigNaNF64UI( uA.ui ); 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_le.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | bool f64_le( float64_t a, float64_t b ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | union ui64_f64 uB; 13 | uint_fast64_t uiB; 14 | bool signA, signB; 15 | 16 | uA.f = a; 17 | uiA = uA.ui; 18 | uB.f = b; 19 | uiB = uB.ui; 20 | if ( 21 | ( ( expF64UI( uiA ) == 0x7FF ) && fracF64UI( uiA ) ) 22 | || ( ( expF64UI( uiB ) == 0x7FF ) && fracF64UI( uiB ) ) 23 | ) { 24 | softfloat_raiseFlags( softfloat_flag_invalid ); 25 | return false; 26 | } 27 | signA = signF64UI( uiA ); 28 | signB = signF64UI( uiB ); 29 | return 30 | ( signA != signB ) 31 | ? signA || ! ( ( uiA | uiB ) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) 32 | : ( uiA == uiB ) || ( signA ^ ( uiA < uiB ) ); 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_le_quiet.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | bool f64_le_quiet( float64_t a, float64_t b ) 10 | { 11 | union ui64_f64 uA; 12 | uint_fast64_t uiA; 13 | union ui64_f64 uB; 14 | uint_fast64_t uiB; 15 | bool signA, signB; 16 | 17 | uA.f = a; 18 | uiA = uA.ui; 19 | uB.f = b; 20 | uiB = uB.ui; 21 | if ( 22 | ( ( expF64UI( uiA ) == 0x7FF ) && fracF64UI( uiA ) ) 23 | || ( ( expF64UI( uiB ) == 0x7FF ) && fracF64UI( uiB ) ) 24 | ) { 25 | if ( 26 | softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB ) 27 | ) { 28 | softfloat_raiseFlags( softfloat_flag_invalid ); 29 | } 30 | return false; 31 | } 32 | signA = signF64UI( uiA ); 33 | signB = signF64UI( uiB ); 34 | return 35 | ( signA != signB ) 36 | ? signA || ! ( ( uiA | uiB ) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) 37 | : ( uiA == uiB ) || ( signA ^ ( uiA < uiB ) ); 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_lt.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | bool f64_lt( float64_t a, float64_t b ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | union ui64_f64 uB; 13 | uint_fast64_t uiB; 14 | bool signA, signB; 15 | 16 | uA.f = a; 17 | uiA = uA.ui; 18 | uB.f = b; 19 | uiB = uB.ui; 20 | if ( 21 | ( ( expF64UI( uiA ) == 0x7FF ) && fracF64UI( uiA ) ) 22 | || ( ( expF64UI( uiB ) == 0x7FF ) && fracF64UI( uiB ) ) 23 | ) { 24 | softfloat_raiseFlags( softfloat_flag_invalid ); 25 | return false; 26 | } 27 | signA = signF64UI( uiA ); 28 | signB = signF64UI( uiB ); 29 | return 30 | ( signA != signB ) 31 | ? signA && ( ( uiA | uiB ) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) 32 | : ( uiA != uiB ) && ( signA ^ ( uiA < uiB ) ); 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_lt_quiet.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "specialize.h" 7 | #include "softfloat.h" 8 | 9 | bool f64_lt_quiet( float64_t a, float64_t b ) 10 | { 11 | union ui64_f64 uA; 12 | uint_fast64_t uiA; 13 | union ui64_f64 uB; 14 | uint_fast64_t uiB; 15 | bool signA, signB; 16 | 17 | uA.f = a; 18 | uiA = uA.ui; 19 | uB.f = b; 20 | uiB = uB.ui; 21 | if ( 22 | ( ( expF64UI( uiA ) == 0x7FF ) && fracF64UI( uiA ) ) 23 | || ( ( expF64UI( uiB ) == 0x7FF ) && fracF64UI( uiB ) ) 24 | ) { 25 | if ( 26 | softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB ) 27 | ) { 28 | softfloat_raiseFlags( softfloat_flag_invalid ); 29 | } 30 | return false; 31 | } 32 | signA = signF64UI( uiA ); 33 | signB = signF64UI( uiB ); 34 | return 35 | ( signA != signB ) 36 | ? signA && ( ( uiA | uiB ) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) 37 | : ( uiA != uiB ) && ( signA ^ ( uiA < uiB ) ); 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_mulAdd.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "internals.h" 5 | #include "softfloat.h" 6 | 7 | float64_t f64_mulAdd( float64_t a, float64_t b, float64_t c ) 8 | { 9 | union ui64_f64 uA; 10 | uint_fast64_t uiA; 11 | union ui64_f64 uB; 12 | uint_fast64_t uiB; 13 | union ui64_f64 uC; 14 | uint_fast64_t uiC; 15 | 16 | uA.f = a; 17 | uiA = uA.ui; 18 | uB.f = b; 19 | uiB = uB.ui; 20 | uC.f = c; 21 | uiC = uC.ui; 22 | return softfloat_mulAddF64( 0, uiA, uiB, uiC ); 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_sub.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float64_t f64_sub( float64_t a, float64_t b ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | bool signA; 13 | union ui64_f64 uB; 14 | uint_fast64_t uiB; 15 | bool signB; 16 | float64_t ( *magsRoutine )( uint_fast64_t, uint_fast64_t, bool ); 17 | 18 | uA.f = a; 19 | uiA = uA.ui; 20 | signA = signF64UI( uiA ); 21 | uB.f = b; 22 | uiB = uB.ui; 23 | signB = signF64UI( uiB ); 24 | magsRoutine = 25 | ( signA == signB ) ? softfloat_subMagsF64 : softfloat_addMagsF64; 26 | return magsRoutine( uiA, uiB, signA ); 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_to_f32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "specialize.h" 8 | #include "softfloat.h" 9 | 10 | float32_t f64_to_f32( float64_t a ) 11 | { 12 | union ui64_f64 uA; 13 | uint_fast64_t uiA; 14 | bool sign; 15 | int_fast16_t exp; 16 | uint_fast64_t sig; 17 | uint_fast32_t uiZ, sig32; 18 | union ui32_f32 uZ; 19 | 20 | uA.f = a; 21 | uiA = uA.ui; 22 | sign = signF64UI( uiA ); 23 | exp = expF64UI( uiA ); 24 | sig = fracF64UI( uiA ); 25 | if ( exp == 0x7FF ) { 26 | uiZ = 27 | sig ? softfloat_commonNaNToF32UI( 28 | softfloat_f64UIToCommonNaN( uiA ) ) 29 | : packToF32UI( sign, 0xFF, 0 ); 30 | goto uiZ; 31 | } 32 | sig32 = softfloat_shortShift64RightJam( sig, 22 ); 33 | if ( ! ( exp | sig32 ) ) { 34 | uiZ = packToF32UI( sign, 0, 0 ); 35 | goto uiZ; 36 | } 37 | return softfloat_roundPackToF32( sign, exp - 0x381, sig32 | 0x40000000 ); 38 | uiZ: 39 | uZ.ui = uiZ; 40 | return uZ.f; 41 | 42 | } 43 | 44 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_to_i32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | int_fast32_t f64_to_i32( float64_t a, int_fast8_t roundingMode, bool exact ) 10 | { 11 | union ui64_f64 uA; 12 | uint_fast64_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast64_t sig; 16 | int_fast16_t shiftCount; 17 | 18 | uA.f = a; 19 | uiA = uA.ui; 20 | sign = signF64UI( uiA ); 21 | exp = expF64UI( uiA ); 22 | sig = fracF64UI( uiA ); 23 | if ( exp ) sig |= UINT64_C( 0x0010000000000000 ); 24 | shiftCount = 0x42C - exp; 25 | if ( 0 < shiftCount ) sig = softfloat_shift64RightJam( sig, shiftCount ); 26 | return softfloat_roundPackToI32( sign, sig, roundingMode, exact ); 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_to_i32_r_minMag.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | int_fast32_t f64_to_i32_r_minMag( float64_t a, bool exact ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | int_fast16_t exp; 13 | uint_fast64_t sig; 14 | bool sign; 15 | int_fast16_t shiftCount; 16 | uint_fast32_t absZ; 17 | union { uint32_t ui; int32_t i; } uZ; 18 | int_fast32_t z; 19 | 20 | uA.f = a; 21 | uiA = uA.ui; 22 | exp = expF64UI( uiA ); 23 | sig = fracF64UI( uiA ); 24 | if ( exp < 0x3FF ) { 25 | if ( exact && ( exp | sig ) ) { 26 | softfloat_exceptionFlags |= softfloat_flag_inexact; 27 | } 28 | return 0; 29 | } 30 | sign = signF64UI( uiA ); 31 | if ( 0x41E < exp ) { 32 | if ( ( exp == 0x7FF ) && sig ) sign = 0; 33 | goto invalid; 34 | } 35 | sig |= UINT64_C( 0x0010000000000000 ); 36 | shiftCount = 0x433 - exp; 37 | absZ = sig>>shiftCount; 38 | uZ.ui = sign ? - absZ : absZ; 39 | z = uZ.i; 40 | if ( ( z < 0 ) != sign ) goto invalid; 41 | if ( exact && ( (uint_fast64_t) absZ< 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | int_fast64_t f64_to_i64( float64_t a, int_fast8_t roundingMode, bool exact ) 10 | { 11 | union ui64_f64 uA; 12 | uint_fast64_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast64_t sig; 16 | int_fast16_t shiftCount; 17 | struct uint64_extra sigExtra; 18 | 19 | uA.f = a; 20 | uiA = uA.ui; 21 | sign = signF64UI( uiA ); 22 | exp = expF64UI( uiA ); 23 | sig = fracF64UI( uiA ); 24 | if ( exp ) sig |= UINT64_C( 0x0010000000000000 ); 25 | shiftCount = 0x433 - exp; 26 | if ( shiftCount <= 0 ) { 27 | if ( 0x43E < exp ) { 28 | softfloat_raiseFlags( softfloat_flag_invalid ); 29 | return 30 | ! sign 31 | ? INT64_C( 0x7FFFFFFFFFFFFFFF ) 32 | : - INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1; 33 | } 34 | sigExtra.v = sig<<( - shiftCount ); 35 | sigExtra.extra = 0; 36 | } else { 37 | sigExtra = softfloat_shift64ExtraRightJam( sig, 0, shiftCount ); 38 | } 39 | return 40 | softfloat_roundPackToI64( 41 | sign, sigExtra.v, sigExtra.extra, roundingMode, exact ); 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_to_i64_r_minMag.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | int_fast64_t f64_to_i64_r_minMag( float64_t a, bool exact ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | bool sign; 13 | int_fast16_t exp; 14 | uint_fast64_t sig; 15 | int_fast16_t shiftCount; 16 | int_fast64_t absZ; 17 | 18 | uA.f = a; 19 | uiA = uA.ui; 20 | sign = signF64UI( uiA ); 21 | exp = expF64UI( uiA ); 22 | sig = fracF64UI( uiA ); 23 | shiftCount = exp - 0x433; 24 | if ( 0 <= shiftCount ) { 25 | if ( 0x43E <= exp ) { 26 | if ( uiA != packToF64UI( 1, 0x43E, 0 ) ) { 27 | softfloat_raiseFlags( softfloat_flag_invalid ); 28 | if ( ! sign || ( ( exp == 0x7FF ) && sig ) ) { 29 | return INT64_C( 0x7FFFFFFFFFFFFFFF ); 30 | } 31 | } 32 | return - INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1; 33 | } 34 | sig |= UINT64_C( 0x0010000000000000 ); 35 | absZ = sig<>( - shiftCount ); 45 | if ( exact && (uint64_t) ( sig<<( shiftCount & 63 ) ) ) { 46 | softfloat_exceptionFlags |= softfloat_flag_inexact; 47 | } 48 | } 49 | return sign ? - absZ : absZ; 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_to_ui32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | uint_fast32_t f64_to_ui32( float64_t a, int_fast8_t roundingMode, bool exact ) 10 | { 11 | union ui64_f64 uA; 12 | uint_fast64_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast64_t sig; 16 | int_fast16_t shiftCount; 17 | 18 | uA.f = a; 19 | uiA = uA.ui; 20 | sign = signF64UI( uiA ); 21 | exp = expF64UI( uiA ); 22 | sig = fracF64UI( uiA ); 23 | if ( exp ) sig |= UINT64_C( 0x0010000000000000 ); 24 | shiftCount = 0x42C - exp; 25 | if ( 0 < shiftCount ) sig = softfloat_shift64RightJam( sig, shiftCount ); 26 | return softfloat_roundPackToUI32( sign, sig, roundingMode, exact ); 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_to_ui32_r_minMag.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | uint_fast32_t f64_to_ui32_r_minMag( float64_t a, bool exact ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | int_fast16_t exp; 13 | uint_fast64_t sig; 14 | int_fast16_t shiftCount; 15 | uint_fast32_t z; 16 | 17 | uA.f = a; 18 | uiA = uA.ui; 19 | exp = expF64UI( uiA ); 20 | sig = fracF64UI( uiA ); 21 | if ( exp < 0x3FF ) { 22 | if ( exact && ( exp | sig ) ) { 23 | softfloat_exceptionFlags |= softfloat_flag_inexact; 24 | } 25 | return 0; 26 | } 27 | if ( signF64UI( uiA ) || ( 0x41E < exp ) ) { 28 | softfloat_raiseFlags( softfloat_flag_invalid ); 29 | return 0xFFFFFFFF; 30 | } 31 | sig |= UINT64_C( 0x0010000000000000 ); 32 | shiftCount = 0x433 - exp; 33 | z = sig>>shiftCount; 34 | if ( exact && ( (uint_fast64_t) z< 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | uint_fast64_t f64_to_ui64( float64_t a, int_fast8_t roundingMode, bool exact ) 10 | { 11 | union ui64_f64 uA; 12 | uint_fast64_t uiA; 13 | bool sign; 14 | int_fast16_t exp; 15 | uint_fast64_t sig; 16 | int_fast16_t shiftCount; 17 | struct uint64_extra sigExtra; 18 | 19 | uA.f = a; 20 | uiA = uA.ui; 21 | sign = signF64UI( uiA ); 22 | exp = expF64UI( uiA ); 23 | sig = fracF64UI( uiA ); 24 | if ( exp ) sig |= UINT64_C( 0x0010000000000000 ); 25 | shiftCount = 0x433 - exp; 26 | if ( shiftCount <= 0 ) { 27 | if ( 0x43E < exp ) { 28 | softfloat_raiseFlags( softfloat_flag_invalid ); 29 | return UINT64_C( 0xFFFFFFFFFFFFFFFF ); 30 | } 31 | sigExtra.v = sig<<( - shiftCount ); 32 | sigExtra.extra = 0; 33 | } else { 34 | sigExtra = softfloat_shift64ExtraRightJam( sig, 0, shiftCount ); 35 | } 36 | return 37 | softfloat_roundPackToUI64( 38 | sign, sigExtra.v, sigExtra.extra, roundingMode, exact ); 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/f64_to_ui64_r_minMag.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | uint_fast64_t f64_to_ui64_r_minMag( float64_t a, bool exact ) 9 | { 10 | union ui64_f64 uA; 11 | uint_fast64_t uiA; 12 | int_fast16_t exp; 13 | uint_fast64_t sig; 14 | int_fast16_t shiftCount; 15 | uint_fast64_t z; 16 | 17 | uA.f = a; 18 | uiA = uA.ui; 19 | exp = expF64UI( uiA ); 20 | sig = fracF64UI( uiA ); 21 | if ( exp < 0x3FF ) { 22 | if ( exact && ( exp | sig ) ) { 23 | softfloat_exceptionFlags |= softfloat_flag_inexact; 24 | } 25 | return 0; 26 | } 27 | if ( signF64UI( uiA ) ) goto invalid; 28 | shiftCount = exp - 0x433; 29 | if ( 0 <= shiftCount ) { 30 | if ( 0x43E < exp ) goto invalid; 31 | z = ( sig | UINT64_C( 0x0010000000000000 ) )<>( - shiftCount ); 35 | if ( exact && (uint64_t) ( sig<<( shiftCount & 63 ) ) ) { 36 | softfloat_exceptionFlags |= softfloat_flag_inexact; 37 | } 38 | } 39 | return z; 40 | invalid: 41 | softfloat_raiseFlags( softfloat_flag_invalid ); 42 | return UINT64_C( 0xFFFFFFFFFFFFFFFF ); 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/i32_to_f32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float32_t i32_to_f32( int_fast32_t a ) 9 | { 10 | bool sign; 11 | union ui32_f32 uZ; 12 | 13 | sign = ( a < 0 ); 14 | if ( ! ( a & 0x7FFFFFFF ) ) { 15 | uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0; 16 | return uZ.f; 17 | } 18 | return softfloat_normRoundPackToF32( sign, 0x9C, sign ? - a : a ); 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/i32_to_f64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | float64_t i32_to_f64( int_fast32_t a ) 10 | { 11 | uint_fast64_t uiZ; 12 | bool sign; 13 | uint_fast32_t absA; 14 | int shiftCount; 15 | union ui64_f64 uZ; 16 | 17 | if ( ! a ) { 18 | uiZ = 0; 19 | } else { 20 | sign = ( a < 0 ); 21 | absA = sign ? - a : a; 22 | shiftCount = softfloat_countLeadingZeros32( absA ) + 21; 23 | uiZ = 24 | packToF64UI( 25 | sign, 0x432 - shiftCount, (uint_fast64_t) absA< 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | #include "softfloat.h" 8 | 9 | float32_t i64_to_f32( int_fast64_t a ) 10 | { 11 | bool sign; 12 | uint_fast64_t absA; 13 | int shiftCount; 14 | union ui32_f32 u; 15 | uint_fast32_t sig; 16 | 17 | sign = ( a < 0 ); 18 | absA = sign ? - (uint_fast64_t) a : a; 19 | shiftCount = softfloat_countLeadingZeros64( absA ) - 40; 20 | if ( 0 <= shiftCount ) { 21 | u.ui = 22 | a ? packToF32UI( 23 | sign, 0x95 - shiftCount, (uint_fast32_t) absA< 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float64_t i64_to_f64( int_fast64_t a ) 9 | { 10 | bool sign; 11 | union ui64_f64 uZ; 12 | 13 | sign = ( a < 0 ); 14 | if ( ! ( a & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) ) { 15 | uZ.ui = sign ? packToF64UI( 1, 0x43E, 0 ) : 0; 16 | return uZ.f; 17 | } 18 | return softfloat_normRoundPackToF64( sign, 0x43C, sign ? - a : a ); 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_add128.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint128 7 | softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 8 | { 9 | struct uint128 z; 10 | 11 | z.v0 = a0 + b0; 12 | z.v64 = a64 + b64; 13 | z.v64 += ( z.v0 < a0 ); 14 | return z; 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_add192.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint192 7 | softfloat_add192( 8 | uint64_t a128, 9 | uint64_t a64, 10 | uint64_t a0, 11 | uint64_t b128, 12 | uint64_t b64, 13 | uint64_t b0 14 | ) 15 | { 16 | struct uint192 z; 17 | unsigned int carry64, carry128; 18 | 19 | z.v0 = a0 + b0; 20 | carry64 = ( z.v0 < a0 ); 21 | z.v64 = a64 + b64; 22 | carry128 = ( z.v64 < a64 ); 23 | z.v128 = a128 + b128; 24 | z.v64 += carry64; 25 | carry128 += ( z.v64 < carry64 ); 26 | z.v128 += carry128; 27 | return z; 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_commonNaNToF32UI.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "specialize.h" 5 | 6 | /*---------------------------------------------------------------------------- 7 | | Returns the result of converting the canonical NaN `a' to the single- 8 | | precision floating-point format. 9 | *----------------------------------------------------------------------------*/ 10 | 11 | uint_fast32_t softfloat_commonNaNToF32UI( struct commonNaN a ) 12 | { 13 | 14 | return (uint_fast32_t) a.sign<<31 | 0x7FFFFFFF; 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_commonNaNToF64UI.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "specialize.h" 5 | 6 | /*---------------------------------------------------------------------------- 7 | | Returns the result of converting the canonical NaN `a' to the double- 8 | | precision floating-point format. 9 | *----------------------------------------------------------------------------*/ 10 | 11 | uint_fast64_t softfloat_commonNaNToF64UI( struct commonNaN a ) 12 | { 13 | 14 | return 15 | (uint_fast64_t) a.sign<<63 | UINT64_C( 0x7FFFFFFFFFFFFFFF ); 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_countLeadingZeros32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "primitives.h" 4 | 5 | int softfloat_countLeadingZeros32( uint32_t a ) 6 | { 7 | int count; 8 | 9 | count = 0; 10 | if ( a < 0x10000 ) { 11 | count = 16; 12 | a <<= 16; 13 | } 14 | if ( a < 0x1000000 ) { 15 | count += 8; 16 | a <<= 8; 17 | } 18 | count += softfloat_countLeadingZeros8[ a>>24 ]; 19 | return count; 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_countLeadingZeros64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "primitives.h" 4 | #include "platform.h" 5 | 6 | int softfloat_countLeadingZeros64( uint64_t a ) 7 | { 8 | int count; 9 | uint32_t a32; 10 | 11 | count = 32; 12 | a32 = a; 13 | if ( UINT64_C( 0x100000000 ) <= a ) { 14 | count = 0; 15 | a32 = a>>32; 16 | } 17 | /*------------------------------------------------------------------------ 18 | | From here, result is current count + count leading zeros of `a32'. 19 | *------------------------------------------------------------------------*/ 20 | if ( a32 < 0x10000 ) { 21 | count += 16; 22 | a32 <<= 16; 23 | } 24 | if ( a32 < 0x1000000 ) { 25 | count += 8; 26 | a32 <<= 8; 27 | } 28 | count += softfloat_countLeadingZeros8[ a32>>24 ]; 29 | return count; 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_countLeadingZeros8.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | const uint8_t softfloat_countLeadingZeros8[ 256 ] = { 7 | 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 8 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 9 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 11 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 15 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_eq128.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | 7 | bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 8 | { 9 | 10 | return ( a64 == b64 ) && ( a0 == b0 ); 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_estimateDiv128To64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | uint64_t softfloat_estimateDiv128To64( uint64_t a64, uint64_t a0, uint64_t b ) 7 | { 8 | uint32_t b32; 9 | uint64_t z; 10 | struct uint128 term, rem; 11 | uint64_t rem32; 12 | 13 | if ( b <= a64 ) return UINT64_C( 0xFFFFFFFFFFFFFFFF ); 14 | b32 = b>>32; 15 | z = ( (uint64_t) b32<<32 <= a64 ) ? UINT64_C( 0xFFFFFFFF00000000 ) 16 | : ( a64 / b32 )<<32; 17 | term = softfloat_mul64To128( b, z ); 18 | rem = softfloat_sub128( a64, a0, term.v64, term.v0 ); 19 | while ( UINT64_C( 0x8000000000000000 ) <= rem.v64 ) { 20 | z -= UINT64_C( 0x100000000 ); 21 | rem = softfloat_add128( rem.v64, rem.v0, b32, (uint64_t) ( b<<32 ) ); 22 | } 23 | rem32 = ( rem.v64<<32 ) | ( rem.v0>>32 ); 24 | z |= ( (uint64_t) b32<<32 <= rem32 ) ? 0xFFFFFFFF : rem32 / b32; 25 | return z; 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_estimateSqrt32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | uint32_t softfloat_estimateSqrt32( unsigned int expA, uint32_t a ) 7 | { 8 | static const uint16_t sqrtOddAdjustments[] = { 9 | 0x0004, 0x0022, 0x005D, 0x00B1, 0x011D, 0x019F, 0x0236, 0x02E0, 10 | 0x039C, 0x0468, 0x0545, 0x0631, 0x072B, 0x0832, 0x0946, 0x0A67 11 | }; 12 | static const uint16_t sqrtEvenAdjustments[] = { 13 | 0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E, 14 | 0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002 15 | }; 16 | int index; 17 | uint32_t z; 18 | union { uint32_t ui; int32_t i; } u32; 19 | 20 | index = ( a>>27 ) & 15; 21 | if ( expA & 1 ) { 22 | z = 0x4000 + ( a>>17 ) - sqrtOddAdjustments[ index ]; 23 | z = ( ( a / z )<<14 ) + ( z<<15 ); 24 | a >>= 1; 25 | } else { 26 | z = 0x8000 + ( a>>17 ) - sqrtEvenAdjustments[ index ]; 27 | z = a / z + z; 28 | z = ( 0x20000 <= z ) ? 0xFFFF8000 : z<<15; 29 | if ( z <= a ) { 30 | u32.ui = a; 31 | return u32.i>>1; 32 | } 33 | } 34 | return (uint32_t) ( ( (uint64_t) a<<31 ) / z ) + ( z>>1 ); 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_f32UIToCommonNaN.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "specialize.h" 5 | #include "softfloat.h" 6 | 7 | /*---------------------------------------------------------------------------- 8 | | Returns the result of converting the single-precision floating-point NaN 9 | | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid 10 | | exception is raised. 11 | *----------------------------------------------------------------------------*/ 12 | struct commonNaN softfloat_f32UIToCommonNaN( uint_fast32_t uiA ) 13 | { 14 | struct commonNaN z; 15 | 16 | if ( softfloat_isSigNaNF32UI( uiA ) ) { 17 | softfloat_raiseFlags( softfloat_flag_invalid ); 18 | } 19 | z.sign = uiA>>31; 20 | z.v64 = (uint_fast64_t) 0x7FFFF <<41; 21 | z.v0 = 0; 22 | return z; 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_f64UIToCommonNaN.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "specialize.h" 5 | #include "softfloat.h" 6 | 7 | /*---------------------------------------------------------------------------- 8 | | Returns the result of converting the double-precision floating-point NaN 9 | | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid 10 | | exception is raised. 11 | *----------------------------------------------------------------------------*/ 12 | struct commonNaN softfloat_f64UIToCommonNaN( uint_fast64_t uiA ) 13 | { 14 | struct commonNaN z; 15 | 16 | if ( softfloat_isSigNaNF64UI( uiA ) ) { 17 | softfloat_raiseFlags( softfloat_flag_invalid ); 18 | } 19 | z.sign = uiA>>63; 20 | z.v64 = (uint_fast64_t) 0xFFFFFFFFFFFFF <<12; 21 | z.v0 = 0; 22 | return z; 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_isSigNaNF32UI.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "specialize.h" 6 | 7 | bool softfloat_isSigNaNF32UI( uint_fast32_t ui ) 8 | { 9 | 10 | return ( ( ui>>22 & 0x1FF ) == 0x1FE ) && ( ui & 0x003FFFFF ); 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_isSigNaNF64UI.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "specialize.h" 6 | 7 | bool softfloat_isSigNaNF64UI( uint_fast64_t ui ) 8 | { 9 | 10 | return 11 | ( ( ui>>51 & 0xFFF ) == 0xFFE ) 12 | && ( ui & UINT64_C( 0x0007FFFFFFFFFFFF ) ); 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_le128.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | 7 | bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 8 | { 9 | 10 | return ( a64 < b64 ) || ( ( a64 == b64 ) && ( a0 <= b0 ) ); 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_lt128.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | 7 | bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 8 | { 9 | 10 | return ( a64 < b64 ) || ( ( a64 == b64 ) && ( a0 < b0 ) ); 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_mul128By64To192.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint192 7 | softfloat_mul128By64To192( uint64_t a64, uint64_t a0, uint64_t b ) 8 | { 9 | struct uint128 p0, p64; 10 | struct uint192 z; 11 | 12 | p0 = softfloat_mul64To128( a0, b ); 13 | z.v0 = p0.v0; 14 | p64 = softfloat_mul64To128( a64, b ); 15 | z.v64 = p64.v0 + p0.v64; 16 | z.v128 = p64.v64 + ( z.v64 < p64.v0 ); 17 | return z; 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_mul128To256.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint256 7 | softfloat_mul128To256( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 8 | { 9 | struct uint128 p0, p64, p128; 10 | struct uint256 z; 11 | 12 | p0 = softfloat_mul64To128( a0, b0 ); 13 | z.v0 = p0.v0; 14 | p64 = softfloat_mul64To128( a64, b0 ); 15 | z.v64 = p64.v0 + p0.v64; 16 | z.v128 = p64.v64 + ( z.v64 < p64.v0 ); 17 | p128 = softfloat_mul64To128( a64, b64 ); 18 | z.v128 += p128.v0; 19 | z.v192 = p128.v64 + ( z.v128 < p128.v0 ); 20 | p64 = softfloat_mul64To128( a0, b64 ); 21 | z.v64 += p64.v0; 22 | p64.v64 += ( z.v64 < p64.v0 ); 23 | z.v128 += p64.v64; 24 | z.v192 += ( z.v128 < p64.v64 ); 25 | return z; 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_mul64To128.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b ) 7 | { 8 | uint32_t a32, a0, b32, b0; 9 | struct uint128 z; 10 | uint64_t mid1, mid2, mid; 11 | 12 | a32 = a>>32; 13 | a0 = a; 14 | b32 = b>>32; 15 | b0 = b; 16 | z.v0 = (uint64_t) a0 * b0; 17 | mid1 = (uint64_t) a32 * b0; 18 | mid2 = (uint64_t) a0 * b32; 19 | z.v64 = (uint64_t) a32 * b32; 20 | mid = mid1 + mid2; 21 | z.v64 += ( (uint64_t) ( mid < mid1 ) )<<32 | mid>>32; 22 | mid <<= 32; 23 | z.v0 += mid; 24 | z.v64 += ( z.v0 < mid ); 25 | return z; 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_normRoundPackToF32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | 8 | float32_t 9 | softfloat_normRoundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig ) 10 | { 11 | int shiftCount; 12 | union ui32_f32 uZ; 13 | 14 | shiftCount = softfloat_countLeadingZeros32( sig ) - 1; 15 | exp -= shiftCount; 16 | if ( ( 7 <= shiftCount ) && ( (uint16_t) exp < 0xFD ) ) { 17 | uZ.ui = packToF32UI( sign, sig ? exp : 0, sig<<( shiftCount - 7 ) ); 18 | return uZ.f; 19 | } else { 20 | return softfloat_roundPackToF32( sign, exp, sig< 3 | #include 4 | #include "platform.h" 5 | #include "primitives.h" 6 | #include "internals.h" 7 | 8 | float64_t 9 | softfloat_normRoundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig ) 10 | { 11 | int shiftCount; 12 | union ui64_f64 uZ; 13 | 14 | shiftCount = softfloat_countLeadingZeros64( sig ) - 1; 15 | exp -= shiftCount; 16 | if ( ( 10 <= shiftCount ) && ( (uint16_t) exp < 0x7FD ) ) { 17 | uZ.ui = packToF64UI( sign, sig ? exp : 0, sig<<( shiftCount - 10 ) ); 18 | return uZ.f; 19 | } else { 20 | return softfloat_roundPackToF64( sign, exp, sig< 3 | #include "platform.h" 4 | #include "primitives.h" 5 | #include "internals.h" 6 | 7 | struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t sig ) 8 | { 9 | int shiftCount; 10 | struct exp16_sig32 z; 11 | 12 | shiftCount = softfloat_countLeadingZeros32( sig ) - 8; 13 | z.exp = 1 - shiftCount; 14 | z.sig = sig< 3 | #include "platform.h" 4 | #include "primitives.h" 5 | #include "internals.h" 6 | 7 | struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t sig ) 8 | { 9 | int shiftCount; 10 | struct exp16_sig64 z; 11 | 12 | shiftCount = softfloat_countLeadingZeros64( sig ) - 11; 13 | z.exp = 1 - shiftCount; 14 | z.sig = sig< 5 | #include 6 | #include "platform.h" 7 | #include "internals.h" 8 | #include "specialize.h" 9 | #include "softfloat.h" 10 | 11 | /*---------------------------------------------------------------------------- 12 | | Takes two single-precision floating-point values `a' and `b', one of which 13 | | is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a 14 | | signaling NaN, the invalid exception is raised. 15 | *----------------------------------------------------------------------------*/ 16 | 17 | uint_fast32_t 18 | softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB ) 19 | { 20 | if ( softfloat_isSigNaNF32UI( uiA ) | softfloat_isSigNaNF32UI( uiB ) ) { 21 | softfloat_raiseFlags( softfloat_flag_invalid ); 22 | } 23 | return defaultNaNF32UI; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_propagateNaNF64UI.c: -------------------------------------------------------------------------------- 1 | 2 | /*** UPDATE COMMENTS. ***/ 3 | 4 | #include 5 | #include 6 | #include "platform.h" 7 | #include "internals.h" 8 | #include "specialize.h" 9 | #include "softfloat.h" 10 | 11 | /*---------------------------------------------------------------------------- 12 | | Takes two double-precision floating-point values `a' and `b', one of which 13 | | is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a 14 | | signaling NaN, the invalid exception is raised. 15 | *----------------------------------------------------------------------------*/ 16 | 17 | uint_fast64_t 18 | softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB ) 19 | { 20 | if ( softfloat_isSigNaNF64UI( uiA ) | softfloat_isSigNaNF64UI( uiB ) ) { 21 | softfloat_raiseFlags( softfloat_flag_invalid ); 22 | } 23 | return defaultNaNF64UI; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_roundPackToI32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | int_fast32_t 9 | softfloat_roundPackToI32( 10 | bool sign, uint_fast64_t sig, int_fast8_t roundingMode, bool exact ) 11 | { 12 | bool roundNearestEven; 13 | int roundIncrement, roundBits; 14 | uint_fast32_t sig32; 15 | union { uint32_t ui; int32_t i; } uZ; 16 | int_fast32_t z; 17 | 18 | roundNearestEven = ( roundingMode == softfloat_round_nearest_even ); 19 | roundIncrement = 0x40; 20 | if ( 21 | ! roundNearestEven 22 | && ( roundingMode != softfloat_round_nearest_maxMag ) 23 | ) { 24 | roundIncrement = 25 | ( roundingMode == softfloat_round_minMag ) 26 | || ( roundingMode 27 | == ( sign ? softfloat_round_max : softfloat_round_min ) ) 28 | ? 0 29 | : 0x7F; 30 | } 31 | roundBits = sig & 0x7F; 32 | sig += roundIncrement; 33 | if ( sig & UINT64_C( 0xFFFFFF8000000000 ) ) goto invalid; 34 | sig32 = sig>>7; 35 | sig32 &= ~ ( ! ( roundBits ^ 0x40 ) & roundNearestEven ); 36 | uZ.ui = sign ? - sig32 : sig32; 37 | z = uZ.i; 38 | if ( z && ( ( z < 0 ) ^ sign ) ) goto invalid; 39 | if ( exact && roundBits ) { 40 | softfloat_exceptionFlags |= softfloat_flag_inexact; 41 | } 42 | return z; 43 | invalid: 44 | softfloat_raiseFlags( softfloat_flag_invalid ); 45 | return sign ? -0x7FFFFFFF - 1 : 0x7FFFFFFF; 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_roundPackToI64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | int_fast64_t 9 | softfloat_roundPackToI64( 10 | bool sign, 11 | uint_fast64_t sig64, 12 | uint_fast64_t sig0, 13 | int_fast8_t roundingMode, 14 | bool exact 15 | ) 16 | { 17 | bool roundNearestEven, increment; 18 | union { uint64_t ui; int64_t i; } uZ; 19 | int_fast64_t z; 20 | 21 | roundNearestEven = ( roundingMode == softfloat_round_nearest_even ); 22 | increment = ( UINT64_C( 0x8000000000000000 ) <= sig0 ); 23 | if ( 24 | ! roundNearestEven 25 | && ( roundingMode != softfloat_round_nearest_maxMag ) 26 | ) { 27 | increment = 28 | ( roundingMode != softfloat_round_minMag ) 29 | && ( roundingMode 30 | == ( sign ? softfloat_round_min : softfloat_round_max ) ) 31 | && sig0; 32 | } 33 | if ( increment ) { 34 | ++sig64; 35 | if ( ! sig64 ) goto invalid; 36 | sig64 &= 37 | ~ ( ! ( sig0 & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) 38 | & roundNearestEven ); 39 | } 40 | uZ.ui = sign ? - sig64 : sig64; 41 | z = uZ.i; 42 | if ( z && ( ( z < 0 ) ^ sign ) ) goto invalid; 43 | if ( exact && sig0 ) softfloat_exceptionFlags |= softfloat_flag_inexact; 44 | return z; 45 | invalid: 46 | softfloat_raiseFlags( softfloat_flag_invalid ); 47 | return 48 | sign ? - INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1 49 | : INT64_C( 0x7FFFFFFFFFFFFFFF ); 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_roundPackToUI32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | uint_fast32_t 9 | softfloat_roundPackToUI32( 10 | bool sign, uint_fast64_t sig, int_fast8_t roundingMode, bool exact ) 11 | { 12 | bool roundNearestEven; 13 | int roundIncrement, roundBits; 14 | uint_fast32_t z; 15 | 16 | roundNearestEven = ( roundingMode == softfloat_round_nearest_even ); 17 | roundIncrement = 0x40; 18 | if ( 19 | ! roundNearestEven 20 | && ( roundingMode != softfloat_round_nearest_maxMag ) 21 | ) { 22 | roundIncrement = 23 | ( roundingMode == softfloat_round_minMag ) 24 | || ( roundingMode 25 | == ( sign ? softfloat_round_max : softfloat_round_min ) ) 26 | ? 0 27 | : 0x7F; 28 | } 29 | roundBits = sig & 0x7F; 30 | sig += roundIncrement; 31 | if ( sig & UINT64_C( 0xFFFFFF8000000000 ) ) goto invalid; 32 | z = sig>>7; 33 | z &= ~ ( ! ( roundBits ^ 0x40 ) & roundNearestEven ); 34 | if ( sign && z ) goto invalid; 35 | if ( exact && roundBits ) { 36 | softfloat_exceptionFlags |= softfloat_flag_inexact; 37 | } 38 | return z; 39 | invalid: 40 | softfloat_raiseFlags( softfloat_flag_invalid ); 41 | return 0xFFFFFFFF; 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_roundPackToUI64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "platform.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | uint_fast64_t 9 | softfloat_roundPackToUI64( 10 | bool sign, 11 | uint_fast64_t sig64, 12 | uint_fast64_t sig0, 13 | int_fast8_t roundingMode, 14 | bool exact 15 | ) 16 | { 17 | bool roundNearestEven, increment; 18 | 19 | roundNearestEven = ( roundingMode == softfloat_round_nearest_even ); 20 | increment = ( UINT64_C( 0x8000000000000000 ) <= sig0 ); 21 | if ( 22 | ! roundNearestEven 23 | && ( roundingMode != softfloat_round_nearest_maxMag ) 24 | ) { 25 | increment = 26 | ( roundingMode != softfloat_round_minMag ) 27 | && ( roundingMode 28 | == ( sign ? softfloat_round_min : softfloat_round_max ) ) 29 | && sig0; 30 | } 31 | if ( increment ) { 32 | ++sig64; 33 | if ( ! sig64 ) goto invalid; 34 | sig64 &= 35 | ~ ( ! ( sig0 & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) 36 | & roundNearestEven ); 37 | } 38 | if ( sign && sig64 ) goto invalid; 39 | if ( exact && sig0 ) softfloat_exceptionFlags |= softfloat_flag_inexact; 40 | return sig64; 41 | invalid: 42 | softfloat_raiseFlags( softfloat_flag_invalid ); 43 | return UINT64_C( 0xFFFFFFFFFFFFFFFF ); 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shift128ExtraRightJam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint128_extra 7 | softfloat_shift128ExtraRightJam( 8 | uint64_t a64, uint64_t a0, uint64_t extra, unsigned int count ) 9 | { 10 | unsigned int negCount; 11 | struct uint128_extra z; 12 | 13 | negCount = - count; 14 | if ( count < 64 ) { 15 | z.v64 = a64>>count; 16 | z.v0 = a64<<( negCount & 63 ) | a0>>count; 17 | z.extra = a0<<( negCount & 63 ); 18 | } else { 19 | z.v64 = 0; 20 | if ( count == 64 ) { 21 | z.v0 = a64; 22 | z.extra = a0; 23 | } else { 24 | extra |= a0; 25 | if ( count < 128 ) { 26 | z.v0 = a64>>( count & 63 ); 27 | z.extra = a64<<( negCount & 63 ); 28 | } else { 29 | z.v0 = 0; 30 | z.extra = ( count == 128 ) ? a64 : ( a64 != 0 ); 31 | } 32 | } 33 | } 34 | z.extra |= ( extra != 0 ); 35 | return z; 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shift128RightJam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint128 7 | softfloat_shift128RightJam( uint64_t a64, uint64_t a0, unsigned int count ) 8 | { 9 | unsigned int negCount; 10 | struct uint128 z; 11 | 12 | if ( count < 64 ) { 13 | negCount = - count; 14 | z.v64 = a64>>( count & 63 ); 15 | z.v0 = 16 | a64<<( negCount & 63 ) | a0>>count 17 | | ( (uint64_t) ( a0<<( negCount & 63 ) ) != 0 ); 18 | } else { 19 | z.v64 = 0; 20 | z.v0 = 21 | ( count < 128 ) 22 | ? a64>>( count & 63 ) 23 | | ( ( ( a64 & ( ( (uint64_t) 1<<( count & 63 ) ) - 1 ) ) 24 | | a0 ) 25 | != 0 ) 26 | : ( ( a64 | a0 ) != 0 ); 27 | } 28 | return z; 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shift32RightJam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | uint32_t softfloat_shift32RightJam( uint32_t a, unsigned int count ) 7 | { 8 | 9 | return 10 | ( count < 32 ) 11 | ? a>>count | ( (uint32_t) ( a<<( ( - count ) & 31 ) ) != 0 ) 12 | : ( a != 0 ); 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shift64ExtraRightJam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint64_extra 7 | softfloat_shift64ExtraRightJam( 8 | uint64_t a, uint64_t extra, unsigned int count ) 9 | { 10 | struct uint64_extra z; 11 | 12 | if ( count < 64 ) { 13 | z.v = a>>count; 14 | z.extra = a<<( ( - count ) & 63 ); 15 | } else { 16 | z.v = 0; 17 | z.extra = ( count == 64 ) ? a : ( a != 0 ); 18 | } 19 | z.extra |= ( extra != 0 ); 20 | return z; 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shift64RightJam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | uint64_t softfloat_shift64RightJam( uint64_t a, unsigned int count ) 7 | { 8 | 9 | return 10 | ( count < 64 ) 11 | ? a>>count | ( (uint64_t) ( a<<( ( - count ) & 63 ) ) != 0 ) 12 | : ( a != 0 ); 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shortShift128ExtraRightJam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint128_extra 7 | softfloat_shortShift128ExtraRightJam( 8 | uint64_t a64, uint64_t a0, uint64_t extra, unsigned int count ) 9 | { 10 | unsigned int negCount; 11 | struct uint128_extra z; 12 | 13 | negCount = - count; 14 | z.v64 = a64>>count; 15 | z.v0 = a64<<( negCount & 63 ) | a0>>count; 16 | z.extra = a0<<( negCount & 63 ) | ( extra != 0 ); 17 | return z; 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shortShift128Left.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint128 7 | softfloat_shortShift128Left( uint64_t a64, uint64_t a0, unsigned int count ) 8 | { 9 | struct uint128 z; 10 | 11 | z.v64 = a64<>( ( - count ) & 63 ); 12 | z.v0 = a0< 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint128 7 | softfloat_shortShift128Right( uint64_t a64, uint64_t a0, unsigned int count ) 8 | { 9 | struct uint128 z; 10 | 11 | z.v64 = a64>>count; 12 | z.v0 = a64<<( ( - count ) & 63 ) | a0>>count; 13 | return z; 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shortShift192Left.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint192 7 | softfloat_shortShift192Left( 8 | uint64_t a128, uint64_t a64, uint64_t a0, unsigned int count ) 9 | { 10 | unsigned int negCount; 11 | struct uint192 z; 12 | 13 | negCount = - count; 14 | z.v128 = a128<>( negCount & 63 ); 15 | z.v64 = a64<>( negCount & 63 ); 16 | z.v0 = a0< 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | uint32_t softfloat_shortShift32Right1Jam( uint32_t a ) 7 | { 8 | 9 | return a>>1 | ( a & 1 ); 10 | 11 | } 12 | 13 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shortShift64ExtraRightJam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint64_extra 7 | softfloat_shortShift64ExtraRightJam( 8 | uint64_t a, uint64_t extra, unsigned int count ) 9 | { 10 | struct uint64_extra z; 11 | 12 | z.v = a>>count; 13 | z.extra = a<<( ( - count ) & 63 ) | ( extra != 0 ); 14 | return z; 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_shortShift64RightJam.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | uint64_t softfloat_shortShift64RightJam( uint64_t a, unsigned int count ) 7 | { 8 | 9 | return a>>count | ( ( a & ( ( (uint64_t) 1< 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint128 7 | softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 8 | { 9 | struct uint128 z; 10 | 11 | z.v0 = a0 - b0; 12 | z.v64 = a64 - b64; 13 | z.v64 -= ( a0 < b0 ); 14 | return z; 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/s_sub192.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | 6 | struct uint192 7 | softfloat_sub192( 8 | uint64_t a128, 9 | uint64_t a64, 10 | uint64_t a0, 11 | uint64_t b128, 12 | uint64_t b64, 13 | uint64_t b0 14 | ) 15 | { 16 | struct uint192 z; 17 | unsigned int borrow64, borrow128; 18 | 19 | z.v0 = a0 - b0; 20 | borrow64 = ( a0 < b0 ); 21 | z.v64 = a64 - b64; 22 | borrow128 = ( a64 < b64 ); 23 | z.v128 = a128 - b128; 24 | borrow128 += ( z.v64 < borrow64 ); 25 | z.v64 -= borrow64; 26 | z.v128 -= borrow128; 27 | return z; 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/softfloat_state.c: -------------------------------------------------------------------------------- 1 | 2 | /*** COMMENTS. ***/ 3 | 4 | #include 5 | #include "platform.h" 6 | #include "internals.h" 7 | #include "specialize.h" 8 | #include "softfloat.h" 9 | 10 | /*---------------------------------------------------------------------------- 11 | | Floating-point rounding mode, extended double-precision rounding precision, 12 | | and exception flags. 13 | *----------------------------------------------------------------------------*/ 14 | int_fast8_t softfloat_roundingMode = softfloat_round_nearest_even; 15 | int_fast8_t softfloat_detectTininess = init_detectTininess; 16 | int_fast8_t softfloat_exceptionFlags = 0; 17 | 18 | int_fast8_t floatx80_roundingPrecision = 80; 19 | 20 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/softfloat_types.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef softfloat_types_h 3 | #define softfloat_types_h 4 | 5 | /*** COMMENTS. ***/ 6 | 7 | #include 8 | #include 9 | 10 | typedef uint32_t float32_t; 11 | typedef uint64_t float64_t; 12 | typedef struct { uint64_t v; uint16_t x; } floatx80_t; 13 | typedef struct { uint64_t v[ 2 ]; } float128_t; 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/ui32_to_f32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float32_t ui32_to_f32( uint_fast32_t a ) 9 | { 10 | union ui32_f32 uZ; 11 | 12 | if ( ! a ) { 13 | uZ.ui = 0; 14 | return uZ.f; 15 | } 16 | if ( a & 0x80000000 ) { 17 | return 18 | softfloat_roundPackToF32( 19 | 0, 0x9D, softfloat_shortShift32Right1Jam( a ) ); 20 | } else { 21 | return softfloat_normRoundPackToF32( 0, 0x9C, a ); 22 | } 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /softfloat/softfloat-c/ui32_to_f64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "platform.h" 4 | #include "primitives.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float64_t ui32_to_f64( uint_fast32_t a ) 9 | { 10 | uint_fast64_t uiZ; 11 | int shiftCount; 12 | union ui64_f64 uZ; 13 | 14 | if ( ! a ) { 15 | uiZ = 0; 16 | } else { 17 | shiftCount = softfloat_countLeadingZeros32( a ) + 21; 18 | uiZ = 19 | packToF64UI( 20 | 0, 0x432 - shiftCount, (uint_fast64_t) a< 3 | #include "platform.h" 4 | #include "primitives.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float32_t ui64_to_f32( uint_fast64_t a ) 9 | { 10 | int shiftCount; 11 | union ui32_f32 u; 12 | uint_fast32_t sig; 13 | 14 | shiftCount = softfloat_countLeadingZeros64( a ) - 40; 15 | if ( 0 <= shiftCount ) { 16 | u.ui = 17 | a ? packToF32UI( 18 | 0, 0x95 - shiftCount, (uint_fast32_t) a< 3 | #include "platform.h" 4 | #include "primitives.h" 5 | #include "internals.h" 6 | #include "softfloat.h" 7 | 8 | float64_t ui64_to_f64( uint_fast64_t a ) 9 | { 10 | union ui64_f64 uZ; 11 | 12 | if ( ! a ) { 13 | uZ.ui = 0; 14 | return uZ.f; 15 | } 16 | if ( a & UINT64_C( 0x8000000000000000 ) ) { 17 | return 18 | softfloat_roundPackToF64( 19 | 0, 0x43D, softfloat_shortShift64RightJam( a, 1 ) ); 20 | } else { 21 | return softfloat_normRoundPackToF64( 0, 0x43C, a ); 22 | } 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /syscall-tests/Makefile: -------------------------------------------------------------------------------- 1 | #========================================================================= 2 | # Makefile 3 | #========================================================================= 4 | 5 | TESTS = read-test.c \ 6 | stat-test.c \ 7 | open-close-test.c \ 8 | args-test.c \ 9 | malloc-test.c \ 10 | fcntl-test.c \ 11 | 12 | ARM_TESTS = uname-test.c \ 13 | 14 | # TODO: create objects first? 15 | 16 | NATIVE_TARGETS = $(patsubst %.c, %-native, $(TESTS)) 17 | MAVEN_TARGETS = $(patsubst %.c, %-maven, $(TESTS)) 18 | ARM_TARGETS = $(patsubst %.c, %-arm, $(TESTS)) 19 | ARM_NL_TARGETS = $(patsubst %.c, %-arm-nl, $(TESTS)) 20 | RISCV_TARGETS = $(patsubst %.c, %-riscv, $(TESTS)) 21 | 22 | NATIVE_TARGETS+= $(patsubst %.c, %-native, $(ARM_TESTS)) 23 | ARM_TARGETS += $(patsubst %.c, %-arm, $(ARM_TESTS)) 24 | 25 | all : $(NATIVE_TARGETS) $(MAVEN_TARGETS) $(ARM_TARGETS) $(ARM_NL_TARGETS) $(RISCV_TARGETS) 26 | 27 | # newlib-based arm compiler 28 | ARM_NL_CC = /work/bits0/bi45/misc/arm-toolchain/custom/arm-unknown-eabi/x-tools2/bin/arm-none-eabi-gcc 29 | 30 | $(NATIVE_TARGETS) : %-native : %.c 31 | gcc -o $@ $< 32 | 33 | $(MAVEN_TARGETS) : %-maven : %.c 34 | maven-gcc -o $@ $< 35 | 36 | $(RISCV_TARGETS) : %-riscv : %.c 37 | riscv64-unknown-elf-gcc -o $@ $< 38 | 39 | $(ARM_TARGETS) : %-arm : %.c 40 | arm-unknown-linux-uclibcgnueabi-gcc -static -o $@ $< 41 | 42 | $(ARM_NL_TARGETS) : %-arm-nl : %.c 43 | $(ARM_NL_CC) -Tbrgarm.ld -static -o $@ $< 44 | 45 | clean : 46 | rm $(NATIVE_TARGETS) $(MAVEN_TARGETS) $(ARM_TARGETS) $(ARM_NL_TARGETS) $(RISCV_TARGETS) 47 | 48 | -------------------------------------------------------------------------------- /syscall-tests/args-test.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // args-test.c 3 | //======================================================================== 4 | // Test arguments 5 | 6 | #include 7 | 8 | int main( int argc, char **argv ) { 9 | 10 | printf( "argc = %d\n", argc ); 11 | 12 | int i; 13 | for ( i = 0; i < argc; i++ ) { 14 | 15 | printf( "arg%d = %s\n", i, argv[i] ); 16 | 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /syscall-tests/malloc-test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int *ptr_one; 7 | 8 | ptr_one = (int *)malloc(sizeof(int)); 9 | 10 | if (ptr_one == 0) 11 | { 12 | printf("ERROR: Out of memory\n"); 13 | return 1; 14 | } 15 | 16 | *ptr_one = 25; 17 | printf("%d\n", *ptr_one); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /syscall-tests/open-close-test.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // open-close-test.c 3 | //======================================================================== 4 | // Tests open() and close() 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main() { 13 | 14 | // read a file name 15 | char buf[ 1000 ]; 16 | char *filename = buf; 17 | 18 | fgets( filename, 1000, stdin ); 19 | 20 | printf( "filename: %s\n", filename ); 21 | 22 | // strip out the newline 23 | 24 | int len = strlen( filename ); 25 | if ( filename[ len - 1 ] == '\n' ) 26 | filename[ len - 1 ] = '\0'; 27 | 28 | // open the file 29 | 30 | int fd = open( filename, O_RDONLY ); 31 | 32 | if ( fd == -1 ) { 33 | printf( "Error in open! errno=%d\n", errno ); 34 | } else { 35 | printf( "open successful!\n" ); 36 | 37 | // read the contents of file and write to stdout 38 | int sz; 39 | do { 40 | sz = read( fd, buf, 1000 ); 41 | if ( sz == -1 ) { 42 | printf( "Error in read! errno=%d\n", errno ); 43 | break; 44 | } 45 | 46 | // we add a null char at the end and print 47 | buf[ sz ] = '\0'; 48 | 49 | printf( "%s", buf ); 50 | } while ( sz ); 51 | 52 | // close the file 53 | if ( close( fd ) ) 54 | printf( "Error in close! errno=%d\n", errno ); 55 | else 56 | printf( "close successful!\n" ); 57 | } 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /syscall-tests/read-test.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // read-test.c 3 | //======================================================================== 4 | // Tests read() 5 | 6 | #include 7 | #include 8 | 9 | int main() { 10 | 11 | // test reading from command line and printing it 12 | 13 | char buf[1000]; 14 | 15 | int len = read( 0, buf, 1000 ); 16 | 17 | // we need to null-terminate the string 18 | buf[len] = '\0'; 19 | 20 | printf( "read len=%d\ndata=%s", len, buf ); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /syscall-tests/stat-test.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // stat-test.c 3 | //======================================================================== 4 | // Tests stat syscall 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | int main() { 14 | 15 | // read a path 16 | char path[ 100 ]; 17 | 18 | fgets( path, 100, stdin ); 19 | 20 | printf( "path: %s\n", path ); 21 | 22 | // strip out the newline 23 | 24 | int len = strlen( path ); 25 | if ( path[ len - 1 ] == '\n' ) 26 | path[ len - 1 ] = '\0'; 27 | 28 | struct stat stat_buf; 29 | 30 | int ret = stat( path, &stat_buf ); 31 | 32 | if ( ret ) { 33 | printf( "Error in stat! errno=%d\n", errno ); 34 | } else { 35 | printf( "stat successful!\n" ); 36 | printf( "st_mode %x\n", stat_buf.st_mode ); 37 | printf( "st_ino %x\n", stat_buf.st_ino ); 38 | printf( "st_dev %x\n", stat_buf.st_dev ); 39 | printf( "st_nlink %x\n", stat_buf.st_nlink ); 40 | printf( "st_uid %x\n", stat_buf.st_uid ); 41 | printf( "st_gid %x\n", stat_buf.st_gid ); 42 | printf( "st_size %x\n", stat_buf.st_size ); 43 | printf( "st_atime %x\n", stat_buf.st_atime ); 44 | printf( "st_mtime %x\n", stat_buf.st_mtime ); 45 | printf( "st_ctime %x\n", stat_buf.st_ctime ); 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /syscall-tests/uname-test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main( int argc, char** argv ) { 6 | 7 | struct utsname x; 8 | 9 | printf("hello %p\n", &x); 10 | 11 | uname( &x ) ; 12 | 13 | printf("%p %d %s\n", &x.sysname, sizeof(x.sysname), x.sysname ); 14 | printf("%p %d %s\n", &x.nodename, sizeof(x.nodename), x.nodename ); 15 | printf("%p %d %s\n", &x.release, sizeof(x.release), x.release ); 16 | printf("%p %d %s\n", &x.version, sizeof(x.version), x.version ); 17 | printf("%p %d %s\n", &x.machine, sizeof(x.machine), x.machine ); 18 | 19 | return 1; 20 | } 21 | -------------------------------------------------------------------------------- /ubmark-nosyscalls/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define if we should include subproject ubmark */ 4 | #undef HAVE_UBMARK 5 | 6 | /* Define to the address where bug reports for this package should be sent. */ 7 | #undef PACKAGE_BUGREPORT 8 | 9 | /* Define to the full name of this package. */ 10 | #undef PACKAGE_NAME 11 | 12 | /* Define to the full name and version of this package. */ 13 | #undef PACKAGE_STRING 14 | 15 | /* Define to the one symbol short name of this package. */ 16 | #undef PACKAGE_TARNAME 17 | 18 | /* Define to the home page for this package. */ 19 | #undef PACKAGE_URL 20 | 21 | /* Define to the version of this package. */ 22 | #undef PACKAGE_VERSION 23 | -------------------------------------------------------------------------------- /ubmark-nosyscalls/convert: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -d "dep" ]; then 4 | mkdir dep 5 | fi 6 | 7 | if [ ! -d "obj" ]; then 8 | mkdir obj 9 | fi 10 | 11 | if [ ! -d "bin" ]; then 12 | mkdir bin 13 | fi 14 | 15 | if [ ! -d "dump" ]; then 16 | mkdir dump 17 | fi 18 | 19 | if [ ! -d "vmh" ]; then 20 | mkdir vmh 21 | fi 22 | 23 | mv ubmark* bin/ 24 | mv bin/ubmark*.* dep/ 25 | mv dep/ubmark-config.h . 26 | mv dep/ubmark.mk . 27 | mv *.a dep/ 28 | mv dep/ubmark*.o obj/ 29 | for x in bin/*;do maven-objdump -DC --disassemble-zeroes --section=.text --section=.data --section=.sdata --section=.xcpthandler --section=.init --section=.fini --section=.ctors --section=.dtors --section=.eh_frame --section=.jcr --section=.sbss --section=.bss --section=.rodata $x > $x.dump;done 30 | mv bin/*.dump dump/ 31 | for x in dump/*; 32 | do 33 | sed -i ' 34 | /<\_start>/ i\ 35 | 00000400 <_bootstrap>:\ 36 | \ 00400: 3c1d0007 lui sp,0xf\ 37 | \ 00404: 341dfffc ori sp,0,4095\ 38 | \ 00408: 08000400 j 1000\ 39 | \ 40 | ' $x; 41 | sed -i ' 42 | /1008:/ c\ 43 | \ 1008: 08000408 j 1020 44 | ' $x; 45 | python ../scripts/objdump2vmh.py -f $x; 46 | done 47 | mv dump/*.vmh vmh/ 48 | -------------------------------------------------------------------------------- /ubmark-nosyscalls/scripts/mk-install-dirs.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | # $Id: mkinstalldirs,v 1.1 2003/09/09 22:24:03 mhampton Exp $ 8 | 9 | errstatus=0 10 | 11 | for file 12 | do 13 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 | shift 15 | 16 | pathcomp= 17 | for d 18 | do 19 | pathcomp="$pathcomp$d" 20 | case "$pathcomp" in 21 | -* ) pathcomp=./$pathcomp ;; 22 | esac 23 | 24 | if test ! -d "$pathcomp"; then 25 | echo "mkdir $pathcomp" 1>&2 26 | 27 | mkdir "$pathcomp" || lasterr=$? 28 | 29 | if test ! -d "$pathcomp"; then 30 | errstatus=$lasterr 31 | fi 32 | fi 33 | 34 | pathcomp="$pathcomp/" 35 | done 36 | done 37 | 38 | exit $errstatus 39 | 40 | # mkinstalldirs ends here 41 | -------------------------------------------------------------------------------- /ubmark-nosyscalls/scripts/ubmark.ld: -------------------------------------------------------------------------------- 1 | /*======================================================================*/ 2 | /* Microbenchmark linker script */ 3 | /*======================================================================*/ 4 | /* This is the linker script used when building ubmark. */ 5 | 6 | /*----------------------------------------------------------------------*/ 7 | /* Setup */ 8 | /*----------------------------------------------------------------------*/ 9 | 10 | /* The OUTPUT_ARCH command specifies the machine architecture where the 11 | argument is one of the names used in the BFD library. More 12 | specifically one of the entires in bfd/cpu-mips.c */ 13 | 14 | OUTPUT_ARCH( "mips:maven" ) 15 | 16 | /* The ENTRY command specifies the entry point (ie. first instruction 17 | to execute). */ 18 | 19 | ENTRY( main ) 20 | 21 | /*----------------------------------------------------------------------*/ 22 | /* Sections */ 23 | /*----------------------------------------------------------------------*/ 24 | 25 | SECTIONS 26 | { 27 | 28 | /* xcpthandler: exception handle */ 29 | . = 0x00000004; 30 | .xcpthandler : 31 | { 32 | *(.xcpthandler) 33 | } 34 | 35 | /* text: test code section */ 36 | . = 0x00000400; 37 | .text : 38 | { 39 | *(.text) 40 | } 41 | 42 | /* data: Initialized data segment */ 43 | .data : 44 | { 45 | *(.data) 46 | } 47 | 48 | /* End of uninitalized data segement */ 49 | _end = .; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /ubmark-nosyscalls/ubmark/ubmark-vvadd.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // ubmark-vvadd 3 | //======================================================================== 4 | 5 | #include "ubmark.h" 6 | #include "ubmark-vvadd.dat" 7 | #include 8 | 9 | //------------------------------------------------------------------------ 10 | // vvadd-scalar 11 | //------------------------------------------------------------------------ 12 | 13 | void vvadd_scalar( int *dest, int *src0, int *src1, int size ) 14 | { 15 | int i; 16 | for ( i = 0; i < size; i++ ) 17 | *dest++ = *src0++ + *src1++; 18 | } 19 | 20 | //------------------------------------------------------------------------ 21 | // verify_results 22 | //------------------------------------------------------------------------ 23 | 24 | void verify_results( int dest[], int ref[], int size ) 25 | { 26 | int temp = 0; 27 | int i; 28 | for ( i = 0; i < size; i++ ) { 29 | if ( !( dest[i] == ref[i] ) ) { 30 | test_fail( temp ); 31 | } 32 | } 33 | test_pass( temp ); 34 | } 35 | 36 | //------------------------------------------------------------------------ 37 | // Test Harness 38 | //------------------------------------------------------------------------ 39 | 40 | int main( int argc, char* argv[] ) 41 | { 42 | int iterations = 1; 43 | if (argc > 1) 44 | iterations = atoi( argv[1] ); 45 | 46 | int size = 100; 47 | int dest[size]; 48 | 49 | int i; 50 | for ( i = 0; i < size; i++ ) 51 | dest[i] = 0; 52 | 53 | int temp = 0; 54 | 55 | for ( i = 0; i < iterations; i++ ) { 56 | test_stats_on( temp ); 57 | vvadd_scalar( dest, src0, src1, size ); 58 | test_stats_off( temp ); 59 | } 60 | 61 | verify_results( dest, ref, size ); 62 | 63 | return 0; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /ubmark-nosyscalls/ubmark/ubmark.ac: -------------------------------------------------------------------------------- 1 | #========================================================================= 2 | # Modular C++ Build System Subproject Autoconf Fragment 3 | #========================================================================= 4 | # Please read the documenation in 'mcppbs-uguide.txt' for more details 5 | # on how the Modular C++ Build System works. 6 | 7 | MCPPBS_SUBPROJECT([ubmark]) 8 | 9 | -------------------------------------------------------------------------------- /ubmark-nosyscalls/ubmark/ubmark.mk.in: -------------------------------------------------------------------------------- 1 | #========================================================================= 2 | # Modular C++ Build System Subproject Makefile Fragment 3 | #========================================================================= 4 | # Please read the documenation in 'mcppbs-uguide.txt' for more details 5 | # on how the Modular C++ Build System works. 6 | 7 | ubmark_intdeps = @ubmark_intdeps@ 8 | ubmark_cppflags = @ubmark_cppflags@ 9 | ubmark_ldflags = @ubmark_ldflags@ 10 | ubmark_libs = @ubmark_libs@ 11 | 12 | ubmark_hdrs = \ 13 | ubmark.h \ 14 | 15 | ubmark_srcs = \ 16 | 17 | ubmark_install_prog_srcs = \ 18 | ubmark-vvadd.c \ 19 | ubmark-cmplx-mult.c \ 20 | ubmark-bin-search.c \ 21 | ubmark-masked-filter.c \ 22 | ubmark-mvmult.c \ 23 | ubmark-mvmult-cp2.c \ 24 | 25 | --------------------------------------------------------------------------------