aboutsummaryrefslogtreecommitdiff
path: root/libphobos/libdruntime/gcc
diff options
context:
space:
mode:
authorJakub Dupak <dev@jakubdupak.com>2022-11-06 21:23:12 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2023-02-21 12:36:47 +0100
commitc4c859bff8d0fa3e7be4b83511d7607089e7d7d7 (patch)
tree86348dff733f92d15319b6fb855bffeb17e0a1e4 /libphobos/libdruntime/gcc
parent971d16cbfadeb9a6688d64f724def2ed0aa886d6 (diff)
downloadgcc-c4c859bff8d0fa3e7be4b83511d7607089e7d7d7.zip
gcc-c4c859bff8d0fa3e7be4b83511d7607089e7d7d7.tar.gz
gcc-c4c859bff8d0fa3e7be4b83511d7607089e7d7d7.tar.bz2
gccrs: ast: Dump never type
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing never type visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Diffstat (limited to 'libphobos/libdruntime/gcc')
0 files changed, 0 insertions, 0 deletions
='#n171'>171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
#! /usr/bin/env perl
# This file is dual-licensed, meaning that you can use it under your
# choice of either of the following two licenses:
#
# Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You can obtain
# a copy in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
#
# or
#
# Copyright (c) 2025, Julian Zhu <jz531210@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use strict;
use warnings;

# $output is the last argument if it looks like a file (it has an extension)
# $flavour is the first argument if it doesn't look like a file
my $output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
my $flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;

$output and open STDOUT,">$output";

my $code=<<___;
.text
___

my $K512 = "K512";

# Function arguments

my ($zero,$ra,$tp,$sp,$fp)=map("\$r$_",(0..3,22));
my ($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7)=map("\$r$_",(4..11));
my ($t0,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$x)=map("\$r$_",(12..21));
my ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8)=map("\$r$_",(23..31));

my ($INP, $LEN, $ADDR) = ($a1, $a2, $sp);
my ($KT, $T1, $T2, $T3, $T4, $T5, $T6) = ($t0, $t1, $t2, $t3, $t4, $t5, $t6);
my ($A, $B, $C, $D ,$E ,$F ,$G ,$H) = ($s0, $s1, $s2, $s3, $s4, $s5, $s6, $s7);

sub MSGSCHEDULE0 {
    my ($index) = @_;
    my $code=<<___;
    ld.d $T1, $INP, 8*$index
    revb.d $T1, $T1
    st.d $T1, $ADDR, 8*$index
___
    return $code;
}

sub MSGSCHEDULE1 {
    my ($index) = @_;
    my $code=<<___;
    ld.d $T1, $ADDR, (($index-2)&0x0f)*8
    ld.d $T2, $ADDR, (($index-15)&0x0f)*8
    ld.d $T3, $ADDR, (($index-7)&0x0f)*8
    ld.d $T4, $ADDR, ($index&0x0f)*8
    rotri.d $T5, $T1, 19
    rotri.d $T6, $T1, 61
    srli.d $T1, $T1, 6
    xor $T1, $T1, $T5
    xor $T1, $T1, $T6
    add.d $T1, $T1, $T3
    rotri.d $T5, $T2, 1
    rotri.d $T6, $T2, 8
    srli.d $T2, $T2, 7
    xor $T2, $T2, $T5
    xor $T2, $T2, $T6
    add.d $T1, $T1, $T2
    add.d $T1, $T1, $T4
    st.d $T1, $ADDR, 8*($index&0x0f)
___
    return $code;
}

sub sha512_T1 {
    my ($index, $e, $f, $g, $h) = @_;
    my $code=<<___;
    ld.d $T4, $KT, 8*$index
    add.d $h, $h, $T1
    add.d $h, $h, $T4
    rotri.d $T2, $e, 14
    rotri.d $T3, $e, 18
    rotri.d $T4, $e, 41
    xor $T2, $T2, $T3
    xor $T1, $f, $g
    xor $T2, $T2, $T4
    and $T1, $T1, $e
    add.d $h, $h, $T2
    xor $T1, $T1, $g
    add.d $T1, $T1, $h
___
    return $code;
}

sub sha512_T2 {
    my ($a, $b, $c) = @_;
    my $code=<<___;
    rotri.d $T2, $a, 28
    rotri.d $T3, $a, 34
    rotri.d $T4, $a, 39
    xor $T2, $T2, $T3
    xor $T5, $b, $c
    and $T3, $b, $c
    and $T5, $T5, $a
    xor $T2, $T2, $T4
    xor $T3, $T3, $T5
    add.d $T2, $T2, $T3
___
    return $code;
}

