1#! /usr/bin/env perl
2# Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the OpenSSL license (the "License").  You may not use
5# this file except in compliance with the License.  You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9$output = pop;
10open STDOUT,">$output";
11
12$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
13push(@INC,"${dir}.");
14
15require "uplink-common.pl";
16
17local $V=8;	# max number of args uplink functions may accept...
18my $loc0 = "r".(32+$V);
19print <<___;
20.text
21.global	OPENSSL_Uplink#
22.type	OPENSSL_Uplink#,\@function
23
24___
25for ($i=1;$i<=$N;$i++) {
26print <<___;
27.proc	lazy$i#
28lazy$i:
29	.prologue
30{ .mii;	.save	ar.pfs,$loc0
31	alloc	loc0=ar.pfs,$V,3,2,0
32	.save	b0,loc1
33	mov	loc1=b0
34	addl	loc2=\@ltoff(OPENSSL_UplinkTable#),gp	};;
35	.body
36{ .mmi;	ld8	out0=[loc2]
37	mov	out1=$i					};;
38{ .mib;	add	loc2=8*$i,out0
39	br.call.sptk.many	b0=OPENSSL_Uplink#	};;
40{ .mmi;	ld8	r31=[loc2];;
41	ld8	r30=[r31],8				};;
42{ .mii;	ld8	gp=[r31]
43	mov	b6=r30
44	mov	b0=loc1					};;
45{ .mib;	mov	ar.pfs=loc0
46	br.many	b6					};;
47.endp	lazy$i#
48
49___
50}
51print <<___;
52.data
53.global OPENSSL_UplinkTable#
54OPENSSL_UplinkTable:    data8   $N      // amount of following entries
55___
56for ($i=1;$i<=$N;$i++) {   print "      data8   \@fptr(lazy$i#)\n";   }
57print <<___;
58.size   OPENSSL_UplinkTable,.-OPENSSL_UplinkTable#
59___
60
61close STDOUT;
62