sub SHA512ROUND {
    my ($index, $a, $b, $c, $d, $e, $f, $g, $h) = @_;
    my $code=<<___;
    @{[sha512_T1 $index, $e, $f, $g, $h]}
    @{[sha512_T2 $a, $b, $c]}
    add.d $d, $d, $T1
    add.d $h, $T2, $T1
___
    return $code;
}

sub SHA512ROUND0 {
    my ($index, $a, $b, $c, $d, $e, $f, $g, $h) = @_;
    my $code=<<___;
    @{[MSGSCHEDULE0 $index]}
    @{[SHA512ROUND $index, $a, $b, $c, $d, $e, $f, $g, $h]}
___
    return $code;
}

sub SHA512ROUND1 {
    my ($index, $a, $b, $c, $d, $e, $f, $g, $h) = @_;
    my $code=<<___;
    @{[MSGSCHEDULE1 $index]}
    @{[SHA512ROUND $index, $a, $b, $c, $d, $e, $f, $g, $h]}
___
    return $code;
}

################################################################################
# void sha512_block_data_order(void *c, const void *p, size_t len)
$code .= <<___;
.p2align 3
.globl sha512_block_data_order
.type   sha512_block_data_order,\@function
sha512_block_data_order:

    addi.d $sp, $sp, -80

    st.d $s0, $sp, 0
    st.d $s1, $sp, 8
    st.d $s2, $sp, 16
    st.d $s3, $sp, 24
    st.d $s4, $sp, 32
    st.d $s5, $sp, 40
    st.d $s6, $sp, 48
    st.d $s7, $sp, 56
    st.d $s8, $sp, 64
    st.d $fp, $sp, 72

    addi.d $sp, $sp, -128

    la $KT, $K512

    # load ctx
    ld.d $A, $a0, 0
    ld.d $B, $a0, 8
    ld.d $C, $a0, 16
    ld.d $D, $a0, 24
    ld.d $E, $a0, 32
    ld.d $F, $a0, 40
    ld.d $G, $a0, 48
    ld.d $H, $a0, 56

L_round_loop:
    # Decrement length by 1
    addi.d $LEN, $LEN, -1

    @{[SHA512ROUND0 0, $A, $B, $C, $D, $E, $F, $G, $H]}
    @{[SHA512ROUND0 1, $H, $A, $B, $C, $D, $E, $F, $G]}
    @{[SHA512ROUND0 2, $G, $H, $A, $B, $C, $D, $E, $F]}
    @{[SHA512ROUND0 3, $F, $G, $H, $A, $B, $C, $D, $E]}

    @{[SHA512ROUND0 4, $E, $F, $G, $H, $A, $B, $C, $D]}
    @{[SHA512ROUND0 5, $D, $E, $F, $G, $H, $A, $B, $C]}
    @{[SHA512ROUND0 6, $C, $D, $E, $F, $G, $H, $A, $B]}
    @{[SHA512ROUND0 7, $B, $C, $D, $E, $F, $G, $H, $A]}

    @{[SHA512ROUND0 8, $A, $B, $C, $D, $E, $F, $G, $H]}
    @{[SHA512ROUND0 9, $H, $A, $B, $C, $D, $E, $F, $G]}
    @{[SHA512ROUND0 10, $G, $H, $A, $B, $C, $D, $E, $F]}
    @{[SHA512ROUND0 11, $F, $G, $H, $A, $B, $C, $D, $E]}

    @{[SHA512ROUND0 12, $E, $F, $G, $H, $A, $B, $C, $D]}
    @{[SHA512ROUND0 13, $D, $E, $F, $G, $H, $A, $B, $C]}
    @{[SHA512ROUND0 14, $C, $D, $E, $F, $G, $H, $A, $B]}
    @{[SHA512ROUND0 15, $B, $C, $D, $E, $F, $G, $H, $A]}

    @{[SHA512ROUND1 16, $A, $B, $C, $D, $E, $F, $G, $H]}
    @{[SHA512ROUND1 17, $H, $A, $B, $C, $D, $E, $F, $G]}
    @{[SHA512ROUND1 18, $G, $H, $A, $B, $C, $D, $E, $F]}
    @{[SHA512ROUND1 19, $F, $G, $H, $A, $B, $C, $D, $E]}